diff --git a/client/X11/xf_event.c b/client/X11/xf_event.c index 53dbddf5c..969a8007f 100644 --- a/client/X11/xf_event.c +++ b/client/X11/xf_event.c @@ -454,7 +454,8 @@ boolean xf_event_ConfigureNotify(xfInfo* xfi, XEvent* event, boolean app) // ConfigureNotify coordinates are expressed relative to the window parent. // Translate these to root window coordinates. Window childWindow; - XTranslateCoordinates(xfi->display, xfw->handle, DefaultRootWindow(xfi->display), + XTranslateCoordinates(xfi->display, xfw->handle, + RootWindowOfScreen(xfi->screen), 0, 0, &xfw->left, &xfw->top, &childWindow); xfw->width = event->xconfigure.width; diff --git a/client/X11/xf_rail.c b/client/X11/xf_rail.c index 90d314ff1..2f8517831 100644 --- a/client/X11/xf_rail.c +++ b/client/X11/xf_rail.c @@ -63,6 +63,17 @@ void xf_rail_paint(xfInfo* xfi, rdpRail* rail, sint32 uleft, sint32 utop, uint32 if (intersect) { + // Sometimes the RDP server and the local server + // are not synchronized for window position and size. + // This happens after a local move. In this case + // ignore the update because it will result in copying + // invalid data. Wait for the next update. + if ( xfw->left != window->windowOffsetX || + xfw->top != window->windowOffsetY || + xfw->width != window->windowWidth || + xfw->height != window->windowHeight) + continue; + xf_UpdateWindowArea(xfi, xfw, ileft - wleft, itop - wtop, iwidth, iheight); } } @@ -262,14 +273,6 @@ void xf_rail_adjust_position(xfInfo* xfi, rdpWindow *window) if (! xfw->is_mapped || xfw->local_move.state != LMS_NOT_ACTIVE) return; - DEBUG_X11_LMS("window=0x%X rc={l=%d t=%d r=%d b=%d} w=%u h=%u" - " RDP=0x%X rc={l=%d t=%d} w=%d h=%d", - (uint32) xfw->handle, xfw->left, xfw->top, - xfw->right, xfw->bottom, xfw->width, xfw->height, - window->windowId, - window->windowOffsetX, window->windowOffsetY, - window->windowWidth, window->windowHeight); - // If current window position disagrees with RDP window position, send // update to RDP server if ( xfw->left != window->windowOffsetX || @@ -283,6 +286,14 @@ void xf_rail_adjust_position(xfInfo* xfi, rdpWindow *window) window_move.right = xfw->right; window_move.bottom = xfw->bottom; + DEBUG_X11_LMS("window=0x%X rc={l=%d t=%d r=%d b=%d} w=%u h=%u" + " RDP=0x%X rc={l=%d t=%d} w=%d h=%d", + (uint32) xfw->handle, xfw->left, xfw->top, + xfw->right, xfw->bottom, xfw->width, xfw->height, + window->windowId, + window->windowOffsetX, window->windowOffsetY, + window->windowWidth, window->windowHeight); + xf_send_rail_client_event(channels, RDP_EVENT_TYPE_RAIL_CLIENT_WINDOW_MOVE, &window_move); } } @@ -306,7 +317,7 @@ void xf_rail_end_local_move(xfInfo* xfi, rdpWindow *window) window_move.right = xfw->right + 1; // In the update to RDP the position is one past the window window_move.bottom = xfw->bottom + 1; - DEBUG_X11_LMS("ClientWindowMove: window=0x%X rc={l=%d t=%d r=%d b=%d}", + DEBUG_X11_LMS("window=0x%X rc={l=%d t=%d r=%d b=%d}", (uint32) xfw->handle, xfw->left, xfw->top, xfw->right, xfw->bottom); xf_send_rail_client_event(channels, RDP_EVENT_TYPE_RAIL_CLIENT_WINDOW_MOVE, &window_move); @@ -487,7 +498,8 @@ void xf_process_rail_server_localmovesize_event(xfInfo* xfi, rdpChannels* channe break; case RAIL_WMSZ_MOVE: //0x9 direction = _NET_WM_MOVERESIZE_MOVE; - XTranslateCoordinates(xfi->display, xfw->handle, DefaultRootWindow(xfi->display), + XTranslateCoordinates(xfi->display, xfw->handle, + RootWindowOfScreen(xfi->screen), movesize->posX, movesize->posY, &x, &y, &child_window); break; case RAIL_WMSZ_KEYMOVE: //0xA @@ -506,8 +518,6 @@ void xf_process_rail_server_localmovesize_event(xfInfo* xfi, rdpChannels* channe { xf_StartLocalMoveSize(xfi, xfw, direction, x, y); } else { - xf_MoveWindow(xfi, xfw, movesize->posX, movesize->posY, - xfw->width, xfw->height); xf_EndLocalMoveSize(xfi, xfw, false); } } diff --git a/client/X11/xf_window.c b/client/X11/xf_window.c index a73470a23..cf2053614 100644 --- a/client/X11/xf_window.c +++ b/client/X11/xf_window.c @@ -97,7 +97,7 @@ void xf_SendClientEvent(xfInfo *xfi, xfWindow* window, Atom atom, unsigned int n } DEBUG_X11("Send ClientMessage Event: wnd=0x%04X", (unsigned int) xevent.xclient.window); - XSendEvent(xfi->display, DefaultRootWindow(xfi->display), False, + XSendEvent(xfi->display, RootWindowOfScreen(xfi->screen), False, SubstructureRedirectMask | SubstructureNotifyMask, &xevent); XSync(xfi->display, False); @@ -237,6 +237,7 @@ void xf_SetWindowStyle(xfInfo* xfi, xfWindow* window, uint32 style, uint32 ex_st attrs.override_redirect = True; XChangeWindowAttributes(xfi->display, window->handle, CWOverrideRedirect, &attrs); window->is_transient = true; + xf_SetWindowUnlisted(xfi, window); window_type = xfi->_NET_WM_WINDOW_TYPE_POPUP; } @@ -245,6 +246,7 @@ void xf_SetWindowStyle(xfInfo* xfi, xfWindow* window, uint32 style, uint32 ex_st // This includes dialogs, popups, etc, that need to be // full-fledged windows window_type = xfi->_NET_WM_WINDOW_TYPE_DIALOG; + xf_SetWindowUnlisted(xfi, window); } else { @@ -393,11 +395,6 @@ xfWindow* xf_CreateWindow(xfInfo* xfi, rdpWindow* wnd, int x, int y, int width, window->is_mapped = false; window->is_transient = false; - // Proper behavior of tooltips, dropdown menus, etc, depend on the local window - // manager not modify them. Set override_redirect on these windows. RDP window - // styles don't map 1 to 1 to X window styles, but the presence of WM_POPUP - // appears to be sufficient for setting override_redirect. - window->handle = XCreateWindow(xfi->display, RootWindowOfScreen(xfi->screen), x, y, window->width, window->height, 0, xfi->depth, InputOutput, xfi->visual, CWBackPixel | CWBackingStore | CWOverrideRedirect | CWColormap | @@ -491,7 +488,7 @@ void xf_StartLocalMoveSize(xfInfo* xfi, xfWindow* window, int direction, int x, window->local_move.root_y = y; window->local_move.state = LMS_STARTING; - XTranslateCoordinates(xfi->display, DefaultRootWindow(xfi->display), window->handle, + XTranslateCoordinates(xfi->display, RootWindowOfScreen(xfi->screen), window->handle, window->local_move.root_x, window->local_move.root_y, &window->local_move.window_x, @@ -551,6 +548,9 @@ void xf_MoveWindow(xfInfo* xfi, xfWindow* window, int x, int y, int width, int h if ((width * height) < 1) return; + if (window->local_move.state != LMS_NOT_ACTIVE) + return; + if ((window->width != width) || (window->height != height)) resize = true; @@ -686,14 +686,14 @@ void xf_UpdateWindowArea(xfInfo* xfi, xfWindow* window, int x, int y, int width, rdpWindow* wnd; wnd = window->window; - ax = x + wnd->windowOffsetX; - ay = y + wnd->windowOffsetY; + ax = x + window->left; + ay = y + window->top; - if (ax + width > wnd->windowOffsetX + wnd->windowWidth) - width = (wnd->windowOffsetX + wnd->windowWidth - 1) - ax; + if (ax + width >= window->right) + width = window->right - ax + 1; - if (ay + height > wnd->windowOffsetY + wnd->windowHeight) - height = (wnd->windowOffsetY + wnd->windowHeight - 1) - ay; + if (ay + height >= window->bottom) + height = window->bottom - ay + 1; if (xfi->sw_gdi) {