[clutter/clutter-1.18] wayland: Implement support for 'cursor-visible' stage property
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/clutter-1.18] wayland: Implement support for 'cursor-visible' stage property
- Date: Thu, 14 Nov 2013 18:35:15 +0000 (UTC)
commit 7c2b88f73b378575536dfafcb979a01a183328e6
Author: Jonas Ådahl <jadahl gmail com>
Date: Sat Oct 5 22:58:19 2013 +0900
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
clutter/wayland/clutter-backend-wayland-priv.h | 2 +
clutter/wayland/clutter-backend-wayland.c | 9 +---
clutter/wayland/clutter-input-device-wayland.c | 58 ++++++++++++++---------
clutter/wayland/clutter-stage-wayland.c | 11 +++++
clutter/wayland/clutter-stage-wayland.h | 1 +
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 e917b7f..a278754 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 48e8ead..aa3bc7b 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 5ec3437..94a8186 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 4110026..4c3e0c3 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 3b041c1..46092c3 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]