1 From a91e9dd202640598d8dec091c67ec94536390e7f Mon Sep 17 00:00:00 2001
2 From: "Owen W. Taylor" <otaylor@fishsoup.net>
3 Date: Mon, 17 Oct 2011 17:27:43 -0400
4 Subject: [PATCH] Fix logic for figuring out what ConfigureNotify positions
7 When reading ahead in the queue for ConfigureNotify events, it's necessary
8 to look for intermediate ReparentNotify events as well, since they will
9 determine whether the position in the event can be trusted or not.
11 src/gui/kernel/qapplication_x11.cpp | 47 ++++++++++++++++++++++++++++++----
12 1 files changed, 41 insertions(+), 6 deletions(-)
14 diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp
15 index 408e9ac..3a1d3eb 100644
16 --- a/src/gui/kernel/qapplication_x11.cpp
17 +++ b/src/gui/kernel/qapplication_x11.cpp
18 @@ -816,6 +816,27 @@ static Bool qt_sync_request_scanner(Display*, XEvent *event, XPointer arg)
22 +struct qt_configure_event_data
28 +static Bool qt_configure_event_scanner(Display*, XEvent *event, XPointer arg)
30 + qt_configure_event_data *data =
31 + reinterpret_cast<qt_configure_event_data*>(arg);
32 + if (event->type == ConfigureNotify &&
33 + event->xconfigure.window == data->window) {
35 + } else if (event->type == ReparentNotify &&
36 + event->xreparent.window == data->window) {
37 + data->parent = event->xreparent.parent;
43 static void qt_x11_create_intern_atoms()
45 const char *names[QX11Data::NAtoms];
46 @@ -5273,8 +5294,11 @@ bool QETWidget::translateConfigEvent(const XEvent *event)
47 if (d->extra->compress_events) {
48 // ConfigureNotify compression for faster opaque resizing
50 - while (XCheckTypedWindowEvent(X11->display, internalWinId(), ConfigureNotify,
52 + qt_configure_event_data configureData;
53 + configureData.window = internalWinId();
54 + configureData.parent = d->topData()->parentWinId;
55 + while (XCheckIfEvent(X11->display, &otherEvent,
56 + &qt_configure_event_scanner, (XPointer)&configureData)) {
57 if (qt_x11EventFilter(&otherEvent))
60 @@ -5287,13 +5311,19 @@ bool QETWidget::translateConfigEvent(const XEvent *event)
61 newSize.setWidth(otherEvent.xconfigure.width);
62 newSize.setHeight(otherEvent.xconfigure.height);
65 + && (configureData.parent == XNone ||
66 + configureData.parent == QX11Info::appRootWindow());
68 if (otherEvent.xconfigure.send_event || trust) {
69 newCPos.rx() = otherEvent.xconfigure.x +
70 otherEvent.xconfigure.border_width;
71 newCPos.ry() = otherEvent.xconfigure.y +
72 otherEvent.xconfigure.border_width;
80 qt_sync_request_event_data sync_event;
81 @@ -5306,9 +5336,14 @@ bool QETWidget::translateConfigEvent(const XEvent *event)
85 - // we didn't get an updated position of the toplevel.
86 - // either we haven't moved or there is a bug in the window manager.
87 - // anyway, let's query the position to be certain.
88 + // If the last configure event didn't have a trustable position,
89 + // it's necessary to query, see ICCCM 4.24:
91 + // Any real ConfigureNotify event on a top-level window implies
92 + // that the window’s position on the root may have changed, even
93 + // though the event reports that the window’s position in its
94 + // parent is unchanged because the window may have been reparented.
98 XTranslateCoordinates(X11->display, internalWinId(),