compositor: Repick surface when grab ends
authorKristian Høgsberg <krh@bitplanet.net>
Tue, 6 Sep 2011 17:41:47 +0000 (13:41 -0400)
committerKristian Høgsberg <krh@bitplanet.net>
Tue, 6 Sep 2011 17:41:47 +0000 (13:41 -0400)
We were doing it manually in a few places and forgetting it in the
implicit grab case.

compositor/compositor.c
compositor/shell.c

index c7099f0..ba19bd8 100644 (file)
@@ -1408,6 +1408,7 @@ notify_button(struct wl_input_device *device,
        struct wlsc_binding *b;
        struct wlsc_surface *surface =
                (struct wlsc_surface *) device->pointer_focus;
+       int32_t sx, sy;
 
        if (state)
                wlsc_compositor_idle_inhibit(compositor);
@@ -1434,8 +1435,13 @@ notify_button(struct wl_input_device *device,
                device->grab->interface->button(device->grab, time,
                                                button, state);
 
-       if (!state && device->grab && device->grab_button == button)
+       if (!state && device->grab && device->grab_button == button) {
                wl_input_device_end_grab(device, time);
+               surface = pick_surface(device, &sx, &sy);
+               wl_input_device_set_pointer_focus(device, &surface->surface,
+                                                 time, device->x, device->y,
+                                                 sx, sy);
+       }
 }
 
 static void
index cdc9e0a..4c959e6 100644 (file)
@@ -58,14 +58,6 @@ move_grab_button(struct wl_grab *grab,
 static void
 move_grab_end(struct wl_grab *grab, uint32_t time)
 {
-       struct wlsc_surface *es;
-       struct wl_input_device *device = grab->input_device;
-       int32_t sx, sy;
-
-       es = pick_surface(grab->input_device, &sx, &sy);
-       wl_input_device_set_pointer_focus(device,
-                                         &es->surface, time,
-                                         device->x, device->y, sx, sy);
        free(grab);
 }
 
@@ -162,14 +154,6 @@ resize_grab_button(struct wl_grab *grab,
 static void
 resize_grab_end(struct wl_grab *grab, uint32_t time)
 {
-       struct wlsc_surface *es;
-       struct wl_input_device *device = grab->input_device;
-       int32_t sx, sy;
-
-       es = pick_surface(grab->input_device, &sx, &sy);
-       wl_input_device_set_pointer_focus(device,
-                                         &es->surface, time,
-                                         device->x, device->y, sx, sy);
        free(grab);
 }
 
@@ -481,20 +465,12 @@ static void
 drag_grab_end(struct wl_grab *grab, uint32_t time)
 {
        struct wl_drag *drag = container_of(grab, struct wl_drag, grab);
-       struct wlsc_surface *es;
-       struct wl_input_device *device = grab->input_device;
-       int32_t sx, sy;
 
        if (drag->target)
                wl_resource_post_event(&drag->drag_offer.resource,
                                       WL_DRAG_OFFER_DROP);
 
        wl_drag_set_pointer_focus(drag, NULL, time, 0, 0, 0, 0);
-
-       es = pick_surface(grab->input_device, &sx, &sy);
-       wl_input_device_set_pointer_focus(device,
-                                         &es->surface, time,
-                                         device->x, device->y, sx, sy);
 }
 
 static const struct wl_grab_interface drag_grab_interface = {