Skip to content

Commit

Permalink
fix hi-dpi snap/move window (#64)
Browse files Browse the repository at this point in the history
Co-authored-by: Hideyuki Nagase <hideyukn@ntdev.microsoft.com>
  • Loading branch information
hideyukn88 and Hideyuki Nagase authored Apr 18, 2022
1 parent fc79745 commit 7fe0231
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 27 deletions.
2 changes: 1 addition & 1 deletion include/libweston/backend-rdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct weston_rdprail_shell_api {

/** Move a window.
*/
void (*request_window_move)(struct weston_surface *surface, int x, int y);
void (*request_window_move)(struct weston_surface *surface, int x, int y, int width, int height);

/** Snap a window.
*/
Expand Down
14 changes: 0 additions & 14 deletions libweston/backend-rdp/rdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -483,20 +483,6 @@ rdp_matrix_transform_scale(struct weston_matrix *matrix, int *sx, int *sy)
}
}

/* TO BE REMOVED */
static inline int32_t
to_weston_x(RdpPeerContext *peer, int32_t x)
{
return x - peer->regionClientHeads.extents.x1;
}

/* TO BE REMOVED */
static inline int32_t
to_weston_y(RdpPeerContext *peer, int32_t y)
{
return y - peer->regionClientHeads.extents.y1;
}

static inline void
to_weston_scale_only(RdpPeerContext *peer, struct weston_output *output, float scale, int *x, int *y)
{
Expand Down
38 changes: 27 additions & 11 deletions libweston/backend-rdp/rdprail.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,9 @@ rail_client_SnapArrange_callback(int fd, uint32_t mask, void *arg)
struct rdp_backend *b = peerCtx->rdpBackend;
struct weston_surface *surface;
struct weston_surface_rail_state *rail_state;
pixman_rectangle32_t snapArrangeRect;

rdp_debug(b, "SnapArrange(%d) - (%d, %d, %d, %d)\n",
rdp_debug(b, "Client: SnapArrange: WindowId:0x%x at (%d, %d) %dx%d\n",
snap->windowId,
snap->left,
snap->top,
Expand All @@ -353,12 +354,18 @@ rail_client_SnapArrange_callback(int fd, uint32_t mask, void *arg)
rail_state = (struct weston_surface_rail_state *)surface->backend_state;
if (b->rdprail_shell_api &&
b->rdprail_shell_api->request_window_move) {
/* TODO: HI-DPI MULTIMON */
snapArrangeRect.x = snap->left;
snapArrangeRect.y = snap->top;
snapArrangeRect.width = snap->right - snap->left;
snapArrangeRect.height = snap->bottom - snap->top;
to_weston_coordinate(peerCtx,
&snapArrangeRect.x, &snapArrangeRect.y,
&snapArrangeRect.width, &snapArrangeRect.height);
b->rdprail_shell_api->request_window_snap(surface,
to_weston_x(peerCtx, snap->left),
to_weston_y(peerCtx, snap->top),
snap->right - snap->left,
snap->bottom - snap->top);
snapArrangeRect.x,
snapArrangeRect.y,
snapArrangeRect.width,
snapArrangeRect.height);
}

rail_state->forceUpdateWindowState = true;
Expand All @@ -384,8 +391,9 @@ rail_client_WindowMove_callback(int fd, uint32_t mask, void *arg)
RdpPeerContext *peerCtx = (RdpPeerContext *)client->context;
struct rdp_backend *b = peerCtx->rdpBackend;
struct weston_surface *surface;
pixman_rectangle32_t windowMoveRect;

rdp_debug(b, "WindowMove(%d) - (%d, %d, %d, %d)\n",
rdp_debug(b, "Client: WindowMove: WindowId:0x0x at (%d, %d) %dx%d\n",
windowMove->windowId,
windowMove->left,
windowMove->top,
Expand All @@ -398,10 +406,18 @@ rail_client_WindowMove_callback(int fd, uint32_t mask, void *arg)
if (surface) {
if (b->rdprail_shell_api &&
b->rdprail_shell_api->request_window_move) {
/* TODO: HI-DPI MULTIMON */
windowMoveRect.x = windowMove->left;
windowMoveRect.y = windowMove->top;
windowMoveRect.width = windowMove->right - windowMove->left;
windowMoveRect.height = windowMove->bottom - windowMove->top;
to_weston_coordinate(peerCtx,
&windowMoveRect.x, &windowMoveRect.y,
&windowMoveRect.width, &windowMoveRect.height);
b->rdprail_shell_api->request_window_move(surface,
to_weston_x(peerCtx, windowMove->left),
to_weston_y(peerCtx, windowMove->top));
windowMoveRect.x,
windowMoveRect.y,
windowMoveRect.width,
windowMoveRect.height);
}
}

Expand Down Expand Up @@ -2682,7 +2698,7 @@ rdp_rail_peer_activate(freerdp_peer* client)
UINT32 railHandshakeFlags =
(TS_RAIL_ORDER_HANDSHAKEEX_FLAGS_HIDEF
| TS_RAIL_ORDER_HANDSHAKE_EX_FLAGS_EXTENDED_SPI_SUPPORTED
/*| TS_RAIL_ORDER_HANDSHAKE_EX_FLAGS_SNAP_ARRANGE_SUPPORTED*/);
/* | TS_RAIL_ORDER_HANDSHAKE_EX_FLAGS_SNAP_ARRANGE_SUPPORTED */);
handshakeEx.buildNumber = 0;
handshakeEx.railHandshakeFlags = railHandshakeFlags;
if (peerCtx->rail_server_context->ServerHandshakeEx(peerCtx->rail_server_context, &handshakeEx) != CHANNEL_RC_OK)
Expand Down
3 changes: 2 additions & 1 deletion rdprail-shell/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -2665,7 +2665,7 @@ shell_backend_request_window_restore(struct weston_surface *surface)
}

static void
shell_backend_request_window_move(struct weston_surface *surface, int x, int y)
shell_backend_request_window_move(struct weston_surface *surface, int x, int y, int width, int height)
{
struct weston_view *view;
struct shell_surface *shsurf = get_shell_surface(surface);
Expand All @@ -2680,6 +2680,7 @@ shell_backend_request_window_move(struct weston_surface *surface, int x, int y)

assert(!shsurf->snapped.is_maximized_requested);
weston_view_set_position(view, x, y);
//TODO: support window resize (width x height)
}

static void
Expand Down

0 comments on commit 7fe0231

Please sign in to comment.