diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2012-06-22 14:38:12 -0400 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2012-06-22 14:38:12 -0400 |
commit | 9afb5f61f8e77f33c63e17f54720f12f9c40287c (patch) | |
tree | 5accef0550edcade4edf72aa9cb8c98590cf67c4 | |
parent | 67e16be8aa9408d77dc291d9accb238fb9422c94 (diff) |
Send modifier event to pointer focus when it changes too
-rw-r--r-- | src/wayland-server.c | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/src/wayland-server.c b/src/wayland-server.c index 8372b06..1ff11ec 100644 --- a/src/wayland-server.c +++ b/src/wayland-server.c @@ -532,13 +532,30 @@ default_grab_key(struct wl_keyboard_grab *grab, } } +static struct wl_resource * +find_resource_for_surface(struct wl_list *list, struct wl_surface *surface) +{ + struct wl_resource *r; + + if (!surface) + return NULL; + + wl_list_for_each(r, list, link) { + if (r->client == surface->resource.client) + return r; + } + + return NULL; +} + static void default_grab_modifiers(struct wl_keyboard_grab *grab, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group) { struct wl_keyboard *keyboard = grab->keyboard; - struct wl_resource *resource; + struct wl_pointer *pointer = keyboard->seat->pointer; + struct wl_resource *resource, *pr; resource = keyboard->focus_resource; if (!resource) @@ -546,6 +563,19 @@ default_grab_modifiers(struct wl_keyboard_grab *grab, uint32_t serial, wl_keyboard_send_modifiers(resource, serial, mods_depressed, mods_latched, mods_locked, group); + + if (pointer && pointer->focus && pointer->focus != keyboard->focus) { + pr = find_resource_for_surface(&keyboard->resource_list, + pointer->focus); + if (pr) { + wl_keyboard_send_modifiers(pr, + serial, + keyboard->modifiers.mods_depressed, + keyboard->modifiers.mods_latched, + keyboard->modifiers.mods_locked, + keyboard->modifiers.group); + } + } } static const struct wl_keyboard_grab_interface @@ -704,22 +734,6 @@ wl_seat_set_touch(struct wl_seat *seat, struct wl_touch *touch) seat_send_updated_caps(seat); } -static struct wl_resource * -find_resource_for_surface(struct wl_list *list, struct wl_surface *surface) -{ - struct wl_resource *r; - - if (!surface) - return NULL; - - wl_list_for_each(r, list, link) { - if (r->client == surface->resource.client) - return r; - } - - return NULL; -} - WL_EXPORT void wl_pointer_set_focus(struct wl_pointer *pointer, struct wl_surface *surface, wl_fixed_t sx, wl_fixed_t sy) |