mirror of
https://github.com/brl/mutter.git
synced 2024-11-12 17:27:03 -05:00
wayland: drop wayland backend
This commit is contained in:
parent
04c84b049f
commit
89daa8d4fa
@ -533,33 +533,6 @@ egl_source_h = \
|
||||
egl_source_h_priv = egl/clutter-backend-eglnative.h egl/clutter-stage-eglnative.h
|
||||
egl_source_c = egl/clutter-backend-eglnative.c egl/clutter-stage-eglnative.c
|
||||
|
||||
# Wayland backend rules
|
||||
if SUPPORT_WAYLAND
|
||||
backend_source_h_priv += \
|
||||
wayland/clutter-backend-wayland.h \
|
||||
wayland/clutter-backend-wayland-priv.h \
|
||||
wayland/clutter-stage-wayland.h \
|
||||
wayland/clutter-event-wayland.h \
|
||||
wayland/clutter-input-device-wayland.h \
|
||||
wayland/clutter-device-manager-wayland.h
|
||||
|
||||
backend_source_c += \
|
||||
wayland/clutter-backend-wayland.c \
|
||||
wayland/clutter-stage-wayland.c \
|
||||
wayland/clutter-event-wayland.c \
|
||||
wayland/clutter-input-device-wayland.c \
|
||||
wayland/clutter-device-manager-wayland.c
|
||||
|
||||
|
||||
clutterwayland_includedir = $(clutter_includedir)/wayland
|
||||
clutterwayland_include_HEADERS = wayland/clutter-wayland.h
|
||||
|
||||
clutter-wayland-$(CLUTTER_API_VERSION).pc: clutter-$(CLUTTER_API_VERSION).pc
|
||||
$(QUIET_GEN)cp -f $< $(@F)
|
||||
|
||||
pc_files += clutter-wayland-$(CLUTTER_API_VERSION).pc
|
||||
endif # SUPPORT_WAYLAND
|
||||
|
||||
if SUPPORT_WAYLAND_COMPOSITOR
|
||||
wayland_compositor_source_h = \
|
||||
wayland/clutter-wayland-compositor.h \
|
||||
|
@ -77,9 +77,6 @@
|
||||
#ifdef CLUTTER_WINDOWING_EGL
|
||||
#include "egl/clutter-backend-eglnative.h"
|
||||
#endif
|
||||
#ifdef CLUTTER_INPUT_WAYLAND
|
||||
#include "wayland/clutter-device-manager-wayland.h"
|
||||
#endif
|
||||
|
||||
#ifdef CLUTTER_HAS_WAYLAND_COMPOSITOR_SUPPORT
|
||||
#include <cogl/cogl-wayland-server.h>
|
||||
@ -620,14 +617,6 @@ clutter_backend_real_init_events (ClutterBackend *backend)
|
||||
_clutter_events_tslib_init (backend);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#ifdef CLUTTER_INPUT_WAYLAND
|
||||
if (clutter_check_windowing_backend (CLUTTER_WINDOWING_WAYLAND) &&
|
||||
(input_backend == NULL || input_backend == I_(CLUTTER_INPUT_WAYLAND)))
|
||||
{
|
||||
_clutter_events_wayland_init (backend);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (input_backend != NULL)
|
||||
{
|
||||
|
@ -76,9 +76,6 @@
|
||||
#ifdef CLUTTER_WINDOWING_EGL
|
||||
#include "egl/clutter-backend-eglnative.h"
|
||||
#endif
|
||||
#ifdef CLUTTER_WINDOWING_WAYLAND
|
||||
#include "wayland/clutter-backend-wayland.h"
|
||||
#endif
|
||||
|
||||
#include <cogl/cogl.h>
|
||||
#include <cogl-pango/cogl-pango.h>
|
||||
@ -3628,12 +3625,6 @@ clutter_check_windowing_backend (const char *backend_type)
|
||||
|
||||
backend_type = g_intern_string (backend_type);
|
||||
|
||||
#ifdef CLUTTER_WINDOWING_WAYLAND
|
||||
if (backend_type == I_(CLUTTER_WINDOWING_WAYLAND) &&
|
||||
CLUTTER_IS_BACKEND_WAYLAND (context->backend))
|
||||
return TRUE;
|
||||
else
|
||||
#endif
|
||||
#ifdef CLUTTER_WINDOWING_EGL
|
||||
if (backend_type == I_(CLUTTER_WINDOWING_EGL) &&
|
||||
CLUTTER_IS_BACKEND_EGL_NATIVE (context->backend))
|
||||
|
@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Clutter.
|
||||
*
|
||||
* An OpenGL based 'interactive canvas' library.
|
||||
*
|
||||
* Copyright (C) 2010, 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:
|
||||
* Matthew Allum
|
||||
* Robert Bragg
|
||||
* Kristian Høgsberg
|
||||
*/
|
||||
|
||||
#ifndef __CLUTTER_BACKEND_WAYLAND_PRIV_H__
|
||||
#define __CLUTTER_BACKEND_WAYLAND_PRIV_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <clutter/clutter-event.h>
|
||||
#include <clutter/clutter-backend.h>
|
||||
#include <clutter/clutter-device-manager.h>
|
||||
|
||||
#include "clutter-backend-private.h"
|
||||
#include "clutter-backend-wayland.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
struct _ClutterBackendWayland
|
||||
{
|
||||
ClutterBackend parent_instance;
|
||||
|
||||
ClutterDeviceManager *device_manager;
|
||||
|
||||
struct wl_display *wayland_display;
|
||||
struct wl_registry *wayland_registry;
|
||||
struct wl_compositor *wayland_compositor;
|
||||
struct wl_shell *wayland_shell;
|
||||
struct wl_shm *wayland_shm;
|
||||
struct wl_surface *cursor_surface;
|
||||
struct wl_buffer *cursor_buffer;
|
||||
struct wl_output *wayland_output;
|
||||
struct wl_cursor_theme *cursor_theme;
|
||||
|
||||
gint cursor_x, cursor_y;
|
||||
gint output_width, output_height;
|
||||
|
||||
GSource *wayland_source;
|
||||
|
||||
/* event timer */
|
||||
GTimer *event_timer;
|
||||
};
|
||||
|
||||
void _clutter_backend_wayland_ensure_cursor (ClutterBackendWayland *backend_wayland);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __CLUTTER_BACKEND_WAYLAND_PRIV_H__ */
|
@ -1,383 +0,0 @@
|
||||
/*
|
||||
* Clutter.
|
||||
*
|
||||
* An OpenGL based 'interactive canvas' library.
|
||||
*
|
||||
* Copyright (C) 2010, 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:
|
||||
* Matthew Allum
|
||||
* Robert Bragg
|
||||
* Kristian Høgsberg
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include "clutter-debug.h"
|
||||
#include "clutter-private.h"
|
||||
#include "clutter-main.h"
|
||||
#include "clutter-stage-private.h"
|
||||
|
||||
#include "wayland/clutter-backend-wayland.h"
|
||||
#include "wayland/clutter-backend-wayland-priv.h"
|
||||
#include "wayland/clutter-device-manager-wayland.h"
|
||||
#include "wayland/clutter-event-wayland.h"
|
||||
#include "wayland/clutter-stage-wayland.h"
|
||||
#include "wayland/clutter-wayland.h"
|
||||
#include "cogl/clutter-stage-cogl.h"
|
||||
|
||||
#include <wayland-client.h>
|
||||
#include <wayland-cursor.h>
|
||||
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <cogl/cogl.h>
|
||||
#include <cogl/cogl-wayland-client.h>
|
||||
|
||||
G_DEFINE_TYPE (ClutterBackendWayland, clutter_backend_wayland, CLUTTER_TYPE_BACKEND);
|
||||
|
||||
static struct wl_display *_foreign_display = NULL;
|
||||
static gboolean _no_event_dispatch = FALSE;
|
||||
|
||||
static void
|
||||
clutter_backend_wayland_dispose (GObject *gobject)
|
||||
{
|
||||
ClutterBackendWayland *backend_wayland = CLUTTER_BACKEND_WAYLAND (gobject);
|
||||
|
||||
if (backend_wayland->device_manager)
|
||||
{
|
||||
g_object_unref (backend_wayland->device_manager);
|
||||
backend_wayland->device_manager = NULL;
|
||||
}
|
||||
|
||||
if (backend_wayland->cursor_buffer)
|
||||
{
|
||||
wl_buffer_destroy (backend_wayland->cursor_buffer);
|
||||
backend_wayland->cursor_buffer = NULL;
|
||||
}
|
||||
|
||||
if (backend_wayland->cursor_theme)
|
||||
{
|
||||
wl_cursor_theme_destroy (backend_wayland->cursor_theme);
|
||||
backend_wayland->cursor_theme = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (clutter_backend_wayland_parent_class)->dispose (gobject);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
output_handle_mode (void *data,
|
||||
struct wl_output *wl_output,
|
||||
uint32_t flags,
|
||||
int width,
|
||||
int height,
|
||||
int refresh)
|
||||
{
|
||||
ClutterBackendWayland *backend_wayland = data;
|
||||
|
||||
if (flags & WL_OUTPUT_MODE_CURRENT)
|
||||
{
|
||||
backend_wayland->output_width = width;
|
||||
backend_wayland->output_height = height;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
output_handle_geometry (void *data,
|
||||
struct wl_output *wl_output,
|
||||
int x,
|
||||
int y,
|
||||
int physical_width,
|
||||
int physical_height,
|
||||
int subpixel,
|
||||
const char *make,
|
||||
const char *model,
|
||||
int32_t transform)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static const struct wl_output_listener wayland_output_listener = {
|
||||
output_handle_geometry,
|
||||
output_handle_mode,
|
||||
};
|
||||
|
||||
|
||||
static void
|
||||
registry_handle_global (void *data,
|
||||
struct wl_registry *registry,
|
||||
uint32_t id,
|
||||
const char *interface,
|
||||
uint32_t version)
|
||||
{
|
||||
ClutterBackendWayland *backend_wayland = data;
|
||||
|
||||
if (strcmp (interface, "wl_compositor") == 0)
|
||||
backend_wayland->wayland_compositor =
|
||||
wl_registry_bind (registry, id, &wl_compositor_interface, 1);
|
||||
else if (strcmp (interface, "wl_seat") == 0)
|
||||
{
|
||||
ClutterDeviceManager *device_manager = backend_wayland->device_manager;
|
||||
_clutter_device_manager_wayland_add_input_group (device_manager, id);
|
||||
}
|
||||
else if (strcmp (interface, "wl_shell") == 0)
|
||||
{
|
||||
backend_wayland->wayland_shell =
|
||||
wl_registry_bind (registry, id, &wl_shell_interface, 1);
|
||||
}
|
||||
else if (strcmp (interface, "wl_shm") == 0)
|
||||
{
|
||||
backend_wayland->wayland_shm =
|
||||
wl_registry_bind (registry, id, &wl_shm_interface, 1);
|
||||
}
|
||||
else if (strcmp (interface, "wl_output") == 0)
|
||||
{
|
||||
/* FIXME: Support multiple outputs */
|
||||
backend_wayland->wayland_output =
|
||||
wl_registry_bind (registry, id, &wl_output_interface, 1);
|
||||
wl_output_add_listener (backend_wayland->wayland_output,
|
||||
&wayland_output_listener,
|
||||
backend_wayland);
|
||||
}
|
||||
}
|
||||
|
||||
static const struct wl_registry_listener wayland_registry_listener = {
|
||||
registry_handle_global,
|
||||
};
|
||||
|
||||
static gboolean
|
||||
clutter_backend_wayland_post_parse (ClutterBackend *backend,
|
||||
GError **error)
|
||||
{
|
||||
ClutterBackendWayland *backend_wayland = CLUTTER_BACKEND_WAYLAND (backend);
|
||||
|
||||
/* TODO: expose environment variable/commandline option for this... */
|
||||
backend_wayland->wayland_display = _foreign_display;
|
||||
if (backend_wayland->wayland_display == NULL)
|
||||
backend_wayland->wayland_display = wl_display_connect (NULL);
|
||||
|
||||
if (!backend_wayland->wayland_display)
|
||||
{
|
||||
g_set_error (error, CLUTTER_INIT_ERROR,
|
||||
CLUTTER_INIT_ERROR_BACKEND,
|
||||
"Failed to open Wayland display socket");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
backend_wayland->wayland_registry =
|
||||
wl_display_get_registry (backend_wayland->wayland_display);
|
||||
|
||||
backend_wayland->wayland_source =
|
||||
_clutter_event_source_wayland_new (backend_wayland->wayland_display);
|
||||
g_source_attach (backend_wayland->wayland_source, NULL);
|
||||
|
||||
g_object_set (clutter_settings_get_default (), "font-dpi", 96 * 1024, NULL);
|
||||
|
||||
/* XXX: We require the device manager to exist as soon as we connect to the
|
||||
* compositor and setup an event handler because we will immediately be
|
||||
* notified of the available input devices which need to be associated with
|
||||
* the device-manager.
|
||||
*
|
||||
* FIXME: At some point we could perhaps just collapse the
|
||||
* _clutter_backend_post_parse(), and _clutter_backend_init_events()
|
||||
* functions into one called something like _clutter_backend_init() which
|
||||
* would allow the real backend to manage the precise order of
|
||||
* initialization.
|
||||
*/
|
||||
backend_wayland->device_manager =
|
||||
_clutter_device_manager_wayland_new (backend);
|
||||
|
||||
/* Set up listener so we'll catch all events. */
|
||||
wl_registry_add_listener (backend_wayland->wayland_registry,
|
||||
&wayland_registry_listener,
|
||||
backend_wayland);
|
||||
|
||||
/* Wait until we have been notified about the compositor and shell objects */
|
||||
while (!(backend_wayland->wayland_compositor &&
|
||||
backend_wayland->wayland_shell))
|
||||
wl_display_roundtrip (backend_wayland->wayland_display);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static CoglRenderer *
|
||||
clutter_backend_wayland_get_renderer (ClutterBackend *backend,
|
||||
GError **error)
|
||||
{
|
||||
ClutterBackendWayland *backend_wayland = CLUTTER_BACKEND_WAYLAND (backend);
|
||||
CoglRenderer *renderer;
|
||||
|
||||
CLUTTER_NOTE (BACKEND, "Creating a new wayland renderer");
|
||||
|
||||
renderer = cogl_renderer_new ();
|
||||
|
||||
cogl_wayland_renderer_set_event_dispatch_enabled (renderer, !_no_event_dispatch);
|
||||
cogl_renderer_set_winsys_id (renderer, COGL_WINSYS_ID_EGL_WAYLAND);
|
||||
|
||||
cogl_wayland_renderer_set_foreign_display (renderer,
|
||||
backend_wayland->wayland_display);
|
||||
|
||||
return renderer;
|
||||
}
|
||||
|
||||
static CoglDisplay *
|
||||
clutter_backend_wayland_get_display (ClutterBackend *backend,
|
||||
CoglRenderer *renderer,
|
||||
CoglSwapChain *swap_chain,
|
||||
GError **error)
|
||||
{
|
||||
CoglOnscreenTemplate *onscreen_template = NULL;
|
||||
CoglDisplay *display;
|
||||
|
||||
onscreen_template = cogl_onscreen_template_new (swap_chain);
|
||||
|
||||
/* XXX: I have some doubts that this is a good design.
|
||||
* Conceptually should we be able to check an onscreen_template
|
||||
* without more details about the CoglDisplay configuration?
|
||||
*/
|
||||
if (!cogl_renderer_check_onscreen_template (renderer,
|
||||
onscreen_template,
|
||||
error))
|
||||
goto error;
|
||||
|
||||
display = cogl_display_new (renderer, onscreen_template);
|
||||
|
||||
return display;
|
||||
|
||||
error:
|
||||
if (onscreen_template)
|
||||
cogl_object_unref (onscreen_template);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_backend_wayland_class_init (ClutterBackendWaylandClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
ClutterBackendClass *backend_class = CLUTTER_BACKEND_CLASS (klass);
|
||||
|
||||
gobject_class->dispose = clutter_backend_wayland_dispose;
|
||||
|
||||
backend_class->stage_window_type = CLUTTER_TYPE_STAGE_WAYLAND;
|
||||
|
||||
backend_class->post_parse = clutter_backend_wayland_post_parse;
|
||||
backend_class->get_renderer = clutter_backend_wayland_get_renderer;
|
||||
backend_class->get_display = clutter_backend_wayland_get_display;
|
||||
}
|
||||
|
||||
void
|
||||
_clutter_backend_wayland_ensure_cursor (ClutterBackendWayland *backend_wayland)
|
||||
{
|
||||
struct wl_cursor *cursor;
|
||||
|
||||
backend_wayland->cursor_theme =
|
||||
wl_cursor_theme_load (NULL, /* default */
|
||||
32,
|
||||
backend_wayland->wayland_shm);
|
||||
|
||||
cursor = wl_cursor_theme_get_cursor (backend_wayland->cursor_theme,
|
||||
"left_ptr");
|
||||
|
||||
backend_wayland->cursor_buffer =
|
||||
wl_cursor_image_get_buffer (cursor->images[0]);
|
||||
|
||||
if (backend_wayland->cursor_buffer)
|
||||
{
|
||||
backend_wayland->cursor_x = cursor->images[0]->hotspot_x;
|
||||
backend_wayland->cursor_y = cursor->images[0]->hotspot_y;
|
||||
}
|
||||
|
||||
backend_wayland->cursor_surface =
|
||||
wl_compositor_create_surface (backend_wayland->wayland_compositor);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_backend_wayland_init (ClutterBackendWayland *backend_wayland)
|
||||
{
|
||||
}
|
||||
|
||||
ClutterBackend *
|
||||
clutter_backend_wayland_new (void)
|
||||
{
|
||||
return g_object_new (CLUTTER_TYPE_BACKEND_WAYLAND, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_wayland_set_display
|
||||
* @display: pointer to a wayland display
|
||||
*
|
||||
* Sets the display connection Clutter should use; must be called
|
||||
* before clutter_init(), clutter_init_with_args() or other functions
|
||||
* pertaining Clutter's initialization process.
|
||||
*
|
||||
* If you are parsing the command line arguments by retrieving Clutter's
|
||||
* #GOptionGroup with clutter_get_option_group() and calling
|
||||
* g_option_context_parse() yourself, you should also call
|
||||
* clutter_wayland_set_display() before g_option_context_parse().
|
||||
*
|
||||
* Since: 1.16
|
||||
*/
|
||||
void
|
||||
clutter_wayland_set_display (struct wl_display *display)
|
||||
{
|
||||
if (_clutter_context_is_initialized ())
|
||||
{
|
||||
g_warning ("%s() can only be used before calling clutter_init()",
|
||||
G_STRFUNC);
|
||||
return;
|
||||
}
|
||||
|
||||
_foreign_display = display;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_wayland_disable_event_retrieval:
|
||||
*
|
||||
* Disables the dispatch of the events in the main loop.
|
||||
*
|
||||
* This is useful for integrating Clutter with another library that will do the
|
||||
* event dispatch; in general only a single source should be acting on changes
|
||||
* on the Wayland file descriptor.
|
||||
*
|
||||
* This function can only be called before calling clutter_init().
|
||||
*
|
||||
* This function should not be normally used by applications.
|
||||
*
|
||||
* Since: 1.16
|
||||
*/
|
||||
void
|
||||
clutter_wayland_disable_event_retrieval (void)
|
||||
{
|
||||
if (_clutter_context_is_initialized ())
|
||||
{
|
||||
g_warning ("%s() can only be used before calling clutter_init()",
|
||||
G_STRFUNC);
|
||||
return;
|
||||
}
|
||||
|
||||
_no_event_dispatch = TRUE;
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Clutter.
|
||||
*
|
||||
* An OpenGL based 'interactive canvas' library.
|
||||
*
|
||||
* Copyright (C) 2010, 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:
|
||||
* Matthew Allum
|
||||
* Robert Bragg
|
||||
* Kristian Høgsberg
|
||||
*/
|
||||
|
||||
#ifndef __CLUTTER_BACKEND_WAYLAND_H__
|
||||
#define __CLUTTER_BACKEND_WAYLAND_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <clutter/clutter-event.h>
|
||||
#include <clutter/clutter-backend.h>
|
||||
#include <clutter/clutter-device-manager.h>
|
||||
|
||||
#include "clutter-backend-private.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CLUTTER_TYPE_BACKEND_WAYLAND (clutter_backend_wayland_get_type ())
|
||||
#define CLUTTER_BACKEND_WAYLAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_BACKEND_WAYLAND, ClutterBackendWayland))
|
||||
#define CLUTTER_IS_BACKEND_WAYLAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_BACKEND_WAYLAND))
|
||||
#define CLUTTER_BACKEND_WAYLAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_BACKEND_WAYLAND, ClutterBackendWaylandClass))
|
||||
#define CLUTTER_IS_BACKEND_WAYLAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_BACKEND_WAYLAND))
|
||||
#define CLUTTER_BACKEND_WAYLAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_BACKEND_WAYLAND, ClutterBackendWaylandClass))
|
||||
|
||||
typedef struct _ClutterBackendWayland ClutterBackendWayland;
|
||||
typedef struct _ClutterBackendWaylandClass ClutterBackendWaylandClass;
|
||||
|
||||
struct _ClutterBackendWaylandClass
|
||||
{
|
||||
ClutterBackendClass parent_class;
|
||||
};
|
||||
|
||||
GType clutter_backend_wayland_get_type (void) G_GNUC_CONST;
|
||||
|
||||
ClutterBackend *clutter_backend_wayland_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __CLUTTER_BACKEND_WAYLAND_H__ */
|
@ -1,215 +0,0 @@
|
||||
/*
|
||||
* 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 "wayland/clutter-backend-wayland.h"
|
||||
#include "wayland/clutter-backend-wayland-priv.h"
|
||||
#include "clutter-debug.h"
|
||||
#include "clutter-device-manager-private.h"
|
||||
#include "clutter-private.h"
|
||||
|
||||
#include <wayland-client.h>
|
||||
#include <wayland-client-protocol.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)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
_clutter_device_manager_wayland_add_input_group (ClutterDeviceManager *manager,
|
||||
uint32_t id)
|
||||
{
|
||||
ClutterBackend *backend = _clutter_device_manager_get_backend (manager);
|
||||
ClutterBackendWayland *backend_wayland = CLUTTER_BACKEND_WAYLAND (backend);
|
||||
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_registry_bind (backend_wayland->wayland_registry, id,
|
||||
&wl_seat_interface, 1);
|
||||
wl_seat_add_listener (device->input_device,
|
||||
&_clutter_seat_wayland_listener,
|
||||
device);
|
||||
wl_seat_set_user_data (device->input_device, device);
|
||||
|
||||
_clutter_device_manager_add_device (manager, CLUTTER_INPUT_DEVICE (device));
|
||||
}
|
||||
|
||||
ClutterDeviceManager *
|
||||
_clutter_device_manager_wayland_new (ClutterBackend *backend)
|
||||
{
|
||||
return g_object_new (CLUTTER_TYPE_DEVICE_MANAGER_WAYLAND,
|
||||
"backend", backend,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void
|
||||
_clutter_events_wayland_init (ClutterBackend *backend)
|
||||
{
|
||||
ClutterBackendWayland *backend_wayland = CLUTTER_BACKEND_WAYLAND (backend);
|
||||
|
||||
/* XXX: We actually create the wayland device manager in the backend
|
||||
* post_parse vfunc because that's the point where we connect to a compositor
|
||||
* and that's also the point where we will be notified of input devices so we
|
||||
* need the device-manager to exist early on.
|
||||
*
|
||||
* To be consistent with other clutter backends though we only associate the
|
||||
* device manager with the backend when _clutter_events_wayland_init() is
|
||||
* called in _clutter_backend_init_events(). This should still allow the
|
||||
* runtime selection of an alternative input backend if desired and in that
|
||||
* case the wayland device manager will be benign.
|
||||
*
|
||||
* FIXME: At some point we could perhaps collapse the
|
||||
* _clutter_backend_post_parse(), and _clutter_backend_init_events()
|
||||
* functions into one called something like _clutter_backend_init() which
|
||||
* would allow the real backend to manage the precise order of
|
||||
* initialization.
|
||||
*/
|
||||
|
||||
backend->device_manager = g_object_ref (backend_wayland->device_manager);
|
||||
}
|
||||
|
||||
void
|
||||
_clutter_events_wayland_uninit (ClutterBackend *backend)
|
||||
{
|
||||
g_object_unref (backend->device_manager);
|
||||
backend->device_manager = NULL;
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
/*
|
||||
* 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:
|
||||
* Robert Bragg <robert@linux.intel.com>
|
||||
*/
|
||||
|
||||
#ifndef __CLUTTER_DEVICE_MANAGER_WAYLAND_H__
|
||||
#define __CLUTTER_DEVICE_MANAGER_WAYLAND_H__
|
||||
|
||||
#include <clutter/clutter-device-manager.h>
|
||||
#include <wayland/clutter-backend-wayland.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;
|
||||
|
||||
ClutterDeviceManager *
|
||||
_clutter_device_manager_wayland_new (ClutterBackend *backend);
|
||||
|
||||
void
|
||||
_clutter_device_manager_wayland_add_input_group (ClutterDeviceManager *manager,
|
||||
uint32_t id);
|
||||
|
||||
void
|
||||
_clutter_events_wayland_init (ClutterBackend *backend);
|
||||
|
||||
void
|
||||
_clutter_events_wayland_uninit (ClutterBackend *backend);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __CLUTTER_DEVICE_MANAGER_WAYLAND_H__ */
|
@ -1,125 +0,0 @@
|
||||
/*
|
||||
* Clutter.
|
||||
*
|
||||
* An OpenGL based 'interactive canvas' library.
|
||||
*
|
||||
* Copyright (C) 2010 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:
|
||||
* Matthew Allum
|
||||
* Robert Bragg
|
||||
* Kristian Høgsberg
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <wayland-client.h>
|
||||
|
||||
#include "clutter-event.h"
|
||||
#include "clutter-main.h"
|
||||
#include "clutter-private.h"
|
||||
#include "clutter-stage-private.h"
|
||||
|
||||
#include "clutter-event-wayland.h"
|
||||
|
||||
typedef struct _ClutterEventSourceWayland
|
||||
{
|
||||
GSource source;
|
||||
struct wl_display *display;
|
||||
} ClutterEventSourceWayland;
|
||||
|
||||
static gboolean
|
||||
clutter_event_source_wayland_prepare (GSource *base, gint *timeout)
|
||||
{
|
||||
ClutterEventSourceWayland *source = (ClutterEventSourceWayland *) base;
|
||||
gboolean retval;
|
||||
|
||||
_clutter_threads_acquire_lock ();
|
||||
|
||||
*timeout = -1;
|
||||
|
||||
/* We have to add/remove the GPollFD if we want to update our
|
||||
* poll event mask dynamically. Instead, let's just flush all
|
||||
* writes on idle */
|
||||
wl_display_flush (source->display);
|
||||
|
||||
retval = clutter_events_pending ();
|
||||
|
||||
_clutter_threads_release_lock ();
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
clutter_event_source_wayland_check (GSource *base)
|
||||
{
|
||||
gboolean retval;
|
||||
|
||||
_clutter_threads_acquire_lock ();
|
||||
|
||||
retval = clutter_events_pending ();
|
||||
|
||||
_clutter_threads_release_lock ();
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
clutter_event_source_wayland_dispatch (GSource *base,
|
||||
GSourceFunc callback,
|
||||
gpointer data)
|
||||
{
|
||||
ClutterEvent *event;
|
||||
|
||||
_clutter_threads_acquire_lock ();
|
||||
|
||||
event = clutter_event_get ();
|
||||
|
||||
if (event)
|
||||
{
|
||||
/* forward the event into clutter for emission etc. */
|
||||
_clutter_stage_queue_event (event->any.stage, event, FALSE);
|
||||
}
|
||||
|
||||
_clutter_threads_release_lock ();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GSourceFuncs clutter_event_source_wayland_funcs = {
|
||||
clutter_event_source_wayland_prepare,
|
||||
clutter_event_source_wayland_check,
|
||||
clutter_event_source_wayland_dispatch,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
GSource *
|
||||
_clutter_event_source_wayland_new (struct wl_display *display)
|
||||
{
|
||||
ClutterEventSourceWayland *source;
|
||||
|
||||
source = (ClutterEventSourceWayland *)
|
||||
g_source_new (&clutter_event_source_wayland_funcs,
|
||||
sizeof (ClutterEventSourceWayland));
|
||||
source->display = display;
|
||||
|
||||
return &source->source;
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* 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 <robert@linux.intel.com>
|
||||
*/
|
||||
|
||||
#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__ */
|
@ -1,628 +0,0 @@
|
||||
/*
|
||||
* Clutter.
|
||||
*
|
||||
* An OpenGL based 'interactive canvas' library.
|
||||
*
|
||||
* Copyright (C) 2010 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:
|
||||
* Matthew Allum
|
||||
* Robert Bragg
|
||||
* Kristian Høgsberg
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
#include <wayland-util.h>
|
||||
#include <wayland-client.h>
|
||||
|
||||
#include "clutter-debug.h"
|
||||
#include "clutter-device-manager-private.h"
|
||||
#include "clutter-event-private.h"
|
||||
#include "clutter-private.h"
|
||||
#include "clutter-keysyms.h"
|
||||
#include "evdev/clutter-xkb-utils.h"
|
||||
#include "clutter-input-device-wayland.h"
|
||||
#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"
|
||||
|
||||
typedef struct _ClutterInputDeviceClass ClutterInputDeviceWaylandClass;
|
||||
|
||||
#define clutter_input_device_wayland_get_type \
|
||||
_clutter_input_device_wayland_get_type
|
||||
|
||||
G_DEFINE_TYPE (ClutterInputDeviceWayland,
|
||||
clutter_input_device_wayland,
|
||||
CLUTTER_TYPE_INPUT_DEVICE);
|
||||
|
||||
/* This gives us a fake time source for higher level abstractions to have an
|
||||
* understanding of when an event happens. All that matters are that this is a
|
||||
* monotonic increasing millisecond accurate time for events to be compared with.
|
||||
*/
|
||||
static guint32
|
||||
_clutter_wayland_get_time (void)
|
||||
{
|
||||
return g_get_monotonic_time () / 1000;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_wayland_handle_motion (void *data,
|
||||
struct wl_pointer *pointer,
|
||||
uint32_t _time,
|
||||
wl_fixed_t x, wl_fixed_t y)
|
||||
{
|
||||
ClutterInputDeviceWayland *device = data;
|
||||
ClutterStageCogl *stage_cogl;
|
||||
ClutterEvent *event;
|
||||
|
||||
if (!device->pointer_focus)
|
||||
return;
|
||||
|
||||
stage_cogl = device->pointer_focus;
|
||||
|
||||
event = clutter_event_new (CLUTTER_MOTION);
|
||||
event->motion.stage = stage_cogl->wrapper;
|
||||
event->motion.device = CLUTTER_INPUT_DEVICE (device);
|
||||
event->motion.time = _clutter_wayland_get_time ();
|
||||
event->motion.modifier_state = 0;
|
||||
event->motion.x = wl_fixed_to_double (x);
|
||||
event->motion.y = wl_fixed_to_double (y);
|
||||
|
||||
device->x = event->motion.x;
|
||||
device->y = event->motion.y;
|
||||
|
||||
_clutter_event_push (event, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_wayland_handle_button (void *data,
|
||||
struct wl_pointer *pointer,
|
||||
uint32_t serial, uint32_t _time,
|
||||
uint32_t button, uint32_t state)
|
||||
{
|
||||
ClutterInputDeviceWayland *device = data;
|
||||
ClutterStageCogl *stage_cogl;
|
||||
ClutterEvent *event;
|
||||
ClutterEventType type;
|
||||
ClutterModifierType modifier_mask = 0;
|
||||
|
||||
if (!device->pointer_focus)
|
||||
return;
|
||||
|
||||
stage_cogl = device->pointer_focus;
|
||||
|
||||
if (state)
|
||||
type = CLUTTER_BUTTON_PRESS;
|
||||
else
|
||||
type = CLUTTER_BUTTON_RELEASE;
|
||||
|
||||
event = clutter_event_new (type);
|
||||
event->button.stage = stage_cogl->wrapper;
|
||||
event->button.device = CLUTTER_INPUT_DEVICE (device);
|
||||
event->button.time = _clutter_wayland_get_time ();
|
||||
event->button.x = device->x;
|
||||
event->button.y = device->y;
|
||||
_clutter_xkb_translate_state (event, device->xkb, 0);
|
||||
|
||||
/* evdev button codes */
|
||||
switch (button) {
|
||||
case 272:
|
||||
event->button.button = 1;
|
||||
modifier_mask = CLUTTER_BUTTON1_MASK;
|
||||
break;
|
||||
case 273:
|
||||
event->button.button = 3;
|
||||
modifier_mask = CLUTTER_BUTTON2_MASK;
|
||||
break;
|
||||
case 274:
|
||||
event->button.button = 2;
|
||||
modifier_mask = CLUTTER_BUTTON3_MASK;
|
||||
break;
|
||||
}
|
||||
|
||||
if (modifier_mask)
|
||||
{
|
||||
if (state)
|
||||
device->button_modifier_state |= modifier_mask;
|
||||
else
|
||||
device->button_modifier_state &= ~modifier_mask;
|
||||
}
|
||||
|
||||
event->button.modifier_state = device->button_modifier_state;
|
||||
|
||||
_clutter_event_push (event, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_wayland_handle_axis (void *data,
|
||||
struct wl_pointer *pointer,
|
||||
uint32_t time,
|
||||
uint32_t axis,
|
||||
wl_fixed_t value)
|
||||
{
|
||||
ClutterInputDeviceWayland *device = data;
|
||||
ClutterStageCogl *stage_cogl;
|
||||
ClutterEvent *event;
|
||||
gdouble delta_x, delta_y;
|
||||
gdouble delta_factor;
|
||||
|
||||
if (!device->pointer_focus)
|
||||
return;
|
||||
|
||||
stage_cogl = device->pointer_focus;
|
||||
event = clutter_event_new (CLUTTER_SCROLL);
|
||||
event->scroll.time = _clutter_wayland_get_time ();
|
||||
event->scroll.stage = stage_cogl->wrapper;
|
||||
event->scroll.direction = CLUTTER_SCROLL_SMOOTH;
|
||||
event->scroll.x = device->x;
|
||||
event->scroll.y = device->y;
|
||||
|
||||
/* Wayland pointer axis events are in pointer motion coordinate space.
|
||||
* To convert to Xi2 discrete step coordinate space, multiply the factor
|
||||
* 1/10. */
|
||||
delta_factor = 1.0 / 10.0;
|
||||
if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL)
|
||||
{
|
||||
delta_x = wl_fixed_to_double (value) * delta_factor;
|
||||
delta_y = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
delta_x = 0;
|
||||
delta_y = wl_fixed_to_double (value) * delta_factor;
|
||||
}
|
||||
clutter_event_set_scroll_delta (event, delta_x, delta_y);
|
||||
|
||||
_clutter_xkb_translate_state (event, device->xkb, 0);
|
||||
|
||||
_clutter_event_push (event, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_wayland_handle_keymap (void *data,
|
||||
struct wl_keyboard *keyboard,
|
||||
uint32_t format,
|
||||
int32_t fd,
|
||||
uint32_t size)
|
||||
{
|
||||
ClutterInputDeviceWayland *device = data;
|
||||
struct xkb_context *ctx;
|
||||
struct xkb_keymap *keymap;
|
||||
char *map_str;
|
||||
|
||||
if (device->xkb)
|
||||
{
|
||||
xkb_state_unref (device->xkb);
|
||||
device->xkb = NULL;
|
||||
}
|
||||
|
||||
ctx = xkb_context_new (0);
|
||||
if (!ctx)
|
||||
{
|
||||
close (fd);
|
||||
return;
|
||||
}
|
||||
|
||||
if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1)
|
||||
{
|
||||
close (fd);
|
||||
return;
|
||||
}
|
||||
|
||||
map_str = mmap (NULL, size, PROT_READ, MAP_SHARED, fd, 0);
|
||||
if (map_str == MAP_FAILED)
|
||||
{
|
||||
close (fd);
|
||||
return;
|
||||
}
|
||||
|
||||
keymap = xkb_map_new_from_string (ctx,
|
||||
map_str,
|
||||
XKB_KEYMAP_FORMAT_TEXT_V1,
|
||||
0);
|
||||
xkb_context_unref (ctx);
|
||||
munmap (map_str, size);
|
||||
close (fd);
|
||||
|
||||
if (!keymap)
|
||||
{
|
||||
g_warning ("failed to compile keymap\n");
|
||||
return;
|
||||
}
|
||||
|
||||
device->xkb = xkb_state_new (keymap);
|
||||
xkb_map_unref (keymap);
|
||||
if (!device->xkb)
|
||||
{
|
||||
g_warning ("failed to create XKB state object\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* XXX: Need a wl_keyboard event to harmonise these across clients. */
|
||||
#define KEY_REPEAT_DELAY 660
|
||||
#define KEY_REPEAT_INTERVAL 40
|
||||
|
||||
static gboolean
|
||||
clutter_wayland_repeat_key (void *data)
|
||||
{
|
||||
ClutterInputDeviceWayland *device = data;
|
||||
ClutterStageCogl *stage_cogl = device->keyboard_focus;
|
||||
ClutterEvent *event;
|
||||
|
||||
event = _clutter_key_event_new_from_evdev ((ClutterInputDevice *) device,
|
||||
(ClutterInputDevice*) device,
|
||||
stage_cogl->wrapper,
|
||||
device->xkb, 0,
|
||||
device->repeat_time,
|
||||
device->repeat_key,
|
||||
1);
|
||||
device->repeat_time += KEY_REPEAT_INTERVAL;
|
||||
_clutter_event_push (event, FALSE);
|
||||
|
||||
if (!device->is_initial_repeat)
|
||||
return TRUE;
|
||||
|
||||
g_source_remove (device->repeat_source);
|
||||
device->repeat_source = g_timeout_add (KEY_REPEAT_INTERVAL,
|
||||
clutter_wayland_repeat_key,
|
||||
device);
|
||||
device->is_initial_repeat = FALSE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_wayland_handle_key (void *data,
|
||||
struct wl_keyboard *keyboard,
|
||||
uint32_t serial, uint32_t _time,
|
||||
uint32_t key, uint32_t state)
|
||||
{
|
||||
ClutterInputDeviceWayland *device = data;
|
||||
ClutterStageCogl *stage_cogl = device->keyboard_focus;
|
||||
ClutterEvent *event;
|
||||
|
||||
if (!device->keyboard_focus)
|
||||
return;
|
||||
if (!device->xkb)
|
||||
return;
|
||||
|
||||
event = _clutter_key_event_new_from_evdev ((ClutterInputDevice *) device,
|
||||
(ClutterInputDevice *) device,
|
||||
stage_cogl->wrapper,
|
||||
device->xkb, 0,
|
||||
_clutter_wayland_get_time (),
|
||||
key, state);
|
||||
|
||||
_clutter_event_push (event, FALSE);
|
||||
|
||||
if (!xkb_key_repeats (xkb_state_get_map (device->xkb), key))
|
||||
return;
|
||||
|
||||
if (state)
|
||||
{
|
||||
if (device->repeat_key != XKB_KEYCODE_INVALID)
|
||||
g_source_remove (device->repeat_source);
|
||||
device->repeat_key = key;
|
||||
device->repeat_time = _time + KEY_REPEAT_DELAY;
|
||||
device->repeat_source = g_timeout_add (KEY_REPEAT_DELAY,
|
||||
clutter_wayland_repeat_key,
|
||||
device);
|
||||
device->is_initial_repeat = TRUE;
|
||||
}
|
||||
else if (device->repeat_key == key)
|
||||
{
|
||||
g_source_remove (device->repeat_source);
|
||||
device->repeat_key = XKB_KEYCODE_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_wayland_handle_modifiers (void *data,
|
||||
struct wl_keyboard *keyboard,
|
||||
uint32_t serial,
|
||||
uint32_t mods_depressed,
|
||||
uint32_t mods_latched,
|
||||
uint32_t mods_locked,
|
||||
uint32_t group)
|
||||
{
|
||||
ClutterInputDeviceWayland *device = data;
|
||||
|
||||
if (!device->xkb)
|
||||
return;
|
||||
|
||||
xkb_state_update_mask (device->xkb,
|
||||
mods_depressed,
|
||||
mods_latched,
|
||||
mods_locked,
|
||||
0,
|
||||
0,
|
||||
group);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_wayland_handle_pointer_enter (void *data,
|
||||
struct wl_pointer *pointer,
|
||||
uint32_t serial,
|
||||
struct wl_surface *surface,
|
||||
wl_fixed_t x, wl_fixed_t y)
|
||||
{
|
||||
ClutterInputDeviceWayland *device = data;
|
||||
ClutterStageWayland *stage_wayland;
|
||||
ClutterStageCogl *stage_cogl;
|
||||
ClutterEvent *event;
|
||||
ClutterBackend *backend;
|
||||
ClutterBackendWayland *backend_wayland;
|
||||
|
||||
stage_wayland = 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),
|
||||
stage_cogl->wrapper);
|
||||
|
||||
event = clutter_event_new (CLUTTER_ENTER);
|
||||
event->crossing.stage = stage_cogl->wrapper;
|
||||
event->crossing.time = _clutter_wayland_get_time ();
|
||||
event->crossing.x = wl_fixed_to_double (x);
|
||||
event->crossing.y = wl_fixed_to_double (y);
|
||||
event->crossing.source = CLUTTER_ACTOR (stage_cogl->wrapper);
|
||||
event->crossing.device = CLUTTER_INPUT_DEVICE (device);
|
||||
|
||||
device->x = event->crossing.x;
|
||||
device->y = event->crossing.y;
|
||||
|
||||
_clutter_event_push (event, FALSE);
|
||||
|
||||
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
|
||||
clutter_wayland_handle_pointer_leave (void *data,
|
||||
struct wl_pointer *pointer,
|
||||
uint32_t serial,
|
||||
struct wl_surface *surface)
|
||||
{
|
||||
ClutterInputDeviceWayland *device = data;
|
||||
ClutterStageCogl *stage_cogl;
|
||||
ClutterEvent *event;
|
||||
|
||||
if (surface == NULL)
|
||||
return;
|
||||
|
||||
if (!CLUTTER_IS_STAGE_COGL (wl_surface_get_user_data (surface)))
|
||||
return;
|
||||
|
||||
stage_cogl = wl_surface_get_user_data (surface);
|
||||
g_assert (device->pointer_focus == stage_cogl);
|
||||
|
||||
event = clutter_event_new (CLUTTER_LEAVE);
|
||||
event->crossing.stage = stage_cogl->wrapper;
|
||||
event->crossing.time = _clutter_wayland_get_time ();
|
||||
event->crossing.x = device->x;
|
||||
event->crossing.y = device->y;
|
||||
event->crossing.source = CLUTTER_ACTOR (stage_cogl->wrapper);
|
||||
event->crossing.device = CLUTTER_INPUT_DEVICE (device);
|
||||
|
||||
_clutter_event_push (event, FALSE);
|
||||
|
||||
device->pointer_focus = NULL;
|
||||
_clutter_input_device_set_stage (CLUTTER_INPUT_DEVICE (device), NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_wayland_handle_keyboard_enter (void *data,
|
||||
struct wl_keyboard *keyboard,
|
||||
uint32_t serial,
|
||||
struct wl_surface *surface,
|
||||
struct wl_array *keys)
|
||||
{
|
||||
ClutterInputDeviceWayland *device = data;
|
||||
ClutterStageCogl *stage_cogl;
|
||||
|
||||
if (!CLUTTER_IS_STAGE_COGL (wl_surface_get_user_data (surface)))
|
||||
return;
|
||||
|
||||
stage_cogl = wl_surface_get_user_data (surface);
|
||||
g_assert (device->keyboard_focus == NULL);
|
||||
device->keyboard_focus = stage_cogl;
|
||||
|
||||
_clutter_stage_update_state (stage_cogl->wrapper,
|
||||
0,
|
||||
CLUTTER_STAGE_STATE_ACTIVATED);
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_wayland_handle_keyboard_leave (void *data,
|
||||
struct wl_keyboard *keyboard,
|
||||
uint32_t serial,
|
||||
struct wl_surface *surface)
|
||||
{
|
||||
ClutterInputDeviceWayland *device = data;
|
||||
ClutterStageCogl *stage_cogl;
|
||||
|
||||
if (!surface)
|
||||
return;
|
||||
if (!CLUTTER_IS_STAGE_COGL (wl_surface_get_user_data (surface)))
|
||||
return;
|
||||
|
||||
stage_cogl = wl_surface_get_user_data (surface);
|
||||
g_assert (device->keyboard_focus == stage_cogl);
|
||||
|
||||
_clutter_stage_update_state (stage_cogl->wrapper,
|
||||
CLUTTER_STAGE_STATE_ACTIVATED,
|
||||
0);
|
||||
|
||||
if (device->repeat_key != XKB_KEYCODE_INVALID)
|
||||
{
|
||||
g_source_remove (device->repeat_source);
|
||||
device->repeat_key = XKB_KEYCODE_INVALID;
|
||||
}
|
||||
|
||||
device->keyboard_focus = NULL;
|
||||
}
|
||||
|
||||
static const struct wl_keyboard_listener _clutter_keyboard_wayland_listener = {
|
||||
clutter_wayland_handle_keymap,
|
||||
clutter_wayland_handle_keyboard_enter,
|
||||
clutter_wayland_handle_keyboard_leave,
|
||||
clutter_wayland_handle_key,
|
||||
clutter_wayland_handle_modifiers,
|
||||
};
|
||||
|
||||
static const struct wl_pointer_listener _clutter_pointer_wayland_listener = {
|
||||
clutter_wayland_handle_pointer_enter,
|
||||
clutter_wayland_handle_pointer_leave,
|
||||
clutter_wayland_handle_motion,
|
||||
clutter_wayland_handle_button,
|
||||
clutter_wayland_handle_axis,
|
||||
};
|
||||
|
||||
static void
|
||||
clutter_wayland_handle_seat (void *data,
|
||||
struct wl_seat *seat,
|
||||
uint32_t capabilities)
|
||||
{
|
||||
ClutterInputDeviceWayland *device = data;
|
||||
|
||||
/* XXX: Needs to handle removals too. */
|
||||
|
||||
if ((capabilities & WL_SEAT_CAPABILITY_POINTER) && !device->has_pointer)
|
||||
{
|
||||
struct wl_pointer *pointer;
|
||||
|
||||
pointer = wl_seat_get_pointer (seat);
|
||||
if (pointer)
|
||||
{
|
||||
wl_pointer_add_listener (pointer,
|
||||
&_clutter_pointer_wayland_listener,
|
||||
device);
|
||||
wl_pointer_set_user_data (pointer, device);
|
||||
device->has_pointer = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ((capabilities & WL_SEAT_CAPABILITY_KEYBOARD) && !device->has_keyboard)
|
||||
{
|
||||
struct wl_keyboard *keyboard;
|
||||
|
||||
keyboard = wl_seat_get_keyboard (seat);
|
||||
if (keyboard)
|
||||
{
|
||||
wl_keyboard_add_listener (keyboard,
|
||||
&_clutter_keyboard_wayland_listener,
|
||||
device);
|
||||
wl_keyboard_set_user_data (keyboard, device);
|
||||
device->has_keyboard = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const struct wl_seat_listener _clutter_seat_wayland_listener = {
|
||||
clutter_wayland_handle_seat,
|
||||
};
|
||||
|
||||
static gboolean
|
||||
clutter_input_device_wayland_keycode_to_evdev (ClutterInputDevice *device,
|
||||
guint hardware_keycode,
|
||||
guint *evdev_keycode)
|
||||
{
|
||||
/* The hardware keycodes from the wayland backend are already evdev
|
||||
keycodes */
|
||||
*evdev_keycode = hardware_keycode;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_input_device_wayland_class_init (ClutterInputDeviceWaylandClass *klass)
|
||||
{
|
||||
klass->keycode_to_evdev = clutter_input_device_wayland_keycode_to_evdev;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_input_device_wayland_init (ClutterInputDeviceWayland *self)
|
||||
{
|
||||
self->repeat_key = XKB_KEYCODE_INVALID;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_wayland_input_device_get_wl_seat: (skip)
|
||||
* @device: a #ClutterInputDevice
|
||||
*
|
||||
* Access the underlying data structure representing the Wayland device that is
|
||||
* backing this #ClutterInputDevice.
|
||||
*
|
||||
* Note: this function can only be called when running on the Wayland platform.
|
||||
* Calling this function at any other time will return %NULL.
|
||||
*
|
||||
* Returns: (transfer none): the Wayland input device associated with the
|
||||
* @device
|
||||
*
|
||||
* Since: 1.10
|
||||
*/
|
||||
struct wl_seat *
|
||||
clutter_wayland_input_device_get_wl_seat (ClutterInputDevice *device)
|
||||
{
|
||||
ClutterInputDeviceWayland *wayland_device;
|
||||
|
||||
if (!CLUTTER_INPUT_DEVICE_WAYLAND (device))
|
||||
return NULL;
|
||||
|
||||
wayland_device = CLUTTER_INPUT_DEVICE_WAYLAND (device);
|
||||
|
||||
return wayland_device->input_device;
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* 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 <robert@linux.intel.com>
|
||||
*/
|
||||
|
||||
#ifndef __CLUTTER_INPUT_DEVICE_WAYLAND_H__
|
||||
#define __CLUTTER_INPUT_DEVICE_WAYLAND_H__
|
||||
|
||||
#include <xkbcommon/xkbcommon.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_seat *input_device;
|
||||
ClutterStageCogl *pointer_focus;
|
||||
ClutterStageCogl *keyboard_focus;
|
||||
gdouble x, y;
|
||||
struct xkb_state *xkb;
|
||||
gint has_pointer;
|
||||
gint has_keyboard;
|
||||
xkb_keycode_t repeat_key;
|
||||
guint repeat_time;
|
||||
guint repeat_source;
|
||||
gboolean is_initial_repeat;
|
||||
ClutterModifierType button_modifier_state;
|
||||
};
|
||||
|
||||
GType _clutter_input_device_wayland_get_type (void) G_GNUC_CONST;
|
||||
|
||||
extern const struct wl_seat_listener _clutter_seat_wayland_listener;
|
||||
|
||||
#endif /* __CLUTTER_INPUT_DEVICE_WAYLAND_H__ */
|
@ -1,365 +0,0 @@
|
||||
/*
|
||||
* Clutter.
|
||||
*
|
||||
* An OpenGL based 'interactive canvas' library.
|
||||
*
|
||||
* Copyright (C) 2010 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:
|
||||
* Matthew Allum
|
||||
* Robert Bragg
|
||||
* Kristian Høgsberg
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include "clutter-wayland.h"
|
||||
#include "clutter-stage-wayland.h"
|
||||
#include "clutter-backend-wayland.h"
|
||||
#include "clutter-backend-wayland-priv.h"
|
||||
#include "clutter-stage-window.h"
|
||||
#include "clutter-stage-private.h"
|
||||
#include "clutter-event-private.h"
|
||||
#include "clutter-wayland.h"
|
||||
#include <cogl/cogl.h>
|
||||
#include <cogl/cogl-wayland-client.h>
|
||||
|
||||
static ClutterStageWindowIface *clutter_stage_window_parent_iface = NULL;
|
||||
|
||||
static void clutter_stage_window_iface_init (ClutterStageWindowIface *iface);
|
||||
|
||||
#define clutter_stage_wayland_get_type _clutter_stage_wayland_get_type
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (ClutterStageWayland,
|
||||
clutter_stage_wayland,
|
||||
CLUTTER_TYPE_STAGE_COGL,
|
||||
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_STAGE_WINDOW,
|
||||
clutter_stage_window_iface_init));
|
||||
|
||||
static void
|
||||
handle_ping (void *data,
|
||||
struct wl_shell_surface *shell_surface,
|
||||
uint32_t serial)
|
||||
{
|
||||
wl_shell_surface_pong(shell_surface, serial);
|
||||
}
|
||||
|
||||
static void
|
||||
handle_configure (void *data,
|
||||
struct wl_shell_surface *shell_surface,
|
||||
uint32_t edges,
|
||||
int32_t width,
|
||||
int32_t height)
|
||||
{
|
||||
ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL(data);
|
||||
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 void
|
||||
handle_popup_done (void *data,
|
||||
struct wl_shell_surface *shell_surface)
|
||||
{
|
||||
/* XXX: Fill me in. */
|
||||
}
|
||||
|
||||
static const struct wl_shell_surface_listener shell_surface_listener = {
|
||||
handle_ping,
|
||||
handle_configure,
|
||||
handle_popup_done,
|
||||
};
|
||||
|
||||
static void
|
||||
clutter_stage_wayland_set_fullscreen (ClutterStageWindow *stage_window,
|
||||
gboolean fullscreen);
|
||||
|
||||
static gboolean
|
||||
clutter_stage_wayland_realize (ClutterStageWindow *stage_window)
|
||||
{
|
||||
ClutterStageWayland *stage_wayland = CLUTTER_STAGE_WAYLAND (stage_window);
|
||||
ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
|
||||
struct wl_surface *wl_surface;
|
||||
struct wl_shell_surface *wl_shell_surface;
|
||||
|
||||
clutter_stage_window_parent_iface->realize (stage_window);
|
||||
|
||||
wl_surface = cogl_wayland_onscreen_get_surface (stage_cogl->onscreen);
|
||||
wl_surface_set_user_data (wl_surface, stage_wayland);
|
||||
stage_wayland->wayland_surface = wl_surface;
|
||||
|
||||
if (!stage_wayland->foreign_wl_surface)
|
||||
{
|
||||
wl_shell_surface =
|
||||
cogl_wayland_onscreen_get_shell_surface (stage_cogl->onscreen);
|
||||
wl_shell_surface_add_listener (wl_shell_surface,
|
||||
&shell_surface_listener,
|
||||
stage_wayland);
|
||||
stage_wayland->wayland_shell_surface = wl_shell_surface;
|
||||
}
|
||||
|
||||
if (stage_wayland->fullscreen)
|
||||
clutter_stage_wayland_set_fullscreen (stage_window, TRUE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_stage_wayland_show (ClutterStageWindow *stage_window,
|
||||
gboolean do_raise)
|
||||
{
|
||||
ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
|
||||
ClutterStageWayland *stage_wayland = CLUTTER_STAGE_WAYLAND (stage_window);
|
||||
|
||||
clutter_stage_window_parent_iface->show (stage_window, do_raise);
|
||||
|
||||
if (stage_wayland->wayland_shell_surface)
|
||||
wl_shell_surface_set_toplevel (stage_wayland->wayland_shell_surface);
|
||||
|
||||
stage_wayland->shown = TRUE;
|
||||
|
||||
/* We need to queue a redraw after the stage is shown because all of
|
||||
* the other queue redraws up to this point will have been ignored
|
||||
* because the actor was not visible. The other backends do not need
|
||||
* to do this because they will get expose events at some point, but
|
||||
* that does not happen for Wayland. */
|
||||
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)
|
||||
{
|
||||
ClutterStageWayland *stage_wayland = CLUTTER_STAGE_WAYLAND (stage_window);
|
||||
ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
|
||||
ClutterBackend *backend = CLUTTER_BACKEND (stage_cogl->backend);
|
||||
ClutterBackendWayland *backend_wayland = CLUTTER_BACKEND_WAYLAND (backend);
|
||||
ClutterActor *stage = _clutter_stage_window_get_wrapper (stage_window);
|
||||
|
||||
stage_wayland->fullscreen = fullscreen;
|
||||
|
||||
if (!stage_wayland->wayland_shell_surface)
|
||||
return;
|
||||
|
||||
if (fullscreen)
|
||||
{
|
||||
_clutter_stage_update_state (stage_cogl->wrapper,
|
||||
0,
|
||||
CLUTTER_STAGE_STATE_FULLSCREEN);
|
||||
|
||||
/* FIXME: In future versions of the Wayland protocol we'll get a
|
||||
* configure with the dimensions we can use - but for now we have to
|
||||
* use the dimensions from the output's mode
|
||||
*/
|
||||
clutter_actor_set_size (stage,
|
||||
backend_wayland->output_width,
|
||||
backend_wayland->output_height);
|
||||
|
||||
/* FIXME: And we must force a redraw so that new sized buffer gets
|
||||
* attached
|
||||
*/
|
||||
_clutter_stage_window_redraw (stage_window);
|
||||
wl_shell_surface_set_fullscreen (stage_wayland->wayland_shell_surface,
|
||||
WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT,
|
||||
0,
|
||||
NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
_clutter_stage_update_state (stage_cogl->wrapper,
|
||||
CLUTTER_STAGE_STATE_FULLSCREEN,
|
||||
0);
|
||||
|
||||
wl_shell_surface_set_toplevel (stage_wayland->wayland_shell_surface);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_stage_wayland_resize (ClutterStageWindow *stage_window,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
ClutterStageCogl *stage_cogl = CLUTTER_STAGE_COGL (stage_window);
|
||||
ClutterStageWayland *stage_wayland = CLUTTER_STAGE_WAYLAND (stage_window);
|
||||
|
||||
/* Resize preserving top left */
|
||||
if (stage_cogl->onscreen)
|
||||
{
|
||||
cogl_wayland_onscreen_resize (stage_cogl->onscreen, width, height, 0, 0);
|
||||
|
||||
/* Only trigger a redraw if the stage window has been shown */
|
||||
if (stage_wayland->shown)
|
||||
_clutter_stage_window_redraw (stage_window);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
clutter_stage_wayland_can_clip_redraws (ClutterStageWindow *stage_window)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_stage_wayland_init (ClutterStageWayland *stage_wayland)
|
||||
{
|
||||
stage_wayland->cursor_visible = TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_stage_window_iface_init (ClutterStageWindowIface *iface)
|
||||
{
|
||||
clutter_stage_window_parent_iface = g_type_interface_peek_parent (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;
|
||||
iface->can_clip_redraws = clutter_stage_wayland_can_clip_redraws;
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_stage_wayland_class_init (ClutterStageWaylandClass *klass)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_wayland_stage_get_wl_shell_surface: (skip)
|
||||
* @stage: a #ClutterStage
|
||||
*
|
||||
* Access the underlying data structure representing the shell surface that is
|
||||
* backing the #ClutterStage
|
||||
*
|
||||
* Note: this function can only be called when running on the Wayland
|
||||
* platform. Calling this function at any other time will return %NULL.
|
||||
*
|
||||
* Returns: (transfer none): the Wayland shell surface associated with
|
||||
* @stage
|
||||
*
|
||||
* Since: 1.10
|
||||
*/
|
||||
struct wl_shell_surface *
|
||||
clutter_wayland_stage_get_wl_shell_surface (ClutterStage *stage)
|
||||
{
|
||||
ClutterStageWindow *stage_window = _clutter_stage_get_window (stage);
|
||||
ClutterStageWayland *stage_wayland;
|
||||
|
||||
if (!CLUTTER_IS_STAGE_WAYLAND (stage_window))
|
||||
return NULL;
|
||||
|
||||
stage_wayland = CLUTTER_STAGE_WAYLAND (stage_window);
|
||||
|
||||
return stage_wayland->wayland_shell_surface;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_wayland_stage_get_wl_surface: (skip)
|
||||
* @stage: a #ClutterStage
|
||||
*
|
||||
* Access the underlying data structure representing the surface that is
|
||||
* backing the #ClutterStage
|
||||
*
|
||||
* Note: this function can only be called when running on the Wayland
|
||||
* platform. Calling this function at any other time will return %NULL.
|
||||
*
|
||||
* Returns: (transfer none): the Wayland surface associated with @stage
|
||||
*
|
||||
* Since: 1.10
|
||||
*/
|
||||
struct wl_surface *
|
||||
clutter_wayland_stage_get_wl_surface (ClutterStage *stage)
|
||||
{
|
||||
ClutterStageWindow *stage_window = _clutter_stage_get_window (stage);
|
||||
ClutterStageWayland *stage_wayland;
|
||||
|
||||
if (!CLUTTER_IS_STAGE_WAYLAND (stage_window))
|
||||
return NULL;
|
||||
|
||||
stage_wayland = CLUTTER_STAGE_WAYLAND (stage_window);
|
||||
|
||||
return stage_wayland->wayland_surface;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_wayland_stage_set_wl_surface:
|
||||
* @stage: a #ClutterStage
|
||||
* @surface: A Wayland surface to associate with the @stage.
|
||||
*
|
||||
* Allows you to explicitly provide an existing Wayland surface to associate
|
||||
* with @stage, preventing Cogl from allocating a surface and shell surface for
|
||||
* the stage automatically.
|
||||
*
|
||||
* This function must be called before @stage is shown.
|
||||
*
|
||||
* Note: this function can only be called when running on the Wayland
|
||||
* platform. Calling this function at any other time has no effect.
|
||||
*
|
||||
* Since: 1.16
|
||||
*/
|
||||
void
|
||||
clutter_wayland_stage_set_wl_surface (ClutterStage *stage,
|
||||
struct wl_surface *surface)
|
||||
{
|
||||
ClutterStageWindow *stage_window = _clutter_stage_get_window (stage);
|
||||
ClutterStageWayland *stage_wayland;
|
||||
ClutterStageCogl *stage_cogl;
|
||||
|
||||
if (!CLUTTER_IS_STAGE_WAYLAND (stage_window))
|
||||
return;
|
||||
|
||||
stage_cogl = CLUTTER_STAGE_COGL (stage_window);
|
||||
|
||||
if (stage_cogl->onscreen == NULL)
|
||||
{
|
||||
ClutterBackend *backend = clutter_get_default_backend ();
|
||||
|
||||
/* Use the same default dimensions as clutter_stage_cogl_realize() */
|
||||
stage_cogl->onscreen = cogl_onscreen_new (backend->cogl_context,
|
||||
800, 600);
|
||||
|
||||
cogl_wayland_onscreen_set_foreign_surface (stage_cogl->onscreen,
|
||||
surface);
|
||||
|
||||
stage_wayland = CLUTTER_STAGE_WAYLAND (stage_window);
|
||||
stage_wayland->foreign_wl_surface = TRUE;
|
||||
}
|
||||
else
|
||||
g_warning (G_STRLOC ": cannot set foreign surface for stage");
|
||||
}
|
@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Clutter.
|
||||
*
|
||||
* An OpenGL based 'interactive canvas' library.
|
||||
*
|
||||
* Copyright (C) 2010,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:
|
||||
* Matthew Allum
|
||||
* Robert Bragg
|
||||
* Kristian Høgsberg
|
||||
*/
|
||||
|
||||
#ifndef __CLUTTER_STAGE_WAYLAND_H__
|
||||
#define __CLUTTER_STAGE_WAYLAND_H__
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <clutter/clutter-stage.h>
|
||||
|
||||
#include "cogl/clutter-stage-cogl.h"
|
||||
|
||||
#define CLUTTER_TYPE_STAGE_WAYLAND (_clutter_stage_wayland_get_type ())
|
||||
#define CLUTTER_STAGE_WAYLAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_STAGE_WAYLAND, ClutterStageWayland))
|
||||
#define CLUTTER_IS_STAGE_WAYLAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_STAGE_WAYLAND))
|
||||
#define CLUTTER_STAGE_WAYLAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_STAGE_WAYLAND, ClutterStageWaylandClass))
|
||||
#define CLUTTER_IS_STAGE_WAYLAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_STAGE_WAYLAND))
|
||||
#define CLUTTER_STAGE_WAYLAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_STAGE_WAYLAND, ClutterStageWaylandClass))
|
||||
|
||||
typedef struct _ClutterStageWayland ClutterStageWayland;
|
||||
typedef struct _ClutterStageWaylandClass ClutterStageWaylandClass;
|
||||
|
||||
struct _ClutterStageWayland
|
||||
{
|
||||
ClutterStageCogl parent_instance;
|
||||
|
||||
struct wl_surface *wayland_surface;
|
||||
struct wl_shell_surface *wayland_shell_surface;
|
||||
gboolean fullscreen;
|
||||
gboolean foreign_wl_surface;
|
||||
gboolean shown;
|
||||
gboolean cursor_visible;
|
||||
};
|
||||
|
||||
struct _ClutterStageWaylandClass
|
||||
{
|
||||
ClutterStageCoglClass parent_class;
|
||||
};
|
||||
|
||||
GType _clutter_stage_wayland_get_type (void) G_GNUC_CONST;
|
||||
|
||||
#endif /* __CLUTTER_STAGE_WAYLAND_H__ */
|
@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Clutter.
|
||||
*
|
||||
* An OpenGL based 'interactive canvas' library.
|
||||
*
|
||||
* Copyright (C) 2012 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/>.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* SECTION:clutter-wayland
|
||||
* @short_description: Wayland specific API
|
||||
*
|
||||
* The Wayland backend for Clutter provides some specific API, allowing
|
||||
* integration with the Wayland client API for acessing the underlying data
|
||||
* structures
|
||||
*
|
||||
* The Clutter Wayland API is available since Clutter 1.10
|
||||
*/
|
||||
|
||||
#ifndef __CLUTTER_WAYLAND_H__
|
||||
#define __CLUTTER_WAYLAND_H__
|
||||
|
||||
#include <glib.h>
|
||||
#include <wayland-client.h>
|
||||
#include <clutter/clutter.h>
|
||||
G_BEGIN_DECLS
|
||||
|
||||
CLUTTER_AVAILABLE_IN_1_10
|
||||
struct wl_seat *clutter_wayland_input_device_get_wl_seat (ClutterInputDevice *device);
|
||||
|
||||
CLUTTER_AVAILABLE_IN_1_10
|
||||
struct wl_shell_surface *clutter_wayland_stage_get_wl_shell_surface (ClutterStage *stage);
|
||||
|
||||
CLUTTER_AVAILABLE_IN_1_10
|
||||
struct wl_surface *clutter_wayland_stage_get_wl_surface (ClutterStage *stage);
|
||||
|
||||
CLUTTER_AVAILABLE_IN_1_16
|
||||
void clutter_wayland_stage_set_wl_surface (ClutterStage *stage, struct wl_surface *surface);
|
||||
|
||||
CLUTTER_AVAILABLE_IN_1_16
|
||||
void clutter_wayland_set_display (struct wl_display *display);
|
||||
|
||||
CLUTTER_AVAILABLE_IN_1_16
|
||||
void clutter_wayland_disable_event_retrieval (void);
|
||||
|
||||
G_END_DECLS
|
||||
#endif /* __CLUTTER_WAYLAND_H__ */
|
61
configure.ac
61
configure.ac
@ -214,10 +214,6 @@ AC_ARG_ENABLE([x11-backend],
|
||||
[AS_HELP_STRING([--enable-x11-backend=@<:@yes/no@:>@], [Enable the X11 backend (default=check)])],
|
||||
[enable_x11=$enableval],
|
||||
[enable_x11=check])
|
||||
AC_ARG_ENABLE([wayland-backend],
|
||||
[AS_HELP_STRING([--enable-wayland-backend=@<:@yes/no@:>@], [Enable the Wayland client backend (default=check)])],
|
||||
[enable_wayland=$enableval],
|
||||
[enable_wayland=check])
|
||||
AC_ARG_ENABLE([egl-backend],
|
||||
[AS_HELP_STRING([--enable-egl-backend=@<:@yes/no@:>@], [Enable the EGL framebuffer backend (default=no)])],
|
||||
[enable_egl=$enableval],
|
||||
@ -264,57 +260,6 @@ AS_IF([test "x$enable_x11" = "xyes"],
|
||||
[])
|
||||
])
|
||||
|
||||
AS_IF([test "x$enable_wayland" != xno],
|
||||
[
|
||||
# We need to manually check for Wayland support in Cogl because
|
||||
# the windowing systems are not exposed in the pkg-config file
|
||||
saved_CFLAGS="${CFLAGS}"
|
||||
CFLAGS="`$PKG_CONFIG --cflags cogl-1.0`"
|
||||
|
||||
AC_MSG_CHECKING([for Wayland Cogl backend])
|
||||
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||
#include <cogl/cogl.h>
|
||||
]],
|
||||
[[
|
||||
#ifndef COGL_HAS_EGL_PLATFORM_WAYLAND_SUPPORT
|
||||
#error Cogl compiled without Wayland support
|
||||
#endif
|
||||
]])], [
|
||||
AC_MSG_RESULT(yes)
|
||||
have_cogl_wayland=yes
|
||||
], [
|
||||
AC_MSG_RESULT(no)
|
||||
have_cogl_wayland=no
|
||||
])
|
||||
|
||||
CFLAGS="${saved_CFLAGS}"
|
||||
AS_IF([test "x$have_cogl_wayland" = xyes],
|
||||
[
|
||||
PKG_CHECK_EXISTS([wayland-client wayland-cursor xkbcommon gdk-pixbuf-2.0],
|
||||
[
|
||||
BACKEND_PC_FILES="$BACKEND_PC_FILES wayland-cursor wayland-client xkbcommon"
|
||||
BACKEND_PC_FILES_PRIVATE="$BACKEND_PC_FILES_PRIVATE gdk-pixbuf-2.0"
|
||||
|
||||
CLUTTER_BACKENDS="$CLUTTER_BACKENDS wayland"
|
||||
CLUTTER_INPUT_BACKENDS="$CLUTTER_INPUT_BACKENDS wayland"
|
||||
|
||||
SUPPORT_WAYLAND=1
|
||||
SUPPORT_COGL=1
|
||||
],
|
||||
[
|
||||
AS_IF([test "x$enable_wayland" = xyes],
|
||||
[AC_MSG_ERROR(["*** Missing dependencies for Wayland support ***"])],
|
||||
[enable_wayland=no])
|
||||
])
|
||||
],
|
||||
[
|
||||
AS_IF([test "x$enable_wayland" = xyes],
|
||||
[AC_MSG_ERROR("*** Cogl is missing Wayland support ***")],
|
||||
[enable_wayland=no])
|
||||
])
|
||||
])
|
||||
|
||||
dnl Note this is orthogonal to the client side support and you can
|
||||
dnl use the Wayland compositor features with any of the clutter
|
||||
dnl backends with corresponding Cogl support.
|
||||
@ -427,18 +372,12 @@ AS_IF([test "x$SUPPORT_GLX" = "x1"],
|
||||
AS_IF([test "x$SUPPORT_EGL" = "x1"],
|
||||
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
|
||||
#define CLUTTER_WINDOWING_EGL \"eglnative\""])
|
||||
AS_IF([test "x$SUPPORT_WAYLAND" = "x1"],
|
||||
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
|
||||
#define CLUTTER_WINDOWING_WAYLAND \"wayland\""])
|
||||
AS_IF([test "x$SUPPORT_EVDEV" = "x1"],
|
||||
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
|
||||
#define CLUTTER_INPUT_EVDEV \"evdev\""])
|
||||
AS_IF([test "x$SUPPORT_TSLIB" = "x1"],
|
||||
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
|
||||
#define CLUTTER_INPUT_TSLIB \"tslib\""])
|
||||
AS_IF([test "x$SUPPORT_WAYLAND" = "x1"],
|
||||
[CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
|
||||
#define CLUTTER_INPUT_WAYLAND \"wayland\""])
|
||||
|
||||
# the 'null' input backend is special
|
||||
CLUTTER_CONFIG_DEFINES="$CLUTTER_CONFIG_DEFINES
|
||||
|
Loading…
Reference in New Issue
Block a user