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>
This commit is contained in:
David Edmundson 2019-09-13 15:31:49 +02:00
parent 0f2472eb8b
commit 235f8f12fa

View File

@ -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);
}
}