From 68382ff1b3a7703d8c2503c93da09425d9ece1de Mon Sep 17 00:00:00 2001 From: RichardG867 Date: Sat, 22 Jul 2023 17:17:39 -0300 Subject: [PATCH] qt: Capture fullscreen shortcuts on Windows raw input, fixes #3434 --- src/qt/qt_mainwindow.cpp | 38 +++++++++++++++++++++------------ src/qt/qt_mainwindow.hpp | 1 + src/qt/qt_winrawinputfilter.cpp | 2 ++ 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 04317800d..5c37573c8 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -1249,11 +1249,7 @@ MainWindow::keyPressEvent(QKeyEvent *event) #endif } - if (!fs_off_signal && (video_fullscreen > 0) && keyboard_isfsexit()) - fs_off_signal = true; - - if (!fs_on_signal && (video_fullscreen == 0) && keyboard_isfsenter()) - fs_on_signal = true; + checkFullscreenHotkey(true); if (keyboard_ismsexit()) plat_mouse_capture(0); @@ -1289,15 +1285,7 @@ MainWindow::keyReleaseEvent(QKeyEvent *event) } } - if (fs_off_signal && (video_fullscreen > 0) && keyboard_isfsexit()) { - ui->actionFullscreen->trigger(); - fs_off_signal = false; - } - - if (fs_on_signal && (video_fullscreen == 0) && keyboard_isfsenter()) { - ui->actionFullscreen->trigger(); - fs_on_signal = false; - } + checkFullscreenHotkey(false); if (!send_keyboard_input || event->isAutoRepeat()) return; @@ -1309,6 +1297,28 @@ MainWindow::keyReleaseEvent(QKeyEvent *event) #endif } +void +MainWindow::checkFullscreenHotkey(bool down) +{ + if (down) { + if (!fs_off_signal && (video_fullscreen > 0) && keyboard_isfsexit()) + fs_off_signal = true; + + if (!fs_on_signal && (video_fullscreen == 0) && keyboard_isfsenter()) + fs_on_signal = true; + } else { + if (fs_off_signal && (video_fullscreen > 0) && keyboard_isfsexit()) { + ui->actionFullscreen->trigger(); + fs_off_signal = false; + } + + if (fs_on_signal && (video_fullscreen == 0) && keyboard_isfsenter()) { + ui->actionFullscreen->trigger(); + fs_on_signal = false; + } + } +} + QSize MainWindow::getRenderWidgetSize() { diff --git a/src/qt/qt_mainwindow.hpp b/src/qt/qt_mainwindow.hpp index 79b5d9dda..9bbfcaa6a 100644 --- a/src/qt/qt_mainwindow.hpp +++ b/src/qt/qt_mainwindow.hpp @@ -32,6 +32,7 @@ public: void blitToWidget(int x, int y, int w, int h, int monitor_index); QSize getRenderWidgetSize(); void setSendKeyboardInput(bool enabled); + void checkFullscreenHotkey(bool down); std::array, 8> renderers; signals: diff --git a/src/qt/qt_winrawinputfilter.cpp b/src/qt/qt_winrawinputfilter.cpp index bac049391..64ed22ccf 100644 --- a/src/qt/qt_winrawinputfilter.cpp +++ b/src/qt/qt_winrawinputfilter.cpp @@ -237,6 +237,8 @@ WindowsRawInputFilter::keyboard_handle(PRAWINPUT raw) break; } + window->checkFullscreenHotkey(!(rawKB.Flags & RI_KEY_BREAK)); + /* Translate right CTRL to left ALT if the user has so chosen. */ if ((scancode == 0x11d) && rctrl_is_lalt)