mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 01:50:42 -05:00
seat: Move set_cursor_surface and all that tracking to MetaWaylandPointer
This commit is contained in:
parent
ae0853ed86
commit
4510b82361
@ -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, ¤t);
|
||||
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);
|
||||
}
|
||||
|
@ -107,4 +107,8 @@ meta_wayland_pointer_update_current_focus (MetaWaylandPointer *pointer,
|
||||
void
|
||||
meta_wayland_pointer_update_cursor_surface (MetaWaylandPointer *pointer);
|
||||
|
||||
void
|
||||
meta_wayland_pointer_set_cursor_surface (MetaWaylandPointer *pointer,
|
||||
MetaWaylandSurface *surface);
|
||||
|
||||
#endif /* __META_WAYLAND_POINTER_H__ */
|
||||
|
@ -52,17 +52,7 @@ static void
|
||||
set_cursor_surface (MetaWaylandSeat *seat,
|
||||
MetaWaylandSurface *surface)
|
||||
{
|
||||
if (seat->pointer.cursor_surface == surface)
|
||||
return;
|
||||
|
||||
if (seat->pointer.cursor_surface)
|
||||
wl_list_remove (&seat->pointer.cursor_surface_destroy_listener.link);
|
||||
|
||||
seat->pointer.cursor_surface = surface;
|
||||
|
||||
if (seat->pointer.cursor_surface)
|
||||
wl_resource_add_destroy_listener (seat->pointer.cursor_surface->resource,
|
||||
&seat->pointer.cursor_surface_destroy_listener);
|
||||
meta_wayland_pointer_set_cursor_surface (&seat->pointer, surface);
|
||||
}
|
||||
|
||||
void
|
||||
@ -199,16 +189,6 @@ bind_seat (struct wl_client *client,
|
||||
wl_seat_send_name (resource, "seat0");
|
||||
}
|
||||
|
||||
static void
|
||||
pointer_handle_cursor_surface_destroy (struct wl_listener *listener, void *data)
|
||||
{
|
||||
MetaWaylandPointer *pointer = wl_container_of (listener, pointer, cursor_surface_destroy_listener);
|
||||
MetaWaylandSeat *seat = wl_container_of (pointer, seat, pointer);
|
||||
|
||||
set_cursor_surface (seat, NULL);
|
||||
meta_wayland_seat_update_cursor_surface (seat);
|
||||
}
|
||||
|
||||
MetaWaylandSeat *
|
||||
meta_wayland_seat_new (struct wl_display *display)
|
||||
{
|
||||
@ -225,11 +205,6 @@ meta_wayland_seat_new (struct wl_display *display)
|
||||
|
||||
seat->current_stage = 0;
|
||||
|
||||
seat->pointer.cursor_surface = NULL;
|
||||
seat->pointer.cursor_surface_destroy_listener.notify = pointer_handle_cursor_surface_destroy;
|
||||
seat->pointer.hotspot_x = 16;
|
||||
seat->pointer.hotspot_y = 16;
|
||||
|
||||
wl_global_create (display, &wl_seat_interface, META_WL_SEAT_VERSION, seat, bind_seat);
|
||||
|
||||
return seat;
|
||||
@ -238,8 +213,6 @@ meta_wayland_seat_new (struct wl_display *display)
|
||||
void
|
||||
meta_wayland_seat_free (MetaWaylandSeat *seat)
|
||||
{
|
||||
set_cursor_surface (seat, NULL);
|
||||
|
||||
meta_wayland_pointer_release (&seat->pointer);
|
||||
meta_wayland_keyboard_release (&seat->keyboard);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user