Blame SOURCES/qt-everywhere-opensource-src-4.8.5-QTBUG-21900.patch

462c49
diff -up qt-everywhere-opensource-src-4.8.5/src/gui/kernel/qapplication_x11.cpp.QTBUG-21900 qt-everywhere-opensource-src-4.8.5/src/gui/kernel/qapplication_x11.cpp
462c49
--- qt-everywhere-opensource-src-4.8.5/src/gui/kernel/qapplication_x11.cpp.QTBUG-21900	2013-05-30 16:18:05.000000000 -0500
462c49
+++ qt-everywhere-opensource-src-4.8.5/src/gui/kernel/qapplication_x11.cpp	2013-06-09 11:53:45.891771748 -0500
462c49
@@ -818,6 +818,27 @@ static Bool qt_sync_request_scanner(Disp
462c49
 #endif
462c49
 #endif // QT_NO_XSYNC
462c49
 
462c49
+struct qt_configure_event_data
462c49
+{
462c49
+    WId window;
462c49
+    WId parent;
462c49
+};
462c49
+
462c49
+static Bool qt_configure_event_scanner(Display*, XEvent *event, XPointer arg)
462c49
+{
462c49
+    qt_configure_event_data *data =
462c49
+        reinterpret_cast<qt_configure_event_data*>(arg);
462c49
+    if (event->type == ConfigureNotify &&
462c49
+        event->xconfigure.window == data->window) {
462c49
+        return true;
462c49
+    } else if (event->type == ReparentNotify &&
462c49
+               event->xreparent.window == data->window) {
462c49
+        data->parent = event->xreparent.parent;
462c49
+    }
462c49
+
462c49
+    return false;
462c49
+}
462c49
+
462c49
 static void qt_x11_create_intern_atoms()
462c49
 {
462c49
     const char *names[QX11Data::NAtoms];
462c49
@@ -5302,8 +5323,11 @@ bool QETWidget::translateConfigEvent(con
462c49
         if (d->extra->compress_events) {
462c49
             // ConfigureNotify compression for faster opaque resizing
462c49
             XEvent otherEvent;
462c49
-            while (XCheckTypedWindowEvent(X11->display, internalWinId(), ConfigureNotify,
462c49
-                                          &otherEvent)) {
462c49
+            qt_configure_event_data configureData;
462c49
+            configureData.window = internalWinId();
462c49
+            configureData.parent = d->topData()->parentWinId;
462c49
+            while (XCheckIfEvent(X11->display, &otherEvent,
462c49
+                                 &qt_configure_event_scanner, (XPointer)&configureData)) {
462c49
                 if (qt_x11EventFilter(&otherEvent))
462c49
                     continue;
462c49
 
462c49
@@ -5316,13 +5340,19 @@ bool QETWidget::translateConfigEvent(con
462c49
                 newSize.setWidth(otherEvent.xconfigure.width);
462c49
                 newSize.setHeight(otherEvent.xconfigure.height);
462c49
 
462c49
+                trust = isVisible()
462c49
+                        && (configureData.parent == XNone ||
462c49
+                            configureData.parent == QX11Info::appRootWindow());
462c49
+
462c49
                 if (otherEvent.xconfigure.send_event || trust) {
462c49
                     newCPos.rx() = otherEvent.xconfigure.x +
462c49
                                    otherEvent.xconfigure.border_width;
462c49
                     newCPos.ry() = otherEvent.xconfigure.y +
462c49
                                    otherEvent.xconfigure.border_width;
462c49
                     isCPos = true;
462c49
-                }
462c49
+                } else {
462c49
+                    isCPos = false;
462c49
+               }
462c49
             }
462c49
 #ifndef QT_NO_XSYNC
462c49
             qt_sync_request_event_data sync_event;
462c49
@@ -5335,9 +5365,14 @@ bool QETWidget::translateConfigEvent(con
462c49
         }
462c49
 
462c49
         if (!isCPos) {
462c49
-            // we didn't get an updated position of the toplevel.
462c49
-            // either we haven't moved or there is a bug in the window manager.
462c49
-            // anyway, let's query the position to be certain.
462c49
+            // If the last configure event didn't have a trustable position,
462c49
+            // it's necessary to query, see ICCCM 4.24:
462c49
+            //
462c49
+            //  Any real ConfigureNotify event on a top-level window implies
462c49
+            //  that the window’s position on the root may have changed, even
462c49
+            //  though the event reports that the window’s position in its
462c49
+            //  parent is unchanged because the window may have been reparented.
462c49
+
462c49
             int x, y;
462c49
             Window child;
462c49
             XTranslateCoordinates(X11->display, internalWinId(),