2009-11-24 11:22:44 -05:00
|
|
|
/*
|
|
|
|
* Clutter.
|
|
|
|
*
|
|
|
|
* An OpenGL based 'interactive canvas' library.
|
|
|
|
*
|
2011-01-18 07:57:12 -05:00
|
|
|
* Copyright © 2009, 2010, 2011 Intel Corp.
|
2009-11-24 11:22:44 -05:00
|
|
|
*
|
|
|
|
* 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>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:clutter-input-device
|
|
|
|
* @short_description: An input device managed by Clutter
|
|
|
|
*
|
|
|
|
* #ClutterInputDevice represents an input device known to Clutter.
|
|
|
|
*
|
|
|
|
* The #ClutterInputDevice class holds the state of the device, but
|
|
|
|
* its contents are usually defined by the Clutter backend in use.
|
|
|
|
*/
|
|
|
|
|
2009-11-23 11:07:16 -05:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
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 07:32:04 -05:00
|
|
|
#include "clutter-input-device.h"
|
|
|
|
|
2010-10-21 07:16:05 -04:00
|
|
|
#include "clutter-actor-private.h"
|
2009-11-23 11:07:16 -05:00
|
|
|
#include "clutter-debug.h"
|
2010-10-21 05:54:14 -04:00
|
|
|
#include "clutter-device-manager-private.h"
|
2009-11-23 11:07:16 -05:00
|
|
|
#include "clutter-enum-types.h"
|
2011-02-18 11:27:49 -05:00
|
|
|
#include "clutter-event-private.h"
|
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 07:32:04 -05:00
|
|
|
#include "clutter-marshal.h"
|
2009-11-23 11:07:16 -05:00
|
|
|
#include "clutter-private.h"
|
2010-10-21 06:29:09 -04:00
|
|
|
#include "clutter-stage-private.h"
|
2009-11-23 11:07:16 -05:00
|
|
|
|
2013-09-03 06:51:19 -04:00
|
|
|
#include <math.h>
|
|
|
|
|
2009-11-23 11:07:16 -05:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
|
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 07:32:04 -05:00
|
|
|
PROP_BACKEND,
|
|
|
|
|
2009-11-23 11:07:16 -05:00
|
|
|
PROP_ID,
|
2010-06-21 05:20:32 -04:00
|
|
|
PROP_NAME,
|
|
|
|
|
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 07:32:04 -05:00
|
|
|
PROP_DEVICE_TYPE,
|
|
|
|
PROP_DEVICE_MANAGER,
|
|
|
|
PROP_DEVICE_MODE,
|
|
|
|
|
|
|
|
PROP_HAS_CURSOR,
|
2011-01-19 11:23:45 -05:00
|
|
|
PROP_ENABLED,
|
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 07:32:04 -05:00
|
|
|
|
|
|
|
PROP_N_AXES,
|
|
|
|
|
2010-06-21 05:20:32 -04:00
|
|
|
PROP_LAST
|
2009-11-23 11:07:16 -05:00
|
|
|
};
|
|
|
|
|
2012-07-11 11:21:28 -04:00
|
|
|
static void _clutter_input_device_free_touch_info (gpointer data);
|
|
|
|
|
|
|
|
|
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 07:32:04 -05:00
|
|
|
static GParamSpec *obj_props[PROP_LAST] = { NULL, };
|
|
|
|
|
2009-11-23 11:07:16 -05:00
|
|
|
G_DEFINE_TYPE (ClutterInputDevice, clutter_input_device, G_TYPE_OBJECT);
|
|
|
|
|
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 07:32:04 -05:00
|
|
|
static void
|
|
|
|
clutter_input_device_dispose (GObject *gobject)
|
|
|
|
{
|
|
|
|
ClutterInputDevice *device = CLUTTER_INPUT_DEVICE (gobject);
|
|
|
|
|
2013-11-29 10:43:45 -05:00
|
|
|
g_clear_pointer (&device->device_name, g_free);
|
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 07:32:04 -05:00
|
|
|
|
|
|
|
if (device->associated != NULL)
|
|
|
|
{
|
2011-05-27 10:12:15 -04:00
|
|
|
if (device->device_mode == CLUTTER_INPUT_MODE_SLAVE)
|
|
|
|
_clutter_input_device_remove_slave (device->associated, device);
|
|
|
|
|
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 07:32:04 -05:00
|
|
|
_clutter_input_device_set_associated_device (device->associated, NULL);
|
|
|
|
g_object_unref (device->associated);
|
|
|
|
device->associated = NULL;
|
|
|
|
}
|
|
|
|
|
2013-11-21 10:23:00 -05:00
|
|
|
g_clear_pointer (&device->axes, g_array_unref);
|
|
|
|
g_clear_pointer (&device->keys, g_array_unref);
|
2013-11-21 08:48:00 -05:00
|
|
|
g_clear_pointer (&device->scroll_info, g_array_unref);
|
2013-11-21 10:23:00 -05:00
|
|
|
g_clear_pointer (&device->touch_sequences_info, g_hash_table_unref);
|
2012-07-11 11:21:28 -04:00
|
|
|
|
|
|
|
if (device->inv_touch_sequence_actors)
|
|
|
|
{
|
|
|
|
GHashTableIter iter;
|
|
|
|
gpointer key, value;
|
|
|
|
|
|
|
|
g_hash_table_iter_init (&iter, device->inv_touch_sequence_actors);
|
|
|
|
while (g_hash_table_iter_next (&iter, &key, &value))
|
|
|
|
g_list_free (value);
|
|
|
|
|
|
|
|
g_hash_table_unref (device->inv_touch_sequence_actors);
|
|
|
|
device->inv_touch_sequence_actors = NULL;
|
|
|
|
}
|
|
|
|
|
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 07:32:04 -05:00
|
|
|
G_OBJECT_CLASS (clutter_input_device_parent_class)->dispose (gobject);
|
|
|
|
}
|
|
|
|
|
2009-11-23 11:07:16 -05:00
|
|
|
static void
|
|
|
|
clutter_input_device_set_property (GObject *gobject,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
ClutterInputDevice *self = CLUTTER_INPUT_DEVICE (gobject);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_ID:
|
|
|
|
self->id = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_DEVICE_TYPE:
|
|
|
|
self->device_type = g_value_get_enum (value);
|
|
|
|
break;
|
|
|
|
|
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 07:32:04 -05:00
|
|
|
case PROP_DEVICE_MANAGER:
|
|
|
|
self->device_manager = g_value_get_object (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_DEVICE_MODE:
|
|
|
|
self->device_mode = g_value_get_enum (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_BACKEND:
|
|
|
|
self->backend = g_value_get_object (value);
|
|
|
|
break;
|
|
|
|
|
2010-01-15 06:37:43 -05:00
|
|
|
case PROP_NAME:
|
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 07:32:04 -05:00
|
|
|
self->device_name = g_value_dup_string (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_HAS_CURSOR:
|
|
|
|
self->has_cursor = g_value_get_boolean (value);
|
2010-01-15 06:37:43 -05:00
|
|
|
break;
|
|
|
|
|
2011-01-19 11:23:45 -05:00
|
|
|
case PROP_ENABLED:
|
2011-01-19 12:03:27 -05:00
|
|
|
clutter_input_device_set_enabled (self, g_value_get_boolean (value));
|
2011-01-19 11:23:45 -05:00
|
|
|
break;
|
|
|
|
|
2009-11-23 11:07:16 -05:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_input_device_get_property (GObject *gobject,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
ClutterInputDevice *self = CLUTTER_INPUT_DEVICE (gobject);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_ID:
|
|
|
|
g_value_set_int (value, self->id);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_DEVICE_TYPE:
|
|
|
|
g_value_set_enum (value, self->device_type);
|
|
|
|
break;
|
|
|
|
|
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 07:32:04 -05:00
|
|
|
case PROP_DEVICE_MANAGER:
|
|
|
|
g_value_set_object (value, self->device_manager);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_DEVICE_MODE:
|
|
|
|
g_value_set_enum (value, self->device_mode);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_BACKEND:
|
|
|
|
g_value_set_object (value, self->backend);
|
|
|
|
break;
|
|
|
|
|
2010-01-15 06:37:43 -05:00
|
|
|
case PROP_NAME:
|
|
|
|
g_value_set_string (value, self->device_name);
|
|
|
|
break;
|
|
|
|
|
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 07:32:04 -05:00
|
|
|
case PROP_HAS_CURSOR:
|
|
|
|
g_value_set_boolean (value, self->has_cursor);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_N_AXES:
|
2011-01-19 12:03:27 -05:00
|
|
|
g_value_set_uint (value, clutter_input_device_get_n_axes (self));
|
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 07:32:04 -05:00
|
|
|
break;
|
|
|
|
|
2011-01-19 11:23:45 -05:00
|
|
|
case PROP_ENABLED:
|
|
|
|
g_value_set_boolean (value, self->is_enabled);
|
|
|
|
break;
|
|
|
|
|
2009-11-23 11:07:16 -05:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_input_device_class_init (ClutterInputDeviceClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
2009-11-24 11:22:44 -05:00
|
|
|
/**
|
|
|
|
* ClutterInputDevice:id:
|
|
|
|
*
|
|
|
|
* The unique identifier of the device
|
|
|
|
*
|
|
|
|
* Since: 1.2
|
|
|
|
*/
|
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 07:32:04 -05:00
|
|
|
obj_props[PROP_ID] =
|
|
|
|
g_param_spec_int ("id",
|
|
|
|
P_("Id"),
|
|
|
|
P_("Unique identifier of the device"),
|
|
|
|
-1, G_MAXINT,
|
|
|
|
0,
|
|
|
|
CLUTTER_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY);
|
2009-11-23 11:07:16 -05:00
|
|
|
|
2010-01-15 06:37:43 -05:00
|
|
|
/**
|
|
|
|
* ClutterInputDevice:name:
|
|
|
|
*
|
|
|
|
* The name of the device
|
|
|
|
*
|
|
|
|
* Since: 1.2
|
|
|
|
*/
|
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 07:32:04 -05:00
|
|
|
obj_props[PROP_NAME] =
|
|
|
|
g_param_spec_string ("name",
|
|
|
|
P_("Name"),
|
|
|
|
P_("The name of the device"),
|
|
|
|
NULL,
|
|
|
|
CLUTTER_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY);
|
2010-01-15 06:37:43 -05:00
|
|
|
|
2009-11-24 11:22:44 -05:00
|
|
|
/**
|
|
|
|
* ClutterInputDevice:device-type:
|
|
|
|
*
|
|
|
|
* The type of the device
|
|
|
|
*
|
|
|
|
* Since: 1.2
|
|
|
|
*/
|
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 07:32:04 -05:00
|
|
|
obj_props[PROP_DEVICE_TYPE] =
|
|
|
|
g_param_spec_enum ("device-type",
|
|
|
|
P_("Device Type"),
|
|
|
|
P_("The type of the device"),
|
|
|
|
CLUTTER_TYPE_INPUT_DEVICE_TYPE,
|
|
|
|
CLUTTER_POINTER_DEVICE,
|
|
|
|
CLUTTER_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY);
|
|
|
|
|
2011-01-19 12:03:27 -05:00
|
|
|
/**
|
|
|
|
* ClutterInputDevice:device-manager:
|
|
|
|
*
|
|
|
|
* The #ClutterDeviceManager instance which owns the device
|
|
|
|
*
|
|
|
|
* Since: 1.6
|
|
|
|
*/
|
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 07:32:04 -05:00
|
|
|
obj_props[PROP_DEVICE_MANAGER] =
|
|
|
|
g_param_spec_object ("device-manager",
|
|
|
|
P_("Device Manager"),
|
|
|
|
P_("The device manager instance"),
|
|
|
|
CLUTTER_TYPE_DEVICE_MANAGER,
|
|
|
|
CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
|
|
|
|
2011-01-19 12:03:27 -05:00
|
|
|
/**
|
|
|
|
* ClutterInputDevice:mode:
|
|
|
|
*
|
|
|
|
* The mode of the device.
|
|
|
|
*
|
|
|
|
* Since: 1.6
|
|
|
|
*/
|
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 07:32:04 -05:00
|
|
|
obj_props[PROP_DEVICE_MODE] =
|
|
|
|
g_param_spec_enum ("device-mode",
|
|
|
|
P_("Device Mode"),
|
|
|
|
P_("The mode of the device"),
|
|
|
|
CLUTTER_TYPE_INPUT_MODE,
|
|
|
|
CLUTTER_INPUT_MODE_FLOATING,
|
|
|
|
CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
|
|
|
|
2011-01-19 12:03:27 -05:00
|
|
|
/**
|
|
|
|
* ClutterInputDevice:has-cursor:
|
|
|
|
*
|
|
|
|
* Whether the device has an on screen cursor following its movement.
|
|
|
|
*
|
|
|
|
* Since: 1.6
|
|
|
|
*/
|
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 07:32:04 -05:00
|
|
|
obj_props[PROP_HAS_CURSOR] =
|
|
|
|
g_param_spec_boolean ("has-cursor",
|
|
|
|
P_("Has Cursor"),
|
|
|
|
P_("Whether the device has a cursor"),
|
|
|
|
FALSE,
|
|
|
|
CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
|
|
|
|
2011-01-19 12:03:27 -05:00
|
|
|
/**
|
|
|
|
* ClutterInputDevice:enabled:
|
|
|
|
*
|
|
|
|
* Whether the device is enabled.
|
|
|
|
*
|
|
|
|
* A device with the #ClutterInputDevice:device-mode property set
|
|
|
|
* to %CLUTTER_INPUT_MODE_MASTER cannot be disabled.
|
|
|
|
*
|
|
|
|
* A device must be enabled in order to receive events from it.
|
|
|
|
*
|
|
|
|
* Since: 1.6
|
|
|
|
*/
|
2011-01-19 11:23:45 -05:00
|
|
|
obj_props[PROP_ENABLED] =
|
|
|
|
g_param_spec_boolean ("enabled",
|
|
|
|
P_("Enabled"),
|
|
|
|
P_("Whether the device is enabled"),
|
|
|
|
FALSE,
|
|
|
|
CLUTTER_PARAM_READWRITE);
|
|
|
|
|
2011-01-19 12:03:27 -05:00
|
|
|
/**
|
|
|
|
* ClutterInputDevice:n-axes:
|
|
|
|
*
|
|
|
|
* The number of axes of the device.
|
|
|
|
*
|
|
|
|
* Since: 1.6
|
|
|
|
*/
|
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 07:32:04 -05:00
|
|
|
obj_props[PROP_N_AXES] =
|
|
|
|
g_param_spec_uint ("n-axes",
|
|
|
|
P_("Number of Axes"),
|
|
|
|
P_("The number of axes on the device"),
|
|
|
|
0, G_MAXUINT,
|
|
|
|
0,
|
|
|
|
CLUTTER_PARAM_READABLE);
|
|
|
|
|
2011-01-19 12:03:27 -05:00
|
|
|
/**
|
|
|
|
* ClutterInputDevice:backend:
|
|
|
|
*
|
|
|
|
* The #ClutterBackend that created the device.
|
|
|
|
*
|
|
|
|
* Since: 1.6
|
|
|
|
*/
|
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 07:32:04 -05:00
|
|
|
obj_props[PROP_BACKEND] =
|
|
|
|
g_param_spec_object ("backend",
|
|
|
|
P_("Backend"),
|
|
|
|
P_("The backend instance"),
|
|
|
|
CLUTTER_TYPE_BACKEND,
|
|
|
|
CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
|
|
|
|
|
|
|
gobject_class->dispose = clutter_input_device_dispose;
|
|
|
|
gobject_class->set_property = clutter_input_device_set_property;
|
|
|
|
gobject_class->get_property = clutter_input_device_get_property;
|
|
|
|
g_object_class_install_properties (gobject_class, PROP_LAST, obj_props);
|
2009-11-23 11:07:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_input_device_init (ClutterInputDevice *self)
|
|
|
|
{
|
|
|
|
self->id = -1;
|
|
|
|
self->device_type = CLUTTER_POINTER_DEVICE;
|
|
|
|
|
|
|
|
self->click_count = 0;
|
|
|
|
|
2009-12-07 18:05:20 -05:00
|
|
|
self->current_time = self->previous_time = CLUTTER_CURRENT_TIME;
|
|
|
|
self->current_x = self->previous_x = -1;
|
|
|
|
self->current_y = self->previous_y = -1;
|
|
|
|
self->current_button_number = self->previous_button_number = -1;
|
|
|
|
self->current_state = self->previous_state = 0;
|
2012-07-11 11:21:28 -04:00
|
|
|
|
|
|
|
self->touch_sequences_info =
|
|
|
|
g_hash_table_new_full (NULL, NULL,
|
|
|
|
NULL, _clutter_input_device_free_touch_info);
|
|
|
|
self->inv_touch_sequence_actors = g_hash_table_new (NULL, NULL);
|
2009-11-23 11:07:16 -05:00
|
|
|
}
|
|
|
|
|
2012-08-21 10:26:30 -04:00
|
|
|
static ClutterTouchInfo *
|
|
|
|
_clutter_input_device_ensure_touch_info (ClutterInputDevice *device,
|
|
|
|
ClutterEventSequence *sequence,
|
|
|
|
ClutterStage *stage)
|
|
|
|
{
|
|
|
|
ClutterTouchInfo *info;
|
|
|
|
|
|
|
|
info = g_hash_table_lookup (device->touch_sequences_info, sequence);
|
|
|
|
|
|
|
|
if (info == NULL)
|
|
|
|
{
|
|
|
|
info = g_slice_new0 (ClutterTouchInfo);
|
|
|
|
info->sequence = sequence;
|
|
|
|
g_hash_table_insert (device->touch_sequences_info, sequence, info);
|
|
|
|
|
|
|
|
if (g_hash_table_size (device->touch_sequences_info) == 1)
|
|
|
|
_clutter_input_device_set_stage (device, stage);
|
|
|
|
}
|
|
|
|
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
2011-01-19 12:03:27 -05:00
|
|
|
/*< private >
|
|
|
|
* clutter_input_device_set_coords:
|
2009-11-24 11:22:44 -05:00
|
|
|
* @device: a #ClutterInputDevice
|
2012-07-11 11:21:28 -04:00
|
|
|
* @sequence: a #ClutterEventSequence or NULL
|
2009-11-24 11:22:44 -05:00
|
|
|
* @x: X coordinate of the device
|
|
|
|
* @y: Y coordinate of the device
|
|
|
|
*
|
|
|
|
* Stores the last known coordinates of the device
|
|
|
|
*/
|
2009-11-23 11:07:16 -05:00
|
|
|
void
|
2012-07-11 11:21:28 -04:00
|
|
|
_clutter_input_device_set_coords (ClutterInputDevice *device,
|
|
|
|
ClutterEventSequence *sequence,
|
|
|
|
gint x,
|
2012-08-21 10:26:30 -04:00
|
|
|
gint y,
|
|
|
|
ClutterStage *stage)
|
2009-11-23 11:07:16 -05:00
|
|
|
{
|
|
|
|
g_return_if_fail (CLUTTER_IS_INPUT_DEVICE (device));
|
|
|
|
|
2012-07-11 11:21:28 -04:00
|
|
|
if (sequence == NULL)
|
|
|
|
{
|
|
|
|
if (device->current_x != x)
|
|
|
|
device->current_x = x;
|
|
|
|
|
|
|
|
if (device->current_y != y)
|
|
|
|
device->current_y = y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-08-21 10:26:30 -04:00
|
|
|
ClutterTouchInfo *info;
|
|
|
|
info = _clutter_input_device_ensure_touch_info (device, sequence, stage);
|
2012-07-11 11:21:28 -04:00
|
|
|
info->current_x = x;
|
|
|
|
info->current_y = y;
|
|
|
|
}
|
2009-11-23 11:07:16 -05:00
|
|
|
}
|
|
|
|
|
2011-01-19 12:03:27 -05:00
|
|
|
/*< private >
|
|
|
|
* clutter_input_device_set_state:
|
2009-11-24 11:22:44 -05:00
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
* @state: a bitmask of modifiers
|
|
|
|
*
|
|
|
|
* Stores the last known modifiers state of the device
|
|
|
|
*/
|
2009-11-23 11:07:16 -05:00
|
|
|
void
|
|
|
|
_clutter_input_device_set_state (ClutterInputDevice *device,
|
|
|
|
ClutterModifierType state)
|
|
|
|
{
|
|
|
|
g_return_if_fail (CLUTTER_IS_INPUT_DEVICE (device));
|
|
|
|
|
2009-12-07 18:05:20 -05:00
|
|
|
device->current_state = state;
|
2009-11-23 11:07:16 -05:00
|
|
|
}
|
|
|
|
|
2013-08-14 10:49:00 -04:00
|
|
|
/**
|
|
|
|
* clutter_input_device_get_modifier_state:
|
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
*
|
|
|
|
* Retrieves the current modifiers state of the device, as seen
|
|
|
|
* by the last event Clutter processed.
|
|
|
|
*
|
|
|
|
* Return value: the last known modifier state
|
|
|
|
*
|
|
|
|
* Since: 1.16
|
|
|
|
*/
|
|
|
|
ClutterModifierType
|
|
|
|
clutter_input_device_get_modifier_state (ClutterInputDevice *device)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), 0);
|
|
|
|
|
|
|
|
return device->current_state;
|
|
|
|
}
|
|
|
|
|
2011-01-19 12:03:27 -05:00
|
|
|
/*< private >
|
|
|
|
* clutter_input_device_set_time:
|
2009-11-24 11:22:44 -05:00
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
* @time_: the time
|
|
|
|
*
|
|
|
|
* Stores the last known event time of the device
|
|
|
|
*/
|
2009-11-23 11:07:16 -05:00
|
|
|
void
|
|
|
|
_clutter_input_device_set_time (ClutterInputDevice *device,
|
|
|
|
guint32 time_)
|
|
|
|
{
|
|
|
|
g_return_if_fail (CLUTTER_IS_INPUT_DEVICE (device));
|
|
|
|
|
2009-12-07 18:05:20 -05:00
|
|
|
if (device->current_time != time_)
|
|
|
|
device->current_time = time_;
|
2009-11-23 11:07:16 -05:00
|
|
|
}
|
|
|
|
|
2011-01-19 12:03:27 -05:00
|
|
|
/*< private >
|
|
|
|
* clutter_input_device_set_stage:
|
2009-11-24 11:22:44 -05:00
|
|
|
* @device: a #ClutterInputDevice
|
2010-01-14 12:14:33 -05:00
|
|
|
* @stage: a #ClutterStage or %NULL
|
2009-11-24 11:22:44 -05:00
|
|
|
*
|
|
|
|
* Stores the stage under the device
|
|
|
|
*/
|
2010-01-08 12:51:00 -05:00
|
|
|
void
|
|
|
|
_clutter_input_device_set_stage (ClutterInputDevice *device,
|
|
|
|
ClutterStage *stage)
|
|
|
|
{
|
2011-01-27 12:26:16 -05:00
|
|
|
if (device->stage == stage)
|
|
|
|
return;
|
2010-01-08 12:51:00 -05:00
|
|
|
|
|
|
|
device->stage = stage;
|
|
|
|
|
2011-01-27 12:26:16 -05:00
|
|
|
/* we leave the ->cursor_actor in place in order to check
|
|
|
|
* if we left the stage without crossing it again; this way
|
|
|
|
* we can emit a leave event on the cursor actor right before
|
|
|
|
* we emit the leave event on the stage.
|
2010-01-14 12:14:33 -05:00
|
|
|
*/
|
2010-01-08 12:51:00 -05:00
|
|
|
}
|
|
|
|
|
2011-12-05 08:49:28 -05:00
|
|
|
/*< private >
|
|
|
|
* clutter_input_device_get_stage:
|
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
*
|
|
|
|
* Retrieves the stage currently associated with @device.
|
|
|
|
*
|
|
|
|
* Return value: The stage currently associated with @device.
|
|
|
|
*/
|
|
|
|
ClutterStage *
|
|
|
|
_clutter_input_device_get_stage (ClutterInputDevice *device)
|
|
|
|
{
|
|
|
|
return device->stage;
|
|
|
|
}
|
|
|
|
|
2012-07-11 11:21:28 -04:00
|
|
|
static void
|
|
|
|
_clutter_input_device_free_touch_info (gpointer data)
|
|
|
|
{
|
|
|
|
g_slice_free (ClutterTouchInfo, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ClutterActor *
|
|
|
|
_clutter_input_device_get_actor (ClutterInputDevice *device,
|
|
|
|
ClutterEventSequence *sequence)
|
|
|
|
{
|
|
|
|
ClutterTouchInfo *info;
|
|
|
|
|
|
|
|
if (sequence == NULL)
|
|
|
|
return device->cursor_actor;
|
|
|
|
|
|
|
|
info = g_hash_table_lookup (device->touch_sequences_info, sequence);
|
|
|
|
|
|
|
|
return info->actor;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void on_cursor_actor_destroy (ClutterActor *actor,
|
|
|
|
ClutterInputDevice *device);
|
|
|
|
|
|
|
|
static void
|
|
|
|
_clutter_input_device_associate_actor (ClutterInputDevice *device,
|
|
|
|
ClutterEventSequence *sequence,
|
|
|
|
ClutterActor *actor)
|
|
|
|
{
|
|
|
|
if (sequence == NULL)
|
|
|
|
device->cursor_actor = actor;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GList *sequences =
|
|
|
|
g_hash_table_lookup (device->inv_touch_sequence_actors, actor);
|
2012-08-21 10:26:30 -04:00
|
|
|
ClutterTouchInfo *info;
|
|
|
|
ClutterStage *stage = CLUTTER_STAGE (clutter_actor_get_stage (actor));
|
2012-07-11 11:21:28 -04:00
|
|
|
|
2012-08-21 10:26:30 -04:00
|
|
|
info = _clutter_input_device_ensure_touch_info (device, sequence, stage);
|
2012-07-11 11:21:28 -04:00
|
|
|
info->actor = actor;
|
|
|
|
|
|
|
|
g_hash_table_insert (device->inv_touch_sequence_actors,
|
|
|
|
actor, g_list_prepend (sequences, sequence));
|
|
|
|
}
|
|
|
|
|
|
|
|
g_signal_connect (actor,
|
|
|
|
"destroy", G_CALLBACK (on_cursor_actor_destroy),
|
|
|
|
device);
|
|
|
|
_clutter_actor_set_has_pointer (actor, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_clutter_input_device_unassociate_actor (ClutterInputDevice *device,
|
|
|
|
ClutterActor *actor,
|
|
|
|
gboolean destroyed)
|
|
|
|
{
|
|
|
|
if (device->cursor_actor == actor)
|
|
|
|
device->cursor_actor = NULL;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GList *l, *sequences =
|
|
|
|
g_hash_table_lookup (device->inv_touch_sequence_actors,
|
|
|
|
actor);
|
|
|
|
|
|
|
|
for (l = sequences; l != NULL; l = l->next)
|
|
|
|
{
|
|
|
|
ClutterTouchInfo *info =
|
|
|
|
g_hash_table_lookup (device->touch_sequences_info, l->data);
|
|
|
|
|
|
|
|
if (info)
|
|
|
|
info->actor = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (sequences);
|
|
|
|
g_hash_table_remove (device->inv_touch_sequence_actors, actor);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (destroyed == FALSE)
|
|
|
|
{
|
|
|
|
g_signal_handlers_disconnect_by_func (actor,
|
|
|
|
G_CALLBACK (on_cursor_actor_destroy),
|
|
|
|
device);
|
|
|
|
_clutter_actor_set_has_pointer (actor, FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
on_cursor_actor_destroy (ClutterActor *actor,
|
|
|
|
ClutterInputDevice *device)
|
|
|
|
{
|
|
|
|
_clutter_input_device_unassociate_actor (device, actor, TRUE);
|
|
|
|
}
|
|
|
|
|
2011-01-19 12:03:27 -05:00
|
|
|
/*< private >
|
|
|
|
* clutter_input_device_set_actor:
|
2009-11-24 11:33:03 -05:00
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
* @actor: a #ClutterActor
|
2011-01-27 12:26:16 -05:00
|
|
|
* @emit_crossing: %TRUE to emit crossing events
|
2009-11-24 11:33:03 -05:00
|
|
|
*
|
|
|
|
* Sets the actor under the pointer coordinates of @device
|
|
|
|
*
|
|
|
|
* This function is called by _clutter_input_device_update()
|
|
|
|
* and it will:
|
|
|
|
*
|
|
|
|
* - queue a %CLUTTER_LEAVE event on the previous pointer actor
|
|
|
|
* of @device, if any
|
|
|
|
* - set to %FALSE the :has-pointer property of the previous
|
|
|
|
* pointer actor of @device, if any
|
|
|
|
* - queue a %CLUTTER_ENTER event on the new pointer actor
|
|
|
|
* - set to %TRUE the :has-pointer property of the new pointer
|
|
|
|
* actor
|
|
|
|
*/
|
2010-01-08 12:51:00 -05:00
|
|
|
void
|
2012-07-11 11:21:28 -04:00
|
|
|
_clutter_input_device_set_actor (ClutterInputDevice *device,
|
|
|
|
ClutterEventSequence *sequence,
|
|
|
|
ClutterActor *actor,
|
|
|
|
gboolean emit_crossing)
|
2010-01-08 12:51:00 -05:00
|
|
|
{
|
2012-07-11 11:21:28 -04:00
|
|
|
ClutterActor *old_actor = _clutter_input_device_get_actor (device, sequence);
|
2009-11-24 11:33:03 -05:00
|
|
|
|
2012-07-11 11:21:28 -04:00
|
|
|
if (old_actor == actor)
|
2009-11-24 11:33:03 -05:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (old_actor != NULL)
|
2010-01-08 12:51:00 -05:00
|
|
|
{
|
2012-07-11 11:21:28 -04:00
|
|
|
ClutterActor *tmp_old_actor;
|
|
|
|
|
2011-01-27 12:26:16 -05:00
|
|
|
if (emit_crossing)
|
|
|
|
{
|
|
|
|
ClutterEvent *event;
|
|
|
|
|
|
|
|
event = clutter_event_new (CLUTTER_LEAVE);
|
|
|
|
event->crossing.time = device->current_time;
|
|
|
|
event->crossing.flags = 0;
|
|
|
|
event->crossing.stage = device->stage;
|
2012-07-11 11:21:28 -04:00
|
|
|
event->crossing.source = old_actor;
|
2011-01-27 12:26:16 -05:00
|
|
|
event->crossing.x = device->current_x;
|
|
|
|
event->crossing.y = device->current_y;
|
|
|
|
event->crossing.related = actor;
|
|
|
|
clutter_event_set_device (event, device);
|
|
|
|
|
|
|
|
/* we need to make sure that this event is processed
|
|
|
|
* before any other event we might have queued up until
|
|
|
|
* now, so we go on, and synthesize the event emission
|
|
|
|
* ourselves
|
|
|
|
*/
|
|
|
|
_clutter_process_event (event);
|
|
|
|
|
|
|
|
clutter_event_free (event);
|
|
|
|
}
|
2009-11-24 11:33:03 -05:00
|
|
|
|
2010-12-29 16:49:13 -05:00
|
|
|
/* processing the event might have destroyed the actor */
|
2012-07-11 11:21:28 -04:00
|
|
|
tmp_old_actor = _clutter_input_device_get_actor (device, sequence);
|
|
|
|
_clutter_input_device_unassociate_actor (device,
|
|
|
|
old_actor,
|
|
|
|
tmp_old_actor == NULL);
|
|
|
|
old_actor = tmp_old_actor;
|
2009-11-24 11:33:03 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (actor != NULL)
|
|
|
|
{
|
2012-07-11 11:21:28 -04:00
|
|
|
_clutter_input_device_associate_actor (device, sequence, actor);
|
|
|
|
|
2011-01-27 12:26:16 -05:00
|
|
|
if (emit_crossing)
|
2010-02-22 06:30:14 -05:00
|
|
|
{
|
2011-01-27 12:26:16 -05:00
|
|
|
ClutterEvent *event;
|
|
|
|
|
|
|
|
event = clutter_event_new (CLUTTER_ENTER);
|
|
|
|
event->crossing.time = device->current_time;
|
|
|
|
event->crossing.flags = 0;
|
|
|
|
event->crossing.stage = device->stage;
|
|
|
|
event->crossing.x = device->current_x;
|
|
|
|
event->crossing.y = device->current_y;
|
|
|
|
event->crossing.source = actor;
|
|
|
|
event->crossing.related = old_actor;
|
|
|
|
clutter_event_set_device (event, device);
|
|
|
|
|
|
|
|
/* see above */
|
|
|
|
_clutter_process_event (event);
|
|
|
|
|
|
|
|
clutter_event_free (event);
|
2010-02-22 06:30:14 -05:00
|
|
|
}
|
2010-01-08 12:51:00 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-23 11:07:16 -05:00
|
|
|
/**
|
|
|
|
* clutter_input_device_get_device_type:
|
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
*
|
|
|
|
* Retrieves the type of @device
|
|
|
|
*
|
|
|
|
* Return value: the type of the device
|
|
|
|
*
|
|
|
|
* Since: 1.0
|
|
|
|
*/
|
|
|
|
ClutterInputDeviceType
|
|
|
|
clutter_input_device_get_device_type (ClutterInputDevice *device)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device),
|
|
|
|
CLUTTER_POINTER_DEVICE);
|
|
|
|
|
|
|
|
return device->device_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_input_device_get_device_id:
|
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
*
|
|
|
|
* Retrieves the unique identifier of @device
|
|
|
|
*
|
|
|
|
* Return value: the identifier of the device
|
|
|
|
*
|
|
|
|
* Since: 1.0
|
|
|
|
*/
|
|
|
|
gint
|
|
|
|
clutter_input_device_get_device_id (ClutterInputDevice *device)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), -1);
|
|
|
|
|
|
|
|
return device->id;
|
|
|
|
}
|
2010-01-08 12:51:00 -05:00
|
|
|
|
2011-01-19 11:23:45 -05:00
|
|
|
/**
|
|
|
|
* clutter_input_device_set_enabled:
|
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
* @enabled: %TRUE to enable the @device
|
|
|
|
*
|
|
|
|
* Enables or disables a #ClutterInputDevice.
|
|
|
|
*
|
|
|
|
* Only devices with a #ClutterInputDevice:device-mode property set
|
|
|
|
* to %CLUTTER_INPUT_MODE_SLAVE or %CLUTTER_INPUT_MODE_FLOATING can
|
|
|
|
* be disabled.
|
|
|
|
*
|
|
|
|
* Since: 1.6
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_input_device_set_enabled (ClutterInputDevice *device,
|
|
|
|
gboolean enabled)
|
|
|
|
{
|
|
|
|
g_return_if_fail (CLUTTER_IS_INPUT_DEVICE (device));
|
|
|
|
|
|
|
|
enabled = !!enabled;
|
|
|
|
|
|
|
|
if (!enabled && device->device_mode == CLUTTER_INPUT_MODE_MASTER)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (device->is_enabled == enabled)
|
|
|
|
return;
|
|
|
|
|
|
|
|
device->is_enabled = enabled;
|
|
|
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (device), obj_props[PROP_ENABLED]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_input_device_get_enabled:
|
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
*
|
|
|
|
* Retrieves whether @device is enabled.
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if the device is enabled
|
|
|
|
*
|
|
|
|
* Since: 1.6
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
clutter_input_device_get_enabled (ClutterInputDevice *device)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), FALSE);
|
|
|
|
|
|
|
|
return device->is_enabled;
|
|
|
|
}
|
|
|
|
|
2009-11-24 11:22:44 -05:00
|
|
|
/**
|
2012-07-11 11:21:28 -04:00
|
|
|
* clutter_input_device_get_coords:
|
|
|
|
* @device: a #ClutterInputDevice
|
2012-07-17 17:41:04 -04:00
|
|
|
* @sequence: (allow-none): a #ClutterEventSequence, or %NULL if
|
|
|
|
* the device is not touch-based
|
|
|
|
* @point: (out caller-allocates): return location for the pointer
|
|
|
|
* or touch point
|
2009-11-24 11:22:44 -05:00
|
|
|
*
|
2012-07-11 11:21:28 -04:00
|
|
|
* Retrieves the latest coordinates of a pointer or touch point of
|
2012-07-17 17:41:04 -04:00
|
|
|
* @device.
|
2009-11-24 11:22:44 -05:00
|
|
|
*
|
2012-07-11 11:21:28 -04:00
|
|
|
* Return value: %FALSE if the device's sequence hasn't been found,
|
2012-07-17 17:41:04 -04:00
|
|
|
* and %TRUE otherwise.
|
2012-07-11 11:21:28 -04:00
|
|
|
*
|
|
|
|
* Since: 1.12
|
2009-11-24 11:22:44 -05:00
|
|
|
*/
|
2012-07-11 11:21:28 -04:00
|
|
|
gboolean
|
|
|
|
clutter_input_device_get_coords (ClutterInputDevice *device,
|
|
|
|
ClutterEventSequence *sequence,
|
|
|
|
ClutterPoint *point)
|
2010-01-08 12:51:00 -05:00
|
|
|
{
|
2012-07-11 11:21:28 -04:00
|
|
|
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), FALSE);
|
|
|
|
g_return_val_if_fail (point != NULL, FALSE);
|
2010-01-08 12:51:00 -05:00
|
|
|
|
2012-07-11 11:21:28 -04:00
|
|
|
if (sequence == NULL)
|
|
|
|
{
|
|
|
|
point->x = device->current_x;
|
|
|
|
point->y = device->current_y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ClutterTouchInfo *info =
|
|
|
|
g_hash_table_lookup (device->touch_sequences_info, sequence);
|
|
|
|
|
|
|
|
if (info == NULL)
|
|
|
|
return FALSE;
|
2010-01-08 12:51:00 -05:00
|
|
|
|
2012-07-11 11:21:28 -04:00
|
|
|
point->x = info->current_x;
|
|
|
|
point->y = info->current_y;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2010-01-08 12:51:00 -05:00
|
|
|
}
|
|
|
|
|
2010-01-12 06:53:12 -05:00
|
|
|
/*
|
|
|
|
* _clutter_input_device_update:
|
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
*
|
|
|
|
* Updates the input @device by determining the #ClutterActor underneath the
|
|
|
|
* pointer's cursor
|
|
|
|
*
|
|
|
|
* This function calls _clutter_input_device_set_actor() if needed.
|
|
|
|
*
|
|
|
|
* This function only works for #ClutterInputDevice of type
|
|
|
|
* %CLUTTER_POINTER_DEVICE.
|
|
|
|
*
|
|
|
|
* Since: 1.2
|
|
|
|
*/
|
2010-01-08 12:51:00 -05:00
|
|
|
ClutterActor *
|
2012-07-11 11:21:28 -04:00
|
|
|
_clutter_input_device_update (ClutterInputDevice *device,
|
|
|
|
ClutterEventSequence *sequence,
|
|
|
|
gboolean emit_crossing)
|
2010-01-08 12:51:00 -05:00
|
|
|
{
|
|
|
|
ClutterStage *stage;
|
|
|
|
ClutterActor *new_cursor_actor;
|
|
|
|
ClutterActor *old_cursor_actor;
|
2012-07-11 11:21:28 -04:00
|
|
|
ClutterPoint point = { -1, -1 };
|
2010-01-08 12:51:00 -05: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 07:32:04 -05:00
|
|
|
if (device->device_type == CLUTTER_KEYBOARD_DEVICE)
|
|
|
|
return NULL;
|
2010-01-12 06:53:12 -05:00
|
|
|
|
2010-01-08 12:51:00 -05:00
|
|
|
stage = device->stage;
|
2010-11-11 19:11:27 -05:00
|
|
|
if (G_UNLIKELY (stage == NULL))
|
|
|
|
{
|
2012-09-21 04:05:59 -04:00
|
|
|
CLUTTER_NOTE (EVENT, "No stage defined for device %d '%s'",
|
|
|
|
clutter_input_device_get_device_id (device),
|
2010-12-07 17:06:07 -05:00
|
|
|
clutter_input_device_get_device_name (device));
|
2010-11-11 19:11:27 -05:00
|
|
|
return NULL;
|
|
|
|
}
|
2010-02-10 12:12:27 -05:00
|
|
|
|
2012-07-11 11:21:28 -04:00
|
|
|
clutter_input_device_get_coords (device, sequence, &point);
|
2010-01-12 06:53:12 -05:00
|
|
|
|
2012-07-11 11:21:28 -04:00
|
|
|
old_cursor_actor = _clutter_input_device_get_actor (device, sequence);
|
2011-03-15 09:17:04 -04:00
|
|
|
new_cursor_actor =
|
2012-07-11 11:21:28 -04:00
|
|
|
_clutter_stage_do_pick (stage, point.x, point.y, CLUTTER_PICK_REACTIVE);
|
2010-01-08 12:51:00 -05:00
|
|
|
|
2009-11-24 11:22:44 -05:00
|
|
|
/* if the pick could not find an actor then we do not update the
|
|
|
|
* input device, to avoid ghost enter/leave events; the pick should
|
|
|
|
* never fail, except for bugs in the glReadPixels() implementation
|
|
|
|
* in which case this is the safest course of action anyway
|
|
|
|
*/
|
2010-01-08 12:51:00 -05:00
|
|
|
if (new_cursor_actor == NULL)
|
2009-11-24 11:33:03 -05:00
|
|
|
return NULL;
|
2010-01-08 12:51:00 -05:00
|
|
|
|
|
|
|
CLUTTER_NOTE (EVENT,
|
2012-08-17 14:20:21 -04:00
|
|
|
"Actor under cursor (device %d, at %.2f, %.2f): %s",
|
2010-01-08 12:51:00 -05:00
|
|
|
clutter_input_device_get_device_id (device),
|
2012-08-17 14:20:21 -04:00
|
|
|
point.x,
|
|
|
|
point.y,
|
|
|
|
_clutter_actor_get_debug_name (new_cursor_actor));
|
2010-01-08 12:51:00 -05:00
|
|
|
|
2010-01-12 06:53:12 -05:00
|
|
|
/* short-circuit here */
|
2009-11-24 11:33:03 -05:00
|
|
|
if (new_cursor_actor == old_cursor_actor)
|
|
|
|
return old_cursor_actor;
|
|
|
|
|
2012-07-11 11:21:28 -04:00
|
|
|
_clutter_input_device_set_actor (device, sequence,
|
|
|
|
new_cursor_actor,
|
|
|
|
emit_crossing);
|
2010-01-08 12:51:00 -05:00
|
|
|
|
2012-07-11 11:21:28 -04:00
|
|
|
return new_cursor_actor;
|
2010-01-08 12:51:00 -05:00
|
|
|
}
|
2010-01-12 06:53:12 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_input_device_get_pointer_actor:
|
|
|
|
* @device: a #ClutterInputDevice of type %CLUTTER_POINTER_DEVICE
|
|
|
|
*
|
|
|
|
* Retrieves the #ClutterActor underneath the pointer of @device
|
|
|
|
*
|
|
|
|
* Return value: (transfer none): a pointer to the #ClutterActor or %NULL
|
|
|
|
*
|
|
|
|
* Since: 1.2
|
|
|
|
*/
|
|
|
|
ClutterActor *
|
|
|
|
clutter_input_device_get_pointer_actor (ClutterInputDevice *device)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), NULL);
|
|
|
|
g_return_val_if_fail (device->device_type == CLUTTER_POINTER_DEVICE, NULL);
|
|
|
|
|
|
|
|
return device->cursor_actor;
|
|
|
|
}
|
2010-01-15 06:37:43 -05:00
|
|
|
|
2010-02-17 13:21:50 -05:00
|
|
|
/**
|
|
|
|
* clutter_input_device_get_pointer_stage:
|
|
|
|
* @device: a #ClutterInputDevice of type %CLUTTER_POINTER_DEVICE
|
|
|
|
*
|
|
|
|
* Retrieves the #ClutterStage underneath the pointer of @device
|
|
|
|
*
|
|
|
|
* Return value: (transfer none): a pointer to the #ClutterStage or %NULL
|
|
|
|
*
|
|
|
|
* Since: 1.2
|
|
|
|
*/
|
|
|
|
ClutterStage *
|
|
|
|
clutter_input_device_get_pointer_stage (ClutterInputDevice *device)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), NULL);
|
|
|
|
g_return_val_if_fail (device->device_type == CLUTTER_POINTER_DEVICE, NULL);
|
|
|
|
|
|
|
|
return device->stage;
|
|
|
|
}
|
|
|
|
|
2010-01-15 06:37:43 -05:00
|
|
|
/**
|
|
|
|
* clutter_input_device_get_device_name:
|
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
*
|
|
|
|
* Retrieves the name of the @device
|
|
|
|
*
|
|
|
|
* Return value: the name of the device, or %NULL. The returned string
|
|
|
|
* is owned by the #ClutterInputDevice and should never be modified
|
|
|
|
* or freed
|
|
|
|
*
|
|
|
|
* Since: 1.2
|
|
|
|
*/
|
Eliminate G_CONST_RETURN
The G_CONST_RETURN define in GLib is, and has always been, a bit fuzzy.
We always used it to conform to the platform, at least for public-facing
API.
At first I assumed it has something to do with brain-damaged compilers
or with weird platforms where const was not really supported; sadly,
it's something much, much worse: it's a define that can be toggled at
compile-time to remove const from the signature of public API. This is a
truly terrifying feature that I assume was added in the past century,
and whose inception clearly had something to do with massive doses of
absynthe and opium — because any other explanation would make the
existence of such a feature even worse than assuming drugs had anything
to do with it.
Anyway, and pleasing the gods, this dubious feature is being
removed/deprecated in GLib; see bug:
https://bugzilla.gnome.org/show_bug.cgi?id=644611
Before deprecation, though, we should just remove its usage from the
whole API. We should especially remove its usage from Cally's internals,
since there it never made sense in the first place.
2011-06-07 10:49:20 -04:00
|
|
|
const gchar *
|
2010-01-15 06:37:43 -05:00
|
|
|
clutter_input_device_get_device_name (ClutterInputDevice *device)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), NULL);
|
|
|
|
|
|
|
|
return device->device_name;
|
|
|
|
}
|
2010-02-17 13:21:50 -05:00
|
|
|
|
2011-01-18 12:33:22 -05:00
|
|
|
/**
|
|
|
|
* clutter_input_device_get_has_cursor:
|
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
*
|
|
|
|
* Retrieves whether @device has a pointer that follows the
|
|
|
|
* device motion.
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if the device has a cursor
|
|
|
|
*
|
|
|
|
* Since: 1.6
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
clutter_input_device_get_has_cursor (ClutterInputDevice *device)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), FALSE);
|
|
|
|
|
|
|
|
return device->has_cursor;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_input_device_get_device_mode:
|
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
*
|
|
|
|
* Retrieves the #ClutterInputMode of @device.
|
|
|
|
*
|
|
|
|
* Return value: the device mode
|
|
|
|
*
|
|
|
|
* Since: 1.6
|
|
|
|
*/
|
|
|
|
ClutterInputMode
|
|
|
|
clutter_input_device_get_device_mode (ClutterInputDevice *device)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device),
|
|
|
|
CLUTTER_INPUT_MODE_FLOATING);
|
|
|
|
|
|
|
|
return device->device_mode;
|
|
|
|
}
|
|
|
|
|
2010-02-17 13:21:50 -05:00
|
|
|
/**
|
|
|
|
* clutter_input_device_update_from_event:
|
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
* @update_stage: whether to update the #ClutterStage of the @device
|
|
|
|
* using the stage of the event
|
|
|
|
*
|
|
|
|
* Forcibly updates the state of the @device using a #ClutterEvent
|
|
|
|
*
|
|
|
|
* This function should never be used by applications: it is meant
|
|
|
|
* for integration with embedding toolkits, like clutter-gtk
|
|
|
|
*
|
2010-02-18 06:34:06 -05:00
|
|
|
* Embedding toolkits that disable the event collection inside Clutter
|
|
|
|
* need to use this function to update the state of input devices depending
|
|
|
|
* on a #ClutterEvent that they are going to submit to the event handling code
|
|
|
|
* in Clutter though clutter_do_event(). Since the input devices hold the state
|
|
|
|
* that is going to be used to fill in fields like the #ClutterButtonEvent
|
|
|
|
* click count, or to emit synthesized events like %CLUTTER_ENTER and
|
|
|
|
* %CLUTTER_LEAVE, it is necessary for embedding toolkits to also be
|
|
|
|
* responsible of updating the input device state.
|
|
|
|
*
|
|
|
|
* For instance, this might be the code to translate an embedding toolkit
|
|
|
|
* native motion notification into a Clutter #ClutterMotionEvent and ask
|
|
|
|
* Clutter to process it:
|
|
|
|
*
|
|
|
|
* |[
|
|
|
|
* ClutterEvent c_event;
|
|
|
|
*
|
2014-03-17 19:07:58 -04:00
|
|
|
* translate_native_event_to_clutter (native_event, &c_event);
|
2010-02-18 06:34:06 -05:00
|
|
|
*
|
2014-03-17 19:07:58 -04:00
|
|
|
* clutter_do_event (&c_event);
|
2010-02-18 06:34:06 -05:00
|
|
|
* ]|
|
|
|
|
*
|
|
|
|
* Before letting clutter_do_event() process the event, it is necessary to call
|
|
|
|
* clutter_input_device_update_from_event():
|
|
|
|
*
|
|
|
|
* |[
|
|
|
|
* ClutterEvent c_event;
|
|
|
|
* ClutterDeviceManager *manager;
|
|
|
|
* ClutterInputDevice *device;
|
|
|
|
*
|
2014-03-17 19:07:58 -04:00
|
|
|
* translate_native_event_to_clutter (native_event, &c_event);
|
2010-02-18 06:34:06 -05:00
|
|
|
*
|
2014-03-17 19:07:58 -04:00
|
|
|
* // get the device manager
|
2010-02-18 06:34:06 -05:00
|
|
|
* manager = clutter_device_manager_get_default ();
|
|
|
|
*
|
2014-03-17 19:07:58 -04:00
|
|
|
* // use the default Core Pointer that Clutter backends register by default
|
2010-02-18 06:34:06 -05:00
|
|
|
* device = clutter_device_manager_get_core_device (manager, %CLUTTER_POINTER_DEVICE);
|
|
|
|
*
|
2014-03-17 19:07:58 -04:00
|
|
|
* // update the state of the input device
|
|
|
|
* clutter_input_device_update_from_event (device, &c_event, FALSE);
|
2010-02-18 06:34:06 -05:00
|
|
|
*
|
2014-03-17 19:07:58 -04:00
|
|
|
* clutter_do_event (&c_event);
|
2010-02-18 06:34:06 -05:00
|
|
|
* ]|
|
|
|
|
*
|
|
|
|
* The @update_stage boolean argument should be used when the input device
|
|
|
|
* enters and leaves a #ClutterStage; it will use the #ClutterStage field
|
|
|
|
* of the passed @event to update the stage associated to the input device.
|
|
|
|
*
|
2010-02-17 13:21:50 -05:00
|
|
|
* Since: 1.2
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_input_device_update_from_event (ClutterInputDevice *device,
|
|
|
|
ClutterEvent *event,
|
|
|
|
gboolean update_stage)
|
|
|
|
{
|
|
|
|
ClutterModifierType event_state;
|
2012-07-11 11:21:28 -04:00
|
|
|
ClutterEventSequence *sequence;
|
2010-02-17 13:21:50 -05:00
|
|
|
ClutterStage *event_stage;
|
|
|
|
gfloat event_x, event_y;
|
|
|
|
guint32 event_time;
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_INPUT_DEVICE (device));
|
|
|
|
g_return_if_fail (event != NULL);
|
|
|
|
|
|
|
|
event_state = clutter_event_get_state (event);
|
|
|
|
event_time = clutter_event_get_time (event);
|
|
|
|
event_stage = clutter_event_get_stage (event);
|
2012-07-11 11:21:28 -04:00
|
|
|
sequence = clutter_event_get_event_sequence (event);
|
2010-02-17 13:21:50 -05:00
|
|
|
clutter_event_get_coords (event, &event_x, &event_y);
|
|
|
|
|
2012-08-21 10:26:30 -04:00
|
|
|
_clutter_input_device_set_coords (device, sequence, event_x, event_y, event_stage);
|
2010-02-17 13:21:50 -05:00
|
|
|
_clutter_input_device_set_state (device, event_state);
|
|
|
|
_clutter_input_device_set_time (device, event_time);
|
|
|
|
|
|
|
|
if (update_stage)
|
|
|
|
_clutter_input_device_set_stage (device, event_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 07:32:04 -05:00
|
|
|
|
2011-01-19 12:03:27 -05:00
|
|
|
/*< private >
|
|
|
|
* clutter_input_device_reset_axes:
|
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
*
|
|
|
|
* Resets the axes on @device
|
|
|
|
*/
|
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 07:32:04 -05:00
|
|
|
void
|
|
|
|
_clutter_input_device_reset_axes (ClutterInputDevice *device)
|
|
|
|
{
|
|
|
|
if (device->axes != NULL)
|
|
|
|
{
|
|
|
|
g_array_free (device->axes, TRUE);
|
2011-01-21 09:12:19 -05:00
|
|
|
device->axes = NULL;
|
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 07:32:04 -05:00
|
|
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (device), obj_props[PROP_N_AXES]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-19 12:03:27 -05:00
|
|
|
/*< private >
|
|
|
|
* clutter_input_device_add_axis:
|
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
* @axis: the axis type
|
|
|
|
* @minimum: the minimum axis value
|
|
|
|
* @maximum: the maximum axis value
|
|
|
|
* @resolution: the axis resolution
|
|
|
|
*
|
|
|
|
* Adds an axis of type @axis on @device.
|
|
|
|
*/
|
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 07:32:04 -05:00
|
|
|
guint
|
|
|
|
_clutter_input_device_add_axis (ClutterInputDevice *device,
|
|
|
|
ClutterInputAxis axis,
|
|
|
|
gdouble minimum,
|
|
|
|
gdouble maximum,
|
|
|
|
gdouble resolution)
|
|
|
|
{
|
|
|
|
ClutterAxisInfo info;
|
|
|
|
guint pos;
|
|
|
|
|
|
|
|
if (device->axes == NULL)
|
|
|
|
device->axes = g_array_new (FALSE, TRUE, sizeof (ClutterAxisInfo));
|
|
|
|
|
|
|
|
info.axis = axis;
|
|
|
|
info.min_value = minimum;
|
|
|
|
info.max_value = maximum;
|
|
|
|
info.resolution = resolution;
|
|
|
|
|
|
|
|
switch (axis)
|
|
|
|
{
|
|
|
|
case CLUTTER_INPUT_AXIS_X:
|
|
|
|
case CLUTTER_INPUT_AXIS_Y:
|
|
|
|
info.min_axis = 0;
|
|
|
|
info.max_axis = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_INPUT_AXIS_XTILT:
|
|
|
|
case CLUTTER_INPUT_AXIS_YTILT:
|
|
|
|
info.min_axis = -1;
|
|
|
|
info.max_axis = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
info.min_axis = 0;
|
|
|
|
info.max_axis = 1;
|
2011-01-21 09:12:19 -05:00
|
|
|
break;
|
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 07:32:04 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
device->axes = g_array_append_val (device->axes, info);
|
|
|
|
pos = device->axes->len - 1;
|
|
|
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (device), obj_props[PROP_N_AXES]);
|
|
|
|
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
2011-01-19 08:53:20 -05:00
|
|
|
/*< private >
|
|
|
|
* clutter_input_translate_axis:
|
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
* @index_: the index of the axis
|
|
|
|
* @gint: the absolute value of the axis
|
|
|
|
* @axis_value: (out): the translated value of the axis
|
|
|
|
*
|
|
|
|
* Performs a conversion from the absolute value of the axis
|
|
|
|
* to a relative value.
|
|
|
|
*
|
|
|
|
* The axis at @index_ must not be %CLUTTER_INPUT_AXIS_X or
|
|
|
|
* %CLUTTER_INPUT_AXIS_Y.
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if the conversion was successful
|
|
|
|
*/
|
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 07:32:04 -05:00
|
|
|
gboolean
|
|
|
|
_clutter_input_device_translate_axis (ClutterInputDevice *device,
|
|
|
|
guint index_,
|
2011-01-19 08:53:20 -05:00
|
|
|
gdouble value,
|
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 07:32:04 -05:00
|
|
|
gdouble *axis_value)
|
|
|
|
{
|
|
|
|
ClutterAxisInfo *info;
|
|
|
|
gdouble width;
|
|
|
|
gdouble real_value;
|
|
|
|
|
|
|
|
if (device->axes == NULL || index_ >= device->axes->len)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
info = &g_array_index (device->axes, ClutterAxisInfo, index_);
|
|
|
|
|
|
|
|
if (info->axis == CLUTTER_INPUT_AXIS_X ||
|
|
|
|
info->axis == CLUTTER_INPUT_AXIS_Y)
|
|
|
|
return FALSE;
|
|
|
|
|
2013-09-03 06:51:19 -04:00
|
|
|
if (fabs (info->max_value - info->min_value) < 0.0000001)
|
|
|
|
return FALSE;
|
|
|
|
|
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 07:32:04 -05:00
|
|
|
width = info->max_value - info->min_value;
|
|
|
|
real_value = (info->max_axis * (value - info->min_value)
|
|
|
|
+ info->min_axis * (info->max_value - value))
|
|
|
|
/ width;
|
|
|
|
|
|
|
|
if (axis_value)
|
|
|
|
*axis_value = real_value;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-01-18 11:13:26 -05:00
|
|
|
/**
|
|
|
|
* clutter_input_device_get_axis:
|
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
* @index_: the index of the axis
|
|
|
|
*
|
|
|
|
* Retrieves the type of axis on @device at the given index.
|
|
|
|
*
|
|
|
|
* Return value: the axis type
|
|
|
|
*
|
|
|
|
* Since: 1.6
|
|
|
|
*/
|
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 07:32:04 -05:00
|
|
|
ClutterInputAxis
|
2011-01-18 11:13:26 -05:00
|
|
|
clutter_input_device_get_axis (ClutterInputDevice *device,
|
|
|
|
guint index_)
|
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 07:32:04 -05:00
|
|
|
{
|
|
|
|
ClutterAxisInfo *info;
|
|
|
|
|
2011-01-18 11:55:14 -05:00
|
|
|
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device),
|
|
|
|
CLUTTER_INPUT_AXIS_IGNORE);
|
|
|
|
|
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 07:32:04 -05:00
|
|
|
if (device->axes == NULL)
|
|
|
|
return CLUTTER_INPUT_AXIS_IGNORE;
|
|
|
|
|
|
|
|
if (index_ >= device->axes->len)
|
|
|
|
return CLUTTER_INPUT_AXIS_IGNORE;
|
|
|
|
|
|
|
|
info = &g_array_index (device->axes, ClutterAxisInfo, index_);
|
|
|
|
|
|
|
|
return info->axis;
|
|
|
|
}
|
|
|
|
|
2011-01-18 11:55:14 -05:00
|
|
|
/**
|
|
|
|
* clutter_input_device_get_axis_value:
|
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
* @axes: (array): an array of axes values, typically
|
|
|
|
* coming from clutter_event_get_axes()
|
|
|
|
* @axis: the axis to extract
|
|
|
|
* @value: (out): return location for the axis value
|
|
|
|
*
|
|
|
|
* Extracts the value of the given @axis of a #ClutterInputDevice from
|
|
|
|
* an array of axis values.
|
|
|
|
*
|
2011-01-19 08:54:27 -05:00
|
|
|
* An example of typical usage for this function is:
|
|
|
|
*
|
|
|
|
* |[
|
|
|
|
* ClutterInputDevice *device = clutter_event_get_device (event);
|
|
|
|
* gdouble *axes = clutter_event_get_axes (event, NULL);
|
|
|
|
* gdouble pressure_value = 0;
|
|
|
|
*
|
|
|
|
* clutter_input_device_get_axis_value (device, axes,
|
|
|
|
* CLUTTER_INPUT_AXIS_PRESSURE,
|
2014-03-17 19:07:58 -04:00
|
|
|
* &pressure_value);
|
2011-01-19 08:54:27 -05:00
|
|
|
* ]|
|
|
|
|
*
|
2011-01-18 11:55:14 -05:00
|
|
|
* Return value: %TRUE if the value was set, and %FALSE otherwise
|
|
|
|
*
|
|
|
|
* Since: 1.6
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
clutter_input_device_get_axis_value (ClutterInputDevice *device,
|
|
|
|
gdouble *axes,
|
|
|
|
ClutterInputAxis axis,
|
|
|
|
gdouble *value)
|
|
|
|
{
|
|
|
|
gint i;
|
|
|
|
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), FALSE);
|
|
|
|
g_return_val_if_fail (device->axes != NULL, FALSE);
|
|
|
|
|
|
|
|
for (i = 0; i < device->axes->len; i++)
|
|
|
|
{
|
|
|
|
ClutterAxisInfo *info;
|
|
|
|
|
|
|
|
info = &g_array_index (device->axes, ClutterAxisInfo, i);
|
|
|
|
|
|
|
|
if (info->axis == axis)
|
|
|
|
{
|
|
|
|
if (value)
|
|
|
|
*value = axes[i];
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-01-18 09:09:04 -05:00
|
|
|
/**
|
|
|
|
* clutter_input_device_get_n_axes:
|
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
*
|
|
|
|
* Retrieves the number of axes available on @device.
|
|
|
|
*
|
|
|
|
* Return value: the number of axes on the device
|
|
|
|
*
|
|
|
|
* Since: 1.6
|
|
|
|
*/
|
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 07:32:04 -05:00
|
|
|
guint
|
|
|
|
clutter_input_device_get_n_axes (ClutterInputDevice *device)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), 0);
|
|
|
|
|
|
|
|
if (device->axes != NULL)
|
|
|
|
return device->axes->len;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-01-19 12:03:27 -05:00
|
|
|
/*< private >
|
2011-01-21 05:24:34 -05:00
|
|
|
* clutter_input_device_set_n_keys:
|
2011-01-19 12:03:27 -05:00
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
* @n_keys: the number of keys of the device
|
|
|
|
*
|
|
|
|
* Initializes the keys of @device.
|
|
|
|
*
|
|
|
|
* Call clutter_input_device_set_key() on each key to set the keyval
|
|
|
|
* and modifiers.
|
|
|
|
*/
|
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 07:32:04 -05:00
|
|
|
void
|
2011-01-21 05:24:34 -05:00
|
|
|
_clutter_input_device_set_n_keys (ClutterInputDevice *device,
|
|
|
|
guint n_keys)
|
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 07:32:04 -05:00
|
|
|
{
|
|
|
|
if (device->keys != NULL)
|
|
|
|
g_array_free (device->keys, TRUE);
|
|
|
|
|
|
|
|
device->n_keys = n_keys;
|
|
|
|
device->keys = g_array_sized_new (FALSE, TRUE,
|
|
|
|
sizeof (ClutterKeyInfo),
|
|
|
|
n_keys);
|
|
|
|
}
|
|
|
|
|
2011-01-18 11:13:26 -05:00
|
|
|
/**
|
|
|
|
* clutter_input_device_get_n_keys:
|
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
*
|
|
|
|
* Retrieves the number of keys registered for @device.
|
|
|
|
*
|
|
|
|
* Return value: the number of registered keys
|
|
|
|
*
|
|
|
|
* Since: 1.6
|
|
|
|
*/
|
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 07:32:04 -05:00
|
|
|
guint
|
|
|
|
clutter_input_device_get_n_keys (ClutterInputDevice *device)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), 0);
|
|
|
|
|
2011-01-18 11:13:26 -05:00
|
|
|
return device->n_keys;
|
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 07:32:04 -05:00
|
|
|
}
|
|
|
|
|
2011-01-18 09:09:04 -05:00
|
|
|
/**
|
|
|
|
* clutter_input_device_set_key:
|
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
* @index_: the index of the key
|
|
|
|
* @keyval: the keyval
|
|
|
|
* @modifiers: a bitmask of modifiers
|
|
|
|
*
|
|
|
|
* Sets the keyval and modifiers at the given @index_ for @device.
|
|
|
|
*
|
|
|
|
* Clutter will use the keyval and modifiers set when filling out
|
|
|
|
* an event coming from the same input device.
|
|
|
|
*
|
|
|
|
* Since: 1.6
|
|
|
|
*/
|
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 07:32:04 -05:00
|
|
|
void
|
|
|
|
clutter_input_device_set_key (ClutterInputDevice *device,
|
|
|
|
guint index_,
|
|
|
|
guint keyval,
|
|
|
|
ClutterModifierType modifiers)
|
|
|
|
{
|
|
|
|
ClutterKeyInfo *key_info;
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_INPUT_DEVICE (device));
|
|
|
|
g_return_if_fail (index_ < device->n_keys);
|
|
|
|
|
|
|
|
key_info = &g_array_index (device->keys, ClutterKeyInfo, index_);
|
|
|
|
key_info->keyval = keyval;
|
|
|
|
key_info->modifiers = modifiers;
|
|
|
|
}
|
|
|
|
|
2011-01-18 09:09:04 -05:00
|
|
|
/**
|
|
|
|
* clutter_input_device_get_key:
|
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
* @index_: the index of the key
|
|
|
|
* @keyval: (out): return location for the keyval at @index_
|
|
|
|
* @modifiers: (out): return location for the modifiers at @index_
|
|
|
|
*
|
|
|
|
* Retrieves the key set using clutter_input_device_set_key()
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if a key was set at the given index
|
|
|
|
*
|
|
|
|
* Since: 1.6
|
|
|
|
*/
|
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 07:32:04 -05:00
|
|
|
gboolean
|
|
|
|
clutter_input_device_get_key (ClutterInputDevice *device,
|
|
|
|
guint index_,
|
|
|
|
guint *keyval,
|
|
|
|
ClutterModifierType *modifiers)
|
|
|
|
{
|
|
|
|
ClutterKeyInfo *key_info;
|
|
|
|
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), FALSE);
|
|
|
|
|
|
|
|
if (device->keys == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (index_ > device->keys->len)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
key_info = &g_array_index (device->keys, ClutterKeyInfo, index_);
|
|
|
|
|
|
|
|
if (!key_info->keyval && !key_info->modifiers)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (keyval)
|
|
|
|
*keyval = key_info->keyval;
|
|
|
|
|
|
|
|
if (modifiers)
|
|
|
|
*modifiers = key_info->modifiers;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-01-19 08:54:27 -05:00
|
|
|
/*< private >
|
|
|
|
* clutter_input_device_add_slave:
|
|
|
|
* @master: a #ClutterInputDevice
|
|
|
|
* @slave: a #ClutterInputDevice
|
|
|
|
*
|
|
|
|
* Adds @slave to the list of slave devices of @master
|
|
|
|
*
|
|
|
|
* This function does not increase the reference count of either @master
|
|
|
|
* or @slave.
|
|
|
|
*/
|
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 07:32:04 -05:00
|
|
|
void
|
|
|
|
_clutter_input_device_add_slave (ClutterInputDevice *master,
|
|
|
|
ClutterInputDevice *slave)
|
|
|
|
{
|
|
|
|
if (g_list_find (master->slaves, slave) == NULL)
|
|
|
|
master->slaves = g_list_prepend (master->slaves, slave);
|
|
|
|
}
|
|
|
|
|
2011-01-19 08:54:27 -05:00
|
|
|
/*< private >
|
|
|
|
* clutter_input_device_remove_slave:
|
|
|
|
* @master: a #ClutterInputDevice
|
|
|
|
* @slave: a #ClutterInputDevice
|
|
|
|
*
|
|
|
|
* Removes @slave from the list of slave devices of @master.
|
|
|
|
*
|
|
|
|
* This function does not decrease the reference count of either @master
|
|
|
|
* or @slave.
|
|
|
|
*/
|
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 07:32:04 -05:00
|
|
|
void
|
|
|
|
_clutter_input_device_remove_slave (ClutterInputDevice *master,
|
|
|
|
ClutterInputDevice *slave)
|
|
|
|
{
|
|
|
|
if (g_list_find (master->slaves, slave) != NULL)
|
|
|
|
master->slaves = g_list_remove (master->slaves, slave);
|
|
|
|
}
|
|
|
|
|
2012-07-11 11:21:28 -04:00
|
|
|
/*< private >
|
|
|
|
* clutter_input_device_add_sequence:
|
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
* @sequence: a #ClutterEventSequence
|
|
|
|
*
|
|
|
|
* Start tracking informations related to a touch point (position,
|
|
|
|
* actor underneath the touch point).
|
|
|
|
*/
|
|
|
|
void
|
2012-08-21 10:26:30 -04:00
|
|
|
_clutter_input_device_add_event_sequence (ClutterInputDevice *device,
|
|
|
|
ClutterEvent *event)
|
2012-07-11 11:21:28 -04:00
|
|
|
{
|
2012-08-21 10:26:30 -04:00
|
|
|
ClutterEventSequence *sequence = clutter_event_get_event_sequence (event);
|
|
|
|
ClutterStage *stage;
|
2012-07-11 11:21:28 -04:00
|
|
|
|
|
|
|
if (sequence == NULL)
|
|
|
|
return;
|
|
|
|
|
2012-08-21 10:26:30 -04:00
|
|
|
stage = clutter_event_get_stage (event);
|
|
|
|
if (stage == NULL)
|
2012-07-11 11:21:28 -04:00
|
|
|
return;
|
|
|
|
|
2012-08-21 10:26:30 -04:00
|
|
|
_clutter_input_device_ensure_touch_info (device, sequence, stage);
|
2012-07-11 11:21:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*< private >
|
|
|
|
* clutter_input_device_remove_sequence:
|
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
* @sequence: a #ClutterEventSequence
|
|
|
|
*
|
|
|
|
* Stop tracking informations related to a touch point.
|
|
|
|
*/
|
|
|
|
void
|
2012-08-21 10:26:30 -04:00
|
|
|
_clutter_input_device_remove_event_sequence (ClutterInputDevice *device,
|
|
|
|
ClutterEvent *event)
|
2012-07-11 11:21:28 -04:00
|
|
|
{
|
2012-08-21 10:26:30 -04:00
|
|
|
ClutterEventSequence *sequence = clutter_event_get_event_sequence (event);
|
2012-07-11 11:21:28 -04:00
|
|
|
ClutterTouchInfo *info =
|
|
|
|
g_hash_table_lookup (device->touch_sequences_info, sequence);
|
|
|
|
|
|
|
|
if (info == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (info->actor != NULL)
|
|
|
|
{
|
|
|
|
GList *sequences =
|
|
|
|
g_hash_table_lookup (device->inv_touch_sequence_actors, info->actor);
|
|
|
|
|
|
|
|
sequences = g_list_remove (sequences, sequence);
|
|
|
|
|
|
|
|
g_hash_table_replace (device->inv_touch_sequence_actors,
|
|
|
|
info->actor, sequences);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_hash_table_remove (device->touch_sequences_info, sequence);
|
2012-08-21 10:26:30 -04:00
|
|
|
|
|
|
|
if (g_hash_table_size (device->touch_sequences_info) == 0)
|
|
|
|
_clutter_input_device_set_stage (device, NULL);
|
2012-07-11 11:21:28 -04:00
|
|
|
}
|
|
|
|
|
2011-01-18 07:57:12 -05:00
|
|
|
/**
|
|
|
|
* clutter_input_device_get_slave_devices:
|
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
*
|
|
|
|
* Retrieves the slave devices attached to @device.
|
|
|
|
*
|
|
|
|
* Return value: (transfer container) (element-type Clutter.InputDevice): a
|
|
|
|
* list of #ClutterInputDevice, or %NULL. The contents of the list are
|
|
|
|
* owned by the device. Use g_list_free() when done
|
|
|
|
*
|
|
|
|
* Since: 1.6
|
|
|
|
*/
|
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 07:32:04 -05:00
|
|
|
GList *
|
|
|
|
clutter_input_device_get_slave_devices (ClutterInputDevice *device)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), NULL);
|
|
|
|
|
|
|
|
return g_list_copy (device->slaves);
|
|
|
|
}
|
|
|
|
|
2011-01-18 07:57:12 -05:00
|
|
|
/*< internal >
|
|
|
|
* clutter_input_device_set_associated_device:
|
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
* @associated: (allow-none): a #ClutterInputDevice, or %NULL
|
|
|
|
*
|
|
|
|
* Sets the associated device for @device.
|
|
|
|
*
|
|
|
|
* This function keeps a reference on the associated device.
|
|
|
|
*/
|
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 07:32:04 -05:00
|
|
|
void
|
|
|
|
_clutter_input_device_set_associated_device (ClutterInputDevice *device,
|
|
|
|
ClutterInputDevice *associated)
|
|
|
|
{
|
|
|
|
if (device->associated == associated)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (device->associated != NULL)
|
|
|
|
g_object_unref (device->associated);
|
|
|
|
|
|
|
|
device->associated = associated;
|
|
|
|
if (device->associated != NULL)
|
|
|
|
g_object_ref (device->associated);
|
|
|
|
|
2012-09-21 04:05:59 -04:00
|
|
|
CLUTTER_NOTE (MISC, "Associating device %d '%s' to device %d '%s'",
|
|
|
|
clutter_input_device_get_device_id (device),
|
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 07:32:04 -05:00
|
|
|
clutter_input_device_get_device_name (device),
|
2012-09-21 04:05:59 -04:00
|
|
|
device->associated != NULL
|
|
|
|
? clutter_input_device_get_device_id (device->associated)
|
|
|
|
: -1,
|
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 07:32:04 -05:00
|
|
|
device->associated != NULL
|
|
|
|
? clutter_input_device_get_device_name (device->associated)
|
|
|
|
: "(none)");
|
|
|
|
|
|
|
|
if (device->device_mode != CLUTTER_INPUT_MODE_MASTER)
|
|
|
|
{
|
|
|
|
if (device->associated != NULL)
|
|
|
|
device->device_mode = CLUTTER_INPUT_MODE_SLAVE;
|
|
|
|
else
|
|
|
|
device->device_mode = CLUTTER_INPUT_MODE_FLOATING;
|
|
|
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (device), obj_props[PROP_DEVICE_MODE]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-18 07:57:12 -05:00
|
|
|
/**
|
|
|
|
* clutter_input_device_get_associated_device:
|
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
*
|
|
|
|
* Retrieves a pointer to the #ClutterInputDevice that has been
|
|
|
|
* associated to @device.
|
|
|
|
*
|
|
|
|
* If the #ClutterInputDevice:device-mode property of @device is
|
|
|
|
* set to %CLUTTER_INPUT_MODE_MASTER, this function will return
|
|
|
|
* %NULL.
|
|
|
|
*
|
|
|
|
* Return value: (transfer none): a #ClutterInputDevice, or %NULL
|
|
|
|
*
|
|
|
|
* Since: 1.6
|
|
|
|
*/
|
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 07:32:04 -05:00
|
|
|
ClutterInputDevice *
|
|
|
|
clutter_input_device_get_associated_device (ClutterInputDevice *device)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), NULL);
|
|
|
|
|
|
|
|
return device->associated;
|
|
|
|
}
|
|
|
|
|
2012-01-17 10:40:08 -05:00
|
|
|
/**
|
|
|
|
* clutter_input_device_keycode_to_evdev:
|
|
|
|
* @device: A #ClutterInputDevice
|
|
|
|
* @hardware_keycode: The hardware keycode from a #ClutterKeyEvent
|
|
|
|
* @evdev_keycode: The return location for the evdev keycode
|
|
|
|
*
|
|
|
|
* Translates a hardware keycode from a #ClutterKeyEvent to the
|
|
|
|
* equivalent evdev keycode. Note that depending on the input backend
|
|
|
|
* used by Clutter this function can fail if there is no obvious
|
|
|
|
* mapping between the key codes. The hardware keycode can be taken
|
2012-03-01 10:11:59 -05:00
|
|
|
* from the #ClutterKeyEvent.hardware_keycode member of #ClutterKeyEvent.
|
2012-01-17 10:40:08 -05:00
|
|
|
*
|
|
|
|
* Return value: %TRUE if the conversion succeeded, %FALSE otherwise.
|
2012-03-01 10:11:59 -05:00
|
|
|
*
|
2012-01-17 10:40:08 -05:00
|
|
|
* Since: 1.10
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
clutter_input_device_keycode_to_evdev (ClutterInputDevice *device,
|
|
|
|
guint hardware_keycode,
|
|
|
|
guint *evdev_keycode)
|
|
|
|
{
|
|
|
|
ClutterInputDeviceClass *device_class;
|
|
|
|
|
2012-03-01 10:11:59 -05:00
|
|
|
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), FALSE);
|
|
|
|
|
2012-01-17 10:40:08 -05:00
|
|
|
device_class = CLUTTER_INPUT_DEVICE_GET_CLASS (device);
|
|
|
|
if (device_class->keycode_to_evdev == NULL)
|
|
|
|
return FALSE;
|
|
|
|
else
|
|
|
|
return device_class->keycode_to_evdev (device,
|
|
|
|
hardware_keycode,
|
|
|
|
evdev_keycode);
|
|
|
|
}
|
2012-03-19 08:16:53 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
_clutter_input_device_add_scroll_info (ClutterInputDevice *device,
|
|
|
|
guint index_,
|
|
|
|
ClutterScrollDirection direction,
|
|
|
|
gdouble increment)
|
|
|
|
{
|
|
|
|
ClutterScrollInfo info;
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_INPUT_DEVICE (device));
|
|
|
|
g_return_if_fail (index_ < clutter_input_device_get_n_axes (device));
|
|
|
|
|
|
|
|
info.axis_id = index_;
|
|
|
|
info.direction = direction;
|
|
|
|
info.increment = increment;
|
|
|
|
info.last_value_valid = FALSE;
|
|
|
|
|
|
|
|
if (device->scroll_info == NULL)
|
|
|
|
{
|
|
|
|
device->scroll_info = g_array_new (FALSE,
|
|
|
|
FALSE,
|
|
|
|
sizeof (ClutterScrollInfo));
|
|
|
|
}
|
|
|
|
|
|
|
|
g_array_append_val (device->scroll_info, info);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
_clutter_input_device_get_scroll_delta (ClutterInputDevice *device,
|
|
|
|
guint index_,
|
|
|
|
gdouble value,
|
|
|
|
ClutterScrollDirection *direction_p,
|
|
|
|
gdouble *delta_p)
|
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), FALSE);
|
|
|
|
g_return_val_if_fail (index_ < clutter_input_device_get_n_axes (device), FALSE);
|
|
|
|
|
|
|
|
if (device->scroll_info == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
for (i = 0; i < device->scroll_info->len; i++)
|
|
|
|
{
|
|
|
|
ClutterScrollInfo *info = &g_array_index (device->scroll_info,
|
|
|
|
ClutterScrollInfo,
|
|
|
|
i);
|
|
|
|
|
|
|
|
if (info->axis_id == index_)
|
|
|
|
{
|
|
|
|
if (direction_p != NULL)
|
|
|
|
*direction_p = info->direction;
|
|
|
|
|
|
|
|
if (delta_p != NULL)
|
|
|
|
*delta_p = 0.0;
|
|
|
|
|
|
|
|
if (info->last_value_valid)
|
|
|
|
{
|
|
|
|
if (delta_p != NULL)
|
|
|
|
{
|
|
|
|
*delta_p = (value - info->last_value)
|
|
|
|
/ info->increment;
|
|
|
|
}
|
|
|
|
|
|
|
|
info->last_value = value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
info->last_value = value;
|
|
|
|
info->last_value_valid = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_clutter_input_device_reset_scroll_info (ClutterInputDevice *device)
|
|
|
|
{
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
if (device->scroll_info == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < device->scroll_info->len; i++)
|
|
|
|
{
|
|
|
|
ClutterScrollInfo *info = &g_array_index (device->scroll_info,
|
|
|
|
ClutterScrollInfo,
|
|
|
|
i);
|
|
|
|
|
|
|
|
info->last_value_valid = FALSE;
|
|
|
|
}
|
|
|
|
}
|
2012-06-16 19:44:44 -04:00
|
|
|
|
|
|
|
static void
|
|
|
|
on_grab_sequence_actor_destroy (ClutterActor *actor,
|
|
|
|
ClutterInputDevice *device)
|
|
|
|
{
|
|
|
|
ClutterEventSequence *sequence =
|
|
|
|
g_hash_table_lookup (device->inv_sequence_grab_actors, actor);
|
|
|
|
|
|
|
|
if (sequence != NULL)
|
|
|
|
{
|
|
|
|
g_hash_table_remove (device->sequence_grab_actors, sequence);
|
|
|
|
g_hash_table_remove (device->inv_sequence_grab_actors, actor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_input_device_sequence_grab:
|
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
* @sequence: a #ClutterEventSequence
|
|
|
|
* @actor: a #ClutterActor
|
|
|
|
*
|
|
|
|
* Acquires a grab on @actor for the given @device and the given touch
|
|
|
|
* @sequence.
|
|
|
|
*
|
|
|
|
* Any touch event coming from @device and from @sequence will be
|
|
|
|
* delivered to @actor, bypassing the usual event delivery mechanism,
|
|
|
|
* until the grab is released by calling
|
|
|
|
* clutter_input_device_sequence_ungrab().
|
|
|
|
*
|
|
|
|
* The grab is client-side: even if the windowing system used by the Clutter
|
|
|
|
* backend has the concept of "device grabs", Clutter will not use them.
|
|
|
|
*
|
|
|
|
* Since: 1.12
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_input_device_sequence_grab (ClutterInputDevice *device,
|
|
|
|
ClutterEventSequence *sequence,
|
|
|
|
ClutterActor *actor)
|
|
|
|
{
|
|
|
|
ClutterActor *grab_actor;
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_INPUT_DEVICE (device));
|
|
|
|
g_return_if_fail (CLUTTER_IS_ACTOR (actor));
|
|
|
|
|
|
|
|
if (device->sequence_grab_actors == NULL)
|
|
|
|
{
|
|
|
|
grab_actor = NULL;
|
|
|
|
device->sequence_grab_actors = g_hash_table_new (NULL, NULL);
|
|
|
|
device->inv_sequence_grab_actors = g_hash_table_new (NULL, NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
grab_actor = g_hash_table_lookup (device->sequence_grab_actors, sequence);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (grab_actor != NULL)
|
|
|
|
{
|
|
|
|
g_signal_handlers_disconnect_by_func (grab_actor,
|
|
|
|
G_CALLBACK (on_grab_sequence_actor_destroy),
|
|
|
|
device);
|
|
|
|
g_hash_table_remove (device->sequence_grab_actors, sequence);
|
|
|
|
g_hash_table_remove (device->inv_sequence_grab_actors, grab_actor);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_hash_table_insert (device->sequence_grab_actors, sequence, actor);
|
|
|
|
g_hash_table_insert (device->inv_sequence_grab_actors, actor, sequence);
|
2012-07-18 15:41:59 -04:00
|
|
|
g_signal_connect (actor,
|
2012-06-16 19:44:44 -04:00
|
|
|
"destroy",
|
|
|
|
G_CALLBACK (on_grab_sequence_actor_destroy),
|
|
|
|
device);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_input_device_sequence_ungrab:
|
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
* @sequence: a #ClutterEventSequence
|
|
|
|
*
|
|
|
|
* Releases the grab on the @device for the given @sequence, if one is
|
|
|
|
* in place.
|
|
|
|
*
|
|
|
|
* Since: 1.12
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_input_device_sequence_ungrab (ClutterInputDevice *device,
|
|
|
|
ClutterEventSequence *sequence)
|
|
|
|
{
|
|
|
|
ClutterActor *grab_actor;
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_INPUT_DEVICE (device));
|
|
|
|
|
|
|
|
if (device->sequence_grab_actors == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
grab_actor = g_hash_table_lookup (device->sequence_grab_actors, sequence);
|
|
|
|
|
|
|
|
if (grab_actor == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_signal_handlers_disconnect_by_func (grab_actor,
|
|
|
|
G_CALLBACK (on_grab_sequence_actor_destroy),
|
|
|
|
device);
|
|
|
|
g_hash_table_remove (device->sequence_grab_actors, sequence);
|
|
|
|
g_hash_table_remove (device->inv_sequence_grab_actors, grab_actor);
|
|
|
|
|
|
|
|
if (g_hash_table_size (device->sequence_grab_actors) == 0)
|
|
|
|
{
|
|
|
|
g_hash_table_destroy (device->sequence_grab_actors);
|
|
|
|
device->sequence_grab_actors = NULL;
|
|
|
|
g_hash_table_destroy (device->inv_sequence_grab_actors);
|
|
|
|
device->inv_sequence_grab_actors = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_input_device_sequence_get_grabbed_actor:
|
|
|
|
* @device: a #ClutterInputDevice
|
|
|
|
* @sequence: a #ClutterEventSequence
|
|
|
|
*
|
|
|
|
* Retrieves a pointer to the #ClutterActor currently grabbing the
|
|
|
|
* touch events coming from @device given the @sequence.
|
|
|
|
*
|
|
|
|
* Return value: (transfer none): a #ClutterActor, or %NULL
|
|
|
|
*
|
|
|
|
* Since: 1.12
|
|
|
|
*/
|
|
|
|
ClutterActor *
|
|
|
|
clutter_input_device_sequence_get_grabbed_actor (ClutterInputDevice *device,
|
|
|
|
ClutterEventSequence *sequence)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), NULL);
|
|
|
|
|
|
|
|
if (device->sequence_grab_actors == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return g_hash_table_lookup (device->sequence_grab_actors, sequence);
|
|
|
|
}
|