D5515: Update the ungrabMouse hack for Qt 5.8
David Edmundson
noreply at phabricator.kde.org
Wed Apr 19 17:39:13 UTC 2017
davidedmundson created this revision.
Restricted Application added projects: Plasma, Frameworks.
Restricted Application added subscribers: Frameworks, plasma-devel.
REVISION SUMMARY
There was an unidentified bug where when opening a context menu in
response to a mousePress event led to the next click events not being
registered. The mouse got grabbed by the item in the mousePressEvent,
but when we open a menu it didn't get released. The next click goes to
the currently grabbed item.
A workaround was added back in 2015 (and copied into various other parts
of Plasma) to ungrab the mouse after launching the context menu inside
our rightClickEvent. This doesn't work because qquickwindow code is
shuffled. It now sends the event and then grabs the mouse.
qquickwindow.cpp:653 on Qt5.8.0
Which means we're now trying to do the ungrab, before QWindow has set
our item as the grabber. That obviously doesn't work.
This real bug needs fixing in Qt, (I now know the root cause!)
but we have a workaround here already, we may as well make it work.
Note: This also needs doing in a bajillion (6) places in p-w/p-d.
FWIW, the root cause of all of these bugs is:
- QtQuick internally keeps track of which item has "grabbed" the mouse
- It's weirdly a singleton between windows, but that should be fine
- It relies on the fact that when we get an X mouse press event we
should always get a mouse release event. X is surprisingly smart and
will send this even if you change window focus.
- However - context menus are evil bastards. They do a low level grab
(completely different type of grab than the one above) and grab all
mouse events at the X level
- Our original QtQuickItem which was handling the right click event no
longer gets our release event
- The reason it's only somtimes is we have a "race" between being
created and the grab going through X, and the user actually releasing
the mouse.
TEST PLAN
Had 1 reproducible case
Added this. No longer could reproduce
REPOSITORY
R242 Plasma Framework (Library)
BRANCH
origin-master (branched from master)
REVISION DETAIL
https://phabricator.kde.org/D5515
AFFECTED FILES
src/scriptengines/qml/plasmoid/containmentinterface.cpp
To: davidedmundson, #plasma
Cc: plasma-devel, #frameworks, spstarr, progwolff, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20170419/72670b30/attachment.html>
More information about the Plasma-devel
mailing list