Propagate event accepted state to platform plugins
authorMorten Johan Sørvig <morten.sorvig@digia.com>
Sat, 22 Nov 2014 14:10:34 +0000 (15:10 +0100)
committerMorten Johan Sørvig <morten.sorvig@theqtcompany.com>
Thu, 13 Aug 2015 18:33:03 +0000 (18:33 +0000)
Add en "eventAccepted" field to WindowSystemEvent,
where the event subclasses can record the event
acceptance status. Make handleWindowSystemEvent()
return the accepted status.

This works for synchronous event processing only. If
the event is placed on the QPA event queue then there
is no way to return the accepted state immediately.
In the latter case handleWindowSystemEvent() always
returns "true".

Change-Id: I081aecc54f43588d42d3aaeec7f8458f06937601
Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
src/gui/kernel/qwindowsysteminterface.cpp
src/gui/kernel/qwindowsysteminterface_p.h

index 3ab2f59661d542c4c38676096928957e3ec6d3f8..8c429150a8590f90bd2d8f7d2cb7ec732384977a 100644 (file)
@@ -441,10 +441,12 @@ void QWindowSystemInterfacePrivate::removeWindowSystemEvent(WindowSystemEvent *e
     windowSystemEventQueue.remove(event);
 }
 
-void QWindowSystemInterfacePrivate::handleWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *ev)
+bool QWindowSystemInterfacePrivate::handleWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *ev)
 {
+    bool accepted = true;
     if (synchronousWindowSystemEvents) {
         QGuiApplicationPrivate::processWindowSystemEvent(ev);
+        accepted = ev->eventAccepted;
         delete ev;
     } else {
         windowSystemEventQueue.append(ev);
@@ -452,6 +454,7 @@ void QWindowSystemInterfacePrivate::handleWindowSystemEvent(QWindowSystemInterfa
         if (dispatcher)
             dispatcher->wakeUp();
     }
+    return accepted;
 }
 
 void QWindowSystemInterface::registerTouchDevice(QTouchDevice *device)
index cbc3bad7cda7f0767d7b4c25949402f21c505614..cc0ca6bf812b07db14645c40775f8631edf874ab 100644 (file)
@@ -101,7 +101,7 @@ public:
         };
 
         explicit WindowSystemEvent(EventType t)
-            : type(t), flags(0) { }
+            : type(t), flags(0), eventAccepted(true) { }
         virtual ~WindowSystemEvent() { }
 
         bool synthetic() const  { return flags & Synthetic; }
@@ -109,6 +109,7 @@ public:
 
         EventType type;
         int flags;
+        bool eventAccepted;
     };
 
     class CloseEvent : public WindowSystemEvent {
@@ -480,7 +481,7 @@ public:
     static WindowSystemEvent *getNonUserInputWindowSystemEvent();
     static WindowSystemEvent *peekWindowSystemEvent(EventType t);
     static void removeWindowSystemEvent(WindowSystemEvent *event);
-    static void handleWindowSystemEvent(WindowSystemEvent *ev);
+    static bool handleWindowSystemEvent(WindowSystemEvent *ev);
 
     static QElapsedTimer eventTime;
     static bool synchronousWindowSystemEvents;