From cb406f1afd560762f60c27f7a88fd9f65c15041f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Wed, 9 Oct 2013 10:54:03 -0700 Subject: [PATCH] input: Don't send modifiers if client doesn't have a pointer resource This fixes an uninitialized serial error, were we could send out the modifier event even if the client didn't have a pointer resource. We send out the modifier event to let clients know the modifer mask when they receive a pointer button event. Thus, if the client doesn't have a pointer we don't need to send the modifier event. Additionally we would send out the modifier event with an uninitialized serial number. Finally, this commit restores the order of sending the modifier event before the enter, like it used to be. Not likely to be an issue, since the client will always receive the modifier event before any button event, but it's a little nicer to give the client the modifier events before it receives any pointer events. --- src/input.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/input.c b/src/input.c index 1313b526..a994fb95 100644 --- a/src/input.c +++ b/src/input.c @@ -489,6 +489,12 @@ weston_pointer_set_focus(struct weston_pointer *pointer, serial = wl_display_next_serial(display); + if (kbd && kbd->focus != pointer->focus) + send_modifiers_to_client_in_list(surface_client, + &kbd->resource_list, + serial, + kbd); + move_resources_for_client(focus_resource_list, &pointer->resource_list, surface_client); @@ -503,15 +509,6 @@ weston_pointer_set_focus(struct weston_pointer *pointer, pointer->focus_serial = serial; } - if (kbd && surface && surface->resource && kbd->focus != pointer->focus) { - struct wl_client *surface_client = - wl_resource_get_client(surface->resource); - send_modifiers_to_client_in_list(surface_client, - &kbd->resource_list, - serial, - kbd); - } - pointer->focus = surface; wl_signal_emit(&pointer->focus_signal, pointer); }