Wayland: Dont loose keyboard grab when new OS window created
This commit is contained in:
parent
6f689f3221
commit
82523b14df
1 changed files with 14 additions and 8 deletions
22
glfw/wl_window.c
vendored
22
glfw/wl_window.c
vendored
|
|
@ -46,6 +46,18 @@
|
|||
static bool
|
||||
is_layer_shell(_GLFWwindow *window) { return window->wl.layer_shell.config.type != GLFW_LAYER_SHELL_NONE; }
|
||||
|
||||
static void
|
||||
inhibit_shortcuts_for(_GLFWwindow *window, bool inhibit) {
|
||||
if (inhibit) {
|
||||
if (window->wl.keyboard_shortcuts_inhibitor) return;
|
||||
window->wl.keyboard_shortcuts_inhibitor = zwp_keyboard_shortcuts_inhibit_manager_v1_inhibit_shortcuts(_glfw.wl.keyboard_shortcuts_inhibit_manager, window->wl.surface, _glfw.wl.seat);
|
||||
} else {
|
||||
if (!window->wl.keyboard_shortcuts_inhibitor) return;
|
||||
zwp_keyboard_shortcuts_inhibitor_v1_destroy(window->wl.keyboard_shortcuts_inhibitor);
|
||||
window->wl.keyboard_shortcuts_inhibitor = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
activation_token_done(void *data, struct xdg_activation_token_v1 *xdg_token, const char *token) {
|
||||
for (size_t i = 0; i < _glfw.wl.activation_requests.sz; i++) {
|
||||
|
|
@ -616,6 +628,7 @@ static bool createSurface(_GLFWwindow* window,
|
|||
update_regions(window);
|
||||
|
||||
wl_surface_set_buffer_scale(window->wl.surface, scale);
|
||||
if (_glfw.keyboard_grabbed) inhibit_shortcuts_for(window, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -2826,14 +2839,7 @@ bool
|
|||
_glfwPlatformGrabKeyboard(bool grab) {
|
||||
if (!_glfw.wl.keyboard_shortcuts_inhibit_manager) return false;
|
||||
for (_GLFWwindow* window = _glfw.windowListHead; window; window = window->next) {
|
||||
if (grab) {
|
||||
if (window->wl.keyboard_shortcuts_inhibitor) break;
|
||||
window->wl.keyboard_shortcuts_inhibitor = zwp_keyboard_shortcuts_inhibit_manager_v1_inhibit_shortcuts(_glfw.wl.keyboard_shortcuts_inhibit_manager, window->wl.surface, _glfw.wl.seat);
|
||||
} else {
|
||||
if (!window->wl.keyboard_shortcuts_inhibitor) break;
|
||||
zwp_keyboard_shortcuts_inhibitor_v1_destroy(window->wl.keyboard_shortcuts_inhibitor);
|
||||
window->wl.keyboard_shortcuts_inhibitor = NULL;
|
||||
}
|
||||
inhibit_shortcuts_for(window, grab);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue