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

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