wayland: Move cursor surface role to meta-wayland-pointer.c

The wl_pointer assigns a role to a wl_surface, so it makes sense to put
the related logic there.

https://bugzilla.gnome.org/show_bug.cgi?id=744932
This commit is contained in:
Jonas Ådahl 2015-07-17 22:02:15 +08:00
parent e407f5bbae
commit 7c7cf91c32
6 changed files with 66 additions and 57 deletions

View File

@ -58,6 +58,16 @@
#define DEFAULT_AXIS_STEP_DISTANCE wl_fixed_from_int (10) #define DEFAULT_AXIS_STEP_DISTANCE wl_fixed_from_int (10)
struct _MetaWaylandSurfaceRoleCursor
{
MetaWaylandSurfaceRole parent;
};
GType meta_wayland_surface_role_cursor_get_type (void) G_GNUC_CONST;
G_DEFINE_TYPE (MetaWaylandSurfaceRoleCursor,
meta_wayland_surface_role_cursor,
META_TYPE_WAYLAND_SURFACE_ROLE);
static MetaWaylandPointerClient * static MetaWaylandPointerClient *
meta_wayland_pointer_client_new (void) meta_wayland_pointer_client_new (void)
{ {
@ -851,3 +861,41 @@ meta_wayland_pointer_get_top_popup (MetaWaylandPointer *pointer)
grab = (MetaWaylandPopupGrab*)pointer->grab; grab = (MetaWaylandPopupGrab*)pointer->grab;
return meta_wayland_popup_grab_get_top_popup(grab); return meta_wayland_popup_grab_get_top_popup(grab);
} }
static void
cursor_surface_role_assigned (MetaWaylandSurfaceRole *surface_role)
{
MetaWaylandSurface *surface =
meta_wayland_surface_role_get_surface (surface_role);
meta_wayland_surface_queue_pending_frame_callbacks (surface);
}
static void
cursor_surface_role_commit (MetaWaylandSurfaceRole *surface_role,
MetaWaylandPendingState *pending)
{
MetaWaylandSurface *surface =
meta_wayland_surface_role_get_surface (surface_role);
MetaWaylandPointer *pointer = &surface->compositor->seat->pointer;
meta_wayland_surface_queue_pending_state_frame_callbacks (surface, pending);
if (pending->newly_attached)
meta_wayland_pointer_update_cursor_surface (pointer);
}
static void
meta_wayland_surface_role_cursor_init (MetaWaylandSurfaceRoleCursor *role)
{
}
static void
meta_wayland_surface_role_cursor_class_init (MetaWaylandSurfaceRoleCursorClass *klass)
{
MetaWaylandSurfaceRoleClass *surface_role_class =
META_WAYLAND_SURFACE_ROLE_CLASS (klass);
surface_role_class->assigned = cursor_surface_role_assigned;
surface_role_class->commit = cursor_surface_role_commit;
}

View File

@ -27,9 +27,16 @@
#include "meta-wayland-types.h" #include "meta-wayland-types.h"
#include "meta-wayland-pointer-gesture-swipe.h" #include "meta-wayland-pointer-gesture-swipe.h"
#include "meta-wayland-pointer-gesture-pinch.h" #include "meta-wayland-pointer-gesture-pinch.h"
#include "meta-wayland-surface.h"
#include <meta/meta-cursor-tracker.h> #include <meta/meta-cursor-tracker.h>
#define META_TYPE_WAYLAND_SURFACE_ROLE_CURSOR (meta_wayland_surface_role_cursor_get_type ())
G_DECLARE_FINAL_TYPE (MetaWaylandSurfaceRoleCursor,
meta_wayland_surface_role_cursor,
META, WAYLAND_SURFACE_ROLE_CURSOR,
MetaWaylandSurfaceRole);
struct _MetaWaylandPointerGrabInterface struct _MetaWaylandPointerGrabInterface
{ {
void (*focus) (MetaWaylandPointerGrab *grab, void (*focus) (MetaWaylandPointerGrab *grab,

View File

@ -372,15 +372,6 @@ meta_wayland_seat_set_input_focus (MetaWaylandSeat *seat,
meta_wayland_data_device_set_keyboard_focus (&seat->data_device); meta_wayland_data_device_set_keyboard_focus (&seat->data_device);
} }
void
meta_wayland_seat_update_cursor_surface (MetaWaylandSeat *seat)
{
if ((seat->capabilities & WL_SEAT_CAPABILITY_POINTER) == 0)
return;
meta_wayland_pointer_update_cursor_surface (&seat->pointer);
}
gboolean gboolean
meta_wayland_seat_get_grab_info (MetaWaylandSeat *seat, meta_wayland_seat_get_grab_info (MetaWaylandSeat *seat,
MetaWaylandSurface *surface, MetaWaylandSurface *surface,

View File

@ -58,7 +58,6 @@ void meta_wayland_seat_set_input_focus (MetaWaylandSeat *seat,
MetaWaylandSurface *surface); MetaWaylandSurface *surface);
void meta_wayland_seat_repick (MetaWaylandSeat *seat); void meta_wayland_seat_repick (MetaWaylandSeat *seat);
void meta_wayland_seat_update_cursor_surface (MetaWaylandSeat *seat);
gboolean meta_wayland_seat_get_grab_info (MetaWaylandSeat *seat, gboolean meta_wayland_seat_get_grab_info (MetaWaylandSeat *seat,
MetaWaylandSurface *surface, MetaWaylandSurface *surface,

View File

@ -122,16 +122,6 @@ G_DEFINE_TYPE (MetaWaylandSurfaceRoleWlShellSurface,
meta_wayland_surface_role_wl_shell_surface, meta_wayland_surface_role_wl_shell_surface,
META_TYPE_WAYLAND_SURFACE_ROLE); META_TYPE_WAYLAND_SURFACE_ROLE);
struct _MetaWaylandSurfaceRoleCursor
{
MetaWaylandSurfaceRole parent;
};
GType meta_wayland_surface_role_cursor_get_type (void) G_GNUC_CONST;
G_DEFINE_TYPE (MetaWaylandSurfaceRoleCursor,
meta_wayland_surface_role_cursor,
META_TYPE_WAYLAND_SURFACE_ROLE);
struct _MetaWaylandSurfaceRoleDND struct _MetaWaylandSurfaceRoleDND
{ {
MetaWaylandSurfaceRole parent; MetaWaylandSurfaceRole parent;
@ -267,19 +257,6 @@ meta_wayland_surface_queue_pending_state_frame_callbacks (MetaWaylandSurface
wl_list_init (&pending->frame_callback_list); wl_list_init (&pending->frame_callback_list);
} }
static void
cursor_surface_commit (MetaWaylandSurfaceRole *surface_role,
MetaWaylandPendingState *pending)
{
MetaWaylandSurface *surface =
meta_wayland_surface_role_get_surface (surface_role);
meta_wayland_surface_queue_pending_state_frame_callbacks (surface, pending);
if (pending->newly_attached)
meta_wayland_seat_update_cursor_surface (surface->compositor->seat);
}
static void static void
dnd_surface_commit (MetaWaylandSurfaceRole *surface_role, dnd_surface_commit (MetaWaylandSurfaceRole *surface_role,
MetaWaylandPendingState *pending) MetaWaylandPendingState *pending)
@ -2488,15 +2465,21 @@ meta_wayland_surface_role_get_surface (MetaWaylandSurfaceRole *role)
return priv->surface; return priv->surface;
} }
void
meta_wayland_surface_queue_pending_frame_callbacks (MetaWaylandSurface *surface)
{
wl_list_insert_list (&surface->compositor->frame_callbacks,
&surface->pending_frame_callback_list);
wl_list_init (&surface->pending_frame_callback_list);
}
static void static void
default_role_assigned (MetaWaylandSurfaceRole *surface_role) default_role_assigned (MetaWaylandSurfaceRole *surface_role)
{ {
MetaWaylandSurface *surface = MetaWaylandSurface *surface =
meta_wayland_surface_role_get_surface (surface_role); meta_wayland_surface_role_get_surface (surface_role);
wl_list_insert_list (&surface->compositor->frame_callbacks, meta_wayland_surface_queue_pending_frame_callbacks (surface);
&surface->pending_frame_callback_list);
wl_list_init (&surface->pending_frame_callback_list);
} }
static void static void
@ -2512,21 +2495,6 @@ actor_surface_assigned (MetaWaylandSurfaceRole *surface_role)
wl_list_init (&surface->pending_frame_callback_list); wl_list_init (&surface->pending_frame_callback_list);
} }
static void
meta_wayland_surface_role_cursor_init (MetaWaylandSurfaceRoleCursor *role)
{
}
static void
meta_wayland_surface_role_cursor_class_init (MetaWaylandSurfaceRoleCursorClass *klass)
{
MetaWaylandSurfaceRoleClass *surface_role_class =
META_WAYLAND_SURFACE_ROLE_CLASS (klass);
surface_role_class->assigned = default_role_assigned;
surface_role_class->commit = cursor_surface_commit;
}
static void static void
meta_wayland_surface_role_dnd_init (MetaWaylandSurfaceRoleDND *role) meta_wayland_surface_role_dnd_init (MetaWaylandSurfaceRoleDND *role)
{ {

View File

@ -84,12 +84,6 @@ G_DECLARE_FINAL_TYPE (MetaWaylandSurfaceRoleWlShellSurface,
META, WAYLAND_SURFACE_ROLE_WL_SHELL_SURFACE, META, WAYLAND_SURFACE_ROLE_WL_SHELL_SURFACE,
MetaWaylandSurfaceRole); MetaWaylandSurfaceRole);
#define META_TYPE_WAYLAND_SURFACE_ROLE_CURSOR (meta_wayland_surface_role_cursor_get_type ())
G_DECLARE_FINAL_TYPE (MetaWaylandSurfaceRoleCursor,
meta_wayland_surface_role_cursor,
META, WAYLAND_SURFACE_ROLE_CURSOR,
MetaWaylandSurfaceRole);
#define META_TYPE_WAYLAND_SURFACE_ROLE_DND (meta_wayland_surface_role_dnd_get_type ()) #define META_TYPE_WAYLAND_SURFACE_ROLE_DND (meta_wayland_surface_role_dnd_get_type ())
G_DECLARE_FINAL_TYPE (MetaWaylandSurfaceRoleDND, G_DECLARE_FINAL_TYPE (MetaWaylandSurfaceRoleDND,
meta_wayland_surface_role_dnd, meta_wayland_surface_role_dnd,
@ -251,6 +245,8 @@ void meta_wayland_surface_update_outputs (MetaWaylandSurface *sur
MetaWindow * meta_wayland_surface_get_toplevel_window (MetaWaylandSurface *surface); MetaWindow * meta_wayland_surface_get_toplevel_window (MetaWaylandSurface *surface);
void meta_wayland_surface_queue_pending_frame_callbacks (MetaWaylandSurface *surface);
void meta_wayland_surface_queue_pending_state_frame_callbacks (MetaWaylandSurface *surface, void meta_wayland_surface_queue_pending_state_frame_callbacks (MetaWaylandSurface *surface,
MetaWaylandPendingState *pending); MetaWaylandPendingState *pending);