diff options
author | Gatis Paeglis <gatis.paeglis@qt.io> | 2017-06-02 13:55:46 +0200 |
---|---|---|
committer | Gatis Paeglis <gatis.paeglis@qt.io> | 2018-01-03 09:24:28 +0000 |
commit | 209d8f10e4a13dc63ec8927bf67fdc858c4822e0 (patch) | |
tree | 0e2be53bb20cf818d1b062b009078d22eed65382 /src/plugins/platforms/xcb/qxcbwindow.cpp | |
parent | 2dedf75819d838ef1964de4b8d391655f5bde85d (diff) |
xcb: fix and optimize QXcbConnection::xi2SetMouseGrabEnabled
What was broken:
- m_xiGrab on successful ungrab (XIUngrabDevice) was never set to 'false'.
Which means that we would unnecessarily call XIAllowTouchEvents, even when
we are not grabbing (this did not have any apparent side effects).
What was non optimal:
- Redundant XIQueryDevice calls. XIQueryDevice with XIAllMasterDevices flag
already returns all required devices. Calling XIQueryDevice for every id again
does not make sense.
- Querying for master pointer info on every grab is unnecessary. Simply cache
ids of master devices whenever hierarchy changes.
What remains to be investigated some time later (or never):
The original and the re-factored code grabs all master pointer devices. Not
sure if that is the expected behavior on MPX (Multi-pointer X) systems. Could
there be two context menus, each dismissed separately? MPX concept was introduced
in XI2.0, but testing shows that this setup is not very well supported even on
modern desktop environments. Tested on Ubuntu 16.04, where multiple pointers is
enough for crashing a terminal. Also AFAIK there isn't any bug reports about
broken MPX support in Qt.
Change-Id: I53f99c6efd44abc43a0985e15cff8aae7ebba8f1
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbwindow.cpp')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindow.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index e7096fb8f0..20d030b5c9 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -2560,6 +2560,9 @@ bool QXcbWindow::setMouseGrabEnabled(bool grab) if (!grab && connection()->mouseGrabber() == this) connection()->setMouseGrabber(nullptr); + if (grab && !connection()->canGrab()) + return false; + #if QT_CONFIG(xinput2) if (connection()->hasXInput2() && !connection()->xi2MouseEventsDisabled()) { bool result = connection()->xi2SetMouseGrabEnabled(m_window, grab); @@ -2568,8 +2571,6 @@ bool QXcbWindow::setMouseGrabEnabled(bool grab) return result; } #endif - if (grab && !connection()->canGrab()) - return false; if (!grab) { xcb_ungrab_pointer(xcb_connection(), XCB_TIME_CURRENT_TIME); |