From 6fbf5f46045ddce936a5ca6582b53629668826bd Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Thu, 31 Aug 2017 18:09:49 +0200 Subject: [PATCH xserver] xwayland: avoid grab handler without protocol support If the compositor has no support for the Xwayland keyboard grab protocol, there is no need to set-up our keyboard grab handler. Signed-off-by: Olivier Fourdan --- hw/xwayland/xwayland-input.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c index acb467b91..d45bee410 100644 --- a/hw/xwayland/xwayland-input.c +++ b/hw/xwayland/xwayland-input.c @@ -1050,11 +1050,10 @@ set_grab(struct xwl_seat *xwl_seat, struct xwl_window *xwl_window) release_grab (xwl_seat); xwl_screen = xwl_seat->xwl_screen; - if (xwl_screen->wp_grab) - xwl_seat->keyboard_grab = - zwp_xwayland_keyboard_grab_manager_v1_grab_keyboard(xwl_screen->wp_grab, - xwl_window->surface, - xwl_seat->seat); + xwl_seat->keyboard_grab = + zwp_xwayland_keyboard_grab_manager_v1_grab_keyboard(xwl_screen->wp_grab, + xwl_window->surface, + xwl_seat->seat); } static void @@ -1197,14 +1196,18 @@ init_keyboard(struct xwl_seat *xwl_seat) EnableDevice(xwl_seat->keyboard, TRUE); xwl_seat->keyboard->key->xkbInfo->checkRepeat = keyboard_check_repeat; - master = GetMaster(xwl_seat->keyboard, MASTER_KEYBOARD); - if (master) - setup_keyboard_grab_handler(master); + if (xwl_seat->xwl_screen->wp_grab) { + /* We have Xwayland grab protocol supported by the compositor */ + master = GetMaster(xwl_seat->keyboard, MASTER_KEYBOARD); + if (master) + setup_keyboard_grab_handler(master); + } } static void release_keyboard(struct xwl_seat *xwl_seat) { + release_grab(xwl_seat); wl_keyboard_release(xwl_seat->wl_keyboard); xwl_seat->wl_keyboard = NULL; @@ -1257,7 +1260,6 @@ seat_handle_capabilities(void *data, struct wl_seat *seat, if (caps & WL_SEAT_CAPABILITY_KEYBOARD && xwl_seat->wl_keyboard == NULL) { init_keyboard(xwl_seat); } else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && xwl_seat->wl_keyboard) { - release_grab(xwl_seat); release_keyboard(xwl_seat); } @@ -2401,10 +2403,21 @@ static void init_keyboard_grab(struct xwl_screen *xwl_screen, uint32_t id, uint32_t version) { + struct xwl_seat *xwl_seat; + DeviceIntPtr master; + xwl_screen->wp_grab = wl_registry_bind(xwl_screen->registry, id, &zwp_xwayland_keyboard_grab_manager_v1_interface, 1); + + xorg_list_for_each_entry(xwl_seat, &xwl_screen->seat_list, link) { + if (xwl_seat->keyboard) { + master = GetMaster(xwl_seat->keyboard, MASTER_KEYBOARD); + if (master) + setup_keyboard_grab_handler(master); + } + } } static void -- 2.13.5