[clutter/wip/wayland-surface-actor: 1/2] Updates wayland support
- From: Robert Bragg <rbragg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/wip/wayland-surface-actor: 1/2] Updates wayland support
- Date: Wed, 26 Oct 2011 17:10:52 +0000 (UTC)
commit 755a52b3d97b24247375c2c0fdcfece760ab7610
Author: Robert Bragg <robert linux intel com>
Date: Mon May 9 22:45:33 2011 +0100
Updates wayland support
This updates Wayland support in line with upstream changes to the Wayland
API and protocol.
clutter/Makefile.am | 35 +-
clutter/cogl/clutter-backend-cogl.c | 127 ++++-
clutter/cogl/clutter-backend-cogl.h | 9 +
clutter/cogl/clutter-stage-cogl.c | 8 +
clutter/evdev/clutter-xkb-utils.h | 8 +-
clutter/wayland/clutter-backend-wayland.c | 672 ----------------------
clutter/wayland/clutter-backend-wayland.h | 98 ----
clutter/wayland/clutter-device-manager-wayland.c | 195 +++++++
clutter/wayland/clutter-device-manager-wayland.h | 71 +++
clutter/wayland/clutter-event-wayland.c | 6 +-
clutter/wayland/clutter-event-wayland.h | 38 ++
clutter/wayland/clutter-input-device-wayland.c | 152 ++----
clutter/wayland/clutter-input-device-wayland.h | 57 ++
clutter/wayland/clutter-stage-wayland.c | 650 ---------------------
clutter/wayland/clutter-stage-wayland.h | 114 ----
clutter/wayland/clutter-wayland.h | 61 --
configure.ac | 12 +-
doc/reference/clutter/clutter-sections.txt | 6 -
18 files changed, 581 insertions(+), 1738 deletions(-)
---
diff --git a/clutter/Makefile.am b/clutter/Makefile.am
index 461e7d1..943f7be 100644
--- a/clutter/Makefile.am
+++ b/clutter/Makefile.am
@@ -495,6 +495,20 @@ if SUPPORT_CEX100
backend_source_h += $(cex_h)
endif # SUPPORT_CEX100
+# Wayland backend rules
+if SUPPORT_WAYLAND
+backend_source_h_priv += \
+ $(srcdir)/evdev/clutter-xkb-utils.h \
+ $(srcdir)/wayland/clutter-event-wayland.h \
+ $(srcdir)/wayland/clutter-device-manager-wayland.h
+
+backend_source_c += \
+ $(srcdir)/evdev/clutter-xkb-utils.c \
+ $(srcdir)/wayland/clutter-event-wayland.c \
+ $(srcdir)/wayland/clutter-input-device-wayland.c \
+ $(srcdir)/wayland/clutter-device-manager-wayland.c
+endif # SUPPORT_WAYLAND
+
if SUPPORT_EGL
backend_source_h += $(cogl_source_h) $(egl_source_h)
backend_source_c += $(cogl_source_c)
@@ -540,27 +554,6 @@ clutterosx_includedir = $(clutter_includedir)/osx
clutterosx_include_HEADERS = $(osx_source_h)
endif # SUPPORT_OSX
-# Wayland backend rules
-if SUPPORT_WAYLAND
-backend_source_h += \
- $(srcdir)/wayland/clutter-wayland.h
-
-backend_source_h_priv += \
- $(srcdir)/evdev/clutter-xkb-utils.h \
- $(srcdir)/wayland/clutter-backend-wayland.h \
- $(srcdir)/wayland/clutter-stage-wayland.h
-
-backend_source_c += \
- $(srcdir)/evdev/clutter-xkb-utils.c \
- $(srcdir)/wayland/clutter-backend-wayland.c \
- $(srcdir)/wayland/clutter-stage-wayland.c \
- $(srcdir)/wayland/clutter-event-wayland.c \
- $(srcdir)/wayland/clutter-input-device-wayland.c
-
-clutterwayland_includedir = $(clutter_includedir)/wayland
-clutterwayland_include_HEADERS = $(wayland_source_h)
-endif # SUPPORT_WAYLAND
-
# cally
cally_sources_h = \
$(srcdir)/cally/cally-actor.h \
diff --git a/clutter/cogl/clutter-backend-cogl.c b/clutter/cogl/clutter-backend-cogl.c
index 1ca8850..fdfbf38 100644
--- a/clutter/cogl/clutter-backend-cogl.c
+++ b/clutter/cogl/clutter-backend-cogl.c
@@ -54,6 +54,10 @@
#ifdef COGL_HAS_EGL_PLATFORM_GDL_SUPPORT
#include "clutter-cex100.h"
#endif
+#ifdef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
+#include "wayland/clutter-device-manager-wayland.h"
+#include "wayland/clutter-event-wayland.h"
+#endif
static ClutterBackendCogl *backend_singleton = NULL;
@@ -110,10 +114,76 @@ clutter_backend_cogl_pre_parse (ClutterBackend *backend,
return TRUE;
}
+#ifdef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
+static void
+handle_configure (void *data,
+ struct wl_shell *shell,
+ uint32_t timestamp,
+ uint32_t edges,
+ struct wl_surface *surface,
+ int32_t width,
+ int32_t height)
+{
+ ClutterStageCogl *stage_cogl = wl_surface_get_user_data (surface);
+ CoglFramebuffer *fb = COGL_FRAMEBUFFER (stage_cogl->onscreen);
+
+ if (cogl_framebuffer_get_width (fb) != width ||
+ cogl_framebuffer_get_height (fb) != height)
+ clutter_actor_queue_relayout (CLUTTER_ACTOR (stage_cogl->wrapper));
+
+ clutter_actor_set_size (CLUTTER_ACTOR (stage_cogl->wrapper),
+ width, height);
+
+ /* the resize process is complete, so we can ask the stage
+ * to set up the GL viewport with the new size
+ */
+ clutter_stage_ensure_viewport (stage_cogl->wrapper);
+}
+
+static const struct wl_shell_listener shell_listener = {
+ handle_configure,
+};
+
+static void
+display_handle_global (struct wl_display *display,
+ uint32_t id,
+ const char *interface,
+ uint32_t version,
+ void *data)
+{
+ ClutterBackendCogl *backend_cogl = data;
+
+ if (strcmp (interface, "wl_compositor") == 0)
+ backend_cogl->wayland_compositor = wl_compositor_create (display, id, 1);
+ else if (strcmp (interface, "wl_input_device") == 0)
+ _clutter_wayland_add_input_group (backend_cogl, id);
+ else if (strcmp (interface, "wl_shell") == 0)
+ {
+ backend_cogl->wayland_shell = wl_shell_create (display, id, 1);
+ wl_shell_add_listener (backend_cogl->wayland_shell,
+ &shell_listener, backend_cogl);
+ }
+ else if (strcmp (interface, "wl_shm") == 0)
+ backend_cogl->wayland_shm = wl_shm_create (display, id, 1);
+}
+
+static int
+event_mask_update_cb (uint32_t mask, void *user_data)
+{
+ ClutterBackendCogl *backend_cogl = user_data;
+ backend_cogl->wayland_event_mask = mask;
+ return 0;
+}
+#endif
+
static gboolean
clutter_backend_cogl_post_parse (ClutterBackend *backend,
GError **error)
{
+#ifdef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
+ ClutterBackendCogl *backend_cogl = CLUTTER_BACKEND_COGL (backend);
+#endif
+
#ifdef COGL_HAS_X11_SUPPORT
ClutterBackendClass *parent_class =
CLUTTER_BACKEND_CLASS (_clutter_backend_cogl_parent_class);
@@ -124,6 +194,37 @@ clutter_backend_cogl_post_parse (ClutterBackend *backend,
return TRUE;
#endif
+#ifdef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
+
+ /* TODO: expose environment variable/commandline option for this... */
+ backend_cogl->wayland_display = wl_display_connect (NULL);
+ if (!backend_cogl->wayland_display)
+ {
+ g_set_error (error, CLUTTER_INIT_ERROR,
+ CLUTTER_INIT_ERROR_BACKEND,
+ "Failed to open Wayland display socket");
+ return FALSE;
+ }
+
+ backend_cogl->wayland_source =
+ _clutter_event_source_wayland_new (backend_cogl->wayland_display);
+ g_source_attach (backend_cogl->wayland_source, NULL);
+
+ /* Set up listener so we'll catch all events. */
+ wl_display_add_global_listener (backend_cogl->wayland_display,
+ display_handle_global,
+ backend_cogl);
+
+ wl_display_get_fd (backend_cogl->wayland_display,
+ event_mask_update_cb, backend_cogl);
+
+ /* Wait until we have been notified about the compositor object */
+ while (!backend_cogl->wayland_compositor)
+ wl_display_iterate (backend_cogl->wayland_display,
+ backend_cogl->wayland_event_mask);
+
+#endif
+
g_atexit (clutter_backend_at_exit);
return TRUE;
@@ -137,7 +238,12 @@ clutter_backend_cogl_get_device_manager (ClutterBackend *backend)
if (G_UNLIKELY (backend_cogl->device_manager == NULL))
{
-#ifdef HAVE_EVDEV
+#ifdef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
+ backend_cogl->device_manager =
+ g_object_new (CLUTTER_TYPE_DEVICE_MANAGER_WAYLAND,
+ "backend", backend_cogl,
+ NULL);
+#elif defined (HAVE_EVDEV)
backend_cogl->device_manager =
g_object_new (CLUTTER_TYPE_DEVICE_MANAGER_EVDEV,
"backend", backend_cogl,
@@ -159,6 +265,9 @@ clutter_backend_cogl_init_events (ClutterBackend *backend)
#ifdef HAVE_EVDEV
_clutter_events_evdev_init (CLUTTER_BACKEND (backend));
#endif
+#ifdef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
+ _clutter_events_wayland_init (backend);
+#endif
#ifdef COGL_HAS_X11_SUPPORT
/* Chain up to the X11 backend */
CLUTTER_BACKEND_CLASS (_clutter_backend_cogl_parent_class)->
@@ -179,7 +288,7 @@ static void
clutter_backend_cogl_dispose (GObject *gobject)
{
ClutterBackend *backend = CLUTTER_BACKEND (gobject);
-#ifdef HAVE_TSLIB
+#if defined (HAVE_TSLIB) || defined (COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT)
ClutterBackendCogl *backend_cogl = CLUTTER_BACKEND_COGL (gobject);
#endif
@@ -204,6 +313,9 @@ clutter_backend_cogl_dispose (GObject *gobject)
backend_cogl->event_timer = NULL;
}
#endif
+#ifdef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
+ _clutter_events_wayland_uninit (backend_cogl);
+#endif
}
static GObject *
@@ -291,8 +403,10 @@ static gboolean
clutter_backend_cogl_create_context (ClutterBackend *backend,
GError **error)
{
-#ifdef COGL_HAS_XLIB_SUPPORT
+#if defined (COGL_HAS_XLIB_SUPPORT)
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
+#elif defined (COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT)
+ ClutterBackendCogl *backend_cogl = CLUTTER_BACKEND_COGL (backend);
#endif
CoglSwapChain *swap_chain = NULL;
CoglOnscreenTemplate *onscreen_template = NULL;
@@ -301,9 +415,14 @@ clutter_backend_cogl_create_context (ClutterBackend *backend,
return TRUE;
backend->cogl_renderer = cogl_renderer_new ();
-#ifdef COGL_HAS_XLIB_SUPPORT
+#if defined (COGL_HAS_XLIB_SUPPORT)
cogl_xlib_renderer_set_foreign_display (backend->cogl_renderer,
backend_x11->xdpy);
+#elif defined (COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT)
+ cogl_renderer_wayland_set_foreign_display (backend->cogl_renderer,
+ backend_cogl->wayland_display);
+ cogl_renderer_wayland_set_foreign_compositor (backend->cogl_renderer,
+ backend_cogl->wayland_compositor);
#endif
if (!cogl_renderer_connect (backend->cogl_renderer, error))
goto error;
diff --git a/clutter/cogl/clutter-backend-cogl.h b/clutter/cogl/clutter-backend-cogl.h
index c1563d3..7ea9267 100644
--- a/clutter/cogl/clutter-backend-cogl.h
+++ b/clutter/cogl/clutter-backend-cogl.h
@@ -75,6 +75,15 @@ struct _ClutterBackendCogl
#endif /* COGL_HAS_X11_SUPPORT */
+#ifdef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
+ struct wl_display *wayland_display;
+ struct wl_compositor *wayland_compositor;
+ struct wl_shell *wayland_shell;
+ struct wl_shm *wayland_shm;
+ uint32_t wayland_event_mask;
+ GSource *wayland_source;
+#endif
+
CoglContext *cogl_context;
gboolean can_blit_sub_buffer;
diff --git a/clutter/cogl/clutter-stage-cogl.c b/clutter/cogl/clutter-stage-cogl.c
index 0acec4b..be42827 100644
--- a/clutter/cogl/clutter-stage-cogl.c
+++ b/clutter/cogl/clutter-stage-cogl.c
@@ -104,6 +104,9 @@ clutter_stage_cogl_realize (ClutterStageWindow *stage_window)
#ifdef COGL_HAS_XLIB_SUPPORT
ClutterStageX11 *stage_x11 = CLUTTER_STAGE_X11 (stage_window);
#endif
+#ifdef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
+ struct wl_surface *wl_surface;
+#endif
ClutterBackend *backend;
CoglFramebuffer *framebuffer;
GError *error = NULL;
@@ -153,6 +156,11 @@ clutter_stage_cogl_realize (ClutterStageWindow *stage_window)
* will be ignored, so we need to make sure the stage size is
* updated to this size. */
+#ifdef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
+ wl_surface = cogl_wayland_onscreen_get_surface (stage_cogl->onscreen);
+ wl_input_device_set_user_data (wl_surface, stage_cogl);
+#endif
+
if (cogl_clutter_winsys_has_feature (COGL_WINSYS_FEATURE_SWAP_BUFFERS_EVENT))
{
stage_cogl->swap_callback_id =
diff --git a/clutter/evdev/clutter-xkb-utils.h b/clutter/evdev/clutter-xkb-utils.h
index 34e65c6..527d187 100644
--- a/clutter/evdev/clutter-xkb-utils.h
+++ b/clutter/evdev/clutter-xkb-utils.h
@@ -22,12 +22,16 @@
* Damien Lespiau <damien lespiau intel com>
*/
-#include <X11/extensions/XKBcommon.h>
-
#include "clutter-stage.h"
#include "clutter-event.h"
#include "clutter-input-device.h"
+/* Make sure to include this last because it will typedef KeyCode if
+ * X.h hasn't already been included, but if X.h gets included
+ * afterwards it doesn't have a guard to stop it redeclaring the
+ * typedef. */
+#include <X11/extensions/XKBcommon.h>
+
ClutterEvent * _clutter_key_event_new_from_evdev (ClutterInputDevice *device,
ClutterStage *stage,
struct xkb_desc *xkb,
diff --git a/clutter/wayland/clutter-device-manager-wayland.c b/clutter/wayland/clutter-device-manager-wayland.c
new file mode 100644
index 0000000..263a52f
--- /dev/null
+++ b/clutter/wayland/clutter-device-manager-wayland.c
@@ -0,0 +1,195 @@
+/*
+ * Clutter.
+ *
+ * An OpenGL based 'interactive canvas' library.
+ *
+ * Copyright (C) 2011 Intel Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Emmanuele Bassi <ebassi linux intel com>
+ * Robert Bragg <robert linux intel com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "clutter-input-device-wayland.h"
+#include "clutter-device-manager-wayland.h"
+
+#include "clutter-backend.h"
+#include "clutter-debug.h"
+#include "clutter-device-manager-private.h"
+#include "clutter-private.h"
+
+#include "evdev/clutter-xkb-utils.h"
+
+enum
+{
+ PROP_0
+};
+
+G_DEFINE_TYPE (ClutterDeviceManagerWayland,
+ clutter_device_manager_wayland,
+ CLUTTER_TYPE_DEVICE_MANAGER);
+
+static void
+clutter_device_manager_wayland_add_device (ClutterDeviceManager *manager,
+ ClutterInputDevice *device)
+{
+ ClutterDeviceManagerWayland *manager_wayland = CLUTTER_DEVICE_MANAGER_WAYLAND (manager);
+ ClutterInputDeviceType device_type;
+ gboolean is_pointer, is_keyboard;
+
+ device_type = clutter_input_device_get_device_type (device);
+ is_pointer = (device_type == CLUTTER_POINTER_DEVICE) ? TRUE : FALSE;
+ is_keyboard = (device_type == CLUTTER_KEYBOARD_DEVICE) ? TRUE : FALSE;
+
+ manager_wayland->devices = g_slist_prepend (manager_wayland->devices, device);
+
+ if (is_pointer && manager_wayland->core_pointer == NULL)
+ manager_wayland->core_pointer = device;
+
+ if (is_keyboard && manager_wayland->core_keyboard == NULL)
+ manager_wayland->core_keyboard = device;
+}
+
+static void
+clutter_device_manager_wayland_remove_device (ClutterDeviceManager *manager,
+ ClutterInputDevice *device)
+{
+ ClutterDeviceManagerWayland *manager_wayland = CLUTTER_DEVICE_MANAGER_WAYLAND (manager);
+
+ manager_wayland->devices = g_slist_remove (manager_wayland->devices, device);
+}
+
+static const GSList *
+clutter_device_manager_wayland_get_devices (ClutterDeviceManager *manager)
+{
+ return CLUTTER_DEVICE_MANAGER_WAYLAND (manager)->devices;
+}
+
+static ClutterInputDevice *
+clutter_device_manager_wayland_get_core_device (ClutterDeviceManager *manager,
+ ClutterInputDeviceType type)
+{
+ ClutterDeviceManagerWayland *manager_wayland;
+
+ manager_wayland = CLUTTER_DEVICE_MANAGER_WAYLAND (manager);
+
+ switch (type)
+ {
+ case CLUTTER_POINTER_DEVICE:
+ return manager_wayland->core_pointer;
+
+ case CLUTTER_KEYBOARD_DEVICE:
+ return manager_wayland->core_keyboard;
+
+ case CLUTTER_EXTENSION_DEVICE:
+ default:
+ return NULL;
+ }
+
+ return NULL;
+}
+
+static ClutterInputDevice *
+clutter_device_manager_wayland_get_device (ClutterDeviceManager *manager,
+ gint id)
+{
+ ClutterDeviceManagerWayland *manager_wayland = CLUTTER_DEVICE_MANAGER_WAYLAND (manager);
+ GSList *l;
+
+ for (l = manager_wayland->devices; l != NULL; l = l->next)
+ {
+ ClutterInputDevice *device = l->data;
+
+ if (clutter_input_device_get_device_id (device) == id)
+ return device;
+ }
+
+ return NULL;
+}
+
+static void
+clutter_device_manager_wayland_class_init (ClutterDeviceManagerWaylandClass *klass)
+{
+ ClutterDeviceManagerClass *manager_class;
+
+ manager_class = CLUTTER_DEVICE_MANAGER_CLASS (klass);
+ manager_class->add_device = clutter_device_manager_wayland_add_device;
+ manager_class->remove_device = clutter_device_manager_wayland_remove_device;
+ manager_class->get_devices = clutter_device_manager_wayland_get_devices;
+ manager_class->get_core_device = clutter_device_manager_wayland_get_core_device;
+ manager_class->get_device = clutter_device_manager_wayland_get_device;
+}
+
+static void
+clutter_device_manager_wayland_init (ClutterDeviceManagerWayland *self)
+{
+}
+
+const char *option_xkb_layout = "us";
+const char *option_xkb_variant = "";
+const char *option_xkb_options = "";
+
+void
+_clutter_wayland_add_input_group (ClutterBackendCogl *backend_cogl,
+ uint32_t id)
+{
+ ClutterDeviceManager *manager = clutter_device_manager_get_default ();
+ ClutterInputDeviceWayland *device;
+
+ device = g_object_new (CLUTTER_TYPE_INPUT_DEVICE_WAYLAND,
+ "id", id,
+ "device-type", CLUTTER_POINTER_DEVICE,
+ "name", "wayland device",
+ "enabled", TRUE,
+ NULL);
+
+ device->input_device =
+ wl_input_device_create (backend_cogl->wayland_display, id, 1);
+ wl_input_device_add_listener (device->input_device,
+ &_clutter_input_device_wayland_listener, device);
+ wl_input_device_set_user_data (device->input_device, device);
+
+ device->xkb = _clutter_xkb_desc_new (NULL,
+ option_xkb_layout,
+ option_xkb_variant,
+ option_xkb_options);
+ if (!device->xkb)
+ CLUTTER_NOTE (BACKEND, "Failed to compile keymap");
+
+ _clutter_device_manager_add_device (manager, CLUTTER_INPUT_DEVICE (device));
+}
+
+void
+_clutter_events_wayland_init (ClutterBackendCogl *backend_cogl)
+{
+ CLUTTER_NOTE (EVENT, "Initializing evdev backend");
+
+ /* We just have to create the singleon here */
+ clutter_device_manager_get_default ();
+}
+
+void
+_clutter_events_wayland_uninit (ClutterBackendCogl *backend_cogl)
+{
+ ClutterDeviceManager *manager;
+
+ manager = clutter_device_manager_get_default ();
+ g_object_unref (manager);
+}
diff --git a/clutter/wayland/clutter-device-manager-wayland.h b/clutter/wayland/clutter-device-manager-wayland.h
new file mode 100644
index 0000000..0c6a8bc
--- /dev/null
+++ b/clutter/wayland/clutter-device-manager-wayland.h
@@ -0,0 +1,71 @@
+/*
+ * Clutter.
+ *
+ * An OpenGL based 'interactive canvas' library.
+ *
+ * Copyright (C) 2011 Intel Corp.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Emmanuele Bassi <ebassi linux intel com>
+ */
+
+#ifndef __CLUTTER_DEVICE_MANAGER_WAYLAND_H__
+#define __CLUTTER_DEVICE_MANAGER_WAYLAND_H__
+
+#include <clutter/clutter-device-manager.h>
+#include <clutter/cogl/clutter-backend-cogl.h>
+
+G_BEGIN_DECLS
+
+#define CLUTTER_TYPE_DEVICE_MANAGER_WAYLAND (clutter_device_manager_wayland_get_type ())
+#define CLUTTER_DEVICE_MANAGER_WAYLAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_DEVICE_MANAGER_WAYLAND, ClutterDeviceManagerWayland))
+#define CLUTTER_IS_DEVICE_MANAGER_WAYLAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_DEVICE_MANAGER_WAYLAND))
+#define CLUTTER_DEVICE_MANAGER_WAYLAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_DEVICE_MANAGER_WAYLAND, ClutterDeviceManagerWaylandClass))
+#define CLUTTER_IS_DEVICE_MANAGER_WAYLAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_DEVICE_MANAGER_WAYLAND))
+#define CLUTTER_DEVICE_MANAGER_WAYLAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_DEVICE_MANAGER_WAYLAND, ClutterDeviceManagerWaylandClass))
+
+typedef struct _ClutterDeviceManagerWayland ClutterDeviceManagerWayland;
+typedef struct _ClutterDeviceManagerWaylandClass ClutterDeviceManagerWaylandClass;
+
+struct _ClutterDeviceManagerWayland
+{
+ ClutterDeviceManager parent_instance;
+
+ GSList *devices;
+
+ ClutterInputDevice *core_pointer;
+ ClutterInputDevice *core_keyboard;
+};
+
+struct _ClutterDeviceManagerWaylandClass
+{
+ ClutterDeviceManagerClass parent_class;
+};
+
+GType clutter_device_manager_wayland_get_type (void) G_GNUC_CONST;
+
+void
+_clutter_events_wayland_init (ClutterBackendCogl *backend_cogl);
+
+void
+_clutter_events_wayland_uninit (ClutterBackendCogl *backend_cogl);
+
+void
+_clutter_wayland_add_input_group (ClutterBackendCogl *backend_cogl,
+ uint32_t id);
+
+G_END_DECLS
+
+#endif /* __CLUTTER_DEVICE_MANAGER_WAYLAND_H__ */
diff --git a/clutter/wayland/clutter-event-wayland.c b/clutter/wayland/clutter-event-wayland.c
index 23d9be4..bb5163a 100644
--- a/clutter/wayland/clutter-event-wayland.c
+++ b/clutter/wayland/clutter-event-wayland.c
@@ -55,10 +55,8 @@ clutter_event_source_wayland_prepare (GSource *base, gint *timeout)
/* We have to add/remove the GPollFD if we want to update our
* poll event mask dynamically. Instead, let's just flush all
- * write on idle instead, which is what this amounts to. */
-
- while (source->mask & WL_DISPLAY_WRITABLE)
- wl_display_iterate (source->display, WL_DISPLAY_WRITABLE);
+ * write on idle. */
+ wl_display_flush (source->display);
retval = clutter_events_pending ();
diff --git a/clutter/wayland/clutter-event-wayland.h b/clutter/wayland/clutter-event-wayland.h
new file mode 100644
index 0000000..549b8f7
--- /dev/null
+++ b/clutter/wayland/clutter-event-wayland.h
@@ -0,0 +1,38 @@
+/*
+ * Clutter.
+ *
+ * An OpenGL based 'interactive canvas' library.
+ *
+ * Copyright (C) 2011 Intel Corporation.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+
+ * Authors:
+ * Robert Bragg
+ * Kristian HÃgsberg
+ */
+
+#ifndef __CLUTTER_EVENT_WAYLAND_H__
+#define __CLUTTER_EVENT_WAYLAND_H__
+
+#include <glib-object.h>
+#include <clutter/clutter-event.h>
+
+#include <wayland-client.h>
+
+GSource *
+_clutter_event_source_wayland_new (struct wl_display *display);
+
+#endif /* __CLUTTER_EVENT_WAYLAND_H__ */
diff --git a/clutter/wayland/clutter-input-device-wayland.c b/clutter/wayland/clutter-input-device-wayland.c
index 854ecdd..6243869 100644
--- a/clutter/wayland/clutter-input-device-wayland.c
+++ b/clutter/wayland/clutter-input-device-wayland.c
@@ -38,47 +38,29 @@
#include "clutter-private.h"
#include "clutter-keysyms.h"
#include "clutter-xkb-utils.h"
+#include "clutter-input-device-wayland.h"
-#include "clutter-stage-wayland.h"
-
-#define CLUTTER_TYPE_INPUT_DEVICE_WAYLAND (clutter_input_device_wayland_get_type ())
-#define CLUTTER_INPUT_DEVICE_WAYLAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_INPUT_DEVICE_WAYLAND, ClutterInputDeviceWayland))
-#define CLUTTER_IS_INPUT_DEVICE_WAYLAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_INPUT_DEVICE_WAYLAND))
-
-typedef struct _ClutterInputDeviceWayland ClutterInputDeviceWayland;
-
-GType clutter_input_device_wayland_get_type (void) G_GNUC_CONST;
+#include "cogl/clutter-stage-cogl.h"
typedef struct _ClutterInputDeviceClass ClutterInputDeviceWaylandClass;
-struct _ClutterInputDeviceWayland
-{
- ClutterInputDevice device;
- struct wl_input_device *input_device;
- ClutterStageWayland *pointer_focus;
- ClutterStageWayland *keyboard_focus;
- uint32_t modifier_state;
- int32_t x, y, surface_x, surface_y;
- struct xkb_desc *xkb;
-};
-
G_DEFINE_TYPE (ClutterInputDeviceWayland,
clutter_input_device_wayland,
CLUTTER_TYPE_INPUT_DEVICE);
static void
-clutter_backend_wayland_handle_motion (void *data,
- struct wl_input_device *input_device,
- uint32_t _time,
- int32_t x, int32_t y,
- int32_t sx, int32_t sy)
+clutter_wayland_handle_motion (void *data,
+ struct wl_input_device *input_device,
+ uint32_t _time,
+ int32_t x, int32_t y,
+ int32_t sx, int32_t sy)
{
ClutterInputDeviceWayland *device = data;
- ClutterStageWayland *stage_wayland = device->pointer_focus;
+ ClutterStageCogl *stage_cogl = device->pointer_focus;
ClutterEvent *event;
event = clutter_event_new (CLUTTER_MOTION);
- event->motion.stage = stage_wayland->wrapper;
+ event->motion.stage = stage_cogl->wrapper;
event->motion.device = CLUTTER_INPUT_DEVICE (device);
event->motion.time = _time;
event->motion.modifier_state = 0;
@@ -94,13 +76,13 @@ clutter_backend_wayland_handle_motion (void *data,
}
static void
-clutter_backend_wayland_handle_button (void *data,
- struct wl_input_device *input_device,
- uint32_t _time,
- uint32_t button, uint32_t state)
+clutter_wayland_handle_button (void *data,
+ struct wl_input_device *input_device,
+ uint32_t _time,
+ uint32_t button, uint32_t state)
{
ClutterInputDeviceWayland *device = data;
- ClutterStageWayland *stage_wayland = device->pointer_focus;
+ ClutterStageCogl *stage_cogl = device->pointer_focus;
ClutterEvent *event;
ClutterEventType type;
@@ -110,7 +92,7 @@ clutter_backend_wayland_handle_button (void *data,
type = CLUTTER_BUTTON_RELEASE;
event = clutter_event_new (type);
- event->button.stage = stage_wayland->wrapper;
+ event->button.stage = stage_cogl->wrapper;
event->button.device = CLUTTER_INPUT_DEVICE (device);
event->button.time = _time;
event->button.x = device->surface_x;
@@ -134,17 +116,17 @@ clutter_backend_wayland_handle_button (void *data,
}
static void
-clutter_backend_wayland_handle_key (void *data,
- struct wl_input_device *input_device,
- uint32_t _time,
- uint32_t key, uint32_t state)
+clutter_wayland_handle_key (void *data,
+ struct wl_input_device *input_device,
+ uint32_t _time,
+ uint32_t key, uint32_t state)
{
ClutterInputDeviceWayland *device = data;
- ClutterStageWayland *stage_wayland = device->keyboard_focus;
+ ClutterStageCogl *stage_cogl = device->keyboard_focus;
ClutterEvent *event;
event = _clutter_key_event_new_from_evdev ((ClutterInputDevice *) device,
- stage_wayland->wrapper,
+ stage_cogl->wrapper,
device->xkb,
_time, key, state,
&device->modifier_state);
@@ -153,26 +135,26 @@ clutter_backend_wayland_handle_key (void *data,
}
static void
-clutter_backend_wayland_handle_pointer_focus (void *data,
- struct wl_input_device *input_device,
- uint32_t _time,
- struct wl_surface *surface,
- int32_t x, int32_t y, int32_t sx, int32_t sy)
+clutter_wayland_handle_pointer_focus (void *data,
+ struct wl_input_device *input_device,
+ uint32_t _time,
+ struct wl_surface *surface,
+ int32_t x, int32_t y, int32_t sx, int32_t sy)
{
ClutterInputDeviceWayland *device = data;
- ClutterStageWayland *stage_wayland;
+ ClutterStageCogl *stage_cogl;
ClutterEvent *event;
if (device->pointer_focus)
{
- stage_wayland = device->pointer_focus;
+ stage_cogl = device->pointer_focus;
event = clutter_event_new (CLUTTER_LEAVE);
- event->crossing.stage = stage_wayland->wrapper;
+ event->crossing.stage = stage_cogl->wrapper;
event->crossing.time = _time;
event->crossing.x = sx;
event->crossing.y = sy;
- event->crossing.source = CLUTTER_ACTOR (stage_wayland->wrapper);
+ event->crossing.source = CLUTTER_ACTOR (stage_cogl->wrapper);
event->crossing.device = CLUTTER_INPUT_DEVICE (device);
_clutter_event_push (event, FALSE);
@@ -183,18 +165,18 @@ clutter_backend_wayland_handle_pointer_focus (void *data,
if (surface)
{
- stage_wayland = wl_surface_get_user_data (surface);
+ stage_cogl = wl_surface_get_user_data (surface);
- device->pointer_focus = stage_wayland;
+ device->pointer_focus = stage_cogl;
_clutter_input_device_set_stage (CLUTTER_INPUT_DEVICE (device),
- stage_wayland->wrapper);
+ stage_cogl->wrapper);
event = clutter_event_new (CLUTTER_MOTION);
event->motion.time = _time;
event->motion.x = sx;
event->motion.y = sy;
event->motion.modifier_state = device->modifier_state;
- event->motion.source = CLUTTER_ACTOR (stage_wayland->wrapper);
+ event->motion.source = CLUTTER_ACTOR (stage_cogl->wrapper);
event->motion.device = CLUTTER_INPUT_DEVICE (device);
_clutter_event_push (event, FALSE);
@@ -210,26 +192,26 @@ clutter_backend_wayland_handle_pointer_focus (void *data,
}
static void
-clutter_backend_wayland_handle_keyboard_focus (void *data,
- struct wl_input_device *input_device,
- uint32_t _time,
- struct wl_surface *surface,
- struct wl_array *keys)
+clutter_wayland_handle_keyboard_focus (void *data,
+ struct wl_input_device *input_device,
+ uint32_t _time,
+ struct wl_surface *surface,
+ struct wl_array *keys)
{
ClutterInputDeviceWayland *device = data;
- ClutterStageWayland *stage_wayland;
+ ClutterStageCogl *stage_cogl;
ClutterEvent *event;
uint32_t *k, *end;
if (device->keyboard_focus)
{
- stage_wayland = device->keyboard_focus;
+ stage_cogl = device->keyboard_focus;
device->keyboard_focus = NULL;
event = clutter_event_new (CLUTTER_STAGE_STATE);
event->stage_state.time = _time;
- event->stage_state.stage = stage_wayland->wrapper;
- event->stage_state.stage = stage_wayland->wrapper;
+ event->stage_state.stage = stage_cogl->wrapper;
+ event->stage_state.stage = stage_cogl->wrapper;
event->stage_state.changed_mask = CLUTTER_STAGE_STATE_ACTIVATED;
event->stage_state.new_state = 0;
@@ -238,11 +220,11 @@ clutter_backend_wayland_handle_keyboard_focus (void *data,
if (surface)
{
- stage_wayland = wl_surface_get_user_data (surface);
- device->keyboard_focus = stage_wayland;
+ stage_cogl = wl_surface_get_user_data (surface);
+ device->keyboard_focus = stage_cogl;
event = clutter_event_new (CLUTTER_STAGE_STATE);
- event->stage_state.stage = stage_wayland->wrapper;
+ event->stage_state.stage = stage_cogl->wrapper;
event->stage_state.changed_mask = CLUTTER_STAGE_STATE_ACTIVATED;
event->stage_state.new_state = CLUTTER_STAGE_STATE_ACTIVATED;
@@ -255,12 +237,12 @@ clutter_backend_wayland_handle_keyboard_focus (void *data,
}
}
-static const struct wl_input_device_listener input_device_listener = {
- clutter_backend_wayland_handle_motion,
- clutter_backend_wayland_handle_button,
- clutter_backend_wayland_handle_key,
- clutter_backend_wayland_handle_pointer_focus,
- clutter_backend_wayland_handle_keyboard_focus,
+const struct wl_input_device_listener _clutter_input_device_wayland_listener = {
+ clutter_wayland_handle_motion,
+ clutter_wayland_handle_button,
+ clutter_wayland_handle_key,
+ clutter_wayland_handle_pointer_focus,
+ clutter_wayland_handle_keyboard_focus,
};
static void
@@ -272,33 +254,3 @@ static void
clutter_input_device_wayland_init (ClutterInputDeviceWayland *self)
{
}
-
-const char *option_xkb_layout = "us";
-const char *option_xkb_variant = "";
-const char *option_xkb_options = "";
-
-void
-_clutter_backend_add_input_device (ClutterBackendWayland *backend_wayland,
- uint32_t id)
-{
- ClutterInputDeviceWayland *device;
-
- device = g_object_new (CLUTTER_TYPE_INPUT_DEVICE_WAYLAND,
- "id", id,
- "device-type", CLUTTER_POINTER_DEVICE,
- "name", "wayland device",
- NULL);
-
- device->input_device =
- wl_input_device_create (backend_wayland->wayland_display, id);
- wl_input_device_add_listener (device->input_device,
- &input_device_listener, device);
- wl_input_device_set_user_data (device->input_device, device);
-
- device->xkb = _clutter_xkb_desc_new (NULL,
- option_xkb_layout,
- option_xkb_variant,
- option_xkb_options);
- if (!device->xkb)
- CLUTTER_NOTE (BACKEND, "Failed to compile keymap");
-}
diff --git a/clutter/wayland/clutter-input-device-wayland.h b/clutter/wayland/clutter-input-device-wayland.h
new file mode 100644
index 0000000..297337a
--- /dev/null
+++ b/clutter/wayland/clutter-input-device-wayland.h
@@ -0,0 +1,57 @@
+/*
+ * Clutter.
+ *
+ * An OpenGL based 'interactive canvas' library.
+ *
+ * Copyright (C) 2011 Intel Corporation.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see
+ * <http://www.gnu.org/licenses/>.
+
+ * Authors:
+ * Robert Bragg
+ * Kristian HÃgsberg
+ */
+
+#ifndef __CLUTTER_INPUT_DEVICE_WAYLAND_H__
+#define __CLUTTER_INPUT_DEVICE_WAYLAND_H__
+
+#include <glib-object.h>
+#include <clutter/clutter-event.h>
+
+#include "clutter-device-manager-private.h"
+#include "cogl/clutter-stage-cogl.h"
+
+#define CLUTTER_TYPE_INPUT_DEVICE_WAYLAND (clutter_input_device_wayland_get_type ())
+#define CLUTTER_INPUT_DEVICE_WAYLAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_INPUT_DEVICE_WAYLAND, ClutterInputDeviceWayland))
+#define CLUTTER_IS_INPUT_DEVICE_WAYLAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_INPUT_DEVICE_WAYLAND))
+
+typedef struct _ClutterInputDeviceWayland ClutterInputDeviceWayland;
+
+struct _ClutterInputDeviceWayland
+{
+ ClutterInputDevice device;
+ struct wl_input_device *input_device;
+ ClutterStageCogl *pointer_focus;
+ ClutterStageCogl *keyboard_focus;
+ uint32_t modifier_state;
+ int32_t x, y, surface_x, surface_y;
+ struct xkb_desc *xkb;
+};
+
+GType clutter_input_device_wayland_get_type (void) G_GNUC_CONST;
+
+extern const struct wl_input_device_listener _clutter_input_device_wayland_listener;
+
+#endif /* __CLUTTER_INPUT_DEVICE_WAYLAND_H__ */
diff --git a/configure.ac b/configure.ac
index 8545dbb..1206e72 100644
--- a/configure.ac
+++ b/configure.ac
@@ -253,14 +253,15 @@ AS_CASE([$CLUTTER_FLAVOUR],
CLUTTER_STAGE_TYPE="CLUTTER_TYPE_STAGE_WAYLAND"
SUPPORT_WAYLAND=1
+ SUPPORT_EGL=1
- CLUTTER_WINSYS=wayland
+ CLUTTER_WINSYS=cogl
CLUTTER_SONAME_INFIX=wayland
PKG_CHECK_EXISTS([gl], [BACKEND_PC_FILES="$BACKEND_PC_FILES gl"], [])
PKG_CHECK_EXISTS([egl], [BACKEND_PC_FILES="$BACKEND_PC_FILES egl"], [])
- PKG_CHECK_EXISTS([wayland-client xkbcommon],
- [BACKEND_PC_FILES="$BACKEND_PC_FILES wayland-client xkbcommon"], [])
+ PKG_CHECK_EXISTS([wayland-client wayland-egl xkbcommon],
+ [BACKEND_PC_FILES="$BACKEND_PC_FILES wayland-client wayland-egl xkbcommon"], [])
],
[eglx],
@@ -423,10 +424,9 @@ AM_CONDITIONAL(SUPPORT_EGL, [test "x$SUPPORT_EGL" = "x1"])
AM_CONDITIONAL(SUPPORT_OSX, [test "x$CLUTTER_WINSYS" = "xosx"])
AM_CONDITIONAL(SUPPORT_WIN32, [test "x$CLUTTER_WINSYS" = "xwin32"])
AM_CONDITIONAL(SUPPORT_CEX100, [test "x$SUPPORT_EGL_PLATFORM_GDL" = "x1"])
-AM_CONDITIONAL(SUPPORT_WAYLAND, [test "x$CLUTTER_WINSYS" = "xwayland"])
+AM_CONDITIONAL(SUPPORT_WAYLAND, [test "x$SUPPORT_WAYLAND" = "x1"])
AM_CONDITIONAL(SUPPORT_STUB, [test "x$CLUTTER_WINSYS" = "xwin32" -o \
- "x$CLUTTER_WINSYS" = "xosx" -o \
- "x$CLUTTER_WINSYS" = "xwayland"])
+ "x$CLUTTER_WINSYS" = "xosx"])
AM_CONDITIONAL(USE_TSLIB, [test "x$have_tslib" = "xyes"])
AM_CONDITIONAL(SUPPORT_EVDEV, [test "x$have_evdev" = "xyes"])
diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt
index 891968b..29d7c3b 100644
--- a/doc/reference/clutter/clutter-sections.txt
+++ b/doc/reference/clutter/clutter-sections.txt
@@ -1347,12 +1347,6 @@ clutter_win32_handle_event
</SECTION>
<SECTION>
-<FILE>clutter-wayland</FILE>
-<TITLE>Wayland Specific Support</TITLE>
-clutter_wayland_get_egl_display
-</SECTION>
-
-<SECTION>
<FILE>clutter-version</FILE>
<TITLE>Versioning Macros</TITLE>
CLUTTER_MAJOR_VERSION
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]