Consume KeyDown event if key will be consumed as a shortcut when the user releases the key

This commit is contained in:
Arian Baishya 2023-08-06 02:35:12 -05:00 committed by Joshie
parent 6a8500f670
commit a7dd157f51

View file

@ -224,6 +224,18 @@ void inputSDLThreadRun( void )
wlserver_unlock();
break;
case SDL_KEYDOWN:
// If this keydown event is super + one of the shortcut keys, consume the keydown event, since the corresponding keyup
// event will be consumed by the next case statement when the user releases the key
if ( event.key.keysym.mod & KMOD_LGUI )
{
key = SDLScancodeToLinuxKey( event.key.keysym.scancode );
const uint32_t shortcutKeys[] = {KEY_F, KEY_N, KEY_B, KEY_U, KEY_Y, KEY_I, KEY_O, KEY_S, KEY_G};
const bool isShortcutKey = std::find(std::begin(shortcutKeys), std::end(shortcutKeys), key) != std::end(shortcutKeys);
if ( isShortcutKey )
{
break;
}
}
case SDL_KEYUP:
key = SDLScancodeToLinuxKey( event.key.keysym.scancode );