wayland: Implement support for 'cursor-visible' stage property

This will allow clutter Wayland clients to either not draw any pointer
cursor or draw its own.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>

https://bugzilla.gnome.org/show_bug.cgi?id=709590
This commit is contained in:
Jonas Ådahl 2013-10-05 22:58:19 +09:00 committed by Emmanuele Bassi
parent ef7ad913da
commit 7c2b88f73b
5 changed files with 49 additions and 28 deletions

View File

@ -62,6 +62,8 @@ struct _ClutterBackendWayland
GTimer *event_timer;
};
void _clutter_backend_wayland_ensure_cursor (ClutterBackendWayland *backend_wayland);
G_END_DECLS
#endif /* __CLUTTER_BACKEND_WAYLAND_PRIV_H__ */

View File

@ -63,8 +63,6 @@ G_DEFINE_TYPE (ClutterBackendWayland, clutter_backend_wayland, CLUTTER_TYPE_BACK
static struct wl_display *_foreign_display = NULL;
static gboolean _no_event_dispatch = FALSE;
static void clutter_backend_wayland_load_cursor (ClutterBackendWayland *backend_wayland);
static void
clutter_backend_wayland_dispose (GObject *gobject)
{
@ -224,9 +222,6 @@ clutter_backend_wayland_post_parse (ClutterBackend *backend,
backend_wayland->wayland_shell))
wl_display_roundtrip (backend_wayland->wayland_display);
/* We need the shm object before we can create the cursor */
clutter_backend_wayland_load_cursor (backend_wayland);
return TRUE;
}
@ -296,8 +291,8 @@ clutter_backend_wayland_class_init (ClutterBackendWaylandClass *klass)
backend_class->get_display = clutter_backend_wayland_get_display;
}
static void
clutter_backend_wayland_load_cursor (ClutterBackendWayland *backend_wayland)
void
_clutter_backend_wayland_ensure_cursor (ClutterBackendWayland *backend_wayland)
{
struct wl_cursor *cursor;

View File

@ -44,6 +44,7 @@
#include "clutter-backend-wayland.h"
#include "clutter-backend-wayland-priv.h"
#include "clutter-stage-private.h"
#include "clutter-stage-wayland.h"
#include "clutter-wayland.h"
#include "cogl/clutter-stage-cogl.h"
@ -351,15 +352,17 @@ clutter_wayland_handle_pointer_enter (void *data,
wl_fixed_t x, wl_fixed_t y)
{
ClutterInputDeviceWayland *device = data;
ClutterStageWayland *stage_wayland;
ClutterStageCogl *stage_cogl;
ClutterEvent *event;
ClutterBackend *backend;
ClutterBackendWayland *backend_wayland;
if (!CLUTTER_IS_STAGE_COGL (wl_surface_get_user_data (surface)))
return;
stage_wayland = wl_surface_get_user_data (surface);
stage_cogl = wl_surface_get_user_data (surface);
if (!CLUTTER_IS_STAGE_COGL (stage_wayland))
return;
stage_cogl = CLUTTER_STAGE_COGL (stage_wayland);
device->pointer_focus = stage_cogl;
_clutter_input_device_set_stage (CLUTTER_INPUT_DEVICE (device),
@ -378,26 +381,35 @@ clutter_wayland_handle_pointer_enter (void *data,
_clutter_event_push (event, FALSE);
/* Set the cursor to the cursor loaded at backend initialisation */
backend = clutter_get_default_backend ();
backend_wayland = CLUTTER_BACKEND_WAYLAND (backend);
if (stage_wayland->cursor_visible)
{
/* Set the cursor to the cursor loaded at backend initialisation */
backend = clutter_get_default_backend ();
backend_wayland = CLUTTER_BACKEND_WAYLAND (backend);
wl_pointer_set_cursor (pointer,
serial,
backend_wayland->cursor_surface,
backend_wayland->cursor_x,
backend_wayland->cursor_y);
wl_surface_attach (backend_wayland->cursor_surface,
backend_wayland->cursor_buffer,
0,
0);
wl_surface_damage (backend_wayland->cursor_surface,
0,
0,
32, /* XXX: FFS */
32);
_clutter_backend_wayland_ensure_cursor (backend_wayland);
wl_surface_commit (backend_wayland->cursor_surface);
wl_pointer_set_cursor (pointer,
serial,
backend_wayland->cursor_surface,
backend_wayland->cursor_x,
backend_wayland->cursor_y);
wl_surface_attach (backend_wayland->cursor_surface,
backend_wayland->cursor_buffer,
0,
0);
wl_surface_damage (backend_wayland->cursor_surface,
0,
0,
32, /* XXX: FFS */
32);
wl_surface_commit (backend_wayland->cursor_surface);
}
else
{
wl_pointer_set_cursor (pointer, serial, NULL, 0, 0);
}
}
static void

View File

@ -153,6 +153,15 @@ clutter_stage_wayland_show (ClutterStageWindow *stage_window,
clutter_actor_queue_redraw (CLUTTER_ACTOR (stage_cogl->wrapper));
}
static void
clutter_stage_wayland_set_cursor_visible (ClutterStageWindow *stage_window,
gboolean cursor_visible)
{
ClutterStageWayland *stage_wayland = CLUTTER_STAGE_WAYLAND (stage_window);
stage_wayland->cursor_visible = cursor_visible;
}
static void
clutter_stage_wayland_set_fullscreen (ClutterStageWindow *stage_window,
gboolean fullscreen)
@ -223,6 +232,7 @@ clutter_stage_wayland_resize (ClutterStageWindow *stage_window,
static void
clutter_stage_wayland_init (ClutterStageWayland *stage_wayland)
{
stage_wayland->cursor_visible = TRUE;
}
static void
@ -233,6 +243,7 @@ clutter_stage_window_iface_init (ClutterStageWindowIface *iface)
iface->realize = clutter_stage_wayland_realize;
iface->show = clutter_stage_wayland_show;
iface->set_fullscreen = clutter_stage_wayland_set_fullscreen;
iface->set_cursor_visible = clutter_stage_wayland_set_cursor_visible;
iface->resize = clutter_stage_wayland_resize;
}

View File

@ -55,6 +55,7 @@ struct _ClutterStageWayland
gboolean fullscreen;
gboolean foreign_wl_surface;
gboolean shown;
gboolean cursor_visible;
};
struct _ClutterStageWaylandClass