Changeset View
Changeset View
Standalone View
Standalone View
src/scriptengines/qml/plasmoid/containmentinterface.cpp
Show All 21 Lines | |||||
22 | #include "containmentinterface.h" | 22 | #include "containmentinterface.h" | ||
23 | #include "wallpaperinterface.h" | 23 | #include "wallpaperinterface.h" | ||
24 | #include <kdeclarative/qmlobject.h> | 24 | #include <kdeclarative/qmlobject.h> | ||
25 | 25 | | |||
26 | #include <QClipboard> | 26 | #include <QClipboard> | ||
27 | #include <QQmlExpression> | 27 | #include <QQmlExpression> | ||
28 | #include <QQmlProperty> | 28 | #include <QQmlProperty> | ||
29 | #include <QMimeData> | 29 | #include <QMimeData> | ||
30 | #include <QVersionNumber> | ||||
30 | 31 | | |||
31 | #include <kactioncollection.h> | 32 | #include <kactioncollection.h> | ||
32 | #include <KAcceleratorManager> | 33 | #include <KAcceleratorManager> | ||
33 | #include <kauthorized.h> | 34 | #include <kauthorized.h> | ||
34 | #include <QDebug> | 35 | #include <QDebug> | ||
35 | #include <klocalizedstring.h> | 36 | #include <klocalizedstring.h> | ||
36 | #include <kurlmimedata.h> | 37 | #include <kurlmimedata.h> | ||
37 | #include <QMimeDatabase> | 38 | #include <QMimeDatabase> | ||
▲ Show 20 Lines • Show All 972 Lines • ▼ Show 20 Line(s) | 1009 | } else { | |||
1010 | addContainmentActions(desktopMenu, event); | 1011 | addContainmentActions(desktopMenu, event); | ||
1011 | } | 1012 | } | ||
1012 | 1013 | | |||
1013 | //this is a workaround where Qt now creates the menu widget | 1014 | //this is a workaround where Qt now creates the menu widget | ||
1014 | //in .exec before oxygen can polish it and set the following attribute | 1015 | //in .exec before oxygen can polish it and set the following attribute | ||
1015 | desktopMenu->setAttribute(Qt::WA_TranslucentBackground); | 1016 | desktopMenu->setAttribute(Qt::WA_TranslucentBackground); | ||
1016 | //end workaround | 1017 | //end workaround | ||
1017 | 1018 | | |||
1019 | | ||||
1020 | //this is a workaround where Qt will fail to realise a mouse has been released | ||||
1021 | | ||||
1022 | // this happens if a window which does not accept focus spawns a new window that takes focus and X grab | ||||
1023 | // whilst the mouse is depressed | ||||
1024 | // https://bugreports.qt.io/browse/QTBUG-59044 | ||||
1025 | // this causes the next click to go missing | ||||
1026 | | ||||
1027 | //by releasing manually we avoid that situation | ||||
1028 | auto ungrabMouseHack = [this]() { | ||||
1018 | if (window() && window()->mouseGrabberItem()) { | 1029 | if (window() && window()->mouseGrabberItem()) { | ||
1019 | window()->mouseGrabberItem()->ungrabMouse(); | 1030 | window()->mouseGrabberItem()->ungrabMouse(); | ||
1020 | } | 1031 | } | ||
1032 | }; | ||||
1033 | | ||||
1034 | //pre 5.8.0 QQuickWindow code is "item->grabMouse(); sendEvent(item, mouseEvent)" | ||||
1035 | //post 5.8.0 QQuickWindow code is sendEvent(item, mouseEvent); item->grabMouse() | ||||
1036 | if (QVersionNumber::fromString(qVersion()) > QVersionNumber(5, 8, 0)) { | ||||
1037 | QTimer::singleShot(0, this, ungrabMouseHack); | ||||
1038 | } | ||||
1039 | else { | ||||
1040 | ungrabMouseHack(); | ||||
1041 | } | ||||
1042 | //end workaround | ||||
1021 | 1043 | | |||
1022 | QPoint pos = event->globalPos(); | 1044 | QPoint pos = event->globalPos(); | ||
1023 | if (window() && m_containment->containmentType() == Plasma::Types::PanelContainment) { | 1045 | if (window() && m_containment->containmentType() == Plasma::Types::PanelContainment) { | ||
1024 | desktopMenu->adjustSize(); | 1046 | desktopMenu->adjustSize(); | ||
1025 | 1047 | | |||
1026 | if (QScreen *screen = window()->screen()) { | 1048 | if (QScreen *screen = window()->screen()) { | ||
1027 | const QRect geo = screen->availableGeometry(); | 1049 | const QRect geo = screen->availableGeometry(); | ||
1028 | 1050 | | |||
▲ Show 20 Lines • Show All 163 Lines • Show Last 20 Lines |