summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Ådahl <jadahl@gmail.com>2013-10-05 22:58:19 +0900
committerEmmanuele Bassi <ebassi@gnome.org>2013-10-14 11:53:00 +0100
commit96bfde98a15afdaa1982d87e6e48275cdeb7b23f (patch)
treed7e0fcd5c982a88df8d781ea50199fefe422ba2b
parentbc0b4721122a1ff06f9e1623bf649f6576cb2371 (diff)
downloadclutter-96bfde98a15afdaa1982d87e6e48275cdeb7b23f.tar.gz
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
-rw-r--r--clutter/wayland/clutter-backend-wayland-priv.h2
-rw-r--r--clutter/wayland/clutter-backend-wayland.c9
-rw-r--r--clutter/wayland/clutter-input-device-wayland.c58
-rw-r--r--clutter/wayland/clutter-stage-wayland.c11
-rw-r--r--clutter/wayland/clutter-stage-wayland.h1
5 files changed, 51 insertions, 30 deletions
diff --git a/clutter/wayland/clutter-backend-wayland-priv.h b/clutter/wayland/clutter-backend-wayland-priv.h
index e917b7f8c..a278754ba 100644
--- a/clutter/wayland/clutter-backend-wayland-priv.h
+++ b/clutter/wayland/clutter-backend-wayland-priv.h
@@ -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__ */
diff --git a/clutter/wayland/clutter-backend-wayland.c b/clutter/wayland/clutter-backend-wayland.c
index 48e8eadeb..aa3bc7bb5 100644
--- a/clutter/wayland/clutter-backend-wayland.c
+++ b/clutter/wayland/clutter-backend-wayland.c
@@ -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;
diff --git a/clutter/wayland/clutter-input-device-wayland.c b/clutter/wayland/clutter-input-device-wayland.c
index 5ec343712..94a818698 100644
--- a/clutter/wayland/clutter-input-device-wayland.c
+++ b/clutter/wayland/clutter-input-device-wayland.c
@@ -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);
-
- 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);
+ 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);
+
+ _clutter_backend_wayland_ensure_cursor (backend_wayland);
+
+ 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
diff --git a/clutter/wayland/clutter-stage-wayland.c b/clutter/wayland/clutter-stage-wayland.c
index 411002668..4c3e0c3e0 100644
--- a/clutter/wayland/clutter-stage-wayland.c
+++ b/clutter/wayland/clutter-stage-wayland.c
@@ -154,6 +154,15 @@ clutter_stage_wayland_show (ClutterStageWindow *stage_window,
}
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;
}
diff --git a/clutter/wayland/clutter-stage-wayland.h b/clutter/wayland/clutter-stage-wayland.h
index 3b041c162..46092c3c2 100644
--- a/clutter/wayland/clutter-stage-wayland.h
+++ b/clutter/wayland/clutter-stage-wayland.h
@@ -55,6 +55,7 @@ struct _ClutterStageWayland
gboolean fullscreen;
gboolean foreign_wl_surface;
gboolean shown;
+ gboolean cursor_visible;
};
struct _ClutterStageWaylandClass