2011-01-18 08:05:17 -05:00
|
|
|
/*
|
|
|
|
* 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>
|
|
|
|
*/
|
|
|
|
|
2019-03-22 08:53:00 -04:00
|
|
|
#include "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 07:32:04 -05:00
|
|
|
|
|
|
|
#include <X11/extensions/XInput2.h>
|
|
|
|
|
2019-03-22 08:53:00 -04:00
|
|
|
#include "clutter/clutter-mutter.h"
|
|
|
|
#include "clutter/x11/clutter-x11.h"
|
|
|
|
#include "backends/x11/meta-input-device-x11.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
|
|
|
|
2019-03-22 08:53:00 -04:00
|
|
|
struct _MetaInputDeviceX11
|
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 device;
|
|
|
|
|
2019-03-29 16:14:46 -04:00
|
|
|
int32_t device_id;
|
2016-10-31 13:05:23 -04:00
|
|
|
ClutterInputDeviceTool *current_tool;
|
2018-02-22 11:48:17 -05:00
|
|
|
|
2019-03-29 16:14:46 -04:00
|
|
|
int inhibit_pointer_query_timer;
|
2019-03-14 09:12:34 -04:00
|
|
|
gboolean query_status;
|
|
|
|
float current_x;
|
|
|
|
float current_y;
|
|
|
|
|
2018-02-22 11:48:17 -05:00
|
|
|
#ifdef HAVE_LIBWACOM
|
|
|
|
WacomDevice *wacom_device;
|
2018-02-22 11:50:42 -05:00
|
|
|
GArray *group_modes;
|
2018-02-22 11:48:17 -05: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 07:32:04 -05:00
|
|
|
};
|
|
|
|
|
2019-03-22 08:53:00 -04:00
|
|
|
struct _MetaInputDeviceX11Class
|
|
|
|
{
|
|
|
|
ClutterInputDeviceClass device_class;
|
|
|
|
};
|
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
|
|
|
|
2019-03-22 08:53:00 -04:00
|
|
|
#define N_BUTTONS 5
|
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
|
|
|
|
2019-03-22 08:53:00 -04:00
|
|
|
G_DEFINE_TYPE (MetaInputDeviceX11,
|
|
|
|
meta_input_device_x11,
|
2020-03-06 08:12:59 -05:00
|
|
|
META_TYPE_INPUT_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
|
|
|
|
|
|
|
static void
|
2019-03-22 08:53:00 -04:00
|
|
|
meta_input_device_x11_constructed (GObject *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
|
|
|
{
|
2019-03-22 08:53:00 -04:00
|
|
|
MetaInputDeviceX11 *device_xi2 = META_INPUT_DEVICE_X11 (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
|
|
|
|
2019-03-22 08:53:00 -04:00
|
|
|
g_object_get (object, "id", &device_xi2->device_id, 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
|
|
|
|
2019-03-22 08:53:00 -04:00
|
|
|
if (G_OBJECT_CLASS (meta_input_device_x11_parent_class)->constructed)
|
|
|
|
G_OBJECT_CLASS (meta_input_device_x11_parent_class)->constructed (object);
|
2018-02-22 11:50:42 -05:00
|
|
|
|
|
|
|
#ifdef HAVE_LIBWACOM
|
2019-03-22 08:53:00 -04:00
|
|
|
if (clutter_input_device_get_device_type (CLUTTER_INPUT_DEVICE (object)) == CLUTTER_PAD_DEVICE)
|
2018-02-22 11:50:42 -05:00
|
|
|
{
|
2019-03-29 16:14:46 -04:00
|
|
|
device_xi2->group_modes = g_array_new (FALSE, TRUE, sizeof (uint32_t));
|
2018-02-22 11:50:42 -05:00
|
|
|
g_array_set_size (device_xi2->group_modes,
|
2019-03-22 08:53:00 -04:00
|
|
|
clutter_input_device_get_n_mode_groups (CLUTTER_INPUT_DEVICE (object)));
|
2018-02-22 11:50:42 -05: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 07:32:04 -05:00
|
|
|
}
|
|
|
|
|
2012-01-17 10:40:08 -05:00
|
|
|
static gboolean
|
2019-03-22 08:53:00 -04:00
|
|
|
meta_input_device_x11_keycode_to_evdev (ClutterInputDevice *device,
|
2019-03-29 16:14:46 -04:00
|
|
|
uint32_t hardware_keycode,
|
|
|
|
uint32_t *evdev_keycode)
|
2012-01-17 10:40:08 -05:00
|
|
|
{
|
|
|
|
/* 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 05:58:52 -05:00
|
|
|
static gboolean
|
2019-03-22 08:53:00 -04:00
|
|
|
meta_input_device_x11_is_grouped (ClutterInputDevice *device,
|
|
|
|
ClutterInputDevice *other_device)
|
2017-02-13 05:58:52 -05:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-02-22 11:48:17 -05:00
|
|
|
static void
|
2019-03-22 08:53:00 -04:00
|
|
|
meta_input_device_x11_finalize (GObject *object)
|
2018-02-22 11:48:17 -05:00
|
|
|
{
|
|
|
|
#ifdef HAVE_LIBWACOM
|
2019-03-22 08:53:00 -04:00
|
|
|
MetaInputDeviceX11 *device_xi2 = META_INPUT_DEVICE_X11 (object);
|
2018-02-22 11:48:17 -05:00
|
|
|
|
2018-06-02 14:16:32 -04:00
|
|
|
if (device_xi2->group_modes)
|
|
|
|
g_array_unref (device_xi2->group_modes);
|
2020-03-06 08:37:01 -05:00
|
|
|
#endif
|
2018-02-22 11:48:17 -05:00
|
|
|
|
2019-11-21 18:25:30 -05:00
|
|
|
g_clear_handle_id (&device_xi2->inhibit_pointer_query_timer, g_source_remove);
|
2019-03-14 09:12:34 -04:00
|
|
|
|
2019-03-22 08:53:00 -04:00
|
|
|
G_OBJECT_CLASS (meta_input_device_x11_parent_class)->finalize (object);
|
2018-02-22 11:48:17 -05:00
|
|
|
}
|
|
|
|
|
2019-03-29 16:14:46 -04:00
|
|
|
static int
|
2019-03-22 08:53:00 -04:00
|
|
|
meta_input_device_x11_get_group_n_modes (ClutterInputDevice *device,
|
2019-03-29 16:14:46 -04:00
|
|
|
int group)
|
2018-02-22 11:48:17 -05:00
|
|
|
{
|
|
|
|
#ifdef HAVE_LIBWACOM
|
2020-03-06 08:37:01 -05:00
|
|
|
WacomDevice *wacom_device;
|
|
|
|
|
|
|
|
wacom_device = meta_input_device_get_wacom_device (META_INPUT_DEVICE (device));
|
2018-02-22 11:48:17 -05:00
|
|
|
|
2020-03-06 08:37:01 -05:00
|
|
|
if (wacom_device)
|
2018-02-22 11:48:17 -05:00
|
|
|
{
|
|
|
|
if (group == 0)
|
|
|
|
{
|
2020-03-06 08:37:01 -05:00
|
|
|
if (libwacom_has_ring (wacom_device))
|
|
|
|
return libwacom_get_ring_num_modes (wacom_device);
|
|
|
|
else if (libwacom_get_num_strips (wacom_device) >= 1)
|
|
|
|
return libwacom_get_strips_num_modes (wacom_device);
|
2018-02-22 11:48:17 -05:00
|
|
|
}
|
|
|
|
else if (group == 1)
|
|
|
|
{
|
2020-03-06 08:37:01 -05:00
|
|
|
if (libwacom_has_ring2 (wacom_device))
|
|
|
|
return libwacom_get_ring2_num_modes (wacom_device);
|
|
|
|
else if (libwacom_get_num_strips (wacom_device) >= 2)
|
|
|
|
return libwacom_get_strips_num_modes (wacom_device);
|
2018-02-22 11:48:17 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBWACOM
|
|
|
|
static int
|
2019-03-22 08:53:00 -04:00
|
|
|
meta_input_device_x11_get_button_group (ClutterInputDevice *device,
|
2019-03-29 16:14:46 -04:00
|
|
|
uint32_t button)
|
2018-02-22 11:48:17 -05:00
|
|
|
{
|
2020-03-06 08:37:01 -05:00
|
|
|
WacomDevice *wacom_device;
|
2018-02-22 11:48:17 -05:00
|
|
|
|
2020-03-06 08:37:01 -05:00
|
|
|
wacom_device = meta_input_device_get_wacom_device (META_INPUT_DEVICE (device));
|
|
|
|
|
|
|
|
if (wacom_device)
|
2018-02-22 11:48:17 -05:00
|
|
|
{
|
2019-11-28 16:50:36 -05:00
|
|
|
WacomButtonFlags flags;
|
|
|
|
|
2020-03-06 08:37:01 -05:00
|
|
|
if (button >= libwacom_get_num_buttons (wacom_device))
|
2018-02-22 11:48:17 -05:00
|
|
|
return -1;
|
|
|
|
|
2020-03-06 08:37:01 -05:00
|
|
|
flags = libwacom_get_button_flag (wacom_device, 'A' + button);
|
2019-11-28 16:50:36 -05:00
|
|
|
|
|
|
|
if (flags &
|
|
|
|
(WACOM_BUTTON_RING_MODESWITCH |
|
|
|
|
WACOM_BUTTON_TOUCHSTRIP_MODESWITCH))
|
|
|
|
return 0;
|
|
|
|
if (flags &
|
|
|
|
(WACOM_BUTTON_RING2_MODESWITCH |
|
|
|
|
WACOM_BUTTON_TOUCHSTRIP2_MODESWITCH))
|
|
|
|
return 1;
|
2018-02-22 11:48:17 -05:00
|
|
|
}
|
2019-11-28 16:50:36 -05:00
|
|
|
|
|
|
|
return -1;
|
2018-02-22 11:48:17 -05:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static gboolean
|
2019-03-22 08:53:00 -04:00
|
|
|
meta_input_device_x11_is_mode_switch_button (ClutterInputDevice *device,
|
2019-03-29 16:14:46 -04:00
|
|
|
uint32_t group,
|
|
|
|
uint32_t button)
|
2018-02-22 11:48:17 -05:00
|
|
|
{
|
|
|
|
int button_group = -1;
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBWACOM
|
2019-03-22 08:53:00 -04:00
|
|
|
button_group = meta_input_device_x11_get_button_group (device, button);
|
2018-02-22 11:48:17 -05:00
|
|
|
#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 07:32:04 -05:00
|
|
|
static void
|
2019-03-22 08:53:00 -04:00
|
|
|
meta_input_device_x11_class_init (MetaInputDeviceX11Class *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 07:32:04 -05:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
2011-01-17 12:01:58 -05: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 07:32:04 -05:00
|
|
|
|
2019-03-22 08:53:00 -04:00
|
|
|
gobject_class->constructed = meta_input_device_x11_constructed;
|
|
|
|
gobject_class->finalize = meta_input_device_x11_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 07:32:04 -05:00
|
|
|
|
2019-03-22 08:53:00 -04:00
|
|
|
device_class->keycode_to_evdev = meta_input_device_x11_keycode_to_evdev;
|
|
|
|
device_class->is_grouped = meta_input_device_x11_is_grouped;
|
|
|
|
device_class->get_group_n_modes = meta_input_device_x11_get_group_n_modes;
|
|
|
|
device_class->is_mode_switch_button = meta_input_device_x11_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 07:32:04 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-03-22 08:53:00 -04:00
|
|
|
meta_input_device_x11_init (MetaInputDeviceX11 *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
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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 08:42:56 -04:00
|
|
|
void
|
2019-03-22 08:53:00 -04:00
|
|
|
meta_input_device_x11_translate_state (ClutterEvent *event,
|
|
|
|
XIModifierState *modifiers_state,
|
|
|
|
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 07:32:04 -05:00
|
|
|
{
|
2019-03-29 16:14:46 -04:00
|
|
|
uint32_t button = 0;
|
|
|
|
uint32_t base = 0;
|
|
|
|
uint32_t latched = 0;
|
|
|
|
uint32_t locked = 0;
|
|
|
|
uint32_t 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 07:32:04 -05:00
|
|
|
|
|
|
|
if (modifiers_state)
|
2013-09-04 08:42:56 -04:00
|
|
|
{
|
2019-03-29 16:14:46 -04:00
|
|
|
base = (uint32_t) modifiers_state->base;
|
|
|
|
latched = (uint32_t) modifiers_state->latched;
|
|
|
|
locked = (uint32_t) modifiers_state->locked;
|
2013-09-04 08:42:56 -04: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 (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 07:32:04 -05: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 08:42:56 -04:00
|
|
|
effective = button | base | latched | locked;
|
2013-03-05 19:30:52 -05:00
|
|
|
if (group_state)
|
2013-09-04 08:42:56 -04:00
|
|
|
effective |= (group_state->effective) << 13;
|
2013-03-05 19:30:52 -05:00
|
|
|
|
2013-09-04 08:42:56 -04: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 07:32:04 -05:00
|
|
|
}
|
2016-10-31 13:05:23 -04:00
|
|
|
|
|
|
|
void
|
2019-03-22 08:53:00 -04:00
|
|
|
meta_input_device_x11_update_tool (ClutterInputDevice *device,
|
|
|
|
ClutterInputDeviceTool *tool)
|
2016-10-31 13:05:23 -04:00
|
|
|
{
|
2019-03-22 08:53:00 -04:00
|
|
|
MetaInputDeviceX11 *device_xi2 = META_INPUT_DEVICE_X11 (device);
|
2016-10-31 13:05:23 -04:00
|
|
|
g_set_object (&device_xi2->current_tool, tool);
|
|
|
|
}
|
|
|
|
|
|
|
|
ClutterInputDeviceTool *
|
2019-03-22 08:53:00 -04:00
|
|
|
meta_input_device_x11_get_current_tool (ClutterInputDevice *device)
|
2016-10-31 13:05:23 -04:00
|
|
|
{
|
2019-03-22 08:53:00 -04:00
|
|
|
MetaInputDeviceX11 *device_xi2 = META_INPUT_DEVICE_X11 (device);
|
2016-10-31 13:05:23 -04:00
|
|
|
return device_xi2->current_tool;
|
|
|
|
}
|
2018-02-22 11:48:17 -05:00
|
|
|
|
2019-03-14 09:12:34 -04:00
|
|
|
static gboolean
|
2019-03-22 08:53:00 -04:00
|
|
|
meta_input_device_x11_query_pointer_location (MetaInputDeviceX11 *device_xi2)
|
2019-03-14 09:12:34 -04:00
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
2019-03-22 08:53:00 -04:00
|
|
|
MetaInputDeviceX11 *device_xi2 = META_INPUT_DEVICE_X11 (data);
|
2019-03-14 09:12:34 -04:00
|
|
|
|
|
|
|
device_xi2->inhibit_pointer_query_timer = 0;
|
|
|
|
|
|
|
|
return G_SOURCE_REMOVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2019-03-22 08:53:00 -04:00
|
|
|
meta_input_device_x11_get_pointer_location (ClutterInputDevice *device,
|
|
|
|
float *x,
|
|
|
|
float *y)
|
2019-03-14 09:12:34 -04:00
|
|
|
|
|
|
|
{
|
2019-03-22 08:53:00 -04:00
|
|
|
MetaInputDeviceX11 *device_xi2 = META_INPUT_DEVICE_X11 (device);
|
2019-03-14 09:12:34 -04:00
|
|
|
|
2019-03-22 08:53:00 -04:00
|
|
|
g_return_val_if_fail (META_IS_INPUT_DEVICE_X11 (device), FALSE);
|
2019-03-14 09:12:34 -04:00
|
|
|
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 =
|
2019-03-22 08:53:00 -04:00
|
|
|
meta_input_device_x11_query_pointer_location (device_xi2);
|
2019-03-14 09:12:34 -04:00
|
|
|
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 11:48:17 -05:00
|
|
|
#ifdef HAVE_LIBWACOM
|
2019-03-29 16:14:46 -04:00
|
|
|
uint32_t
|
2019-03-22 08:53:00 -04:00
|
|
|
meta_input_device_x11_get_pad_group_mode (ClutterInputDevice *device,
|
2019-03-29 16:14:46 -04:00
|
|
|
uint32_t group)
|
2018-02-22 11:50:42 -05:00
|
|
|
{
|
2019-03-22 08:53:00 -04:00
|
|
|
MetaInputDeviceX11 *device_xi2 = META_INPUT_DEVICE_X11 (device);
|
2018-02-22 11:50:42 -05:00
|
|
|
|
|
|
|
if (group >= device_xi2->group_modes->len)
|
|
|
|
return 0;
|
|
|
|
|
2019-03-29 16:14:46 -04:00
|
|
|
return g_array_index (device_xi2->group_modes, uint32_t, group);
|
2018-02-22 11:50:42 -05:00
|
|
|
}
|
|
|
|
|
2019-12-13 08:22:12 -05:00
|
|
|
static gboolean
|
|
|
|
pad_switch_mode (ClutterInputDevice *device,
|
|
|
|
uint32_t button,
|
|
|
|
uint32_t group,
|
|
|
|
uint32_t *mode)
|
|
|
|
{
|
|
|
|
MetaInputDeviceX11 *device_x11 = META_INPUT_DEVICE_X11 (device);
|
|
|
|
uint32_t n_buttons, n_modes, button_group, next_mode, i;
|
|
|
|
GList *switch_buttons = NULL;
|
|
|
|
|
|
|
|
n_buttons = libwacom_get_num_buttons (device_x11->wacom_device);
|
|
|
|
|
|
|
|
for (i = 0; i < n_buttons; i++)
|
|
|
|
{
|
|
|
|
button_group = meta_input_device_x11_get_button_group (device, i);
|
|
|
|
if (button_group == group)
|
|
|
|
switch_buttons = g_list_prepend (switch_buttons, GINT_TO_POINTER (button));
|
|
|
|
}
|
|
|
|
|
|
|
|
switch_buttons = g_list_reverse (switch_buttons);
|
|
|
|
n_modes = clutter_input_device_get_group_n_modes (device, group);
|
|
|
|
|
|
|
|
if (g_list_length (switch_buttons) > 1)
|
|
|
|
{
|
|
|
|
/* If there's multiple switch buttons, we don't toggle but assign a mode
|
|
|
|
* to each of those buttons.
|
|
|
|
*/
|
|
|
|
next_mode = g_list_index (switch_buttons, GINT_TO_POINTER (button));
|
|
|
|
}
|
|
|
|
else if (switch_buttons)
|
|
|
|
{
|
|
|
|
uint32_t cur_mode;
|
|
|
|
|
|
|
|
/* If there is a single button, have it toggle across modes */
|
|
|
|
cur_mode = g_array_index (device_x11->group_modes, uint32_t, group);
|
|
|
|
next_mode = (cur_mode + 1) % n_modes;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (switch_buttons);
|
|
|
|
|
|
|
|
if (next_mode < 0 || next_mode > n_modes)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
*mode = next_mode;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-02-22 11:50:42 -05:00
|
|
|
void
|
2019-03-22 08:53:00 -04:00
|
|
|
meta_input_device_x11_update_pad_state (ClutterInputDevice *device,
|
2019-03-29 16:14:46 -04:00
|
|
|
uint32_t button,
|
|
|
|
uint32_t state,
|
|
|
|
uint32_t *group,
|
|
|
|
uint32_t *mode)
|
2018-02-22 11:50:42 -05:00
|
|
|
{
|
2019-03-22 08:53:00 -04:00
|
|
|
MetaInputDeviceX11 *device_xi2 = META_INPUT_DEVICE_X11 (device);
|
2019-03-29 16:14:46 -04:00
|
|
|
uint32_t button_group, *group_mode;
|
2018-02-22 11:50:42 -05:00
|
|
|
|
2019-03-22 08:53:00 -04:00
|
|
|
button_group = meta_input_device_x11_get_button_group (device, button);
|
2018-02-22 11:50:42 -05:00
|
|
|
|
2019-12-13 08:22:12 -05:00
|
|
|
if (button_group < 0 || button_group >= device_xi2->group_modes->len)
|
|
|
|
{
|
|
|
|
if (group)
|
|
|
|
*group = 0;
|
|
|
|
if (mode)
|
|
|
|
*mode = 0;
|
|
|
|
return;
|
|
|
|
}
|
2018-02-22 11:50:42 -05:00
|
|
|
|
2019-03-29 16:14:46 -04:00
|
|
|
group_mode = &g_array_index (device_xi2->group_modes, uint32_t, button_group);
|
2018-02-22 11:50:42 -05:00
|
|
|
|
2019-12-13 08:22:12 -05:00
|
|
|
if (state)
|
2018-02-22 11:50:42 -05:00
|
|
|
{
|
2019-12-13 08:22:12 -05:00
|
|
|
uint32_t next_mode;
|
2018-02-22 11:50:42 -05:00
|
|
|
|
2019-12-13 08:22:12 -05:00
|
|
|
if (pad_switch_mode (device, button, button_group, &next_mode))
|
|
|
|
*group_mode = next_mode;
|
2018-02-22 11:50:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (group)
|
|
|
|
*group = button_group;
|
|
|
|
if (mode)
|
|
|
|
*mode = *group_mode;
|
|
|
|
}
|
2018-02-22 11:48:17 -05:00
|
|
|
#endif
|