From 17c97820b2030759e8b7e431e7d353c30bcff3dc Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Sun, 23 Jan 2022 15:12:03 +0100 Subject: [PATCH] Never forward capture keys In relative mode, Alt and Super are "capture keys". Never forward them to the input manager, to avoid inconsistencies between UP and DOWN events. --- app/src/screen.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/src/screen.c b/app/src/screen.c index cdd84367..af433648 100644 --- a/app/src/screen.c +++ b/app/src/screen.c @@ -824,14 +824,13 @@ sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event) { if (sc_screen_is_mouse_capture_key(key)) { if (!screen->mouse_capture_key_pressed) { screen->mouse_capture_key_pressed = key; - return; } else { // Another mouse capture key has been pressed, cancel // mouse (un)capture screen->mouse_capture_key_pressed = 0; - // Do not return, the event must be forwarded to the - // input manager } + // Mouse capture keys are never forwarded to the device + return; } } break; @@ -840,14 +839,16 @@ sc_screen_handle_event(struct sc_screen *screen, SDL_Event *event) { SDL_Keycode key = event->key.keysym.sym; SDL_Keycode cap = screen->mouse_capture_key_pressed; screen->mouse_capture_key_pressed = 0; - if (key == cap) { - // A mouse capture key has been pressed then released: - // toggle the capture mouse mode - sc_screen_capture_mouse(screen, !screen->mouse_captured); + if (sc_screen_is_mouse_capture_key(key)) { + if (key == cap) { + // A mouse capture key has been pressed then released: + // toggle the capture mouse mode + sc_screen_capture_mouse(screen, + !screen->mouse_captured); + } + // Mouse capture keys are never forwarded to the device return; } - // Do not return, the event must be forwarded to the input - // manager } break; case SDL_MOUSEWHEEL: