From 03e160cfd286bb336e875a180efd83635be7a27f Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Fri, 13 Sep 2019 15:31:49 +0200 Subject: 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 --- src/client/qwaylandinputdevice.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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); } } -- cgit v1.2.3