mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-08 13:29:47 -05:00
Use surface destroy notifier for cancelling grabs
This commit is contained in:
parent
3d76e652c5
commit
a9e8961ea2
2 changed files with 28 additions and 8 deletions
|
|
@ -481,6 +481,22 @@ wlsc_input_device_set_pointer_image(struct wlsc_input_device *device,
|
||||||
pointer_images[type].hotspot_y);
|
pointer_images[type].hotspot_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
wlsc_input_device_end_grab(struct wlsc_input_device *device, uint32_t time);
|
||||||
|
|
||||||
|
static void
|
||||||
|
lose_grab_surface(struct wl_listener *listener,
|
||||||
|
struct wl_surface *surface)
|
||||||
|
{
|
||||||
|
struct wlsc_input_device *device =
|
||||||
|
container_of(listener,
|
||||||
|
struct wlsc_input_device, grab_listener);
|
||||||
|
uint32_t time;
|
||||||
|
|
||||||
|
time = wl_display_get_time(device->ec->wl_display);
|
||||||
|
wlsc_input_device_end_grab(device, time);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
wlsc_input_device_start_grab(struct wlsc_input_device *device,
|
wlsc_input_device_start_grab(struct wlsc_input_device *device,
|
||||||
uint32_t time,
|
uint32_t time,
|
||||||
|
|
@ -498,6 +514,10 @@ wlsc_input_device_start_grab(struct wlsc_input_device *device,
|
||||||
|
|
||||||
wl_input_device_set_pointer_focus(&device->input_device,
|
wl_input_device_set_pointer_focus(&device->input_device,
|
||||||
&wl_grab_surface, time, 0, 0, 0, 0);
|
&wl_grab_surface, time, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
device->grab_listener.func = lose_grab_surface;
|
||||||
|
wl_list_insert(focus->surface.destroy_listener_list.prev,
|
||||||
|
&device->grab_listener.link);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -810,10 +830,6 @@ wlsc_input_device_end_grab(struct wlsc_input_device *device, uint32_t time)
|
||||||
|
|
||||||
switch (device->grab) {
|
switch (device->grab) {
|
||||||
case WLSC_DEVICE_GRAB_DRAG:
|
case WLSC_DEVICE_GRAB_DRAG:
|
||||||
if (drag->target)
|
|
||||||
wl_client_post_event(drag->target,
|
|
||||||
&drag->drag_offer.object,
|
|
||||||
WL_DRAG_OFFER_DROP);
|
|
||||||
wl_drag_set_pointer_focus(drag, NULL, time, 0, 0, 0, 0);
|
wl_drag_set_pointer_focus(drag, NULL, time, 0, 0, 0, 0);
|
||||||
device->drag = NULL;
|
device->drag = NULL;
|
||||||
break;
|
break;
|
||||||
|
|
@ -821,6 +837,7 @@ wlsc_input_device_end_grab(struct wlsc_input_device *device, uint32_t time)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wl_list_remove(&device->grab_listener.link);
|
||||||
device->grab = WLSC_DEVICE_GRAB_NONE;
|
device->grab = WLSC_DEVICE_GRAB_NONE;
|
||||||
es = pick_surface(device, &sx, &sy);
|
es = pick_surface(device, &sx, &sy);
|
||||||
wl_input_device_set_pointer_focus(&device->input_device,
|
wl_input_device_set_pointer_focus(&device->input_device,
|
||||||
|
|
@ -834,6 +851,7 @@ notify_button(struct wlsc_input_device *device,
|
||||||
{
|
{
|
||||||
struct wlsc_surface *surface;
|
struct wlsc_surface *surface;
|
||||||
struct wlsc_compositor *compositor = device->ec;
|
struct wlsc_compositor *compositor = device->ec;
|
||||||
|
struct wl_drag *drag = device->drag;
|
||||||
|
|
||||||
surface = (struct wlsc_surface *) device->input_device.pointer_focus;
|
surface = (struct wlsc_surface *) device->input_device.pointer_focus;
|
||||||
if (surface) {
|
if (surface) {
|
||||||
|
|
@ -874,6 +892,11 @@ notify_button(struct wlsc_input_device *device,
|
||||||
if (!state &&
|
if (!state &&
|
||||||
device->grab != WLSC_DEVICE_GRAB_NONE &&
|
device->grab != WLSC_DEVICE_GRAB_NONE &&
|
||||||
device->grab_button == button) {
|
device->grab_button == button) {
|
||||||
|
drag = device->drag;
|
||||||
|
if (drag && drag->target)
|
||||||
|
wl_client_post_event(drag->target,
|
||||||
|
&drag->drag_offer.object,
|
||||||
|
WL_DRAG_OFFER_DROP);
|
||||||
wlsc_input_device_end_grab(device, time);
|
wlsc_input_device_end_grab(device, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1130,7 +1153,6 @@ drag_cancel(struct wl_client *client, struct wl_drag *drag)
|
||||||
|
|
||||||
time = wl_display_get_time(wl_client_get_display(client));
|
time = wl_display_get_time(wl_client_get_display(client));
|
||||||
wlsc_input_device_end_grab(device, time);
|
wlsc_input_device_end_grab(device, time);
|
||||||
device->drag = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct wl_drag_interface drag_interface = {
|
static const struct wl_drag_interface drag_interface = {
|
||||||
|
|
@ -1151,7 +1173,6 @@ lose_pointer_focus(struct wl_listener *listener,
|
||||||
time = wl_display_get_time(wl_client_get_display(surface->client));
|
time = wl_display_get_time(wl_client_get_display(surface->client));
|
||||||
wl_input_device_set_pointer_focus(&device->input_device,
|
wl_input_device_set_pointer_focus(&device->input_device,
|
||||||
NULL, time, 0, 0, 0, 0);
|
NULL, time, 0, 0, 0, 0);
|
||||||
wlsc_input_device_end_grab(device, time);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
|
|
@ -99,8 +99,7 @@ struct wlsc_input_device {
|
||||||
int32_t grab_dx, grab_dy;
|
int32_t grab_dx, grab_dy;
|
||||||
uint32_t grab_button;
|
uint32_t grab_button;
|
||||||
struct wl_drag *drag;
|
struct wl_drag *drag;
|
||||||
|
struct wl_listener grab_listener;
|
||||||
struct wl_listener listener;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlsc_drm {
|
struct wlsc_drm {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue