Refactor keyboard grab to be managed by the video core

This gives us flexibility to add others hints to control keyboard grab behavior
without having to touch all of the backends. It also allows us to possibly
expose keyboard grab separately from mouse grab for applications that want to
manage those independently.
This commit is contained in:
Cameron Gutman
2021-01-23 16:22:44 -06:00
parent f40551c5f6
commit e1f73e642b
11 changed files with 55 additions and 24 deletions

View File

@@ -676,12 +676,20 @@ Wayland_SetWindowGrab(_THIS, SDL_Window *window, SDL_bool grabbed)
if (grabbed) {
Wayland_input_confine_pointer(window, data->input);
} else {
Wayland_input_unconfine_pointer(data->input);
}
}
if (SDL_GetHintBoolean(SDL_HINT_GRAB_KEYBOARD, SDL_FALSE))
Wayland_input_grab_keyboard(window, data->input);
void
Wayland_SetWindowKeyboardGrab(_THIS, SDL_Window *window, SDL_bool grabbed)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
if (grabbed) {
Wayland_input_grab_keyboard(window, data->input);
} else {
Wayland_input_ungrab_keyboard(window);
Wayland_input_unconfine_pointer(data->input);
}
}