2011-01-18 13:05:17 +00:00
|
|
|
/*
|
|
|
|
* Clutter.
|
|
|
|
*
|
|
|
|
* An OpenGL based 'interactive canvas' library.
|
|
|
|
*
|
|
|
|
* Copyright © 2011 Intel Corp.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Author: Emmanuele Bassi <ebassi@linux.intel.com>
|
|
|
|
*/
|
|
|
|
|
2016-05-05 22:21:51 +08:00
|
|
|
#include "clutter-build-config.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 12:32:04 +00:00
|
|
|
|
|
|
|
#include "clutter-input-device-xi2.h"
|
|
|
|
|
|
|
|
#include "clutter-debug.h"
|
|
|
|
#include "clutter-device-manager-private.h"
|
2013-09-04 14:42:56 +02: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 12:32:04 +00:00
|
|
|
#include "clutter-private.h"
|
|
|
|
#include "clutter-stage-private.h"
|
|
|
|
|
|
|
|
#include "clutter-backend-x11.h"
|
|
|
|
#include "clutter-stage-x11.h"
|
|
|
|
|
|
|
|
#include <X11/extensions/XInput2.h>
|
|
|
|
|
|
|
|
typedef struct _ClutterInputDeviceClass ClutterInputDeviceXI2Class;
|
|
|
|
|
|
|
|
/* a specific XI2 input device */
|
|
|
|
struct _ClutterInputDeviceXI2
|
|
|
|
{
|
|
|
|
ClutterInputDevice device;
|
|
|
|
|
|
|
|
gint device_id;
|
2016-10-31 18:05:23 +01:00
|
|
|
ClutterInputDeviceTool *current_tool;
|
2018-02-22 17:48:17 +01:00
|
|
|
|
2019-03-14 14:12:34 +01:00
|
|
|
guint inhibit_pointer_query_timer;
|
|
|
|
gboolean query_status;
|
|
|
|
float current_x;
|
|
|
|
float current_y;
|
|
|
|
|
2018-02-22 17:48:17 +01:00
|
|
|
#ifdef HAVE_LIBWACOM
|
|
|
|
WacomDevice *wacom_device;
|
2018-02-22 17:50:42 +01:00
|
|
|
GArray *group_modes;
|
2018-02-22 17:48:17 +01:00
|
|
|
#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 12:32:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define N_BUTTONS 5
|
|
|
|
|
|
|
|
#define clutter_input_device_xi2_get_type _clutter_input_device_xi2_get_type
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (ClutterInputDeviceXI2,
|
|
|
|
clutter_input_device_xi2,
|
|
|
|
CLUTTER_TYPE_INPUT_DEVICE);
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_input_device_xi2_constructed (GObject *gobject)
|
|
|
|
{
|
|
|
|
ClutterInputDeviceXI2 *device_xi2 = CLUTTER_INPUT_DEVICE_XI2 (gobject);
|
|
|
|
|
|
|
|
g_object_get (gobject, "id", &device_xi2->device_id, NULL);
|
|
|
|
|
|
|
|
if (G_OBJECT_CLASS (clutter_input_device_xi2_parent_class)->constructed)
|
|
|
|
G_OBJECT_CLASS (clutter_input_device_xi2_parent_class)->constructed (gobject);
|
2018-02-22 17:50:42 +01:00
|
|
|
|
|
|
|
#ifdef HAVE_LIBWACOM
|
|
|
|
if (clutter_input_device_get_device_type (CLUTTER_INPUT_DEVICE (gobject)) == CLUTTER_PAD_DEVICE)
|
|
|
|
{
|
|
|
|
device_xi2->group_modes = g_array_new (FALSE, TRUE, sizeof (guint));
|
|
|
|
g_array_set_size (device_xi2->group_modes,
|
|
|
|
clutter_input_device_get_n_mode_groups (CLUTTER_INPUT_DEVICE (gobject)));
|
|
|
|
}
|
|
|
|
#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 12:32:04 +00:00
|
|
|
}
|
|
|
|
|
2012-01-17 15:40:08 +00:00
|
|
|
static gboolean
|
|
|
|
clutter_input_device_xi2_keycode_to_evdev (ClutterInputDevice *device,
|
|
|
|
guint hardware_keycode,
|
|
|
|
guint *evdev_keycode)
|
|
|
|
{
|
|
|
|
/* When using evdev under X11 the hardware keycodes are the evdev
|
|
|
|
keycodes plus 8. I haven't been able to find any documentation to
|
|
|
|
know what the +8 is for. FIXME: This should probably verify that
|
|
|
|
X server is using evdev. */
|
|
|
|
*evdev_keycode = hardware_keycode - 8;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2017-02-13 11:58:52 +01:00
|
|
|
static gboolean
|
|
|
|
clutter_input_device_xi2_is_grouped (ClutterInputDevice *device,
|
|
|
|
ClutterInputDevice *other_device)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-02-22 17:48:17 +01:00
|
|
|
static void
|
|
|
|
clutter_input_device_xi2_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_LIBWACOM
|
|
|
|
ClutterInputDeviceXI2 *device_xi2 = CLUTTER_INPUT_DEVICE_XI2 (object);
|
|
|
|
|
|
|
|
if (device_xi2->wacom_device)
|
|
|
|
libwacom_destroy (device_xi2->wacom_device);
|
2018-02-22 17:50:42 +01:00
|
|
|
|
2018-06-02 19:16:32 +01:00
|
|
|
if (device_xi2->group_modes)
|
|
|
|
g_array_unref (device_xi2->group_modes);
|
2018-02-22 17:48:17 +01:00
|
|
|
|
2019-03-14 14:12:34 +01:00
|
|
|
if (device_xi2->inhibit_pointer_query_timer)
|
|
|
|
g_source_remove (device_xi2->inhibit_pointer_query_timer);
|
2019-06-10 14:19:17 +03:00
|
|
|
#endif
|
2019-03-14 14:12:34 +01:00
|
|
|
|
2018-02-22 17:48:17 +01:00
|
|
|
G_OBJECT_CLASS (clutter_input_device_xi2_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
clutter_input_device_xi2_get_group_n_modes (ClutterInputDevice *device,
|
|
|
|
gint group)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_LIBWACOM
|
|
|
|
ClutterInputDeviceXI2 *device_xi2 = CLUTTER_INPUT_DEVICE_XI2 (device);
|
|
|
|
|
|
|
|
if (device_xi2->wacom_device)
|
|
|
|
{
|
|
|
|
if (group == 0)
|
|
|
|
{
|
|
|
|
if (libwacom_has_ring (device_xi2->wacom_device))
|
|
|
|
return libwacom_get_ring_num_modes (device_xi2->wacom_device);
|
|
|
|
else if (libwacom_get_num_strips (device_xi2->wacom_device) >= 1)
|
|
|
|
return libwacom_get_strips_num_modes (device_xi2->wacom_device);
|
|
|
|
}
|
|
|
|
else if (group == 1)
|
|
|
|
{
|
|
|
|
if (libwacom_has_ring2 (device_xi2->wacom_device))
|
|
|
|
return libwacom_get_ring2_num_modes (device_xi2->wacom_device);
|
|
|
|
else if (libwacom_get_num_strips (device_xi2->wacom_device) >= 2)
|
|
|
|
return libwacom_get_strips_num_modes (device_xi2->wacom_device);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBWACOM
|
|
|
|
static int
|
|
|
|
clutter_input_device_xi2_get_button_group (ClutterInputDevice *device,
|
|
|
|
guint button)
|
|
|
|
{
|
|
|
|
ClutterInputDeviceXI2 *device_xi2 = CLUTTER_INPUT_DEVICE_XI2 (device);
|
|
|
|
|
|
|
|
if (device_xi2->wacom_device)
|
|
|
|
{
|
|
|
|
if (button >= libwacom_get_num_buttons (device_xi2->wacom_device))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return libwacom_get_button_led_group (device_xi2->wacom_device,
|
|
|
|
'A' + button);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
clutter_input_device_xi2_is_mode_switch_button (ClutterInputDevice *device,
|
|
|
|
guint group,
|
|
|
|
guint button)
|
|
|
|
{
|
|
|
|
int button_group = -1;
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBWACOM
|
|
|
|
button_group = clutter_input_device_xi2_get_button_group (device, button);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return button_group == (int) group;
|
|
|
|
}
|
|
|
|
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
static void
|
|
|
|
clutter_input_device_xi2_class_init (ClutterInputDeviceXI2Class *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
2011-01-17 17:01:58 +00:00
|
|
|
ClutterInputDeviceClass *device_class = CLUTTER_INPUT_DEVICE_CLASS (klass);
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
|
|
|
|
gobject_class->constructed = clutter_input_device_xi2_constructed;
|
2018-02-22 17:48:17 +01:00
|
|
|
gobject_class->finalize = clutter_input_device_xi2_finalize;
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
|
2012-01-17 15:40:08 +00:00
|
|
|
device_class->keycode_to_evdev = clutter_input_device_xi2_keycode_to_evdev;
|
2017-02-13 11:58:52 +01:00
|
|
|
device_class->is_grouped = clutter_input_device_xi2_is_grouped;
|
2018-02-22 17:48:17 +01:00
|
|
|
device_class->get_group_n_modes = clutter_input_device_xi2_get_group_n_modes;
|
|
|
|
device_class->is_mode_switch_button = clutter_input_device_xi2_is_mode_switch_button;
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_input_device_xi2_init (ClutterInputDeviceXI2 *self)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-11-12 15:10:22 -05:00
|
|
|
static ClutterModifierType
|
|
|
|
get_modifier_for_button (int i)
|
|
|
|
{
|
|
|
|
switch (i)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
return CLUTTER_BUTTON1_MASK;
|
|
|
|
case 2:
|
|
|
|
return CLUTTER_BUTTON2_MASK;
|
|
|
|
case 3:
|
|
|
|
return CLUTTER_BUTTON3_MASK;
|
|
|
|
case 4:
|
|
|
|
return CLUTTER_BUTTON4_MASK;
|
|
|
|
case 5:
|
|
|
|
return CLUTTER_BUTTON5_MASK;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-04 14:42:56 +02:00
|
|
|
void
|
|
|
|
_clutter_input_device_xi2_translate_state (ClutterEvent *event,
|
|
|
|
XIModifierState *modifiers_state,
|
2013-03-06 01:30:52 +01:00
|
|
|
XIButtonState *buttons_state,
|
|
|
|
XIGroupState *group_state)
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
{
|
2013-09-04 14:42:56 +02:00
|
|
|
guint button = 0;
|
|
|
|
guint base = 0;
|
|
|
|
guint latched = 0;
|
|
|
|
guint locked = 0;
|
|
|
|
guint effective;
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
|
|
|
|
if (modifiers_state)
|
2013-09-04 14:42:56 +02:00
|
|
|
{
|
|
|
|
base = (guint) modifiers_state->base;
|
|
|
|
latched = (guint) modifiers_state->latched;
|
|
|
|
locked = (guint) modifiers_state->locked;
|
|
|
|
}
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
|
|
|
|
if (buttons_state)
|
|
|
|
{
|
|
|
|
int len, i;
|
|
|
|
|
|
|
|
len = MIN (N_BUTTONS, buttons_state->mask_len * 8);
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
{
|
|
|
|
if (!XIMaskIsSet (buttons_state->mask, i))
|
|
|
|
continue;
|
|
|
|
|
2013-11-12 15:10:22 -05:00
|
|
|
button |= get_modifier_for_button (i);
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-12 15:10:22 -05:00
|
|
|
/* The XIButtonState sent in the event specifies the
|
|
|
|
* state of the buttons before the event. In order to
|
|
|
|
* get the current state of the buttons, we need to
|
|
|
|
* filter out the current button.
|
|
|
|
*/
|
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case CLUTTER_BUTTON_PRESS:
|
|
|
|
button |= (get_modifier_for_button (event->button.button));
|
|
|
|
break;
|
|
|
|
case CLUTTER_BUTTON_RELEASE:
|
|
|
|
button &= ~(get_modifier_for_button (event->button.button));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-09-04 14:42:56 +02:00
|
|
|
effective = button | base | latched | locked;
|
2013-03-06 01:30:52 +01:00
|
|
|
if (group_state)
|
2013-09-04 14:42:56 +02:00
|
|
|
effective |= (group_state->effective) << 13;
|
2013-03-06 01:30:52 +01:00
|
|
|
|
2013-09-04 14:42:56 +02:00
|
|
|
_clutter_event_set_state_full (event, button, base, latched, locked, effective);
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
}
|
2016-10-31 18:05:23 +01:00
|
|
|
|
|
|
|
void
|
|
|
|
clutter_input_device_xi2_update_tool (ClutterInputDevice *device,
|
|
|
|
ClutterInputDeviceTool *tool)
|
|
|
|
{
|
|
|
|
ClutterInputDeviceXI2 *device_xi2 = CLUTTER_INPUT_DEVICE_XI2 (device);
|
|
|
|
g_set_object (&device_xi2->current_tool, tool);
|
|
|
|
}
|
|
|
|
|
|
|
|
ClutterInputDeviceTool *
|
|
|
|
clutter_input_device_xi2_get_current_tool (ClutterInputDevice *device)
|
|
|
|
{
|
|
|
|
ClutterInputDeviceXI2 *device_xi2 = CLUTTER_INPUT_DEVICE_XI2 (device);
|
|
|
|
return device_xi2->current_tool;
|
|
|
|
}
|
2018-02-22 17:48:17 +01:00
|
|
|
|
2019-03-14 14:12:34 +01:00
|
|
|
static gboolean
|
|
|
|
clutter_input_device_xi2_query_pointer_location (ClutterInputDeviceXI2 *device_xi2)
|
|
|
|
{
|
|
|
|
Window xroot_window, xchild_window;
|
|
|
|
double xroot_x, xroot_y, xwin_x, xwin_y;
|
|
|
|
XIButtonState button_state;
|
|
|
|
XIModifierState mod_state;
|
|
|
|
XIGroupState group_state;
|
|
|
|
int result;
|
|
|
|
|
|
|
|
clutter_x11_trap_x_errors ();
|
|
|
|
result = XIQueryPointer (clutter_x11_get_default_display (),
|
|
|
|
device_xi2->device_id,
|
|
|
|
clutter_x11_get_root_window (),
|
|
|
|
&xroot_window,
|
|
|
|
&xchild_window,
|
|
|
|
&xroot_x, &xroot_y,
|
|
|
|
&xwin_x, &xwin_y,
|
|
|
|
&button_state,
|
|
|
|
&mod_state,
|
|
|
|
&group_state);
|
|
|
|
clutter_x11_untrap_x_errors ();
|
|
|
|
|
|
|
|
if (!result)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
device_xi2->current_x = (float) xroot_x;
|
|
|
|
device_xi2->current_y = (float) xroot_y;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
clear_inhibit_pointer_query_cb (gpointer data)
|
|
|
|
{
|
|
|
|
ClutterInputDeviceXI2 *device_xi2 = CLUTTER_INPUT_DEVICE_XI2 (data);
|
|
|
|
|
|
|
|
device_xi2->inhibit_pointer_query_timer = 0;
|
|
|
|
|
|
|
|
return G_SOURCE_REMOVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
clutter_input_device_xi2_get_pointer_location (ClutterInputDevice *device,
|
|
|
|
float *x,
|
|
|
|
float *y)
|
|
|
|
|
|
|
|
{
|
|
|
|
ClutterInputDeviceXI2 *device_xi2 = CLUTTER_INPUT_DEVICE_XI2 (device);
|
|
|
|
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), FALSE);
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE_XI2 (device_xi2), FALSE);
|
|
|
|
g_return_val_if_fail (device->device_type == CLUTTER_POINTER_DEVICE, FALSE);
|
|
|
|
|
|
|
|
/* Throttle XServer queries and roundtrips using an idle timeout */
|
|
|
|
if (device_xi2->inhibit_pointer_query_timer == 0)
|
|
|
|
{
|
|
|
|
device_xi2->query_status =
|
|
|
|
clutter_input_device_xi2_query_pointer_location (device_xi2);
|
|
|
|
device_xi2->inhibit_pointer_query_timer =
|
|
|
|
clutter_threads_add_idle (clear_inhibit_pointer_query_cb, device_xi2);
|
|
|
|
}
|
|
|
|
|
|
|
|
*x = device_xi2->current_x;
|
|
|
|
*y = device_xi2->current_y;
|
|
|
|
|
|
|
|
return device_xi2->query_status;
|
|
|
|
}
|
|
|
|
|
2018-02-22 17:48:17 +01:00
|
|
|
#ifdef HAVE_LIBWACOM
|
|
|
|
void
|
|
|
|
clutter_input_device_xi2_ensure_wacom_info (ClutterInputDevice *device,
|
|
|
|
WacomDeviceDatabase *wacom_db)
|
|
|
|
{
|
|
|
|
ClutterInputDeviceXI2 *device_xi2 = CLUTTER_INPUT_DEVICE_XI2 (device);
|
|
|
|
const gchar *node_path;
|
|
|
|
|
|
|
|
node_path = clutter_input_device_get_device_node (device);
|
|
|
|
device_xi2->wacom_device = libwacom_new_from_path (wacom_db, node_path,
|
|
|
|
WFALLBACK_NONE, NULL);
|
|
|
|
}
|
2018-02-22 17:50:42 +01:00
|
|
|
|
|
|
|
guint
|
|
|
|
clutter_input_device_xi2_get_pad_group_mode (ClutterInputDevice *device,
|
|
|
|
guint group)
|
|
|
|
{
|
|
|
|
ClutterInputDeviceXI2 *device_xi2 = CLUTTER_INPUT_DEVICE_XI2 (device);
|
|
|
|
|
|
|
|
if (group >= device_xi2->group_modes->len)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return g_array_index (device_xi2->group_modes, guint, group);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
clutter_input_device_xi2_update_pad_state (ClutterInputDevice *device,
|
|
|
|
guint button,
|
|
|
|
guint state,
|
|
|
|
guint *group,
|
|
|
|
guint *mode)
|
|
|
|
{
|
|
|
|
ClutterInputDeviceXI2 *device_xi2 = CLUTTER_INPUT_DEVICE_XI2 (device);
|
|
|
|
guint button_group, *group_mode;
|
|
|
|
gboolean is_mode_switch = FALSE;
|
|
|
|
|
|
|
|
button_group = clutter_input_device_xi2_get_button_group (device, button);
|
|
|
|
is_mode_switch = button_group >= 0;
|
|
|
|
|
|
|
|
/* Assign all non-mode-switch buttons to group 0 so far */
|
|
|
|
button_group = MAX (0, button_group);
|
|
|
|
|
|
|
|
if (button_group >= device_xi2->group_modes->len)
|
|
|
|
return;
|
|
|
|
|
|
|
|
group_mode = &g_array_index (device_xi2->group_modes, guint, button_group);
|
|
|
|
|
|
|
|
if (is_mode_switch && state)
|
|
|
|
{
|
|
|
|
guint next, n_modes;
|
|
|
|
|
|
|
|
n_modes = clutter_input_device_get_group_n_modes (device, button_group);
|
|
|
|
next = (*group_mode + 1) % n_modes;
|
|
|
|
*group_mode = next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (group)
|
|
|
|
*group = button_group;
|
|
|
|
if (mode)
|
|
|
|
*mode = *group_mode;
|
|
|
|
}
|
2018-02-22 17:48:17 +01:00
|
|
|
#endif
|