After local X window manager has moved a window to a different location than what...
authorDavid Sundstrom <sunds@bluespace.com>
Fri, 18 Nov 2011 23:46:22 +0000 (17:46 -0600)
committerNot Nyguen Doze <sunds@ubuntu.(none)>
Tue, 6 Dec 2011 23:43:38 +0000 (15:43 -0800)
client/X11/xf_event.c
client/X11/xf_rail.c

index e53cdbc..e5e56f3 100644 (file)
@@ -440,37 +440,52 @@ boolean xf_event_LeaveNotify(xfInfo* xfi, XEvent* event, boolean app)
 
 boolean xf_event_ConfigureNotify(xfInfo* xfi, XEvent* event, boolean app)
 {
-       rdpWindow* window;
-       rdpRail* rail = ((rdpContext*) xfi->context)->rail;
-
-       window = window_list_get_by_extra_id(rail->list, (void*) event->xconfigure.window);
-
-       if (window != NULL)
-       {
-               xfWindow* xfw;
-               uint32 left, top;
-               uint32 right, bottom;
-               uint32 width, height;
-               xfw = (xfWindow*) window->extra;
-
-               left = event->xconfigure.x;
-               top = event->xconfigure.y;
-               width = event->xconfigure.width;
-               height = event->xconfigure.height;
-               right = left + width - 1;
-               bottom = top + height - 1;
-
-               DEBUG_X11_LMS("ConfigureNotify: send_event=%d eventWindow=0x%X window=0x%X above=0x%X rc={l=%d t=%d r=%d b=%d} "
-                       "w=%d h=%d override_redirect=%d",
-                       event->xconfigure.send_event,
-                       (uint32) event->xconfigure.event,
-                       (uint32) event->xconfigure.window,
-                       (uint32) event->xconfigure.above,
-                       left, top, right, bottom, width, height,
-                       event->xconfigure.override_redirect);
-       }
-
-       return true;
+        rdpWindow* window;
+        rdpRail* rail = ((rdpContext*) xfi->context)->rail;
+
+        window = window_list_get_by_extra_id(rail->list, (void*) event->xconfigure.window);
+
+        if (window != NULL)
+        {
+                xfWindow* xfw;
+                xfw = (xfWindow*) window->extra;
+
+                // 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),
+                        0, 0, &xfw->left, &xfw->top, &childWindow);
+
+                xfw->width = event->xconfigure.width;
+                xfw->height = event->xconfigure.height;
+                xfw->right = xfw->left + xfw->width - 1;
+                xfw->bottom = xfw->top + xfw->height - 1;
+
+                if (app)
+                {
+                        // If current window position disagrees with RDP window position, send
+                        // update to RDP server
+                        if ( xfw->left != window->windowOffsetX ||
+                                xfw->top != window->windowOffsetY ||
+                                xfw->width != window->windowWidth ||
+                                xfw->height != window->windowHeight)
+                        {
+                                xf_rail_send_windowmove(xfi, window->windowId,
+                                        xfw->left, xfw->top, xfw->right, xfw->bottom);
+                        }
+                }
+
+                DEBUG_X11_LMS("ConfigureNotify: send_event=%d eventWindow=0x%X window=0x%X above=0x%X rc={l=%d t=%d r=%d b=%d} "
+                        "w=%d h=%d override_redirect=%d",
+                        event->xconfigure.send_event,
+                        (uint32) event->xconfigure.event,
+                        (uint32) event->xconfigure.window,
+                        (uint32) event->xconfigure.above,
+                        xfw->left, xfw->top, xfw->right, xfw->bottom, xfw->width, xfw->height,
+                        event->xconfigure.override_redirect);
+        }
+
+        return True;
 }
 
 boolean xf_event_MapNotify(xfInfo* xfi, XEvent* event, boolean app)
index 52240d9..7ce530d 100644 (file)
@@ -94,6 +94,15 @@ void xf_rail_MoveWindow(rdpRail* rail, rdpWindow* window)
        xfi = (xfInfo*) rail->extra;
        xfw = (xfWindow*) window->extra;
 
+       // Do nothing if window is already in the correct position
+        if ( xfw->left == window->windowOffsetX && 
+               xfw->top == window->windowOffsetY && 
+                xfw->width == window->windowWidth && 
+                xfw->height == window->windowHeight)
+        {
+               return;
+       }
+
        xf_MoveWindow((xfInfo*) rail->extra, xfw,
                        window->windowOffsetX, window->windowOffsetY,
                        window->windowWidth, window->windowHeight);