seat: Move cursor storage to MetaWaylandPointer

This commit is contained in:
Jasper St. Pierre 2014-04-17 16:54:30 -04:00
parent 76544ff6e1
commit ae0853ed86
8 changed files with 61 additions and 48 deletions

View File

@ -147,7 +147,7 @@ make_wayland_cursor_tracker (MetaScreen *screen)
self->pipeline = cogl_pipeline_new (ctx);
compositor = meta_wayland_compositor_get_default ();
compositor->seat->cursor_tracker = self;
compositor->seat->pointer.cursor_tracker = self;
meta_cursor_tracker_update_position (self,
wl_fixed_to_int (compositor->seat->pointer.x),
wl_fixed_to_int (compositor->seat->pointer.y));

View File

@ -222,7 +222,7 @@ meta_launcher_enter (MetaLauncher *launcher)
* update. */
clutter_actor_queue_redraw (compositor->stage);
meta_cursor_tracker_force_update (compositor->seat->cursor_tracker);
meta_cursor_tracker_force_update (compositor->seat->pointer.cursor_tracker);
}
}

View File

@ -49,6 +49,8 @@
#include "meta-wayland-pointer.h"
#include "meta-wayland-private.h"
#include "meta-cursor.h"
#include "meta-cursor-tracker-private.h"
#include <string.h>
@ -599,3 +601,28 @@ meta_wayland_pointer_update_current_focus (MetaWaylandPointer *pointer,
interface->focus (pointer->grab, surface);
}
}
void
meta_wayland_pointer_update_cursor_surface (MetaWaylandPointer *pointer)
{
MetaCursorReference *cursor;
if (pointer->cursor_tracker == NULL)
return;
if (pointer->cursor_surface && pointer->cursor_surface->buffer)
{
struct wl_resource *buffer = pointer->cursor_surface->buffer->resource;
cursor = meta_cursor_reference_from_buffer (pointer->cursor_tracker,
buffer,
pointer->hotspot_x,
pointer->hotspot_y);
}
else
cursor = NULL;
meta_cursor_tracker_set_window_cursor (pointer->cursor_tracker, cursor);
if (cursor)
meta_cursor_reference_unref (cursor);
}

View File

@ -26,6 +26,8 @@
#include "meta-wayland-types.h"
#include <meta/meta-cursor-tracker.h>
struct _MetaWaylandPointerGrabInterface
{
void (*focus) (MetaWaylandPointerGrab *grab,
@ -47,6 +49,11 @@ struct _MetaWaylandPointer
struct wl_list resource_list;
struct wl_list focus_resource_list;
MetaCursorTracker *cursor_tracker;
MetaWaylandSurface *cursor_surface;
struct wl_listener cursor_surface_destroy_listener;
int hotspot_x, hotspot_y;
MetaWaylandSurface *focus_surface;
struct wl_listener focus_surface_listener;
guint32 focus_serial;
@ -97,4 +104,7 @@ void
meta_wayland_pointer_update_current_focus (MetaWaylandPointer *pointer,
MetaWaylandSurface *surface);
void
meta_wayland_pointer_update_cursor_surface (MetaWaylandPointer *pointer);
#endif /* __META_WAYLAND_POINTER_H__ */

View File

@ -52,42 +52,23 @@ static void
set_cursor_surface (MetaWaylandSeat *seat,
MetaWaylandSurface *surface)
{
if (seat->cursor_surface == surface)
if (seat->pointer.cursor_surface == surface)
return;
if (seat->cursor_surface)
wl_list_remove (&seat->cursor_surface_destroy_listener.link);
if (seat->pointer.cursor_surface)
wl_list_remove (&seat->pointer.cursor_surface_destroy_listener.link);
seat->cursor_surface = surface;
seat->pointer.cursor_surface = surface;
if (seat->cursor_surface)
wl_resource_add_destroy_listener (seat->cursor_surface->resource,
&seat->cursor_surface_destroy_listener);
if (seat->pointer.cursor_surface)
wl_resource_add_destroy_listener (seat->pointer.cursor_surface->resource,
&seat->pointer.cursor_surface_destroy_listener);
}
void
meta_wayland_seat_update_cursor_surface (MetaWaylandSeat *seat)
{
MetaCursorReference *cursor;
if (seat->cursor_tracker == NULL)
return;
if (seat->cursor_surface && seat->cursor_surface->buffer)
{
struct wl_resource *buffer = seat->cursor_surface->buffer->resource;
cursor = meta_cursor_reference_from_buffer (seat->cursor_tracker,
buffer,
seat->hotspot_x,
seat->hotspot_y);
}
else
cursor = NULL;
meta_cursor_tracker_set_window_cursor (seat->cursor_tracker, cursor);
if (cursor)
meta_cursor_reference_unref (cursor);
meta_wayland_pointer_update_cursor_surface (&seat->pointer);
}
static void
@ -109,8 +90,8 @@ pointer_set_cursor (struct wl_client *client,
if (seat->pointer.focus_serial - serial > G_MAXUINT32 / 2)
return;
seat->hotspot_x = x;
seat->hotspot_y = y;
seat->pointer.hotspot_x = x;
seat->pointer.hotspot_y = y;
set_cursor_surface (seat, surface);
meta_wayland_seat_update_cursor_surface (seat);
}
@ -221,7 +202,8 @@ bind_seat (struct wl_client *client,
static void
pointer_handle_cursor_surface_destroy (struct wl_listener *listener, void *data)
{
MetaWaylandSeat *seat = wl_container_of (listener, seat, cursor_surface_destroy_listener);
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);
@ -243,10 +225,10 @@ meta_wayland_seat_new (struct wl_display *display)
seat->current_stage = 0;
seat->cursor_surface = NULL;
seat->cursor_surface_destroy_listener.notify = pointer_handle_cursor_surface_destroy;
seat->hotspot_x = 16;
seat->hotspot_y = 16;
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);
@ -397,14 +379,14 @@ meta_wayland_seat_update_pointer (MetaWaylandSeat *seat,
seat->pointer.button_count = count_buttons (event);
if (seat->cursor_tracker)
if (seat->pointer.cursor_tracker)
{
meta_cursor_tracker_update_position (seat->cursor_tracker,
meta_cursor_tracker_update_position (seat->pointer.cursor_tracker,
wl_fixed_to_int (seat->pointer.x),
wl_fixed_to_int (seat->pointer.y));
if (seat->pointer.current == NULL)
meta_cursor_tracker_unset_window_cursor (seat->cursor_tracker);
meta_cursor_tracker_unset_window_cursor (seat->pointer.cursor_tracker);
}
}

View File

@ -27,7 +27,6 @@
#include <clutter/clutter.h>
#include <glib.h>
#include <meta/meta-cursor-tracker.h>
#include "meta-wayland-types.h"
#include "meta-wayland-keyboard.h"
#include "meta-wayland-pointer.h"
@ -59,11 +58,6 @@ struct _MetaWaylandSeat
struct wl_display *display;
MetaCursorTracker *cursor_tracker;
MetaWaylandSurface *cursor_surface;
int hotspot_x, hotspot_y;
struct wl_listener cursor_surface_destroy_listener;
ClutterActor *current_stage;
};

View File

@ -41,8 +41,8 @@ meta_wayland_stage_paint (ClutterActor *actor)
CLUTTER_ACTOR_CLASS (meta_wayland_stage_parent_class)->paint (actor);
compositor = meta_wayland_compositor_get_default ();
if (compositor->seat->cursor_tracker)
meta_cursor_tracker_paint (compositor->seat->cursor_tracker);
if (compositor->seat->pointer.cursor_tracker)
meta_cursor_tracker_paint (compositor->seat->pointer.cursor_tracker);
}
static void

View File

@ -337,7 +337,7 @@ commit_double_buffered_state (MetaWaylandSurface *surface,
actor_surface_commit (surface, pending);
if (surface == compositor->seat->cursor_surface)
if (surface == compositor->seat->pointer.cursor_surface)
cursor_surface_commit (surface, pending);
else if (surface->window)
toplevel_surface_commit (surface, pending);