Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 03006fd6 authored by David Edmundson's avatar David Edmundson

Update ungrab mouse hack for Qt5.8

parent 1e031b90
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment