summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Edmundson <davidedmundson@kde.org>2019-09-13 15:31:49 +0200
committerDavid Edmundson <davidedmundson@kde.org>2019-09-27 23:35:46 +0100
commit03e160cfd286bb336e875a180efd83635be7a27f (patch)
tree01c812840e9553ab02146f98b5c90ce6607ad801
parente579a0d8bdfb69649a9c22add5651d6dabcf142c (diff)
Client: Create context menu event when pressing the menu key
Effectively is a copy of the code in XCB. When the menu key is pressed, a context menu event should be generated at the current cursor position. The global position in the event isn't truly global as that doesn't exist in wayland but should match client expectations. Change-Id: Ib814883aba632ca5eec58730846e1762b680467f Reviewed-by: Johan Helsing <johan.helsing@qt.io>
-rw-r--r--src/client/qwaylandinputdevice.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/client/qwaylandinputdevice.cpp b/src/client/qwaylandinputdevice.cpp
index e39ccf25e..a9da452dc 100644
--- a/src/client/qwaylandinputdevice.cpp
+++ b/src/client/qwaylandinputdevice.cpp
@@ -1158,7 +1158,18 @@ void QWaylandInputDevice::Keyboard::handleKey(ulong timestamp, QEvent::Type type
}
if (!filtered) {
- QWindowSystemInterface::handleExtendedKeyEvent(focusWindow()->window(), timestamp, type, key, modifiers,
+ auto window = focusWindow()->window();
+
+ if (type == QEvent::KeyPress && key == Qt::Key_Menu) {
+ auto cursor = window->screen()->handle()->cursor();
+ if (cursor) {
+ const QPoint globalPos = cursor->pos();
+ const QPoint pos = window->mapFromGlobal(globalPos);
+ QWindowSystemInterface::handleContextMenuEvent(window, false, pos, globalPos, modifiers);
+ }
+ }
+
+ QWindowSystemInterface::handleExtendedKeyEvent(window, timestamp, type, key, modifiers,
nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorepeat, count);
}
}