2009-11-24 16:22:44 +00:00
|
|
|
/*
|
|
|
|
* 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>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2010-01-15 15:29:52 +00:00
|
|
|
* SECTION:clutter-device-manager
|
2009-11-24 16:22:44 +00:00
|
|
|
* @short_description: Maintains the list of input devices
|
|
|
|
*
|
|
|
|
* #ClutterDeviceManager is a singleton object, owned by Clutter, which
|
|
|
|
* maintains the list of #ClutterInputDevice<!-- -->s.
|
|
|
|
*
|
2010-01-15 15:29:52 +00:00
|
|
|
* Depending on the backend used by Clutter it is possible to use the
|
|
|
|
* #ClutterDeviceManager::device-added and
|
|
|
|
* #ClutterDeviceManager::device-removed to monitor addition and removal
|
|
|
|
* of devices.
|
|
|
|
*
|
2009-11-24 16:22:44 +00:00
|
|
|
* #ClutterDeviceManager is available since Clutter 1.2
|
|
|
|
*/
|
|
|
|
|
2009-11-20 15:35:40 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2010-10-21 10:49:37 +00:00
|
|
|
#include "clutter-backend-private.h"
|
2009-11-20 15:35:40 +00:00
|
|
|
#include "clutter-debug.h"
|
2010-10-21 09:54:14 +00:00
|
|
|
#include "clutter-device-manager-private.h"
|
2009-11-20 15:35:40 +00:00
|
|
|
#include "clutter-enum-types.h"
|
|
|
|
#include "clutter-marshal.h"
|
|
|
|
#include "clutter-private.h"
|
2011-02-18 19:27:58 +00:00
|
|
|
#include "clutter-stage-private.h"
|
2009-11-20 15:35:40 +00:00
|
|
|
|
2010-02-17 17:06:25 +00:00
|
|
|
struct _ClutterDeviceManagerPrivate
|
|
|
|
{
|
|
|
|
/* back-pointer to the backend */
|
|
|
|
ClutterBackend *backend;
|
|
|
|
};
|
2009-11-20 15:35:40 +00:00
|
|
|
|
2010-02-17 17:06:25 +00:00
|
|
|
enum
|
2009-11-20 15:35:40 +00:00
|
|
|
{
|
2010-02-17 17:06:25 +00:00
|
|
|
PROP_0,
|
|
|
|
|
2010-06-21 09:20:32 +00:00
|
|
|
PROP_BACKEND,
|
|
|
|
|
|
|
|
PROP_LAST
|
2009-11-20 15:35:40 +00:00
|
|
|
};
|
|
|
|
|
2010-06-21 09:20:32 +00:00
|
|
|
static GParamSpec *obj_props[PROP_LAST];
|
|
|
|
|
2009-11-20 15:35:40 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
DEVICE_ADDED,
|
|
|
|
DEVICE_REMOVED,
|
|
|
|
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
static guint manager_signals[LAST_SIGNAL] = { 0, };
|
|
|
|
|
2013-07-03 13:14:01 +00:00
|
|
|
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (ClutterDeviceManager,
|
|
|
|
clutter_device_manager,
|
|
|
|
G_TYPE_OBJECT)
|
2010-02-17 17:06:25 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2009-11-20 15:35:40 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_device_manager_class_init (ClutterDeviceManagerClass *klass)
|
|
|
|
{
|
2010-02-17 17:06:25 +00:00
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
2010-10-15 14:24:27 +00:00
|
|
|
obj_props[PROP_BACKEND] =
|
|
|
|
g_param_spec_object ("backend",
|
|
|
|
P_("Backend"),
|
|
|
|
P_("The ClutterBackend of the device manager"),
|
|
|
|
CLUTTER_TYPE_BACKEND,
|
|
|
|
CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
|
|
|
|
2010-02-17 17:06:25 +00:00
|
|
|
gobject_class->set_property = clutter_device_manager_set_property;
|
|
|
|
gobject_class->get_property = clutter_device_manager_get_property;
|
2011-03-03 11:35:46 +00:00
|
|
|
g_object_class_install_properties (gobject_class,
|
|
|
|
PROP_LAST,
|
|
|
|
obj_props);
|
2010-02-17 17:06:25 +00:00
|
|
|
|
2010-01-15 15:29:14 +00:00
|
|
|
/**
|
|
|
|
* ClutterDeviceManager::device-added:
|
|
|
|
* @manager: the #ClutterDeviceManager that emitted the signal
|
|
|
|
* @device: the newly added #ClutterInputDevice
|
|
|
|
*
|
|
|
|
* The ::device-added signal is emitted each time a device has been
|
|
|
|
* added to the #ClutterDeviceManager
|
|
|
|
*
|
|
|
|
* Since: 1.2
|
|
|
|
*/
|
2009-11-20 15:35:40 +00:00
|
|
|
manager_signals[DEVICE_ADDED] =
|
|
|
|
g_signal_new (I_("device-added"),
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0,
|
|
|
|
NULL, NULL,
|
2010-06-11 14:49:46 +00:00
|
|
|
_clutter_marshal_VOID__OBJECT,
|
2009-11-20 15:35:40 +00:00
|
|
|
G_TYPE_NONE, 1,
|
2010-01-15 15:29:14 +00:00
|
|
|
CLUTTER_TYPE_INPUT_DEVICE);
|
2009-11-20 15:35:40 +00:00
|
|
|
|
2010-01-15 15:29:14 +00:00
|
|
|
/**
|
|
|
|
* ClutterDeviceManager::device-removed:
|
|
|
|
* @manager: the #ClutterDeviceManager that emitted the signal
|
|
|
|
* @device: the removed #ClutterInputDevice
|
|
|
|
*
|
|
|
|
* The ::device-removed signal is emitted each time a device has been
|
|
|
|
* removed from the #ClutterDeviceManager
|
|
|
|
*
|
|
|
|
* Since: 1.2
|
|
|
|
*/
|
2009-11-20 15:35:40 +00:00
|
|
|
manager_signals[DEVICE_REMOVED] =
|
|
|
|
g_signal_new (I_("device-removed"),
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0,
|
|
|
|
NULL, NULL,
|
2010-06-11 14:49:46 +00:00
|
|
|
_clutter_marshal_VOID__OBJECT,
|
2009-11-20 15:35:40 +00:00
|
|
|
G_TYPE_NONE, 1,
|
2010-01-15 15:29:14 +00:00
|
|
|
CLUTTER_TYPE_INPUT_DEVICE);
|
2009-11-20 15:35:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_device_manager_init (ClutterDeviceManager *self)
|
|
|
|
{
|
2013-07-03 13:14:01 +00:00
|
|
|
self->priv = clutter_device_manager_get_instance_private (self);
|
2009-11-20 15:35:40 +00:00
|
|
|
}
|
|
|
|
|
2009-11-24 16:22:44 +00:00
|
|
|
/**
|
|
|
|
* clutter_device_manager_get_default:
|
|
|
|
*
|
|
|
|
* Retrieves the device manager singleton
|
|
|
|
*
|
|
|
|
* Return value: (transfer none): the #ClutterDeviceManager singleton.
|
|
|
|
* The returned instance is owned by Clutter and it should not be
|
|
|
|
* modified or freed
|
|
|
|
*
|
|
|
|
* Since: 1.2
|
|
|
|
*/
|
2009-11-20 15:35:40 +00:00
|
|
|
ClutterDeviceManager *
|
|
|
|
clutter_device_manager_get_default (void)
|
|
|
|
{
|
2011-11-04 19:25:54 +00:00
|
|
|
ClutterBackend *backend = clutter_get_default_backend ();
|
2009-11-20 15:35:40 +00:00
|
|
|
|
2011-11-04 19:25:54 +00:00
|
|
|
return backend->device_manager;
|
2009-11-20 15:35:40 +00:00
|
|
|
}
|
|
|
|
|
2009-11-24 16:22:44 +00:00
|
|
|
/**
|
|
|
|
* clutter_device_manager_list_devices:
|
|
|
|
* @device_manager: a #ClutterDeviceManager
|
|
|
|
*
|
|
|
|
* Lists all currently registered input devices
|
|
|
|
*
|
2010-09-08 15:41:47 +00:00
|
|
|
* Return value: (transfer container) (element-type Clutter.InputDevice):
|
2009-11-24 16:22:44 +00:00
|
|
|
* a newly allocated list of #ClutterInputDevice objects. Use
|
|
|
|
* g_slist_free() to deallocate it when done
|
|
|
|
*
|
|
|
|
* Since: 1.2
|
|
|
|
*/
|
2009-11-20 15:35:40 +00:00
|
|
|
GSList *
|
|
|
|
clutter_device_manager_list_devices (ClutterDeviceManager *device_manager)
|
|
|
|
{
|
2010-02-17 17:06:25 +00:00
|
|
|
const GSList *devices;
|
|
|
|
|
2009-11-20 15:35:40 +00:00
|
|
|
g_return_val_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager), NULL);
|
|
|
|
|
2010-02-17 17:06:25 +00:00
|
|
|
devices = clutter_device_manager_peek_devices (device_manager);
|
|
|
|
|
|
|
|
return g_slist_copy ((GSList *) devices);
|
2009-11-20 15:35:40 +00:00
|
|
|
}
|
|
|
|
|
2009-11-24 16:22:44 +00:00
|
|
|
/**
|
|
|
|
* clutter_device_manager_peek_devices:
|
|
|
|
* @device_manager: a #ClutterDeviceManager
|
|
|
|
*
|
|
|
|
* Lists all currently registered input devices
|
|
|
|
*
|
2010-09-08 15:41:47 +00:00
|
|
|
* Return value: (transfer none) (element-type Clutter.InputDevice):
|
2009-11-24 16:22:44 +00:00
|
|
|
* a pointer to the internal list of #ClutterInputDevice objects. The
|
|
|
|
* returned list is owned by the #ClutterDeviceManager and should never
|
|
|
|
* be modified or freed
|
|
|
|
*
|
|
|
|
* Since: 1.2
|
|
|
|
*/
|
2009-11-20 15:35:40 +00:00
|
|
|
const GSList *
|
|
|
|
clutter_device_manager_peek_devices (ClutterDeviceManager *device_manager)
|
|
|
|
{
|
2010-02-17 17:06:25 +00:00
|
|
|
ClutterDeviceManagerClass *manager_class;
|
|
|
|
|
2009-11-20 15:35:40 +00:00
|
|
|
g_return_val_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager), NULL);
|
|
|
|
|
2010-02-17 17:06:25 +00:00
|
|
|
manager_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (device_manager);
|
|
|
|
return manager_class->get_devices (device_manager);
|
2009-11-20 15:35:40 +00:00
|
|
|
}
|
|
|
|
|
2009-11-24 16:22:44 +00:00
|
|
|
/**
|
|
|
|
* clutter_device_manager_get_device:
|
|
|
|
* @device_manager: a #ClutterDeviceManager
|
|
|
|
* @device_id: the integer id of a device
|
|
|
|
*
|
|
|
|
* Retrieves the #ClutterInputDevice with the given @device_id
|
|
|
|
*
|
|
|
|
* Return value: (transfer none): a #ClutterInputDevice or %NULL. The
|
|
|
|
* returned device is owned by the #ClutterDeviceManager and should
|
|
|
|
* never be modified or freed
|
|
|
|
*
|
|
|
|
* Since: 1.2
|
|
|
|
*/
|
2009-11-20 15:35:40 +00:00
|
|
|
ClutterInputDevice *
|
|
|
|
clutter_device_manager_get_device (ClutterDeviceManager *device_manager,
|
|
|
|
gint device_id)
|
|
|
|
{
|
2010-02-17 17:06:25 +00:00
|
|
|
ClutterDeviceManagerClass *manager_class;
|
2009-11-20 15:35:40 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager), NULL);
|
|
|
|
|
2010-02-17 17:06:25 +00:00
|
|
|
manager_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (device_manager);
|
|
|
|
return manager_class->get_device (device_manager, device_id);
|
2009-11-20 15:35:40 +00:00
|
|
|
}
|
|
|
|
|
2010-02-17 17:06:25 +00:00
|
|
|
/**
|
|
|
|
* 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)
|
2009-11-20 15:35:40 +00:00
|
|
|
{
|
2010-02-17 17:06:25 +00:00
|
|
|
ClutterDeviceManagerClass *manager_class;
|
2009-11-20 15:35:40 +00:00
|
|
|
|
2010-02-17 17:06:25 +00:00
|
|
|
g_return_val_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager), NULL);
|
2009-11-20 15:35:40 +00:00
|
|
|
|
2010-02-17 17:06:25 +00:00
|
|
|
manager_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (device_manager);
|
|
|
|
return manager_class->get_core_device (device_manager, device_type);
|
2009-11-20 15:35:40 +00:00
|
|
|
}
|
|
|
|
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
void
|
|
|
|
_clutter_device_manager_select_stage_events (ClutterDeviceManager *device_manager,
|
2013-07-10 20:34:48 +00:00
|
|
|
ClutterStage *stage)
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
{
|
|
|
|
ClutterDeviceManagerClass *manager_class;
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager));
|
|
|
|
|
|
|
|
manager_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (device_manager);
|
2013-07-10 20:53:26 +00:00
|
|
|
if (manager_class->select_stage_events)
|
|
|
|
manager_class->select_stage_events (device_manager, stage);
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
}
|
|
|
|
|
2009-11-24 16:22:44 +00:00
|
|
|
/*
|
|
|
|
* _clutter_device_manager_add_device:
|
|
|
|
* @device_manager: a #ClutterDeviceManager
|
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
*
|
|
|
|
* Adds @device to the list of #ClutterInputDevice<!-- -->s maintained
|
|
|
|
* by @device_manager
|
|
|
|
*
|
|
|
|
* The reference count of @device is not increased
|
|
|
|
*
|
|
|
|
* The #ClutterDeviceManager::device-added signal is emitted after
|
|
|
|
* adding @device to the list
|
|
|
|
*/
|
2009-11-20 15:35:40 +00:00
|
|
|
void
|
|
|
|
_clutter_device_manager_add_device (ClutterDeviceManager *device_manager,
|
|
|
|
ClutterInputDevice *device)
|
|
|
|
{
|
2010-02-17 17:06:25 +00:00
|
|
|
ClutterDeviceManagerClass *manager_class;
|
|
|
|
|
2009-11-20 15:35:40 +00:00
|
|
|
g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager));
|
|
|
|
|
2010-02-17 17:06:25 +00:00
|
|
|
manager_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (device_manager);
|
|
|
|
g_assert (manager_class->add_device != NULL);
|
|
|
|
|
|
|
|
manager_class->add_device (device_manager, device);
|
2009-11-24 16:22:44 +00:00
|
|
|
|
|
|
|
g_signal_emit (device_manager, manager_signals[DEVICE_ADDED], 0, device);
|
2009-11-20 15:35:40 +00:00
|
|
|
}
|
|
|
|
|
2009-11-24 16:22:44 +00:00
|
|
|
/*
|
2009-12-07 18:38:18 +00:00
|
|
|
* _clutter_device_manager_remove_device:
|
2009-11-24 16:22:44 +00:00
|
|
|
* @device_manager: a #ClutterDeviceManager
|
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
*
|
|
|
|
* Removes @device from the list of #ClutterInputDevice<!-- -->s
|
|
|
|
* maintained by @device_manager
|
|
|
|
*
|
|
|
|
* The reference count of @device is not decreased
|
|
|
|
*
|
|
|
|
* The #ClutterDeviceManager::device-removed signal is emitted after
|
|
|
|
* removing @device from the list
|
|
|
|
*/
|
2009-11-20 15:35:40 +00:00
|
|
|
void
|
|
|
|
_clutter_device_manager_remove_device (ClutterDeviceManager *device_manager,
|
|
|
|
ClutterInputDevice *device)
|
|
|
|
{
|
2010-02-17 17:06:25 +00:00
|
|
|
ClutterDeviceManagerClass *manager_class;
|
|
|
|
|
2009-11-20 15:35:40 +00:00
|
|
|
g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager));
|
|
|
|
|
2010-02-17 17:06:25 +00:00
|
|
|
manager_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (device_manager);
|
|
|
|
g_assert (manager_class->remove_device != NULL);
|
2009-11-20 15:35:40 +00:00
|
|
|
|
2013-11-21 13:46:04 +00:00
|
|
|
/* The subclass remove_device() method will likely unref it but we
|
|
|
|
have to keep it alive during the signal emission. */
|
|
|
|
g_object_ref (device);
|
2009-11-24 16:22:44 +00:00
|
|
|
|
2013-11-21 13:46:04 +00:00
|
|
|
manager_class->remove_device (device_manager, device);
|
2009-11-24 16:22:44 +00:00
|
|
|
g_signal_emit (device_manager, manager_signals[DEVICE_REMOVED], 0, device);
|
2013-11-21 13:46:04 +00:00
|
|
|
|
|
|
|
g_object_unref (device);
|
2009-11-20 15:35:40 +00:00
|
|
|
}
|
2010-01-08 17:51:00 +00:00
|
|
|
|
2009-11-24 16:22:44 +00:00
|
|
|
/*
|
|
|
|
* _clutter_device_manager_update_devices:
|
|
|
|
* @device_manager: a #ClutterDeviceManager
|
|
|
|
*
|
|
|
|
* Updates every #ClutterInputDevice handled by @device_manager
|
|
|
|
* by performing a pick paint at the coordinates of each pointer
|
|
|
|
* device
|
|
|
|
*/
|
2010-01-08 17:51:00 +00:00
|
|
|
void
|
|
|
|
_clutter_device_manager_update_devices (ClutterDeviceManager *device_manager)
|
|
|
|
{
|
2010-02-17 17:06:25 +00:00
|
|
|
const GSList *d;
|
2010-01-08 17:51:00 +00:00
|
|
|
|
2010-02-17 17:06:25 +00:00
|
|
|
for (d = clutter_device_manager_peek_devices (device_manager);
|
|
|
|
d != NULL;
|
|
|
|
d = d->next)
|
2010-01-08 17:51:00 +00:00
|
|
|
{
|
|
|
|
ClutterInputDevice *device = d->data;
|
|
|
|
ClutterInputDeviceType device_type;
|
|
|
|
|
2009-11-24 16:22:44 +00:00
|
|
|
/* we only care about pointer devices */
|
2010-01-08 17:51:00 +00:00
|
|
|
device_type = clutter_input_device_get_device_type (device);
|
|
|
|
if (device_type != CLUTTER_POINTER_DEVICE)
|
|
|
|
continue;
|
|
|
|
|
2009-11-24 16:22:44 +00:00
|
|
|
/* out of stage */
|
2010-01-08 17:51:00 +00:00
|
|
|
if (device->stage == NULL)
|
|
|
|
continue;
|
|
|
|
|
2011-02-18 19:27:58 +00:00
|
|
|
/* the user disabled motion events delivery on actors for
|
|
|
|
* the stage the device is on; we don't perform any picking
|
|
|
|
* since the source of the events will always be set to be
|
|
|
|
* the stage
|
|
|
|
*/
|
2011-06-20 10:41:28 +00:00
|
|
|
if (!clutter_stage_get_motion_events_enabled (device->stage))
|
2011-02-18 19:27:58 +00:00
|
|
|
continue;
|
|
|
|
|
2012-07-11 15:21:28 +00:00
|
|
|
_clutter_input_device_update (device, NULL, TRUE);
|
2010-01-08 17:51:00 +00:00
|
|
|
}
|
|
|
|
}
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
|
|
|
|
ClutterBackend *
|
|
|
|
_clutter_device_manager_get_backend (ClutterDeviceManager *manager)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_DEVICE_MANAGER (manager), NULL);
|
|
|
|
|
|
|
|
return manager->priv->backend;
|
|
|
|
}
|