summaryrefslogtreecommitdiff
path: root/extra/qt/improved-filter-event.patch
blob: b03cdbe9470c937543857658f90a67b55b82a393 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
--- qt-opensource-4.8.0.old/src/gui/kernel/qapplication_x11.cpp	2011-12-16 03:22:33.918428374 -0500
+++ qt-opensource-4.8.0.new/src/gui/kernel/qapplication_x11.cpp	2012-01-07 18:18:40.258246384 -0500
@@ -4244,7 +4205,12 @@ bool QETWidget::translateMouseEvent(cons
                     && (nextEvent.xclient.message_type == ATOM(_QT_SCROLL_DONE) ||
                     (nextEvent.xclient.message_type == ATOM(WM_PROTOCOLS) &&
                      (Atom)nextEvent.xclient.data.l[0] == ATOM(_NET_WM_SYNC_REQUEST))))) {
-                qApp->x11ProcessEvent(&nextEvent);
+                // As we may run through a significant number of a large class of non-MotionNotify
+                // events here, without returning to the event loop, first pass nextEvent to
+                // QAbstractEventDispatcher::filterEvent() to allow applications which override
+                // QAbstractEventDispatcher::filterEvent() to handle the event first.
+                if (!QAbstractEventDispatcher::instance()->filterEvent(&nextEvent))
+                    qApp->x11ProcessEvent(&nextEvent);
                 continue;
             } else if (nextEvent.type != MotionNotify ||
                        nextEvent.xmotion.window != event->xmotion.window ||
--- qt-opensource-4.8.0.old/src/gui/kernel/qclipboard_x11.cpp	2011-12-08 00:06:02.000000000 -0500
+++ qt-opensource-4.8.0.new/src/gui/kernel/qclipboard_x11.cpp	2012-01-07 18:30:35.298287639 -0500
@@ -573,7 +573,11 @@ bool QX11Data::clipboardWaitForEvent(Win
 
             // process other clipboard events, since someone is probably requesting data from us
             XEvent e;
-            if (XCheckIfEvent(X11->display, &e, checkForClipboardEvents, 0))
+            // Some applications may override QAbstractEventDispatcher::filterEvent(), so
+            // pass event to QAbstractEventDispatcher::filterEvent() before processing in
+            // x11ProcessEvent().
+            if (XCheckIfEvent(X11->display, &e, checkForClipboardEvents, 0) && 
+                !QAbstractEventDispatcher::instance()->filterEvent(&e))
                 qApp->x11ProcessEvent(&e);
 
             now.start();
--- qt-opensource-4.8.0.old/src/gui/kernel/qdnd_x11.cpp	2011-12-08 00:06:02.000000000 -0500
+++ qt-opensource-4.8.0.new/src/gui/kernel/qdnd_x11.cpp	2012-01-07 18:28:13.841279478 -0500
@@ -42,6 +42,7 @@
 #include "qplatformdefs.h"
 
 #include "qapplication.h"
+#include "qabstracteventdispatcher.h"
 
 #ifndef QT_NO_DRAGANDDROP
 
@@ -1941,7 +1942,11 @@ Qt::DropAction QDragManager::drag(QDrag
         timer.start();
         do {
             XEvent event;
-            if (XCheckTypedEvent(X11->display, ClientMessage, &event))
+            // Some applications may override QAbstractEventDispatcher::filterEvent(), so
+            // pass event to QAbstractEventDispatcher::filterEvent() before processing in
+            // x11ProcessEvent().
+            if (XCheckTypedEvent(X11->display, ClientMessage, &event) &&
+                !QAbstractEventDispatcher::instance()->filterEvent(&event))
                 qApp->x11ProcessEvent(&event);
 
             // sleep 50 ms, so we don't use up CPU cycles all the time.
--- qt-opensource-4.8.0.old/src/gui/kernel/qwidget_x11.cpp	2011-12-08 00:06:02.000000000 -0500
+++ qt-opensource-4.8.0.new/src/gui/kernel/qwidget_x11.cpp	2012-01-07 18:29:26.286283657 -0500
@@ -44,6 +44,7 @@
 #include "qdesktopwidget.h"
 #include "qapplication.h"
 #include "qapplication_p.h"
+#include "qabstracteventdispatcher.h"
 #include "qnamespace.h"
 #include "qpainter.h"
 #include "qbitmap.h"
@@ -376,17 +377,22 @@ void qt_x11_wait_for_window_manager(QWid
     do {
         if (XEventsQueued(X11->display, QueuedAlready)) {
             XNextEvent(X11->display, &ev);
-            qApp->x11ProcessEvent(&ev);
-
-            switch (state) {
-            case Initial:
-                if (ev.type == MapNotify && ev.xany.window == winid)
-                    state = Mapped;
-                break;
-            case Mapped:
-                if (ev.type == Expose && ev.xany.window == winid)
-                    return;
-                break;
+            // Some applications may override QAbstractEventDispatcher::filterEvent(), so
+            // pass event to QAbstractEventDispatcher::filterEvent() before processing in
+            // x11ProcessEvent().
+            if (!QAbstractEventDispatcher::instance()->filterEvent(&ev)) {
+                qApp->x11ProcessEvent(&ev);
+
+                switch (state) {
+                case Initial:
+                    if (ev.type == MapNotify && ev.xany.window == winid)
+                        state = Mapped;
+                    break;
+                case Mapped:
+                    if (ev.type == Expose && ev.xany.window == winid)
+                        return;
+                    break;
+                }
             }
         } else {
             if (!XEventsQueued(X11->display, QueuedAfterFlush))