From c5033616e9a7f51a12eba068a4116b8772cbd8d1 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Wed, 26 Nov 2014 15:22:01 -0800 Subject: [PATCH] pointer: Sync the focus surface instead of calling set_focus directly set_focus is really meant to be an internal function, and sync_focus_surface should be able to be called at any time and get things right. --- src/wayland/meta-wayland-pointer.c | 62 +++++++++++++++--------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c index 2b991831a..52d13da92 100644 --- a/src/wayland/meta-wayland-pointer.c +++ b/src/wayland/meta-wayland-pointer.c @@ -65,6 +65,36 @@ unbind_resource (struct wl_resource *resource) wl_list_remove (wl_resource_get_link (resource)); } +static void +sync_focus_surface (MetaWaylandPointer *pointer) +{ + MetaDisplay *display = meta_get_display (); + + switch (display->event_route) + { + case META_EVENT_ROUTE_WINDOW_OP: + /* Don't update the focus surface while we're grabbing a window. */ + return; + + case META_EVENT_ROUTE_COMPOSITOR_GRAB: + /* The compositor has a grab, so remove our focus... */ + meta_wayland_pointer_set_focus (pointer, NULL); + break; + + case META_EVENT_ROUTE_NORMAL: + case META_EVENT_ROUTE_WAYLAND_POPUP: + { + const MetaWaylandPointerGrabInterface *interface = pointer->grab->interface; + interface->focus (pointer->grab, pointer->current); + } + break; + + default: + g_assert_not_reached (); + } + +} + static void set_cursor_surface (MetaWaylandPointer *pointer, MetaWaylandSurface *surface) @@ -179,7 +209,7 @@ default_grab_button (MetaWaylandPointerGrab *grab, } if (pointer->button_count == 0 && event_type == CLUTTER_BUTTON_RELEASE) - meta_wayland_pointer_set_focus (pointer, pointer->current); + sync_focus_surface (pointer); } static const MetaWaylandPointerGrabInterface default_pointer_grab_interface = { @@ -247,36 +277,6 @@ count_buttons (const ClutterEvent *event) return count; } -static void -sync_focus_surface (MetaWaylandPointer *pointer) -{ - MetaDisplay *display = meta_get_display (); - - switch (display->event_route) - { - case META_EVENT_ROUTE_WINDOW_OP: - /* Don't update the focus surface while we're grabbing a window. */ - return; - - case META_EVENT_ROUTE_COMPOSITOR_GRAB: - /* The compositor has a grab, so remove our focus... */ - meta_wayland_pointer_set_focus (pointer, NULL); - break; - - case META_EVENT_ROUTE_NORMAL: - case META_EVENT_ROUTE_WAYLAND_POPUP: - { - const MetaWaylandPointerGrabInterface *interface = pointer->grab->interface; - interface->focus (pointer->grab, pointer->current); - } - break; - - default: - g_assert_not_reached (); - } - -} - static void repick_for_event (MetaWaylandPointer *pointer, const ClutterEvent *for_event)