From b2c18c4a7846bf5e358b18e10b1bb7f2bfa67402 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Tue, 3 Dec 2013 10:46:57 -0500 Subject: [PATCH] Revert "keyboard: Remove focus listener" This reverts commit 0ac142d39e27e2692cbe0b18136a41bee424a6b0. --- src/wayland/meta-wayland-keyboard.c | 17 +++++++++++++++++ src/wayland/meta-wayland-keyboard.h | 1 + 2 files changed, 18 insertions(+) diff --git a/src/wayland/meta-wayland-keyboard.c b/src/wayland/meta-wayland-keyboard.c index ec769e7f4..af164241a 100644 --- a/src/wayland/meta-wayland-keyboard.c +++ b/src/wayland/meta-wayland-keyboard.c @@ -221,6 +221,16 @@ err_keymap_str: return; } +static void +lose_keyboard_focus (struct wl_listener *listener, void *data) +{ + MetaWaylandKeyboard *keyboard = + wl_container_of (listener, keyboard, focus_listener); + + keyboard->focus_resource = NULL; + keyboard->focus = NULL; +} + static gboolean default_grab_key (MetaWaylandKeyboardGrab *grab, uint32_t time, uint32_t key, uint32_t state) @@ -330,6 +340,7 @@ meta_wayland_keyboard_init (MetaWaylandKeyboard *keyboard, wl_list_init (&keyboard->resource_list); wl_array_init (&keyboard->keys); + keyboard->focus_listener.notify = lose_keyboard_focus; keyboard->default_grab.interface = &default_keyboard_grab_interface; keyboard->default_grab.keyboard = keyboard; keyboard->grab = &keyboard->default_grab; @@ -511,6 +522,7 @@ meta_wayland_keyboard_set_focus (MetaWaylandKeyboard *keyboard, struct wl_display *display = wl_client_get_display (client); serial = wl_display_next_serial (display); wl_keyboard_send_leave (resource, serial, keyboard->focus->resource); + wl_list_remove (&keyboard->focus_listener.link); meta_wayland_surface_focused_unset (keyboard->focus); } @@ -545,6 +557,7 @@ meta_wayland_keyboard_set_focus (MetaWaylandKeyboard *keyboard, wl_keyboard_send_enter (resource, serial, surface->resource, &keyboard->keys); } + wl_resource_add_destroy_listener (resource, &keyboard->focus_listener); keyboard->focus_serial = serial; meta_wayland_surface_focused_set (surface); @@ -575,6 +588,10 @@ meta_wayland_keyboard_release (MetaWaylandKeyboard *keyboard) { meta_wayland_xkb_info_destroy (&keyboard->xkb_info); xkb_context_unref (keyboard->xkb_context); + + /* XXX: What about keyboard->resource_list? */ + if (keyboard->focus_resource) + wl_list_remove (&keyboard->focus_listener.link); wl_array_release (&keyboard->keys); } diff --git a/src/wayland/meta-wayland-keyboard.h b/src/wayland/meta-wayland-keyboard.h index f0a793cca..4354faf21 100644 --- a/src/wayland/meta-wayland-keyboard.h +++ b/src/wayland/meta-wayland-keyboard.h @@ -94,6 +94,7 @@ struct _MetaWaylandKeyboard struct wl_list resource_list; MetaWaylandSurface *focus; struct wl_resource *focus_resource; + struct wl_listener focus_listener; uint32_t focus_serial; MetaWaylandKeyboardGrab *grab;