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

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