device: Impose per-backend DeviceManager

The DeviceManager class should be abstract in Clutter, and implemented
by each backend, as different backends will have different ways to
detect, initialize and list devices; the X11 backend alone has *two*
ways of dealing with devices.

This commit makes DeviceManager an abstract class and delegates the
device initialization and enumeration to per-backend sub-classes.

The responsible for creating the device manager is, obviously, the
backend singleton.

The X11 and Win32 backends have been updated to the new layout; the
Win32 backend has been updated blindly, so it might require additional
testing.
This commit is contained in:
Emmanuele Bassi 2010-02-17 17:06:25 +00:00
parent 0bf6d57ab1
commit b398292089
16 changed files with 931 additions and 247 deletions

View File

@ -33,6 +33,7 @@
#include <pango/pango.h>
#include <clutter/clutter-actor.h>
#include <clutter/clutter-device-manager.h>
#include <clutter/clutter-event.h>
#include <clutter/clutter-feature.h>
#include <clutter/clutter-stage.h>
@ -68,7 +69,7 @@ struct _ClutterBackendClass
GError **error);
gboolean (* post_parse) (ClutterBackend *backend,
GError **error);
ClutterStageWindow *(* create_stage) (ClutterBackend *backend,
ClutterStageWindow * (* create_stage) (ClutterBackend *backend,
ClutterStage *wrapper,
GError **error);
void (* init_events) (ClutterBackend *backend);
@ -82,6 +83,7 @@ struct _ClutterBackendClass
GError **error);
void (* ensure_context) (ClutterBackend *backend,
ClutterStage *stage);
ClutterDeviceManager *(* get_device_manager) (ClutterBackend *backend);
/* signals */
void (* resolution_changed) (ClutterBackend *backend);

View File

@ -46,15 +46,19 @@
#include "clutter-marshal.h"
#include "clutter-private.h"
#define CLUTTER_DEVICE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_DEVICE_MANAGER, ClutterDeviceManagerClass))
#define CLUTTER_IS_DEVICE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_DEVICE_MANAGER))
#define CLUTTER_DEVICE_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_DEVICE_MANAGER, ClutterDeviceManagerClass))
#define CLUTTER_DEVICE_MANAGER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), CLUTTER_TYPE_DEVICE_MANAGER, ClutterDeviceManagerPrivate))
typedef struct _ClutterDeviceManagerClass ClutterDeviceManagerClass;
struct _ClutterDeviceManagerClass
struct _ClutterDeviceManagerPrivate
{
GObjectClass parent_instance;
/* back-pointer to the backend */
ClutterBackend *backend;
};
enum
{
PROP_0,
PROP_BACKEND
};
enum
@ -65,15 +69,69 @@ enum
LAST_SIGNAL
};
static ClutterDeviceManager *default_manager = NULL;
static guint manager_signals[LAST_SIGNAL] = { 0, };
G_DEFINE_TYPE (ClutterDeviceManager, clutter_device_manager, G_TYPE_OBJECT);
G_DEFINE_ABSTRACT_TYPE (ClutterDeviceManager,
clutter_device_manager,
G_TYPE_OBJECT);
static void
clutter_device_manager_set_property (GObject *gobject,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
ClutterDeviceManagerPrivate *priv = CLUTTER_DEVICE_MANAGER (gobject)->priv;
switch (prop_id)
{
case PROP_BACKEND:
priv->backend = g_value_get_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
}
}
static void
clutter_device_manager_get_property (GObject *gobject,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
ClutterDeviceManagerPrivate *priv = CLUTTER_DEVICE_MANAGER (gobject)->priv;
switch (prop_id)
{
case PROP_BACKEND:
g_value_set_object (value, priv->backend);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
}
}
static void
clutter_device_manager_class_init (ClutterDeviceManagerClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GParamSpec *pspec;
g_type_class_add_private (klass, sizeof (ClutterDeviceManagerPrivate));
gobject_class->set_property = clutter_device_manager_set_property;
gobject_class->get_property = clutter_device_manager_get_property;
pspec = g_param_spec_object ("backend",
"Backend",
"The ClutterBackend of the device manager",
CLUTTER_TYPE_BACKEND,
CLUTTER_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (gobject_class, PROP_BACKEND, pspec);
/**
* ClutterDeviceManager::device-added:
* @manager: the #ClutterDeviceManager that emitted the signal
@ -118,6 +176,7 @@ clutter_device_manager_class_init (ClutterDeviceManagerClass *klass)
static void
clutter_device_manager_init (ClutterDeviceManager *self)
{
self->priv = CLUTTER_DEVICE_MANAGER_GET_PRIVATE (self);
}
/**
@ -134,10 +193,12 @@ clutter_device_manager_init (ClutterDeviceManager *self)
ClutterDeviceManager *
clutter_device_manager_get_default (void)
{
if (G_UNLIKELY (default_manager == NULL))
default_manager = g_object_new (CLUTTER_TYPE_DEVICE_MANAGER, NULL);
ClutterBackendClass *klass;
return default_manager;
klass = CLUTTER_BACKEND_GET_CLASS (clutter_get_default_backend ());
g_assert (klass->get_device_manager != NULL);
return klass->get_device_manager (clutter_get_default_backend ());
}
/**
@ -155,9 +216,13 @@ clutter_device_manager_get_default (void)
GSList *
clutter_device_manager_list_devices (ClutterDeviceManager *device_manager)
{
const GSList *devices;
g_return_val_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager), NULL);
return g_slist_copy (device_manager->devices);
devices = clutter_device_manager_peek_devices (device_manager);
return g_slist_copy ((GSList *) devices);
}
/**
@ -176,9 +241,12 @@ clutter_device_manager_list_devices (ClutterDeviceManager *device_manager)
const GSList *
clutter_device_manager_peek_devices (ClutterDeviceManager *device_manager)
{
ClutterDeviceManagerClass *manager_class;
g_return_val_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager), NULL);
return device_manager->devices;
manager_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (device_manager);
return manager_class->get_devices (device_manager);
}
/**
@ -198,35 +266,40 @@ ClutterInputDevice *
clutter_device_manager_get_device (ClutterDeviceManager *device_manager,
gint device_id)
{
GSList *l;
ClutterDeviceManagerClass *manager_class;
g_return_val_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager), NULL);
for (l = device_manager->devices; l != NULL; l = l->next)
{
ClutterInputDevice *device = l->data;
if (device->id == device_id)
return device;
}
return NULL;
manager_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (device_manager);
return manager_class->get_device (device_manager, device_id);
}
static gint
input_device_cmp (gconstpointer a,
gconstpointer b)
/**
* clutter_device_manager_get_core_device:
* @device_manager: a #ClutterDeviceManager
* @device_type: the type of the core device
*
* Retrieves the core #ClutterInputDevice of type @device_type
*
* Core devices are devices created automatically by the default
* Clutter backend
*
* Return value: (transfer none): a #ClutterInputDevice or %NULL. The
* returned device is owned by the #ClutterDeviceManager and should
* not be modified or freed
*
* Since: 1.2
*/
ClutterInputDevice *
clutter_device_manager_get_core_device (ClutterDeviceManager *device_manager,
ClutterInputDeviceType device_type)
{
const ClutterInputDevice *device_a = a;
const ClutterInputDevice *device_b = b;
ClutterDeviceManagerClass *manager_class;
if (device_a->id < device_b->id)
return -1;
g_return_val_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager), NULL);
if (device_a->id > device_b->id)
return 1;
return 0;
manager_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (device_manager);
return manager_class->get_core_device (device_manager, device_type);
}
/*
@ -246,11 +319,14 @@ void
_clutter_device_manager_add_device (ClutterDeviceManager *device_manager,
ClutterInputDevice *device)
{
ClutterDeviceManagerClass *manager_class;
g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager));
device_manager->devices = g_slist_insert_sorted (device_manager->devices,
device,
input_device_cmp);
manager_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (device_manager);
g_assert (manager_class->add_device != NULL);
manager_class->add_device (device_manager, device);
g_signal_emit (device_manager, manager_signals[DEVICE_ADDED], 0, device);
}
@ -272,12 +348,14 @@ void
_clutter_device_manager_remove_device (ClutterDeviceManager *device_manager,
ClutterInputDevice *device)
{
ClutterDeviceManagerClass *manager_class;
g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager));
if (g_slist_find (device_manager->devices, device) == NULL)
return;
manager_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (device_manager);
g_assert (manager_class->remove_device != NULL);
device_manager->devices = g_slist_remove (device_manager->devices, device);
manager_class->remove_device (device_manager, device);
g_signal_emit (device_manager, manager_signals[DEVICE_REMOVED], 0, device);
}
@ -293,7 +371,7 @@ _clutter_device_manager_remove_device (ClutterDeviceManager *device_manager,
void
_clutter_device_manager_update_devices (ClutterDeviceManager *device_manager)
{
GSList *d;
const GSList *d;
/* the user disabled motion events delivery on actors; we
* don't perform any picking since the source of the events
@ -302,7 +380,9 @@ _clutter_device_manager_update_devices (ClutterDeviceManager *device_manager)
if (!clutter_get_motion_events_enabled ())
return;
for (d = device_manager->devices; d != NULL; d = d->next)
for (d = clutter_device_manager_peek_devices (device_manager);
d != NULL;
d = d->next)
{
ClutterInputDevice *device = d->data;
ClutterInputDeviceType device_type;

View File

@ -28,14 +28,20 @@
#ifndef __CLUTTER_DEVICE_MANAGER_H__
#define __CLUTTER_DEVICE_MANAGER_H__
#include <glib-object.h>
#include <clutter/clutter-event.h>
#include <clutter/clutter-input-device.h>
G_BEGIN_DECLS
#define CLUTTER_TYPE_DEVICE_MANAGER (clutter_device_manager_get_type ())
#define CLUTTER_DEVICE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_DEVICE_MANAGER, ClutterDeviceManager))
#define CLUTTER_IS_DEVICE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_DEVICE_MANAGER))
#define CLUTTER_DEVICE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_DEVICE_MANAGER, ClutterDeviceManagerClass))
#define CLUTTER_IS_DEVICE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_DEVICE_MANAGER))
#define CLUTTER_DEVICE_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_DEVICE_MANAGER, ClutterDeviceManagerClass))
typedef struct _ClutterDeviceManager ClutterDeviceManager;
typedef struct _ClutterDeviceManagerPrivate ClutterDeviceManagerPrivate;
typedef struct _ClutterDeviceManagerClass ClutterDeviceManagerClass;
/**
* ClutterDeviceManager:
@ -43,7 +49,34 @@ G_BEGIN_DECLS
* The #ClutterDeviceManager structure contains only
* private data
*/
typedef struct _ClutterDeviceManager ClutterDeviceManager;
struct _ClutterDeviceManager
{
/*< private >*/
GObject parent_instance;
ClutterDeviceManagerPrivate *priv;
};
struct _ClutterDeviceManagerClass
{
/*< private >*/
GObjectClass parent_class;
const GSList * (* get_devices) (ClutterDeviceManager *manager);
ClutterInputDevice *(* get_core_device) (ClutterDeviceManager *manager,
ClutterInputDeviceType type);
ClutterInputDevice *(* get_device) (ClutterDeviceManager *manager,
gint id);
void (* add_device) (ClutterDeviceManager *manager,
ClutterInputDevice *device);
void (* remove_device) (ClutterDeviceManager *manager,
ClutterInputDevice *device);
gpointer _padding[8];
};
GType clutter_device_manager_get_type (void) G_GNUC_CONST;
@ -53,6 +86,8 @@ const GSList * clutter_device_manager_peek_devices (ClutterDeviceManager
ClutterInputDevice * clutter_device_manager_get_device (ClutterDeviceManager *device_manager,
gint device_id);
ClutterInputDevice * clutter_device_manager_get_core_device (ClutterDeviceManager *device_manager,
ClutterInputDeviceType type);
G_END_DECLS

View File

@ -127,13 +127,6 @@ struct _ClutterStageManager
GSList *stages;
};
struct _ClutterDeviceManager
{
GObject parent_instance;
GSList *devices;
};
struct _ClutterMainContext
{
ClutterBackend *backend; /* holds a pointer to the windowing

View File

@ -26,6 +26,8 @@ noinst_LTLIBRARIES = libclutter-win32.la
libclutter_win32_la_SOURCES = \
clutter-backend-win32.h \
clutter-backend-win32.c \
clutter-device-manager-win32.h \
clutter-device-manager-win32.c \
clutter-event-win32.c \
clutter-stage-win32.h \
clutter-stage-win32.c \

View File

@ -71,23 +71,10 @@ clutter_backend_win32_init_events (ClutterBackend *backend)
CLUTTER_NOTE (EVENT, "initialising the event loop");
manager = clutter_device_manager_get_default ();
device = g_object_new (CLUTTER_TYPE_INPUT_DEVICE,
"id", 0,
"name", "Core Pointer",
"device-type", CLUTTER_POINTER_DEVICE,
backend_win32->device_manager =
g_object_new (CLUTTER_TYPE_DEVICE_MANAGER_WIN32,
"backend", backend_win32,
NULL);
_clutter_device_manager_add_device (manager, device);
backend_win32->core_pointer = device;
device = g_object_new (CLUTTER_TYPE_INPUT_DEVICE,
"id", 1,
"name", "Core Keyboard",
"device-type", CLUTTER_KEYBOARD_DEVICE,
NULL);
_clutter_device_manager_add_device (manager, device);
backend_win32->core_keyboard = device;
_clutter_backend_win32_events_init (backend);
}
@ -537,6 +524,22 @@ clutter_backend_win32_create_stage (ClutterBackend *backend,
return stage;
}
static ClutterDeviceManager *
clutter_backend_win32_get_device_manager (ClutterBackend *backend)
{
ClutterBackendWin32 *backend_win32 = CLUTTER_BACKEND_WIN32 (backend);
if (G_UNLIKELY (backend_win32->device_manager == NULL))
{
backend_win32->device_manager =
g_object_new (CLUTTER_TYPE_DEVICE_MANAGER_WIN32,
"backend", backend_win32,
NULL);
}
return backend_win32->device_manager;
}
static void
clutter_backend_win32_class_init (ClutterBackendWin32Class *klass)
{
@ -555,6 +558,7 @@ clutter_backend_win32_class_init (ClutterBackendWin32Class *klass)
backend_class->redraw = clutter_backend_win32_redraw;
backend_class->create_context = clutter_backend_win32_create_context;
backend_class->ensure_context = clutter_backend_win32_ensure_context;
backend_class->get_device_manager = clutter_backend_win32_get_device_manager;
}
static void

View File

@ -54,8 +54,7 @@ struct _ClutterBackendWin32
GSource *event_source;
ClutterInputDevice *core_pointer;
ClutterInputDevice *core_keyboard;
ClutterDeviceManager *device_manager;
};
struct _ClutterBackendWin32Class

View File

@ -0,0 +1,173 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2009 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>
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "clutter-backend-x11.h"
#include "clutter-device-manager-x11.h"
#include "clutter-input-device-x11.h"
#include "clutter-stage-x11.h"
#include "clutter-backend.h"
#include "clutter-debug.h"
#include "clutter-device-manager.h"
#include "clutter-private.h"
#ifdef HAVE_XINPUT
#include <X11/extensions/XInput.h>
#endif
enum
{
PROP_0,
PROP_USE_XINPUT_1
};
G_DEFINE_TYPE (ClutterDeviceManagerWin32,
clutter_device_manager_win32,
CLUTTER_TYPE_DEVICE_MANAGER);
static void
clutter_device_manager_win32_constructed (GObject *gobject)
{
ClutterDeviceManager *manager = CLUTTER_DEVICE_MANAGER (gobject);
ClutterInputDevice *device;
device = g_object_new (CLUTTER_TYPE_INPUT_DEVICE,
"id", 0,
"name", "Core Pointer",
"device-type", CLUTTER_POINTER_DEVICE,
NULL);
CLUTTER_NOTE (BACKEND, "Added core pointer device");
_clutter_device_manager_add_device (manager, device);
device = g_object_new (CLUTTER_TYPE_INPUT_DEVICE,
"id", 1,
"name", "Core Keyboard",
"device-type", CLUTTER_KEYBOARD_DEVICE,
NULL);
CLUTTER_NOTE (BACKEND, "Added core keyboard device");
_clutter_device_manager_add_device (manager, device);
}
static void
clutter_device_manager_win32_add_device (ClutterDeviceManager *manager,
ClutterInputDevice *device)
{
ClutterDeviceManagerWin32 *manager_win32 = CLUTTER_DEVICE_MANAGER_WIN32 (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_win32->devices = g_slist_prepend (manager_win32->devices, device);
if (is_pointer && manager_win32->core_pointer == NULL)
manager_win32->core_pointer = device;
if (is_keyboard && manager_win32->core_keyboard == NULL)
manager_win32->core_keyboard = device;
}
static void
clutter_device_manager_win32_remove_device (ClutterDeviceManager *manager,
ClutterInputDevice *device)
{
ClutterDeviceManagerWin32 *manager_win32 = CLUTTER_DEVICE_MANAGER_WIN32 (manager);
manager_win32->devices = g_slist_remove (manager_win32->devices, device);
}
static const GSList *
clutter_device_manager_win32_get_devices (ClutterDeviceManager *manager)
{
return CLUTTER_DEVICE_MANAGER_WIN32 (manager)->devices;
}
static ClutterInputDevice *
clutter_device_manager_win32_get_core_device (ClutterDeviceManager *manager,
ClutterInputDeviceType type)
{
ClutterDeviceManagerWin32 *manager_win32;
manager_win32 = CLUTTER_DEVICE_MANAGER_WIN32 (manager);
switch (type)
{
case CLUTTER_POINTER_DEVICE:
return manager_win32->core_pointer;
case CLUTTER_KEYBOARD_DEVICE:
return manager_win32->core_keyboard;
case CLUTTER_EXTENSION_DEVICE:
default:
return NULL;
}
return NULL;
}
static ClutterInputDevice *
clutter_device_manager_win32_get_device (ClutterDeviceManager *manager,
gint id)
{
ClutterDeviceManagerWin32 *manager_win32 = CLUTTER_DEVICE_MANAGER_WIN32 (manager);
GSList *l;
for (l = manager_win32->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_win32_class_init (ClutterDeviceManagerWin32Class *klass)
{
ClutterDeviceManagerClass *manager_class;
GObjectClass *gobject_class;
gobject_class->constructed = clutter_device_manager_win32_constructed;
manager_class = CLUTTER_DEVICE_MANAGER_CLASS (klass);
manager_class->add_device = clutter_device_manager_win32_add_device;
manager_class->remove_device = clutter_device_manager_win32_remove_device;
manager_class->get_devices = clutter_device_manager_win32_get_devices;
manager_class->get_core_device = clutter_device_manager_win32_get_core_device;
manager_class->get_device = clutter_device_manager_win32_get_device;
}
static void
clutter_device_manager_win32_init (ClutterDeviceManagerWin32 *self)
{
}

View File

@ -0,0 +1,60 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2010 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_WIN32_H__
#define __CLUTTER_DEVICE_MANAGER_WIN32_H__
#include <clutter/clutter-device-manager.h>
G_BEGIN_DECLS
#define CLUTTER_TYPE_DEVICE_MANAGER_WIN32 (clutter_device_manager_win32_get_type ())
#define CLUTTER_DEVICE_MANAGER_WIN32(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_DEVICE_MANAGER_WIN32, ClutterDeviceManagerWin32))
#define CLUTTER_IS_DEVICE_MANAGER_WIN32(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_DEVICE_MANAGER_WIN32))
#define CLUTTER_DEVICE_MANAGER_WIN32_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_DEVICE_MANAGER_WIN32, ClutterDeviceManagerWin32Class))
#define CLUTTER_IS_DEVICE_MANAGER_WIN32_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_DEVICE_MANAGER_WIN32))
#define CLUTTER_DEVICE_MANAGER_WIN32_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_DEVICE_MANAGER_WIN32, ClutterDeviceManagerWin32Class))
typedef struct _ClutterDeviceManagerWin32 ClutterDeviceManagerWin32;
typedef struct _ClutterDeviceManagerWin32Class ClutterDeviceManagerWin32Class;
struct _ClutterDeviceManagerWin32
{
ClutterDeviceManager parent_instance;
GSList *devices;
ClutterInputDevice *core_pointer;
ClutterInputDevice *core_keyboard;
};
struct _ClutterDeviceManagerWin32Class
{
ClutterDeviceManagerClass parent_class;
};
GType clutter_device_manager_win32_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __CLUTTER_DEVICE_MANAGER_WIN32_H__ */

View File

@ -333,6 +333,8 @@ message_translate (ClutterBackend *backend,
{
ClutterBackendWin32 *backend_win32;
ClutterStageWin32 *stage_win32;
ClutterDeviceManager *manager;
ClutterInputDevice *core_device, *core_keyboard;
ClutterStage *stage;
ClutterStageWindow *impl;
gboolean res;
@ -349,6 +351,12 @@ message_translate (ClutterBackend *backend,
event->any.stage = stage;
manager = clutter_device_manager_get_default ();
core_pointer =
clutter_device_manager_get_core_device (manager, CLUTTER_POINTER_DEVICE);
core_keyboard =
clutter_device_manager_get_core_device (manager, CLUTTER_KEYBOARD_DEVICE);
res = TRUE;
switch (msg->message)
@ -434,39 +442,39 @@ message_translate (ClutterBackend *backend,
break;
case WM_LBUTTONDOWN:
make_button_event (msg, event, 1, 1, FALSE, backend_win32->core_pointer);
make_button_event (msg, event, 1, 1, FALSE, core_pointer);
break;
case WM_MBUTTONDOWN:
make_button_event (msg, event, 2, 1, FALSE, backend_win32->core_pointer);
make_button_event (msg, event, 2, 1, FALSE, core_pointer);
break;
case WM_RBUTTONDOWN:
make_button_event (msg, event, 3, 1, FALSE, backend_win32->core_pointer);
make_button_event (msg, event, 3, 1, FALSE, core_pointer);
break;
case WM_LBUTTONUP:
make_button_event (msg, event, 1, 1, TRUE, backend_win32->core_pointer);
make_button_event (msg, event, 1, 1, TRUE, core_pointer);
break;
case WM_MBUTTONUP:
make_button_event (msg, event, 2, 1, TRUE, backend_win32->core_pointer);
make_button_event (msg, event, 2, 1, TRUE, core_pointer);
break;
case WM_RBUTTONUP:
make_button_event (msg, event, 3, 1, TRUE, backend_win32->core_pointer);
make_button_event (msg, event, 3, 1, TRUE, core_pointer);
break;
case WM_LBUTTONDBLCLK:
make_button_event (msg, event, 1, 2, FALSE, backend_win32->core_pointer);
make_button_event (msg, event, 1, 2, FALSE, core_pointer);
break;
case WM_MBUTTONDBLCLK:
make_button_event (msg, event, 2, 2, FALSE, backend_win32->core_pointer);
make_button_event (msg, event, 2, 2, FALSE, core_pointer);
break;
case WM_RBUTTONDBLCLK:
make_button_event (msg, event, 3, 2, FALSE, backend_win32->core_pointer);
make_button_event (msg, event, 3, 2, FALSE, core_pointer);
break;
case WM_MOUSEWHEEL:
@ -475,7 +483,7 @@ message_translate (ClutterBackend *backend,
event->type = CLUTTER_SCROLL;
event->scroll.time = msg->time;
event->scroll.modifier_state = get_modifier_state (LOWORD (msg->wParam));
event->scroll.device = backend_win32->core_pointer;
event->scroll.device = core_pointer;
/* conversion to window coordinates is required */
{
@ -505,7 +513,7 @@ message_translate (ClutterBackend *backend,
event->motion.x = GET_X_LPARAM (msg->lParam);
event->motion.y = GET_Y_LPARAM (msg->lParam);
event->motion.modifier_state = get_modifier_state (msg->wParam);
event->motion.device = backend_win32->core_pointer;
event->motion.device = core_pointer;
/* We need to start tracking when the mouse enters the stage if
we're not already */
@ -530,7 +538,7 @@ message_translate (ClutterBackend *backend,
event->crossing.time = msg->time;
event->crossing.x = msg->pt.x;
event->crossing.y = msg->pt.y;
event->crossing.device = backend_win32->core_pointer;
event->crossing.device = core_pointer;
/* we left the stage */
_clutter_input_device_set_stage (event->crossing.device, NULL);
@ -618,7 +626,7 @@ message_translate (ClutterBackend *backend,
event->key.time = msg->time;
event->key.modifier_state = get_key_modifier_state (key_states);
event->key.hardware_keycode = scan_code;
event->key.device = backend_win32->core_keyboard;
event->key.device = core_keyboard;
}
break;

View File

@ -42,6 +42,8 @@ noinst_LTLIBRARIES = libclutter-x11.la
libclutter_x11_la_SOURCES = \
clutter-backend-x11.h \
clutter-backend-x11.c \
clutter-device-manager-x11.h \
clutter-device-manager-x11.c \
clutter-event-x11.c \
clutter-input-device-x11.h \
clutter-input-device-x11.c \

View File

@ -37,6 +37,7 @@
#include <errno.h>
#include "clutter-backend-x11.h"
#include "clutter-device-manager-x11.h"
#include "clutter-input-device-x11.h"
#include "clutter-stage-x11.h"
#include "clutter-x11.h"
@ -95,129 +96,6 @@ static gboolean clutter_synchronise = FALSE;
static int TrappedErrorCode = 0;
static int (* old_error_handler) (Display *, XErrorEvent *);
static void
clutter_x11_register_input_devices (ClutterBackendX11 *backend)
{
ClutterDeviceManager *manager;
ClutterInputDevice *device;
#ifdef HAVE_XINPUT
XDeviceInfo *x_devices = NULL;
int res, opcode, event, error;
int i, n_devices;
#endif /* HAVE_XINPUT */
manager = clutter_device_manager_get_default ();
if (!clutter_enable_xinput)
{
CLUTTER_NOTE (BACKEND, "XInput support not enabled");
goto default_device;
}
#ifdef HAVE_XINPUT
res = XQueryExtension (backend->xdpy, "XInputExtension",
&opcode,
&event,
&error);
if (!res)
{
CLUTTER_NOTE (BACKEND, "No XInput extension available");
goto default_device;
}
backend->xi_event_base = event;
x_devices = XListInputDevices (backend->xdpy, &n_devices);
if (n_devices == 0)
{
CLUTTER_NOTE (BACKEND, "No XInput devices found");
goto default_device;
}
for (i = 0; i < n_devices; i++)
{
XDeviceInfo *info = x_devices + i;
CLUTTER_NOTE (BACKEND,
"Considering device %li with type %d, %d of %d",
info->id,
info->use,
i, n_devices);
/* we only want 'raw' devices, not virtual ones */
if (info->use == IsXExtensionPointer ||
/* info->use == IsXExtensionKeyboard || XInput1 is broken */
info->use == IsXExtensionDevice)
{
ClutterInputDeviceType device_type;
gint n_events = 0;
switch (info->use)
{
case IsXExtensionPointer:
device_type = CLUTTER_POINTER_DEVICE;
break;
/* XInput1 is broken for keyboards */
case IsXExtensionKeyboard:
device_type = CLUTTER_KEYBOARD_DEVICE;
break;
case IsXExtensionDevice:
device_type = CLUTTER_EXTENSION_DEVICE;
break;
}
device = g_object_new (CLUTTER_TYPE_INPUT_DEVICE_X11,
"id", info->id,
"device-type", device_type,
"name", info->name,
NULL);
n_events = _clutter_input_device_x11_construct (device, backend);
_clutter_device_manager_add_device (manager, device);
if (info->use == IsXExtensionPointer && n_events > 0)
backend->have_xinput = TRUE;
}
}
XFree (x_devices);
#endif /* HAVE_XINPUT */
default_device:
/* fallback code in case:
*
* - we do not have XInput support compiled in
* - we do not have XInput support enabled
* - we do not have the XInput extension
*
* we register two default devices, one for the pointer
* and one for the keyboard. this block must also be
* executed for the XInput support because XI does not
* cover core devices
*/
device = g_object_new (CLUTTER_TYPE_INPUT_DEVICE_X11,
"id", 0,
"name", "Core Pointer",
"device-type", CLUTTER_POINTER_DEVICE,
"is-core", TRUE,
NULL);
CLUTTER_NOTE (BACKEND, "Added core pointer device");
_clutter_device_manager_add_device (manager, device);
backend->core_pointer = device;
device = g_object_new (CLUTTER_TYPE_INPUT_DEVICE_X11,
"id", 1,
"name", "Core Keyboard",
"device-type", CLUTTER_KEYBOARD_DEVICE,
"is-core", TRUE,
NULL);
CLUTTER_NOTE (BACKEND, "Added core keyboard device");
_clutter_device_manager_add_device (manager, device);
backend->core_keyboard = device;
}
gboolean
clutter_backend_x11_pre_parse (ClutterBackend *backend,
GError **error)
@ -309,7 +187,11 @@ clutter_backend_x11_post_parse (ClutterBackend *backend,
clutter_backend_set_resolution (backend, dpi);
/* register input devices */
clutter_x11_register_input_devices (backend_x11);
backend_x11->device_manager =
g_object_new (CLUTTER_TYPE_DEVICE_MANAGER_X11,
"use-xinput-1", clutter_enable_xinput,
"backend", backend_x11,
NULL);
if (clutter_synchronise)
XSynchronize (backend_x11->xdpy, True);
@ -464,6 +346,23 @@ clutter_backend_x11_handle_event (ClutterBackendX11 *backend_x11,
return FALSE;
}
static ClutterDeviceManager *
clutter_backend_x11_get_device_manager (ClutterBackend *backend)
{
ClutterBackendX11 *backend_x11 = CLUTTER_BACKEND_X11 (backend);
if (G_UNLIKELY (backend_x11->device_manager == NULL))
{
backend_x11->device_manager =
g_object_new (CLUTTER_TYPE_DEVICE_MANAGER_X11,
"use-xinput-1", clutter_enable_xinput,
"backend", backend_x11,
NULL);
}
return backend_x11->device_manager;
}
static void
clutter_backend_x11_class_init (ClutterBackendX11Class *klass)
{
@ -480,6 +379,7 @@ clutter_backend_x11_class_init (ClutterBackendX11Class *klass)
backend_class->init_events = clutter_backend_x11_init_events;
backend_class->add_options = clutter_backend_x11_add_options;
backend_class->get_features = clutter_backend_x11_get_features;
backend_class->get_device_manager = clutter_backend_x11_get_device_manager;
backendx11_class->handle_event = clutter_backend_x11_handle_event;
}
@ -590,10 +490,12 @@ clutter_x11_set_display (Display *xdpy)
*
* Enables the use of the XInput extension if present on connected
* XServer and support built into Clutter. XInput allows for multiple
* pointing devices to be used. This must be called before
* clutter_init().
* pointing devices to be used.
*
* You should use #clutter_x11_has_xinput to see if support was enabled.
* This function must be called before clutter_init().
*
* Since XInput might not be supported by the X server, you might
* want to use clutter_x11_has_xinput() to see if support was enabled.
*
* Since: 0.8
*/

View File

@ -82,8 +82,7 @@ struct _ClutterBackendX11
Time last_event_time;
ClutterInputDevice *core_pointer;
ClutterInputDevice *core_keyboard;
ClutterDeviceManager *device_manager;
};
struct _ClutterBackendX11Class

View File

@ -0,0 +1,349 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2009 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>
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "clutter-backend-x11.h"
#include "clutter-device-manager-x11.h"
#include "clutter-input-device-x11.h"
#include "clutter-stage-x11.h"
#include "clutter-backend.h"
#include "clutter-debug.h"
#include "clutter-device-manager.h"
#include "clutter-private.h"
#ifdef HAVE_XINPUT
#include <X11/extensions/XInput.h>
#endif
enum
{
PROP_0,
PROP_USE_XINPUT_1
};
G_DEFINE_TYPE (ClutterDeviceManagerX11,
clutter_device_manager_x11,
CLUTTER_TYPE_DEVICE_MANAGER);
static void
clutter_device_manager_x11_constructed (GObject *gobject)
{
ClutterDeviceManagerX11 *manager_x11;
ClutterBackendX11 *backend_x11;
ClutterDeviceManager *manager;
ClutterInputDevice *device;
#ifdef HAVE_XINPUT
XDeviceInfo *x_devices = NULL;
int res, opcode, event, error;
int i, n_devices;
#endif /* HAVE_XINPUT */
manager = CLUTTER_DEVICE_MANAGER (gobject);
manager_x11 = CLUTTER_DEVICE_MANAGER_X11 (gobject);
if (!manager_x11->use_xinput_1)
{
CLUTTER_NOTE (BACKEND, "XInput support not enabled");
goto default_device;
}
g_object_get (gobject, "backend", &backend_x11, NULL);
g_assert (backend_x11 != NULL);
#ifdef HAVE_XINPUT
res = XQueryExtension (backend_x11->xdpy, "XInputExtension",
&opcode,
&event,
&error);
if (!res)
{
CLUTTER_NOTE (BACKEND, "No XInput extension available");
goto default_device;
}
backend_x11->xi_event_base = event;
x_devices = XListInputDevices (backend_x11->xdpy, &n_devices);
if (n_devices == 0)
{
CLUTTER_NOTE (BACKEND, "No XInput devices found");
goto default_device;
}
for (i = 0; i < n_devices; i++)
{
XDeviceInfo *info = x_devices + i;
CLUTTER_NOTE (BACKEND,
"Considering device %li with type %d, %d of %d",
info->id,
info->use,
i, n_devices);
/* we only want 'raw' devices, not virtual ones */
if (info->use == IsXExtensionPointer ||
/* info->use == IsXExtensionKeyboard || XInput1 is broken */
info->use == IsXExtensionDevice)
{
ClutterInputDeviceType device_type;
gint n_events = 0;
switch (info->use)
{
case IsXExtensionPointer:
device_type = CLUTTER_POINTER_DEVICE;
break;
/* XInput1 is broken for keyboards */
case IsXExtensionKeyboard:
device_type = CLUTTER_KEYBOARD_DEVICE;
break;
case IsXExtensionDevice:
default:
device_type = CLUTTER_EXTENSION_DEVICE;
break;
}
device = g_object_new (CLUTTER_TYPE_INPUT_DEVICE_X11,
"id", info->id,
"device-type", device_type,
"name", info->name,
NULL);
n_events = _clutter_input_device_x11_construct (device, backend_x11);
_clutter_device_manager_add_device (manager, device);
if (info->use == IsXExtensionPointer && n_events > 0)
backend_x11->have_xinput = TRUE;
}
}
XFree (x_devices);
#endif /* HAVE_XINPUT */
default_device:
/* fallback code in case:
*
* - we do not have XInput support compiled in
* - we do not have XInput support enabled
* - we do not have the XInput extension
*
* we register two default devices, one for the pointer
* and one for the keyboard. this block must also be
* executed for the XInput support because XI does not
* cover core devices
*/
device = g_object_new (CLUTTER_TYPE_INPUT_DEVICE_X11,
"id", 0,
"name", "Core Pointer",
"device-type", CLUTTER_POINTER_DEVICE,
"is-core", TRUE,
NULL);
CLUTTER_NOTE (BACKEND, "Added core pointer device");
manager_x11->core_pointer = device;
device = g_object_new (CLUTTER_TYPE_INPUT_DEVICE_X11,
"id", 1,
"name", "Core Keyboard",
"device-type", CLUTTER_KEYBOARD_DEVICE,
"is-core", TRUE,
NULL);
CLUTTER_NOTE (BACKEND, "Added core keyboard device");
manager_x11->core_keyboard = device;
if (G_OBJECT_CLASS (clutter_device_manager_x11_parent_class)->constructed)
G_OBJECT_CLASS (clutter_device_manager_x11_parent_class)->constructed (gobject);
}
static void
clutter_device_manager_x11_add_device (ClutterDeviceManager *manager,
ClutterInputDevice *device)
{
ClutterDeviceManagerX11 *manager_x11 = CLUTTER_DEVICE_MANAGER_X11 (manager);
manager_x11->devices = g_slist_prepend (manager_x11->devices, device);
/* blow the cache */
g_slist_free (manager_x11->all_devices);
manager_x11->all_devices = NULL;
}
static void
clutter_device_manager_x11_remove_device (ClutterDeviceManager *manager,
ClutterInputDevice *device)
{
ClutterDeviceManagerX11 *manager_x11 = CLUTTER_DEVICE_MANAGER_X11 (manager);
manager_x11->devices = g_slist_remove (manager_x11->devices, device);
/* blow the cache */
g_slist_free (manager_x11->all_devices);
manager_x11->all_devices = NULL;
}
static const GSList *
clutter_device_manager_x11_get_devices (ClutterDeviceManager *manager)
{
ClutterDeviceManagerX11 *manager_x11 = CLUTTER_DEVICE_MANAGER_X11 (manager);
/* cache the devices list so that we can keep the core pointer
* and keyboard outside of the ManagerX11:devices list
*/
if (manager_x11->all_devices == NULL)
{
GSList *all_devices = NULL;
all_devices = g_slist_prepend (all_devices, manager_x11->core_keyboard);
all_devices = g_slist_prepend (all_devices, manager_x11->core_pointer);
all_devices->next = manager_x11->devices;
manager_x11->all_devices = all_devices;
}
return CLUTTER_DEVICE_MANAGER_X11 (manager)->all_devices;
}
static ClutterInputDevice *
clutter_device_manager_x11_get_core_device (ClutterDeviceManager *manager,
ClutterInputDeviceType type)
{
ClutterDeviceManagerX11 *manager_x11;
manager_x11 = CLUTTER_DEVICE_MANAGER_X11 (manager);
switch (type)
{
case CLUTTER_POINTER_DEVICE:
return manager_x11->core_pointer;
case CLUTTER_KEYBOARD_DEVICE:
return manager_x11->core_keyboard;
case CLUTTER_EXTENSION_DEVICE:
default:
return NULL;
}
return NULL;
}
static ClutterInputDevice *
clutter_device_manager_x11_get_device (ClutterDeviceManager *manager,
gint id)
{
ClutterDeviceManagerX11 *manager_x11 = CLUTTER_DEVICE_MANAGER_X11 (manager);
GSList *l;
for (l = manager_x11->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_x11_set_property (GObject *gobject,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
ClutterDeviceManagerX11 *manager_x11;
manager_x11 = CLUTTER_DEVICE_MANAGER_X11 (gobject);
switch (prop_id)
{
case PROP_USE_XINPUT_1:
manager_x11->use_xinput_1 = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break;
}
}
static void
clutter_device_manager_x11_get_property (GObject *gobject,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
ClutterDeviceManagerX11 *manager_x11;
manager_x11 = CLUTTER_DEVICE_MANAGER_X11 (gobject);
switch (prop_id)
{
case PROP_USE_XINPUT_1:
g_value_set_boolean (value, manager_x11->use_xinput_1);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break;
}
}
static void
clutter_device_manager_x11_class_init (ClutterDeviceManagerX11Class *klass)
{
ClutterDeviceManagerClass *manager_class;
GObjectClass *gobject_class;
GParamSpec *pspec;
gobject_class = G_OBJECT_CLASS (klass);
gobject_class->set_property = clutter_device_manager_x11_set_property;
gobject_class->get_property = clutter_device_manager_x11_get_property;
gobject_class->constructed = clutter_device_manager_x11_constructed;
manager_class = CLUTTER_DEVICE_MANAGER_CLASS (klass);
manager_class->add_device = clutter_device_manager_x11_add_device;
manager_class->remove_device = clutter_device_manager_x11_remove_device;
manager_class->get_devices = clutter_device_manager_x11_get_devices;
manager_class->get_core_device = clutter_device_manager_x11_get_core_device;
manager_class->get_device = clutter_device_manager_x11_get_device;
pspec = g_param_spec_boolean ("use-xinput-1",
"Use XInput 1",
"Use the XInput 1.0 extension",
FALSE,
CLUTTER_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (gobject_class, PROP_USE_XINPUT_1, pspec);
}
static void
clutter_device_manager_x11_init (ClutterDeviceManagerX11 *self)
{
self->use_xinput_1 = FALSE;
}

View File

@ -0,0 +1,68 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2009 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_X11_H__
#define __CLUTTER_DEVICE_MANAGER_X11_H__
#include <clutter/clutter-device-manager.h>
G_BEGIN_DECLS
#define CLUTTER_TYPE_DEVICE_MANAGER_X11 (clutter_device_manager_x11_get_type ())
#define CLUTTER_DEVICE_MANAGER_X11(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_DEVICE_MANAGER_X11, ClutterDeviceManagerX11))
#define CLUTTER_IS_DEVICE_MANAGER_X11(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_DEVICE_MANAGER_X11))
#define CLUTTER_DEVICE_MANAGER_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_DEVICE_MANAGER_X11, ClutterDeviceManagerX11Class))
#define CLUTTER_IS_DEVICE_MANAGER_X11_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_DEVICE_MANAGER_X11))
#define CLUTTER_DEVICE_MANAGER_X11_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_DEVICE_MANAGER_X11, ClutterDeviceManagerX11Class))
typedef struct _ClutterDeviceManagerX11 ClutterDeviceManagerX11;
typedef struct _ClutterDeviceManagerX11Class ClutterDeviceManagerX11Class;
struct _ClutterDeviceManagerX11
{
ClutterDeviceManager parent_instance;
/* the list of transient devices */
GSList *devices;
/* the list of all devices, transient and core; this can be
* NULL-ified when adding or removing devices
*/
GSList *all_devices;
ClutterInputDevice *core_pointer;
ClutterInputDevice *core_keyboard;
guint use_xinput_1 : 1;
};
struct _ClutterDeviceManagerX11Class
{
ClutterDeviceManagerClass parent_class;
};
GType clutter_device_manager_x11_get_type (void) G_GNUC_CONST;
G_END_DECLS
#endif /* __CLUTTER_DEVICE_MANAGER_X11_H__ */

View File

@ -419,6 +419,7 @@ event_translate (ClutterBackend *backend,
ClutterStageX11 *stage_x11;
ClutterStage *stage;
ClutterStageWindow *impl;
ClutterDeviceManager *manager;
gboolean res, not_yet_handled = FALSE;
Window xwindow, stage_xwindow;
ClutterInputDevice *device;
@ -471,6 +472,8 @@ event_translate (ClutterBackend *backend,
update_last_event_time (backend_x11, xevent);
manager = clutter_device_manager_get_default ();
switch (xevent->type)
{
case ConfigureNotify:
@ -652,7 +655,9 @@ event_translate (ClutterBackend *backend,
case KeyPress:
event->key.type = event->type = CLUTTER_KEY_PRESS;
event->key.device = backend_x11->core_keyboard;
event->key.device =
clutter_device_manager_get_core_device (manager,
CLUTTER_POINTER_DEVICE);
translate_key_event (backend, event, xevent);
@ -687,7 +692,9 @@ event_translate (ClutterBackend *backend,
}
event->key.type = event->type = CLUTTER_KEY_RELEASE;
event->key.device = backend_x11->core_keyboard;
event->key.device =
clutter_device_manager_get_core_device (manager,
CLUTTER_KEYBOARD_DEVICE);
translate_key_event (backend, event, xevent);
break;
@ -701,7 +708,8 @@ event_translate (ClutterBackend *backend,
/* Input device event handling.. */
if (not_yet_handled)
{
device = backend_x11->core_pointer;
device = clutter_device_manager_get_core_device (manager,
CLUTTER_POINTER_DEVICE);
/* Regular X event */
switch (xevent->type)