qt: Port fullscreen key detection behavior from Win32

This commit is contained in:
RichardG867
2023-07-24 17:16:01 -03:00
parent 8d46224893
commit 0d1d069af4
3 changed files with 24 additions and 27 deletions

View File

@@ -1252,7 +1252,7 @@ MainWindow::keyPressEvent(QKeyEvent *event)
#endif #endif
} }
checkFullscreenHotkey(true); checkFullscreenHotkey();
if (keyboard_ismsexit()) if (keyboard_ismsexit())
plat_mouse_capture(0); plat_mouse_capture(0);
@@ -1288,37 +1288,34 @@ MainWindow::keyReleaseEvent(QKeyEvent *event)
} }
} }
checkFullscreenHotkey(false); if (send_keyboard_input && !event->isAutoRepeat()) {
if (!send_keyboard_input || event->isAutoRepeat())
return;
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
processMacKeyboardInput(false, event); processMacKeyboardInput(false, event);
#else #else
processKeyboardInput(false, event->nativeScanCode()); processKeyboardInput(false, event->nativeScanCode());
#endif #endif
}
checkFullscreenHotkey();
} }
void void
MainWindow::checkFullscreenHotkey(bool down) MainWindow::checkFullscreenHotkey()
{ {
if (down) { if (!fs_off_signal && video_fullscreen && keyboard_isfsexit()) {
if (!fs_off_signal && (video_fullscreen > 0) && keyboard_isfsexit()) /* Signal "exit fullscreen mode". */
fs_off_signal = true; fs_off_signal = 1;
} else if (fs_off_signal && video_fullscreen && keyboard_isfsexit_up()) {
ui->actionFullscreen->trigger();
fs_off_signal = 0;
}
if (!fs_on_signal && (video_fullscreen == 0) && keyboard_isfsenter()) if (!fs_on_signal && !video_fullscreen && keyboard_isfsenter()) {
fs_on_signal = true; /* Signal "enter fullscreen mode". */
} else { fs_on_signal = 1;
if (fs_off_signal && (video_fullscreen > 0) && keyboard_isfsexit()) { } else if (fs_on_signal && !video_fullscreen && keyboard_isfsenter_up()) {
ui->actionFullscreen->trigger(); ui->actionFullscreen->trigger();
fs_off_signal = false; fs_on_signal = 0;
}
if (fs_on_signal && (video_fullscreen == 0) && keyboard_isfsenter()) {
ui->actionFullscreen->trigger();
fs_on_signal = false;
}
} }
} }

View File

@@ -32,7 +32,7 @@ public:
void blitToWidget(int x, int y, int w, int h, int monitor_index); void blitToWidget(int x, int y, int w, int h, int monitor_index);
QSize getRenderWidgetSize(); QSize getRenderWidgetSize();
void setSendKeyboardInput(bool enabled); void setSendKeyboardInput(bool enabled);
void checkFullscreenHotkey(bool down); void checkFullscreenHotkey();
std::array<std::unique_ptr<RendererStack>, 8> renderers; std::array<std::unique_ptr<RendererStack>, 8> renderers;
signals: signals:

View File

@@ -237,8 +237,6 @@ WindowsRawInputFilter::keyboard_handle(PRAWINPUT raw)
break; break;
} }
window->checkFullscreenHotkey(!(rawKB.Flags & RI_KEY_BREAK));
/* Translate right CTRL to left ALT if the user has so /* Translate right CTRL to left ALT if the user has so
chosen. */ chosen. */
if ((scancode == 0x11d) && rctrl_is_lalt) if ((scancode == 0x11d) && rctrl_is_lalt)
@@ -248,6 +246,8 @@ WindowsRawInputFilter::keyboard_handle(PRAWINPUT raw)
it's not an invalid scan code. */ it's not an invalid scan code. */
if (scancode != 0xFFFF) if (scancode != 0xFFFF)
keyboard_input(!(rawKB.Flags & RI_KEY_BREAK), scancode); keyboard_input(!(rawKB.Flags & RI_KEY_BREAK), scancode);
window->checkFullscreenHotkey();
} }
} else { } else {
if (rawKB.MakeCode == 0x1D) { if (rawKB.MakeCode == 0x1D) {