seat: Move set_cursor_surface and all that tracking to MetaWaylandPointer

This commit is contained in:
Jasper St. Pierre
2014-04-17 17:00:59 -04:00
parent ae0853ed86
commit 4510b82361
3 changed files with 44 additions and 29 deletions

View File

@ -56,6 +56,32 @@
static void meta_wayland_pointer_end_popup_grab (MetaWaylandPointer *pointer);
static void
set_cursor_surface (MetaWaylandPointer *pointer,
MetaWaylandSurface *surface)
{
if (pointer->cursor_surface == surface)
return;
if (pointer->cursor_surface)
wl_list_remove (&pointer->cursor_surface_destroy_listener.link);
pointer->cursor_surface = surface;
if (pointer->cursor_surface)
wl_resource_add_destroy_listener (pointer->cursor_surface->resource,
&pointer->cursor_surface_destroy_listener);
}
static void
pointer_handle_cursor_surface_destroy (struct wl_listener *listener, void *data)
{
MetaWaylandPointer *pointer = wl_container_of (listener, pointer, cursor_surface_destroy_listener);
set_cursor_surface (pointer, NULL);
meta_wayland_pointer_update_cursor_surface (pointer);
}
static void
pointer_handle_focus_surface_destroy (struct wl_listener *listener, void *data)
{
@ -284,12 +310,17 @@ meta_wayland_pointer_init (MetaWaylandPointer *pointer)
clutter_input_device_get_coords (device, NULL, &current);
pointer->x = wl_fixed_from_double (current.x);
pointer->y = wl_fixed_from_double (current.y);
pointer->cursor_surface = NULL;
pointer->cursor_surface_destroy_listener.notify = pointer_handle_cursor_surface_destroy;
pointer->hotspot_x = 16;
pointer->hotspot_y = 16;
}
void
meta_wayland_pointer_release (MetaWaylandPointer *pointer)
{
/* Do nothing. */
set_cursor_surface (pointer, NULL);
}
static void
@ -626,3 +657,10 @@ meta_wayland_pointer_update_cursor_surface (MetaWaylandPointer *pointer)
if (cursor)
meta_cursor_reference_unref (cursor);
}
void
meta_wayland_pointer_set_cursor_surface (MetaWaylandPointer *pointer,
MetaWaylandSurface *surface)
{
set_cursor_surface (pointer, surface);
}