mirror of
https://github.com/brl/mutter.git
synced 2024-12-25 04:22:05 +00:00
x11: Store core devices on the X11 Backend singleton
Instead of overloading the device id of 0 and 1 we should treat the core devices as special, and have a pointer inside the X11 backend singleton structure, for fast access.
This commit is contained in:
parent
8a579838d5
commit
79ad2b6a72
@ -236,18 +236,22 @@ default_device:
|
|||||||
d = g_object_new (CLUTTER_TYPE_INPUT_DEVICE_X11,
|
d = g_object_new (CLUTTER_TYPE_INPUT_DEVICE_X11,
|
||||||
"id", 0,
|
"id", 0,
|
||||||
"device-type", CLUTTER_POINTER_DEVICE,
|
"device-type", CLUTTER_POINTER_DEVICE,
|
||||||
|
"is-core", TRUE,
|
||||||
NULL);
|
NULL);
|
||||||
d->is_default = TRUE;
|
d->is_default = TRUE;
|
||||||
CLUTTER_NOTE (BACKEND, "Added default pointer device %d", d->id);
|
CLUTTER_NOTE (BACKEND, "Added core pointer device %d", d->id);
|
||||||
_clutter_device_manager_add_device (manager, d);
|
_clutter_device_manager_add_device (manager, d);
|
||||||
|
backend->core_pointer = d;
|
||||||
|
|
||||||
d = g_object_new (CLUTTER_TYPE_INPUT_DEVICE_X11,
|
d = g_object_new (CLUTTER_TYPE_INPUT_DEVICE_X11,
|
||||||
"id", 1,
|
"id", 1,
|
||||||
"device-type", CLUTTER_KEYBOARD_DEVICE,
|
"device-type", CLUTTER_KEYBOARD_DEVICE,
|
||||||
|
"is-core", TRUE,
|
||||||
NULL);
|
NULL);
|
||||||
d->is_default = TRUE;
|
d->is_default = TRUE;
|
||||||
CLUTTER_NOTE (BACKEND, "Added default keyboard device %d", d->id);
|
CLUTTER_NOTE (BACKEND, "Added core keyboard device %d", d->id);
|
||||||
_clutter_device_manager_add_device (manager, d);
|
_clutter_device_manager_add_device (manager, d);
|
||||||
|
backend->core_keyboard = d;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,6 +80,9 @@ struct _ClutterBackendX11
|
|||||||
gboolean have_xinput;
|
gboolean have_xinput;
|
||||||
|
|
||||||
Time last_event_time;
|
Time last_event_time;
|
||||||
|
|
||||||
|
ClutterInputDevice *core_pointer;
|
||||||
|
ClutterInputDevice *core_keyboard;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _ClutterBackendX11Class
|
struct _ClutterBackendX11Class
|
||||||
|
@ -183,7 +183,6 @@ _clutter_backend_x11_events_init (ClutterBackend *backend)
|
|||||||
g_source_add_poll (source, &event_source->event_poll_fd);
|
g_source_add_poll (source, &event_source->event_poll_fd);
|
||||||
g_source_set_can_recurse (source, TRUE);
|
g_source_set_can_recurse (source, TRUE);
|
||||||
g_source_attach (source, NULL);
|
g_source_attach (source, NULL);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -622,10 +621,9 @@ event_translate (ClutterBackend *backend,
|
|||||||
|
|
||||||
case KeyPress:
|
case KeyPress:
|
||||||
event->key.type = event->type = CLUTTER_KEY_PRESS;
|
event->key.type = event->type = CLUTTER_KEY_PRESS;
|
||||||
translate_key_event (backend, event, xevent);
|
event->key.device = backend_x11->core_keyboard;
|
||||||
|
|
||||||
/* default key device if no XInput support is defined */
|
translate_key_event (backend, event, xevent);
|
||||||
event->key.device = clutter_device_manager_get_device (manager, 1);
|
|
||||||
|
|
||||||
set_user_time (backend_x11, &xwindow, xevent->xkey.time);
|
set_user_time (backend_x11, &xwindow, xevent->xkey.time);
|
||||||
break;
|
break;
|
||||||
@ -658,10 +656,9 @@ event_translate (ClutterBackend *backend,
|
|||||||
}
|
}
|
||||||
|
|
||||||
event->key.type = event->type = CLUTTER_KEY_RELEASE;
|
event->key.type = event->type = CLUTTER_KEY_RELEASE;
|
||||||
translate_key_event (backend, event, xevent);
|
event->key.device = backend_x11->core_keyboard;
|
||||||
|
|
||||||
/* default key device if no XInput support is defined */
|
translate_key_event (backend, event, xevent);
|
||||||
event->key.device = clutter_device_manager_get_device (manager, 1);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -675,7 +672,7 @@ event_translate (ClutterBackend *backend,
|
|||||||
{
|
{
|
||||||
if (!clutter_x11_has_xinput ())
|
if (!clutter_x11_has_xinput ())
|
||||||
{
|
{
|
||||||
device = clutter_device_manager_get_device (manager, 0);
|
device = backend_x11->core_pointer;
|
||||||
|
|
||||||
/* Regular X event */
|
/* Regular X event */
|
||||||
switch (xevent->type)
|
switch (xevent->type)
|
||||||
|
@ -22,20 +22,83 @@ struct _ClutterInputDeviceX11
|
|||||||
XEventClass xevent_list[5]; /* MAX 5 event types */
|
XEventClass xevent_list[5]; /* MAX 5 event types */
|
||||||
int num_events;
|
int num_events;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
guint is_core : 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PROP_0,
|
||||||
|
|
||||||
|
PROP_IS_CORE
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (ClutterInputDeviceX11,
|
G_DEFINE_TYPE (ClutterInputDeviceX11,
|
||||||
clutter_input_device_x11,
|
clutter_input_device_x11,
|
||||||
CLUTTER_TYPE_INPUT_DEVICE);
|
CLUTTER_TYPE_INPUT_DEVICE);
|
||||||
|
|
||||||
|
static void
|
||||||
|
clutter_input_device_x11_set_property (GObject *gobject,
|
||||||
|
guint prop_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
ClutterInputDeviceX11 *self = CLUTTER_INPUT_DEVICE_X11 (gobject);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_IS_CORE:
|
||||||
|
self->is_core = g_value_get_boolean (value);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
clutter_input_device_x11_get_property (GObject *gobject,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
ClutterInputDeviceX11 *self = CLUTTER_INPUT_DEVICE_X11 (gobject);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_IS_CORE:
|
||||||
|
g_value_set_boolean (value, self->is_core);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clutter_input_device_x11_class_init (ClutterInputDeviceX11Class *klass)
|
clutter_input_device_x11_class_init (ClutterInputDeviceX11Class *klass)
|
||||||
{
|
{
|
||||||
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
|
GParamSpec *pspec;
|
||||||
|
|
||||||
|
gobject_class->set_property = clutter_input_device_x11_set_property;
|
||||||
|
gobject_class->get_property = clutter_input_device_x11_get_property;
|
||||||
|
|
||||||
|
pspec = g_param_spec_boolean ("is-core",
|
||||||
|
"Is Core",
|
||||||
|
"Whether the device is a core one",
|
||||||
|
FALSE,
|
||||||
|
CLUTTER_PARAM_READWRITE |
|
||||||
|
G_PARAM_CONSTRUCT_ONLY);
|
||||||
|
g_object_class_install_property (gobject_class, PROP_IS_CORE, pspec);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clutter_input_device_x11_init (ClutterInputDeviceX11 *self)
|
clutter_input_device_x11_init (ClutterInputDeviceX11 *self)
|
||||||
{
|
{
|
||||||
|
self->is_core = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gint
|
gint
|
||||||
|
Loading…
Reference in New Issue
Block a user