Skip to content

Commit

Permalink
wayland: cancel key repeat when keyboard focus is lost
Browse files Browse the repository at this point in the history
SDL_SetKeyboardFocus(NULL) will lift any keys still pressed when keyboard focus
leaves the window, but then key repeat comes behind our backs and presses the
key down again. This results in an infinite stream of SDL_KEYDOWN events when
focus leaves the window with a key down (particularly noticeable with Alt+Tab).
  • Loading branch information
cgutman committed Feb 10, 2021
1 parent 2793c9c commit d133a5f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/video/wayland/SDL_waylandevents.c
Expand Up @@ -731,6 +731,12 @@ static void
keyboard_handle_leave(void *data, struct wl_keyboard *keyboard,
uint32_t serial, struct wl_surface *surface)
{
struct SDL_WaylandInput *input = data;

/* Stop key repeat before clearing keyboard focus */
keyboard_repeat_clear(&input->keyboard_repeat);

/* This will release any keys still pressed */
SDL_SetKeyboardFocus(NULL);
}

Expand Down

0 comments on commit d133a5f

Please sign in to comment.