1
0
mirror of https://github.com/brl/mutter.git synced 2025-06-19 03:29:31 +00:00
Files
build
clutter
cally
cex100
cogl
deprecated
egl
evdev
gdk
osx
tslib
wayland
clutter-backend-wayland.c
clutter-backend-wayland.h
clutter-device-manager-wayland.c
clutter-device-manager-wayland.h
clutter-event-wayland.c
clutter-event-wayland.h
clutter-input-device-wayland.c
clutter-input-device-wayland.h
clutter-stage-wayland.c
clutter-stage-wayland.h
clutter-wayland-compositor.h
clutter-wayland-surface.c
clutter-wayland-surface.h
clutter-wayland.h
win32
x11
Makefile.am
abicheck.sh
clutter-action.c
clutter-action.h
clutter-actor-box.c
clutter-actor-meta-private.h
clutter-actor-meta.c
clutter-actor-meta.h
clutter-actor-private.h
clutter-actor.c
clutter-actor.h
clutter-align-constraint.c
clutter-align-constraint.h
clutter-alpha.c
clutter-alpha.h
clutter-animatable.c
clutter-animatable.h
clutter-animation.c
clutter-animation.h
clutter-animator.c
clutter-animator.h
clutter-backend-private.h
clutter-backend.c
clutter-backend.h
clutter-bezier.c
clutter-bezier.h
clutter-bin-layout.c
clutter-bin-layout.h
clutter-bind-constraint.c
clutter-bind-constraint.h
clutter-binding-pool.c
clutter-binding-pool.h
clutter-blur-effect.c
clutter-blur-effect.h
clutter-box-layout.c
clutter-box-layout.h
clutter-brightness-contrast-effect.c
clutter-brightness-contrast-effect.h
clutter-cairo-texture.c
clutter-cairo-texture.h
clutter-canvas.c
clutter-canvas.h
clutter-child-meta.c
clutter-child-meta.h
clutter-click-action.c
clutter-click-action.h
clutter-clone.c
clutter-clone.h
clutter-cogl-compat.h
clutter-color-static.h
clutter-color.c
clutter-color.h
clutter-colorize-effect.c
clutter-colorize-effect.h
clutter-config.h.in
clutter-config.h.win32
clutter-constraint.c
clutter-constraint.h
clutter-container.c
clutter-container.h
clutter-content-private.h
clutter-content.c
clutter-content.h
clutter-debug.h
clutter-deform-effect.c
clutter-deform-effect.h
clutter-deprecated.h
clutter-desaturate-effect.c
clutter-desaturate-effect.h
clutter-device-manager-private.h
clutter-device-manager.c
clutter-device-manager.h
clutter-drag-action.c
clutter-drag-action.h
clutter-drop-action.c
clutter-drop-action.h
clutter-easing.c
clutter-easing.h
clutter-effect-private.h
clutter-effect.c
clutter-effect.h
clutter-enum-types.c.in
clutter-enum-types.h.in
clutter-enums.h
clutter-event-private.h
clutter-event-translator.c
clutter-event-translator.h
clutter-event.c
clutter-event.h
clutter-feature.c
clutter-feature.h
clutter-fixed-layout.c
clutter-fixed-layout.h
clutter-flatten-effect.c
clutter-flatten-effect.h
clutter-flow-layout.c
clutter-flow-layout.h
clutter-gesture-action.c
clutter-gesture-action.h
clutter-group.h
clutter-id-pool.c
clutter-id-pool.h
clutter-image.c
clutter-image.h
clutter-input-device.c
clutter-input-device.h
clutter-interval.c
clutter-interval.h
clutter-keysyms-table.c
clutter-keysyms-update.pl
clutter-keysyms.h
clutter-layout-manager.c
clutter-layout-manager.h
clutter-layout-meta.c
clutter-layout-meta.h
clutter-list-model.c
clutter-list-model.h
clutter-macros.h
clutter-main.c
clutter-main.h
clutter-marshal.list
clutter-master-clock.c
clutter-master-clock.h
clutter-media.c
clutter-media.h
clutter-model-private.h
clutter-model.c
clutter-model.h
clutter-offscreen-effect-private.h
clutter-offscreen-effect.c
clutter-offscreen-effect.h
clutter-page-turn-effect.c
clutter-page-turn-effect.h
clutter-paint-node-private.h
clutter-paint-node.c
clutter-paint-node.h
clutter-paint-nodes.c
clutter-paint-nodes.h
clutter-paint-volume-private.h
clutter-paint-volume.c
clutter-path-constraint.c
clutter-path-constraint.h
clutter-path.c
clutter-path.h
clutter-private.h
clutter-profile.c
clutter-profile.h
clutter-property-transition.c
clutter-property-transition.h
clutter-script-parser.c
clutter-script-private.h
clutter-script.c
clutter-script.h
clutter-scriptable.c
clutter-scriptable.h
clutter-settings-private.h
clutter-settings.c
clutter-settings.h
clutter-shader-effect.c
clutter-shader-effect.h
clutter-shader-types.c
clutter-shader-types.h
clutter-snap-constraint.c
clutter-snap-constraint.h
clutter-stage-manager-private.h
clutter-stage-manager.c
clutter-stage-manager.h
clutter-stage-private.h
clutter-stage-window.c
clutter-stage-window.h
clutter-stage.c
clutter-stage.h
clutter-state.c
clutter-state.h
clutter-swipe-action.c
clutter-swipe-action.h
clutter-table-layout.c
clutter-table-layout.h
clutter-text-buffer.c
clutter-text-buffer.h
clutter-text.c
clutter-text.h
clutter-texture.c
clutter-texture.h
clutter-timeline.c
clutter-timeline.h
clutter-transition.c
clutter-transition.h
clutter-types.h
clutter-units.c
clutter-units.h
clutter-util.c
clutter-version.h.in
clutter.h
clutter.pc.in
clutter.symbols
doc
po
tests
.gitignore
COPYING
ChangeLog.pre-git-import
Makefile.am
NEWS
README.in
README.md
autogen.sh
clutter.doap
config.h.win32.in
configure.ac
mutter/clutter/wayland/clutter-device-manager-wayland.c
Robert Bragg 3e85ad6b95 build: make internal option_xkb_* symbols static
This makes the option_xkb_* symbols declared for the evdev device manager
and the wayland device manager private so we don't get symbol collisions
if both of these backends are enabled.

Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
2011-12-08 16:13:38 +00:00

227 lines
7.4 KiB
C

/*
* 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 "clutter-debug.h"
#include "clutter-device-manager-private.h"
#include "clutter-private.h"
#include "evdev/clutter-xkb-utils.h"
#include <wayland-client.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)
{
}
static const char *option_xkb_layout = "us";
static const char *option_xkb_variant = "";
static const char *option_xkb_options = "";
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_display_bind (backend_wayland->wayland_display, id,
&wl_input_device_interface);
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));
}
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;
}