summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Edmundson <kde@davidedmundson.co.uk>2017-04-25 11:52:59 (GMT)
committerDavid Edmundson <kde@davidedmundson.co.uk>2017-04-25 11:53:46 (GMT)
commit03006fd66ac1c79421a51751fa32dc86bc79bd33 (patch)
tree6ef935fa8ea3873ebb1a188e57ee7bab85f3e3e5
parent1e031b905565204aeb15ecd870cb705462def3ff (diff)
Update ungrab mouse hack for Qt5.8
-rw-r--r--applets/taskmanager/plugin/backend.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/applets/taskmanager/plugin/backend.cpp b/applets/taskmanager/plugin/backend.cpp
index 29af1f5..47da89d 100644
--- a/applets/taskmanager/plugin/backend.cpp
+++ b/applets/taskmanager/plugin/backend.cpp
@@ -34,6 +34,8 @@
#include <QJsonArray>
#include <QQuickItem>
#include <QQuickWindow>
+#include <QVersionNumber>
+#include <QTimer>
#include <KActivities/Consumer>
#include <KActivities/Stats/Cleaning>
@@ -327,9 +329,29 @@ QRect Backend::globalRect(QQuickItem *item) const
void Backend::ungrabMouse(QQuickItem *item) const
{
- if (item && item->window() && item->window()->mouseGrabberItem()) {
- item->window()->mouseGrabberItem()->ungrabMouse();
+ //this is a workaround where Qt will fail to realise a mouse has been released
+
+ // this happens if a window which does not accept focus spawns a new window that takes focus and X grab
+ // whilst the mouse is depressed
+ // https://bugreports.qt.io/browse/QTBUG-59044
+ // this causes the next click to go missing
+
+ //by releasing manually we avoid that situation
+ auto ungrabMouseHack = [item]() {
+ if (item && item->window() && item->window()->mouseGrabberItem()) {
+ item->window()->mouseGrabberItem()->ungrabMouse();
+ }
+ };
+
+ //pre 5.8.0 QQuickWindow code is "item->grabMouse(); sendEvent(item, mouseEvent)"
+ //post 5.8.0 QQuickWindow code is sendEvent(item, mouseEvent); item->grabMouse()
+ if (QVersionNumber::fromString(qVersion()) > QVersionNumber(5, 8, 0)) {
+ QTimer::singleShot(0, item, ungrabMouseHack);
+ }
+ else {
+ ungrabMouseHack();
}
+ //end workaround
}
bool Backend::canPresentWindows() const