qt: Fix Qt 6 modifier key handling on macOS
Per QTBUG-69608 (https://bugreports.qt.io/browse/QTBUG-69608), QKeyEvent::nativeVirtualKey() returns 0 on Qt 6 (and possibly some versions of Qt 5) for keyboard modifier events. Despite being closed, the bug doesn't appear to have been fixed, or perhaps was fixed and then regressed again. Detect this case and handle the events manually by keeping track of the active modifier keys and using QKeyEvent::nativeModifiers() and the platform-specific modifier values. Caps Lock requires some special handling and doesn't get discrete press/release events, at least with the Qt input system; see the code for details. It's possible some other toggle modifiers like Scroll Lock will need special handling along these lines too. Fix #2211.
This commit is contained in:
@@ -118,6 +118,11 @@ private:
|
||||
std::unique_ptr<MachineStatus> status;
|
||||
std::shared_ptr<MediaMenu> mm;
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
uint32_t last_modifiers = 0;
|
||||
void processMacKeyboardInput(bool down, const QKeyEvent* event);
|
||||
#endif
|
||||
|
||||
/* If main window should send keyboard input */
|
||||
bool send_keyboard_input = true;
|
||||
bool shownonce = false;
|
||||
|
||||
Reference in New Issue
Block a user