mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-05 19:08:12 +00:00
keyboard: Release bound keymaps during the destruction process
If a bound keymap is being destroyed, unbind it to ensure that the keyboard state won't be left pointing to an invalid keymap. Backends now no longer need to manually do this when destroying keymaps during keyboard removal and shutdown.
This commit is contained in:
@@ -207,6 +207,10 @@ void SDL_DestroyKeymap(SDL_Keymap *keymap)
|
||||
return;
|
||||
}
|
||||
|
||||
if (keymap == SDL_GetCurrentKeymap(true)) {
|
||||
SDL_SetKeymap(NULL, false);
|
||||
}
|
||||
|
||||
SDL_DestroyHashTable(keymap->scancode_to_keycode);
|
||||
SDL_DestroyHashTable(keymap->keycode_to_scancode);
|
||||
SDL_free(keymap);
|
||||
|
@@ -2258,7 +2258,6 @@ static void Wayland_SeatDestroyKeyboard(SDL_WaylandSeat *seat, bool send_event)
|
||||
if (seat->keyboard.sdl_keymap) {
|
||||
if (seat->keyboard.xkb.current_layout < seat->keyboard.xkb.num_layouts &&
|
||||
seat->keyboard.sdl_keymap[seat->keyboard.xkb.current_layout] == SDL_GetCurrentKeymap(true)) {
|
||||
SDL_SetKeymap(NULL, false);
|
||||
SDL_SetModState(SDL_KMOD_NONE);
|
||||
}
|
||||
for (xkb_layout_index_t i = 0; i < seat->keyboard.xkb.num_layouts; ++i) {
|
||||
|
@@ -240,7 +240,6 @@ void WIN_QuitKeyboard(SDL_VideoDevice *_this)
|
||||
}
|
||||
#endif // !SDL_DISABLE_WINDOWS_IME
|
||||
|
||||
SDL_SetKeymap(NULL, false);
|
||||
for (int i = 0; i < keymap_cache_size; ++i) {
|
||||
SDL_DestroyKeymap(keymap_cache[i].keymap);
|
||||
}
|
||||
|
@@ -380,7 +380,6 @@ void X11_UpdateKeymap(SDL_VideoDevice *_this, bool send_event)
|
||||
if (data->keyboard.xkb_enabled) {
|
||||
XkbStateRec state;
|
||||
|
||||
SDL_SetKeymap(NULL, false);
|
||||
for (unsigned int i = 0; i < XkbNumKbdGroups; ++i) {
|
||||
SDL_DestroyKeymap(data->keyboard.xkb.keymaps[i]);
|
||||
data->keyboard.xkb.keymaps[i] = SDL_CreateKeymap(false);
|
||||
@@ -515,7 +514,6 @@ void X11_QuitKeyboard(SDL_VideoDevice *_this)
|
||||
|
||||
#ifdef SDL_VIDEO_DRIVER_X11_HAS_XKBLIB
|
||||
if (data->keyboard.xkb_enabled) {
|
||||
SDL_SetKeymap(NULL, false);
|
||||
for (int i = 0; i < XkbNumKbdGroups; ++i) {
|
||||
SDL_DestroyKeymap(data->keyboard.xkb.keymaps[i]);
|
||||
data->keyboard.xkb.keymaps[i] = NULL;
|
||||
|
Reference in New Issue
Block a user