clutter: Move evdev input to src/backends/native

The end goal is to have all clutter backend code in src/backends. Input
is the larger chunk of it, which is now part of our specific
MutterClutterBackendNative, this extends to device manager, input devices,
tools and keymap.

This was supposed to be nice and incremental, but there's no sane way
to cut this through. As a result of the refactor, a number of private
Clutter functions are now exported for external backends to be possible.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/672
This commit is contained in:
Carlos Garnacho 2019-03-29 22:03:27 +01:00 committed by Jonas Ådahl
parent ea54ce7d96
commit 8b03d9ecc3
41 changed files with 2134 additions and 2264 deletions

View File

@ -62,9 +62,6 @@
#ifdef CLUTTER_INPUT_X11
#include "x11/clutter-backend-x11.h"
#endif
#ifdef CLUTTER_INPUT_EVDEV
#include "evdev/clutter-device-manager-evdev.h"
#endif
#ifdef CLUTTER_WINDOWING_EGL
#include "egl/clutter-backend-eglnative.h"
#endif
@ -528,32 +525,7 @@ _clutter_create_backend (void)
static void
clutter_backend_real_init_events (ClutterBackend *backend)
{
const char *input_backend = NULL;
input_backend = g_getenv ("CLUTTER_INPUT_BACKEND");
if (input_backend != NULL)
input_backend = g_intern_string (input_backend);
#ifdef CLUTTER_INPUT_EVDEV
/* Evdev can be used regardless of the windowing system */
if ((input_backend != NULL && strcmp (input_backend, CLUTTER_INPUT_EVDEV) == 0)
#ifdef CLUTTER_WINDOWING_EGL
/* but we do want to always use it for EGL native */
|| clutter_check_windowing_backend (CLUTTER_WINDOWING_EGL)
#endif
)
{
_clutter_events_evdev_init (backend);
}
else
#endif
if (input_backend != NULL)
{
if (input_backend != I_(CLUTTER_INPUT_NULL))
g_error ("Unrecognized input backend '%s'", input_backend);
}
else
g_error ("Unknown input backend");
g_error ("Unknown input backend");
}
static ClutterDeviceManager *

View File

@ -10,8 +10,10 @@ void _clutter_event_set_pointer_emulated (ClutterEvent *eve
gboolean is_emulated);
/* Reinjecting queued events for processing */
CLUTTER_EXPORT
void _clutter_process_event (ClutterEvent *event);
CLUTTER_EXPORT
gboolean _clutter_event_process_filters (ClutterEvent *event);
/* clears the event queue inside the main context */

View File

@ -172,6 +172,7 @@ void clutter_virtual_input_device_notify_touch_up (ClutterVirtualInputDevice *vi
CLUTTER_EXPORT
ClutterDeviceManager * clutter_virtual_input_device_get_manager (ClutterVirtualInputDevice *virtual_device);
CLUTTER_EXPORT
int clutter_virtual_input_device_get_device_type (ClutterVirtualInputDevice *virtual_device);
#endif /* __CLUTTER_VIRTUAL_INPUT_DEVICE_H__ */

View File

@ -40,10 +40,6 @@
/* This is a Cogl based backend */
#include "cogl/clutter-stage-cogl.h"
#ifdef HAVE_EVDEV
#include "evdev/clutter-device-manager-evdev.h"
#endif
#include "clutter-debug.h"
#include "clutter-private.h"
#include "clutter-main.h"

View File

@ -1,108 +0,0 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2010 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: Damien Lespiau <damien.lespiau@intel.com>
*/
#ifndef __CLUTTER_DEVICE_MANAGER_EVDEV_H__
#define __CLUTTER_DEVICE_MANAGER_EVDEV_H__
#include <clutter/clutter-backend.h>
#include <clutter/clutter-device-manager.h>
G_BEGIN_DECLS
#define CLUTTER_TYPE_DEVICE_MANAGER_EVDEV (clutter_device_manager_evdev_get_type ())
#define CLUTTER_DEVICE_MANAGER_EVDEV(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_DEVICE_MANAGER_EVDEV, ClutterDeviceManagerEvdev))
#define CLUTTER_IS_DEVICE_MANAGER_EVDEV(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_DEVICE_MANAGER_EVDEV))
#define CLUTTER_DEVICE_MANAGER_EVDEV_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_DEVICE_MANAGER_EVDEV, ClutterDeviceManagerEvdevClass))
#define CLUTTER_IS_DEVICE_MANAGER_EVDEV_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_DEVICE_MANAGER_EVDEV))
#define CLUTTER_DEVICE_MANAGER_EVDEV_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_DEVICE_MANAGER_EVDEV, ClutterDeviceManagerEvdevClass))
typedef struct _ClutterDeviceManagerEvdev ClutterDeviceManagerEvdev;
typedef struct _ClutterDeviceManagerEvdevClass ClutterDeviceManagerEvdevClass;
typedef struct _ClutterDeviceManagerEvdevPrivate ClutterDeviceManagerEvdevPrivate;
typedef struct _ClutterSeatEvdev ClutterSeatEvdev;
struct _ClutterDeviceManagerEvdev
{
ClutterDeviceManager parent_instance;
ClutterDeviceManagerEvdevPrivate *priv;
};
struct _ClutterDeviceManagerEvdevClass
{
ClutterDeviceManagerClass parent_class;
};
GType clutter_device_manager_evdev_get_type (void) G_GNUC_CONST;
void _clutter_events_evdev_init (ClutterBackend *backend);
void _clutter_events_evdev_uninit (ClutterBackend *backend);
gint _clutter_device_manager_evdev_acquire_device_id (ClutterDeviceManagerEvdev *manager_evdev);
void _clutter_device_manager_evdev_release_device_id (ClutterDeviceManagerEvdev *manager_evdev,
ClutterInputDevice *device);
ClutterStage * _clutter_device_manager_evdev_get_stage (ClutterDeviceManagerEvdev *manager_evdev);
void _clutter_device_manager_evdev_constrain_pointer (ClutterDeviceManagerEvdev *manager_evdev,
ClutterInputDevice *core_pointer,
uint64_t time_us,
float x,
float y,
float *new_x,
float *new_y);
void _clutter_device_manager_evdev_filter_relative_motion (ClutterDeviceManagerEvdev *manager_evdev,
ClutterInputDevice *device,
float x,
float y,
float *dx,
float *dy);
void _clutter_device_manager_evdev_dispatch (ClutterDeviceManagerEvdev *manager_evdev);
struct xkb_state * _clutter_device_manager_evdev_get_xkb_state (ClutterDeviceManagerEvdev *manager_evdev);
static inline guint64
us (guint64 us)
{
return us;
}
static inline guint64
ms2us (guint64 ms)
{
return us (ms * 1000);
}
static inline guint32
us2ms (guint64 us)
{
return (guint32) (us / 1000);
}
G_END_DECLS
#endif /* __CLUTTER_DEVICE_MANAGER_EVDEV_H__ */

View File

@ -1,181 +0,0 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2012 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/>.
*
*
*/
#ifndef __CLUTTER_EVDEV_H__
#define __CLUTTER_EVDEV_H__
#include <glib.h>
#include <glib-object.h>
#include <xkbcommon/xkbcommon.h>
#include <clutter/clutter.h>
#include <libinput.h>
G_BEGIN_DECLS
#if !defined(CLUTTER_ENABLE_COMPOSITOR_API) && !defined(CLUTTER_COMPILATION)
#error "You need to define CLUTTER_ENABLE_COMPOSITOR_API before including clutter-evdev.h"
#endif
/**
* ClutterOpenDeviceCallback:
* @path: the device path
* @flags: flags to be passed to open
*
* This callback will be called when Clutter needs to access an input
* device. It should return an open file descriptor for the file at @path,
* or -1 if opening failed.
*/
typedef int (*ClutterOpenDeviceCallback) (const char *path,
int flags,
gpointer user_data,
GError **error);
typedef void (*ClutterCloseDeviceCallback) (int fd,
gpointer user_data);
CLUTTER_EXPORT
void clutter_evdev_set_device_callbacks (ClutterOpenDeviceCallback open_callback,
ClutterCloseDeviceCallback close_callback,
gpointer user_data);
CLUTTER_EXPORT
void clutter_evdev_set_seat_id (const gchar *seat_id);
CLUTTER_EXPORT
void clutter_evdev_release_devices (void);
CLUTTER_EXPORT
void clutter_evdev_reclaim_devices (void);
/**
* ClutterPointerConstrainCallback:
* @device: the core pointer device
* @time: the event time in milliseconds
* @x: (inout): the new X coordinate
* @y: (inout): the new Y coordinate
* @user_data: user data passed to this function
*
* This callback will be called for all pointer motion events, and should
* update (@x, @y) to constrain the pointer position appropriately.
* The subsequent motion event will use the updated values as the new coordinates.
* Note that the coordinates are not clamped to the stage size, and the callback
* must make sure that this happens before it returns.
* Also note that the event will be emitted even if the pointer is constrained
* to be in the same position.
*
* Since: 1.16
*/
typedef void (*ClutterPointerConstrainCallback) (ClutterInputDevice *device,
guint32 time,
float prev_x,
float prev_y,
float *x,
float *y,
gpointer user_data);
CLUTTER_EXPORT
void clutter_evdev_set_pointer_constrain_callback (ClutterDeviceManager *evdev,
ClutterPointerConstrainCallback callback,
gpointer user_data,
GDestroyNotify user_data_notify);
typedef void (*ClutterRelativeMotionFilter) (ClutterInputDevice *device,
float x,
float y,
float *dx,
float *dy,
gpointer user_data);
CLUTTER_EXPORT
void clutter_evdev_set_relative_motion_filter (ClutterDeviceManager *evdev,
ClutterRelativeMotionFilter filter,
gpointer user_data);
CLUTTER_EXPORT
void clutter_evdev_set_keyboard_map (ClutterDeviceManager *evdev,
struct xkb_keymap *keymap);
CLUTTER_EXPORT
struct xkb_keymap * clutter_evdev_get_keyboard_map (ClutterDeviceManager *evdev);
CLUTTER_EXPORT
void clutter_evdev_set_keyboard_layout_index (ClutterDeviceManager *evdev,
xkb_layout_index_t idx);
CLUTTER_EXPORT
xkb_layout_index_t clutter_evdev_get_keyboard_layout_index (ClutterDeviceManager *evdev);
CLUTTER_EXPORT
void clutter_evdev_set_keyboard_numlock (ClutterDeviceManager *evdev,
gboolean numlock_state);
CLUTTER_EXPORT
void clutter_evdev_set_keyboard_repeat (ClutterDeviceManager *evdev,
gboolean repeat,
guint32 delay,
guint32 interval);
typedef gboolean (* ClutterEvdevFilterFunc) (struct libinput_event *event,
gpointer data);
CLUTTER_EXPORT
void clutter_evdev_add_filter (ClutterEvdevFilterFunc func,
gpointer data,
GDestroyNotify destroy_notify);
CLUTTER_EXPORT
void clutter_evdev_remove_filter (ClutterEvdevFilterFunc func,
gpointer data);
CLUTTER_EXPORT
struct libinput_device * clutter_evdev_input_device_get_libinput_device (ClutterInputDevice *device);
CLUTTER_EXPORT
gint32 clutter_evdev_event_sequence_get_slot (const ClutterEventSequence *sequence);
CLUTTER_EXPORT
void clutter_evdev_warp_pointer (ClutterInputDevice *pointer_device,
guint32 time_,
int x,
int y);
CLUTTER_EXPORT
guint32 clutter_evdev_event_get_event_code (const ClutterEvent *event);
CLUTTER_EXPORT
guint64 clutter_evdev_event_get_time_usec (const ClutterEvent *event);
CLUTTER_EXPORT
gboolean clutter_evdev_event_get_relative_motion (const ClutterEvent *event,
double *dx,
double *dy,
double *dx_unaccel,
double *dy_unaccel);
CLUTTER_EXPORT
void clutter_evdev_input_device_tool_set_pressure_curve (ClutterInputDeviceTool *tool,
gdouble curve[4]);
CLUTTER_EXPORT
void clutter_evdev_input_device_tool_set_button_code (ClutterInputDeviceTool *tool,
guint button,
guint evcode);
G_END_DECLS
#endif /* __CLUTTER_EVDEV_H__ */

View File

@ -1,191 +0,0 @@
/* Clutter.
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2015 Red Hat
*
* 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/>.
*
* Authored by:
* Carlos Garnacho <carlosg@gnome.org>
*/
#include "clutter-build-config.h"
#include "clutter/clutter-device-manager-private.h"
#include "clutter/clutter-event-private.h"
#include "clutter-input-device-evdev.h"
#include "clutter-evdev.h"
typedef struct _ClutterEventEvdev ClutterEventEvdev;
struct _ClutterEventEvdev
{
guint32 evcode;
guint64 time_usec;
gboolean has_relative_motion;
double dx;
double dy;
double dx_unaccel;
double dy_unaccel;
};
static ClutterEventEvdev *
_clutter_event_evdev_new (void)
{
return g_slice_new0 (ClutterEventEvdev);
}
ClutterEventEvdev *
_clutter_event_evdev_copy (ClutterEventEvdev *event_evdev)
{
if (event_evdev != NULL)
return g_slice_dup (ClutterEventEvdev, event_evdev);
return NULL;
}
void
_clutter_event_evdev_free (ClutterEventEvdev *event_evdev)
{
if (event_evdev != NULL)
g_slice_free (ClutterEventEvdev, event_evdev);
}
static ClutterEventEvdev *
clutter_evdev_event_ensure_platform_data (ClutterEvent *event)
{
ClutterEventEvdev *event_evdev = _clutter_event_get_platform_data (event);
if (!event_evdev)
{
event_evdev = _clutter_event_evdev_new ();
_clutter_event_set_platform_data (event, event_evdev);
}
return event_evdev;
}
void
_clutter_evdev_event_set_event_code (ClutterEvent *event,
guint32 evcode)
{
ClutterEventEvdev *event_evdev;
event_evdev = clutter_evdev_event_ensure_platform_data (event);
event_evdev->evcode = evcode;
}
void
_clutter_evdev_event_set_time_usec (ClutterEvent *event,
guint64 time_usec)
{
ClutterEventEvdev *event_evdev;
event_evdev = clutter_evdev_event_ensure_platform_data (event);
event_evdev->time_usec = time_usec;
}
void
_clutter_evdev_event_set_relative_motion (ClutterEvent *event,
double dx,
double dy,
double dx_unaccel,
double dy_unaccel)
{
ClutterEventEvdev *event_evdev;
event_evdev = clutter_evdev_event_ensure_platform_data (event);
event_evdev->dx = dx;
event_evdev->dy = dy;
event_evdev->dx_unaccel = dx_unaccel;
event_evdev->dy_unaccel = dy_unaccel;
event_evdev->has_relative_motion = TRUE;
}
/**
* clutter_evdev_event_get_event_code:
* @event: a #ClutterEvent
*
* Returns the event code of the original event. See linux/input.h for more
* information.
*
* Returns: The event code.
**/
guint32
clutter_evdev_event_get_event_code (const ClutterEvent *event)
{
ClutterEventEvdev *event_evdev = _clutter_event_get_platform_data (event);
if (event_evdev)
return event_evdev->evcode;
return 0;
}
/**
* clutter_evdev_event_get_time_usec:
* @event: a #ClutterEvent
*
* Returns the time in microsecond granularity, or 0 if unavailable.
*
* Returns: The time in microsecond granularity, or 0 if unavailable.
*/
guint64
clutter_evdev_event_get_time_usec (const ClutterEvent *event)
{
ClutterEventEvdev *event_evdev = _clutter_event_get_platform_data (event);
if (event_evdev)
return event_evdev->time_usec;
return 0;
}
/**
* clutter_evdev_event_get_pointer_motion
* @event: a #ClutterEvent
*
* If available, the normal and unaccelerated motion deltas are written
* to the dx, dy, dx_unaccel and dy_unaccel and TRUE is returned.
*
* If unavailable, FALSE is returned.
*
* Returns: TRUE on success, otherwise FALSE.
**/
gboolean
clutter_evdev_event_get_relative_motion (const ClutterEvent *event,
double *dx,
double *dy,
double *dx_unaccel,
double *dy_unaccel)
{
ClutterEventEvdev *event_evdev = _clutter_event_get_platform_data (event);
if (event_evdev && event_evdev->has_relative_motion)
{
if (dx)
*dx = event_evdev->dx;
if (dy)
*dy = event_evdev->dy;
if (dx_unaccel)
*dx_unaccel = event_evdev->dx_unaccel;
if (dy_unaccel)
*dy_unaccel = event_evdev->dy_unaccel;
return TRUE;
}
else
return FALSE;
}

View File

@ -1,157 +0,0 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2010 Intel Corp.
* Copyright (C) 2014 Jonas Ådahl
*
* 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: Damien Lespiau <damien.lespiau@intel.com>
* Author: Jonas Ådahl <jadahl@gmail.com>
*/
#ifndef __CLUTTER_INPUT_DEVICE_EVDEV_H__
#define __CLUTTER_INPUT_DEVICE_EVDEV_H__
#include <glib-object.h>
#include <libinput.h>
#include "clutter/clutter-device-manager-private.h"
#include "evdev/clutter-seat-evdev.h"
G_BEGIN_DECLS
#define CLUTTER_TYPE_INPUT_DEVICE_EVDEV _clutter_input_device_evdev_get_type()
#define CLUTTER_INPUT_DEVICE_EVDEV(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
CLUTTER_TYPE_INPUT_DEVICE_EVDEV, ClutterInputDeviceEvdev))
#define CLUTTER_INPUT_DEVICE_EVDEV_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), \
CLUTTER_TYPE_INPUT_DEVICE_EVDEV, ClutterInputDeviceEvdevClass))
#define CLUTTER_IS_INPUT_DEVICE_EVDEV(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
CLUTTER_TYPE_INPUT_DEVICE_EVDEV))
#define CLUTTER_IS_INPUT_DEVICE_EVDEV_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
CLUTTER_TYPE_INPUT_DEVICE_EVDEV))
#define CLUTTER_INPUT_DEVICE_EVDEV_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
CLUTTER_TYPE_INPUT_DEVICE_EVDEV, ClutterInputDeviceEvdevClass))
typedef struct _ClutterInputDeviceEvdev ClutterInputDeviceEvdev;
typedef struct _ClutterEventEvdev ClutterEventEvdev;
struct _ClutterInputDeviceEvdev
{
ClutterInputDevice parent;
struct libinput_device *libinput_device;
ClutterSeatEvdev *seat;
ClutterInputDeviceTool *last_tool;
cairo_matrix_t device_matrix;
gdouble device_aspect_ratio; /* w:h */
gdouble output_ratio; /* w:h */
GHashTable *touches;
/* Keyboard a11y */
ClutterKeyboardA11yFlags a11y_flags;
GList *slow_keys_list;
guint debounce_timer;
guint16 debounce_key;
xkb_mod_mask_t stickykeys_depressed_mask;
xkb_mod_mask_t stickykeys_latched_mask;
xkb_mod_mask_t stickykeys_locked_mask;
guint toggle_slowkeys_timer;
guint16 shift_count;
guint32 last_shift_time;
gint mousekeys_btn;
gboolean mousekeys_btn_states[3];
guint32 mousekeys_first_motion_time; /* ms */
guint32 mousekeys_last_motion_time; /* ms */
guint mousekeys_init_delay;
guint mousekeys_accel_time;
guint mousekeys_max_speed;
gdouble mousekeys_curve_factor;
guint move_mousekeys_timer;
guint16 last_mousekeys_key;
};
GType _clutter_input_device_evdev_get_type (void) G_GNUC_CONST;
ClutterInputDevice * _clutter_input_device_evdev_new (ClutterDeviceManager *manager,
ClutterSeatEvdev *seat,
struct libinput_device *libinput_device);
ClutterInputDevice * _clutter_input_device_evdev_new_virtual (ClutterDeviceManager *manager,
ClutterSeatEvdev *seat,
ClutterInputDeviceType type,
ClutterInputMode mode);
ClutterSeatEvdev * _clutter_input_device_evdev_get_seat (ClutterInputDeviceEvdev *device);
void _clutter_input_device_evdev_update_leds (ClutterInputDeviceEvdev *device,
enum libinput_led leds);
ClutterInputDeviceType _clutter_input_device_evdev_determine_type (struct libinput_device *libinput_device);
ClutterEventEvdev * _clutter_event_evdev_copy (ClutterEventEvdev *event_evdev);
void _clutter_event_evdev_free (ClutterEventEvdev *event_evdev);
void _clutter_evdev_event_set_event_code (ClutterEvent *event,
guint32 evcode);
void _clutter_evdev_event_set_time_usec (ClutterEvent *event,
guint64 time_usec);
void _clutter_evdev_event_set_relative_motion (ClutterEvent *event,
double dx,
double dy,
double dx_unaccel,
double dy_unaccel);
void clutter_input_device_evdev_translate_coordinates (ClutterInputDevice *device,
ClutterStage *stage,
gfloat *x,
gfloat *y);
void clutter_input_device_evdev_apply_kbd_a11y_settings (ClutterInputDeviceEvdev *device,
ClutterKbdA11ySettings *settings);
ClutterTouchState * clutter_input_device_evdev_acquire_touch_state (ClutterInputDeviceEvdev *device,
int device_slot);
ClutterTouchState * clutter_input_device_evdev_lookup_touch_state (ClutterInputDeviceEvdev *device,
int device_slot);
void clutter_input_device_evdev_release_touch_state (ClutterInputDeviceEvdev *device,
ClutterTouchState *touch_state);
void clutter_input_device_evdev_release_touch_slots (ClutterInputDeviceEvdev *device_evdev,
uint64_t time_us);
void clutter_evdev_a11y_maybe_notify_toggle_keys (ClutterInputDeviceEvdev *);
G_END_DECLS
#endif /* __CLUTTER_INPUT_DEVICE_EVDEV_H__ */

View File

@ -1,84 +0,0 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright © 2009, 2010, 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: Carlos Garnacho <carlosg@gnome.org>
*/
#ifndef __CLUTTER_INPUT_DEVICE_EVDEV_TOOL_H__
#define __CLUTTER_INPUT_DEVICE_EVDEV_TOOL_H__
#include <libinput.h>
#include <clutter/clutter-input-device-tool.h>
G_BEGIN_DECLS
#define CLUTTER_TYPE_INPUT_DEVICE_TOOL_EVDEV (clutter_input_device_tool_evdev_get_type ())
#define CLUTTER_INPUT_DEVICE_TOOL_EVDEV(o) \
(G_TYPE_CHECK_INSTANCE_CAST ((o), \
CLUTTER_TYPE_INPUT_DEVICE_TOOL_EVDEV, ClutterInputDeviceToolEvdev))
#define CLUTTER_IS_INPUT_DEVICE_TOOL_EVDEV(o) \
(G_TYPE_CHECK_INSTANCE_TYPE ((o), \
CLUTTER_TYPE_INPUT_DEVICE_TOOL_EVDEV))
#define CLUTTER_INPUT_DEVICE_TOOL_EVDEV_CLASS(c) \
(G_TYPE_CHECK_CLASS_CAST ((c), \
CLUTTER_TYPE_INPUT_DEVICE_TOOL_EVDEV, ClutterInputDeviceToolEvdevClass))
#define CLUTTER_IS_INPUT_DEVICE_TOOL_EVDEV_CLASS(c) \
(G_TYPE_CHECK_CLASS_TYPE ((c), \
CLUTTER_TYPE_INPUT_DEVICE_TOOL_EVDEV))
#define CLUTTER_INPUT_DEVICE_TOOL_EVDEV_GET_CLASS(o) \
(G_TYPE_INSTANCE_GET_CLASS ((o), \
CLUTTER_TYPE_INPUT_DEVICE_TOOL_EVDEV, ClutterInputDeviceToolEvdevClass))
typedef struct _ClutterInputDeviceToolEvdev ClutterInputDeviceToolEvdev;
typedef struct _ClutterInputDeviceToolEvdevClass ClutterInputDeviceToolEvdevClass;
struct _ClutterInputDeviceToolEvdev
{
ClutterInputDeviceTool parent_instance;
struct libinput_tablet_tool *tool;
GHashTable *button_map;
gdouble pressure_curve[4];
};
struct _ClutterInputDeviceToolEvdevClass
{
ClutterInputDeviceToolClass parent_class;
};
GType clutter_input_device_tool_evdev_get_type (void) G_GNUC_CONST;
ClutterInputDeviceTool * clutter_input_device_tool_evdev_new (struct libinput_tablet_tool *tool,
guint64 serial,
ClutterInputDeviceToolType type);
gdouble clutter_input_device_tool_evdev_translate_pressure (ClutterInputDeviceTool *tool,
gdouble pressure);
guint clutter_input_device_tool_evdev_get_button_code (ClutterInputDeviceTool *tool,
guint button);
G_END_DECLS
#endif /* __CLUTTER_INPUT_DEVICE_EVDEV_TOOL_H__ */

View File

@ -1,163 +0,0 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2010 Intel Corp.
* Copyright (C) 2014 Jonas Ådahl
* Copyright (C) 2016 Red Hat Inc.
*
* 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: Damien Lespiau <damien.lespiau@intel.com>
* Author: Jonas Ådahl <jadahl@gmail.com>
*/
#ifndef __CLUTTER_SEAT_EVDEV_H__
#define __CLUTTER_SEAT_EVDEV_H__
#include <libinput.h>
#include <linux/input.h>
#include "clutter-input-device.h"
#include "clutter-device-manager-evdev.h"
#include "clutter-xkb-utils.h"
typedef struct _ClutterTouchState ClutterTouchState;
struct _ClutterTouchState
{
ClutterSeatEvdev *seat;
int device_slot;
int seat_slot;
ClutterPoint coords;
};
struct _ClutterSeatEvdev
{
struct libinput_seat *libinput_seat;
ClutterDeviceManagerEvdev *manager_evdev;
GSList *devices;
ClutterInputDevice *core_pointer;
ClutterInputDevice *core_keyboard;
ClutterTouchState **touch_states;
int n_alloc_touch_states;
struct xkb_state *xkb;
xkb_led_index_t caps_lock_led;
xkb_led_index_t num_lock_led;
xkb_led_index_t scroll_lock_led;
xkb_layout_index_t layout_idx;
uint32_t button_state;
int button_count[KEY_CNT];
/* keyboard repeat */
gboolean repeat;
guint32 repeat_delay;
guint32 repeat_interval;
guint32 repeat_key;
guint32 repeat_count;
guint32 repeat_timer;
ClutterInputDevice *repeat_device;
gfloat pointer_x;
gfloat pointer_y;
/* Emulation of discrete scroll events out of smooth ones */
gfloat accum_scroll_dx;
gfloat accum_scroll_dy;
};
void clutter_seat_evdev_notify_key (ClutterSeatEvdev *seat,
ClutterInputDevice *device,
uint64_t time_us,
uint32_t key,
uint32_t state,
gboolean update_keys);
void clutter_seat_evdev_notify_relative_motion (ClutterSeatEvdev *seat_evdev,
ClutterInputDevice *input_device,
uint64_t time_us,
float dx,
float dy,
float dx_unaccel,
float dy_unaccel);
void clutter_seat_evdev_notify_absolute_motion (ClutterSeatEvdev *seat_evdev,
ClutterInputDevice *input_device,
uint64_t time_us,
float x,
float y,
double *axes);
void clutter_seat_evdev_notify_button (ClutterSeatEvdev *seat,
ClutterInputDevice *input_device,
uint64_t time_us,
uint32_t button,
uint32_t state);
void clutter_seat_evdev_notify_scroll_continuous (ClutterSeatEvdev *seat,
ClutterInputDevice *input_device,
uint64_t time_us,
double dx,
double dy,
ClutterScrollSource source,
ClutterScrollFinishFlags flags);
void clutter_seat_evdev_notify_discrete_scroll (ClutterSeatEvdev *seat,
ClutterInputDevice *input_device,
uint64_t time_us,
double discrete_dx,
double discrete_dy,
ClutterScrollSource source);
void clutter_seat_evdev_notify_touch_event (ClutterSeatEvdev *seat,
ClutterInputDevice *input_device,
ClutterEventType evtype,
uint64_t time_us,
int slot,
double x,
double y);
void clutter_seat_evdev_set_libinput_seat (ClutterSeatEvdev *seat,
struct libinput_seat *libinput_seat);
void clutter_seat_evdev_sync_leds (ClutterSeatEvdev *seat);
ClutterInputDevice * clutter_seat_evdev_get_device (ClutterSeatEvdev *seat,
gint id);
ClutterTouchState * clutter_seat_evdev_acquire_touch_state (ClutterSeatEvdev *seat,
int device_slot);
void clutter_seat_evdev_release_touch_state (ClutterSeatEvdev *seat,
ClutterTouchState *touch_state);
ClutterTouchState * clutter_seat_evdev_get_touch (ClutterSeatEvdev *seat,
guint32 id);
void clutter_seat_evdev_set_stage (ClutterSeatEvdev *seat,
ClutterStage *stage);
void clutter_seat_evdev_clear_repeat_timer (ClutterSeatEvdev *seat);
ClutterSeatEvdev * clutter_seat_evdev_new (ClutterDeviceManagerEvdev *manager_evdev);
void clutter_seat_evdev_free (ClutterSeatEvdev *seat);
#endif /* __CLUTTER_SEAT_EVDEV_H__ */

View File

@ -1,46 +0,0 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2010 Intel Corporation.
*
* 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/>.
* Authors:
* Damien Lespiau <damien.lespiau@intel.com>
*/
#ifndef __CLUTTER_XKB_UTILS_H__
#define __CLUTTER_XKB_UTILS_H__
#include <xkbcommon/xkbcommon.h>
#include "clutter-stage.h"
#include "clutter-event.h"
#include "clutter-input-device.h"
ClutterEvent * _clutter_key_event_new_from_evdev (ClutterInputDevice *device,
ClutterInputDevice *core_keyboard,
ClutterStage *stage,
struct xkb_state *xkb_state,
uint32_t button_state,
uint32_t _time,
uint32_t key,
uint32_t state);
void _clutter_xkb_translate_state (ClutterEvent *event,
struct xkb_state *xkb_state,
uint32_t button_state);
#endif /* __CLUTTER_XKB_UTILS_H__ */

View File

@ -297,28 +297,8 @@ endif
if have_native_backend
clutter_native_nonintrospected_sources = [
'egl/clutter-backend-eglnative.c',
'evdev/clutter-device-manager-evdev.c',
'evdev/clutter-event-evdev.c',
'evdev/clutter-input-device-evdev.c',
'evdev/clutter-input-device-tool-evdev.c',
'evdev/clutter-keymap-evdev.c',
'evdev/clutter-seat-evdev.c',
'evdev/clutter-virtual-input-device-evdev.c',
'evdev/clutter-xkb-utils.c',
]
clutter_backend_nonintrospected_sources += clutter_native_nonintrospected_sources
clutter_native_private_headers = [
'evdev/clutter-evdev.h',
'evdev/clutter-device-manager-evdev.h',
'evdev/clutter-input-device-evdev.h',
'evdev/clutter-input-device-tool-evdev.h',
'evdev/clutter-keymap-evdev.h',
'evdev/clutter-seat-evdev.h',
'evdev/clutter-virtual-input-device-evdev.h',
'evdev/clutter-xkb-utils.h',
]
clutter_backend_private_headers += clutter_native_private_headers
endif
if have_wayland

View File

@ -71,14 +71,6 @@ if have_x11
]
endif
if have_native_backend
clutter_pkg_private_deps += [
libudev_dep,
libinput_dep,
xkbcommon_dep,
]
endif
if have_libwacom
clutter_pkg_private_deps += [
libwacom_dep,

View File

@ -50,6 +50,8 @@
#include "backends/native/meta-barrier-native.h"
#include "backends/native/meta-clutter-backend-native.h"
#include "backends/native/meta-cursor-renderer-native.h"
#include "backends/native/meta-device-manager-native.h"
#include "backends/native/meta-event-native.h"
#include "backends/native/meta-input-settings-native.h"
#include "backends/native/meta-kms.h"
#include "backends/native/meta-kms-device.h"
@ -57,7 +59,6 @@
#include "backends/native/meta-monitor-manager-kms.h"
#include "backends/native/meta-renderer-native.h"
#include "backends/native/meta-stage-native.h"
#include "clutter/evdev/clutter-evdev.h"
#include "core/meta-border.h"
#include "meta/main.h"
@ -343,10 +344,10 @@ meta_backend_native_post_init (MetaBackend *backend)
META_BACKEND_CLASS (meta_backend_native_parent_class)->post_init (backend);
clutter_evdev_set_pointer_constrain_callback (manager, pointer_constrain_callback,
NULL, NULL);
clutter_evdev_set_relative_motion_filter (manager, relative_motion_filter,
meta_backend_get_monitor_manager (backend));
meta_device_manager_native_set_pointer_constrain_callback (manager, pointer_constrain_callback,
NULL, NULL);
meta_device_manager_native_set_relative_motion_filter (manager, relative_motion_filter,
meta_backend_get_monitor_manager (backend));
if (meta_settings_is_experimental_feature_enabled (settings,
META_EXPERIMENTAL_FEATURE_RT_SCHEDULER))
@ -411,7 +412,7 @@ meta_backend_native_warp_pointer (MetaBackend *backend,
guint32 time_ = 0;
/* Warp the input device pointer state. */
clutter_evdev_warp_pointer (device, time_, x, y);
meta_device_manager_native_warp_pointer (device, time_, x, y);
/* Warp displayed pointer cursor. */
meta_cursor_tracker_update_position (cursor_tracker, x, y);
@ -450,7 +451,7 @@ meta_backend_native_set_keymap (MetaBackend *backend,
keymap = xkb_keymap_new_from_names (context, &names, XKB_KEYMAP_COMPILE_NO_FLAGS);
xkb_context_unref (context);
clutter_evdev_set_keyboard_map (manager, keymap);
meta_device_manager_native_set_keyboard_map (manager, keymap);
meta_backend_notify_keymap_changed (backend);
@ -461,7 +462,7 @@ static struct xkb_keymap *
meta_backend_native_get_keymap (MetaBackend *backend)
{
ClutterDeviceManager *manager = clutter_device_manager_get_default ();
return clutter_evdev_get_keyboard_map (manager);
return meta_device_manager_native_get_keyboard_map (manager);
}
static xkb_layout_index_t
@ -469,7 +470,7 @@ meta_backend_native_get_keymap_layout_group (MetaBackend *backend)
{
ClutterDeviceManager *manager = clutter_device_manager_get_default ();
return clutter_evdev_get_keyboard_layout_index (manager);
return meta_device_manager_native_get_keyboard_layout_index (manager);
}
static void
@ -483,7 +484,7 @@ meta_backend_native_lock_layout_group (MetaBackend *backend,
if (old_idx == idx)
return;
clutter_evdev_set_keyboard_layout_index (manager, idx);
meta_device_manager_native_set_keyboard_layout_index (manager, idx);
meta_backend_notify_keymap_layout_group_changed (backend, idx);
}
@ -492,7 +493,7 @@ meta_backend_native_set_numlock (MetaBackend *backend,
gboolean numlock_state)
{
ClutterDeviceManager *manager = clutter_device_manager_get_default ();
clutter_evdev_set_keyboard_numlock (manager, numlock_state);
meta_device_manager_native_set_keyboard_numlock (manager, numlock_state);
}
static gboolean
@ -503,9 +504,9 @@ meta_backend_native_get_relative_motion_deltas (MetaBackend *backend,
double *dx_unaccel,
double *dy_unaccel)
{
return clutter_evdev_event_get_relative_motion (event,
dx, dy,
dx_unaccel, dy_unaccel);
return meta_event_native_get_relative_motion (event,
dx, dy,
dx_unaccel, dy_unaccel);
}
static void
@ -798,7 +799,7 @@ meta_backend_native_pause (MetaBackendNative *native)
MetaMonitorManagerKms *monitor_manager_kms =
META_MONITOR_MANAGER_KMS (monitor_manager);
clutter_evdev_release_devices ();
meta_device_manager_native_release_devices ();
clutter_stage_freeze_updates (stage);
disconnect_udev_device_added_handler (native);
@ -821,7 +822,7 @@ void meta_backend_native_resume (MetaBackendNative *native)
connect_udev_device_added_handler (native);
clutter_evdev_reclaim_devices ();
meta_device_manager_native_reclaim_devices ();
clutter_stage_thaw_updates (stage);
clutter_actor_queue_redraw (CLUTTER_ACTOR (stage));

View File

@ -44,6 +44,8 @@
#include "backends/meta-backend-private.h"
#include "backends/meta-renderer.h"
#include "backends/native/meta-device-manager-native.h"
#include "backends/native/meta-keymap-native.h"
#include "backends/native/meta-stage-native.h"
#include "clutter/clutter.h"
#include "core/bell.h"
@ -54,6 +56,8 @@ struct _MetaClutterBackendNative
ClutterBackendEglNative parent;
MetaStageNative *stage_native;
MetaKeymapNative *keymap;
MetaDeviceManagerNative *device_manager;
};
G_DEFINE_TYPE (MetaClutterBackendNative, meta_clutter_backend_native,
@ -103,6 +107,33 @@ meta_clutter_backend_native_bell_notify (ClutterBackend *backend)
meta_bell_notify (display, NULL);
}
static ClutterDeviceManager *
meta_clutter_backend_native_get_device_manager (ClutterBackend *backend)
{
MetaClutterBackendNative *backend_native = META_CLUTTER_BACKEND_NATIVE (backend);
return CLUTTER_DEVICE_MANAGER (backend_native->device_manager);
}
static ClutterKeymap *
meta_clutter_backend_native_get_keymap (ClutterBackend *backend)
{
MetaClutterBackendNative *backend_native = META_CLUTTER_BACKEND_NATIVE (backend);
return CLUTTER_KEYMAP (backend_native->keymap);
}
static void
meta_clutter_backend_native_init_events (ClutterBackend *backend)
{
MetaClutterBackendNative *backend_native = META_CLUTTER_BACKEND_NATIVE (backend);
backend_native->keymap = g_object_new (META_TYPE_KEYMAP_NATIVE, NULL);
backend_native->device_manager = g_object_new (META_TYPE_DEVICE_MANAGER_NATIVE,
"backend", backend,
NULL);
}
static void
meta_clutter_backend_native_init (MetaClutterBackendNative *clutter_backend_nativen)
{
@ -116,4 +147,7 @@ meta_clutter_backend_native_class_init (MetaClutterBackendNativeClass *klass)
clutter_backend_class->get_renderer = meta_clutter_backend_native_get_renderer;
clutter_backend_class->create_stage = meta_clutter_backend_native_create_stage;
clutter_backend_class->bell_notify = meta_clutter_backend_native_bell_notify;
clutter_backend_class->get_device_manager = meta_clutter_backend_native_get_device_manager;
clutter_backend_class->get_keymap = meta_clutter_backend_native_get_keymap;
clutter_backend_class->init_events = meta_clutter_backend_native_init_events;
}

View File

@ -0,0 +1,194 @@
/*
* Copyright (C) 2010 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: Damien Lespiau <damien.lespiau@intel.com>
*/
#ifndef META_DEVICE_MANAGER_NATIVE_H
#define META_DEVICE_MANAGER_NATIVE_H
#include <libinput.h>
#include <xkbcommon/xkbcommon.h>
#include "clutter/clutter-mutter.h"
#define META_TYPE_DEVICE_MANAGER_NATIVE (meta_device_manager_native_get_type ())
#define META_DEVICE_MANAGER_NATIVE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), META_TYPE_DEVICE_MANAGER_NATIVE, MetaDeviceManagerNative))
#define META_IS_DEVICE_MANAGER_NATIVE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), META_TYPE_DEVICE_MANAGER_NATIVE))
#define META_DEVICE_MANAGER_NATIVE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), META_TYPE_DEVICE_MANAGER_NATIVE, MetaDeviceManagerNativeClass))
#define META_IS_DEVICE_MANAGER_NATIVE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), META_TYPE_DEVICE_MANAGER_NATIVE))
#define META_DEVICE_MANAGER_NATIVE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), META_TYPE_DEVICE_MANAGER_NATIVE, MetaDeviceManagerNativeClass))
typedef struct _MetaDeviceManagerNative MetaDeviceManagerNative;
typedef struct _MetaDeviceManagerNativeClass MetaDeviceManagerNativeClass;
typedef struct _MetaDeviceManagerNativePrivate MetaDeviceManagerNativePrivate;
struct _MetaDeviceManagerNative
{
ClutterDeviceManager parent_instance;
MetaDeviceManagerNativePrivate *priv;
};
struct _MetaDeviceManagerNativeClass
{
ClutterDeviceManagerClass parent_class;
};
GType meta_device_manager_native_get_type (void) G_GNUC_CONST;
gint meta_device_manager_native_acquire_device_id (MetaDeviceManagerNative *manager_evdev);
void meta_device_manager_native_release_device_id (MetaDeviceManagerNative *manager_evdev,
ClutterInputDevice *device);
ClutterStage * meta_device_manager_native_get_stage (MetaDeviceManagerNative *manager_evdev);
void meta_device_manager_native_constrain_pointer (MetaDeviceManagerNative *manager_evdev,
ClutterInputDevice *core_pointer,
uint64_t time_us,
float x,
float y,
float *new_x,
float *new_y);
void meta_device_manager_native_filter_relative_motion (MetaDeviceManagerNative *manager_evdev,
ClutterInputDevice *device,
float x,
float y,
float *dx,
float *dy);
void meta_device_manager_native_dispatch (MetaDeviceManagerNative *manager_evdev);
struct xkb_state * meta_device_manager_native_get_xkb_state (MetaDeviceManagerNative *manager_evdev);
static inline guint64
us (guint64 us)
{
return us;
}
static inline guint64
ms2us (guint64 ms)
{
return us (ms * 1000);
}
static inline guint32
us2ms (guint64 us)
{
return (guint32) (us / 1000);
}
/**
* MetaOpenDeviceCallback:
* @path: the device path
* @flags: flags to be passed to open
*
* This callback will be called when Clutter needs to access an input
* device. It should return an open file descriptor for the file at @path,
* or -1 if opening failed.
*/
typedef int (*MetaOpenDeviceCallback) (const char *path,
int flags,
gpointer user_data,
GError **error);
typedef void (*MetaCloseDeviceCallback) (int fd,
gpointer user_data);
void meta_device_manager_native_set_device_callbacks (MetaOpenDeviceCallback open_callback,
MetaCloseDeviceCallback close_callback,
gpointer user_data);
void meta_device_manager_native_set_seat_id (const gchar *seat_id);
void meta_device_manager_native_release_devices (void);
void meta_device_manager_native_reclaim_devices (void);
/**
* MetaPointerConstrainCallback:
* @device: the core pointer device
* @time: the event time in milliseconds
* @x: (inout): the new X coordinate
* @y: (inout): the new Y coordinate
* @user_data: user data passed to this function
*
* This callback will be called for all pointer motion events, and should
* update (@x, @y) to constrain the pointer position appropriately.
* The subsequent motion event will use the updated values as the new coordinates.
* Note that the coordinates are not clamped to the stage size, and the callback
* must make sure that this happens before it returns.
* Also note that the event will be emitted even if the pointer is constrained
* to be in the same position.
*/
typedef void (* MetaPointerConstrainCallback) (ClutterInputDevice *device,
guint32 time,
float prev_x,
float prev_y,
float *x,
float *y,
gpointer user_data);
void meta_device_manager_native_set_pointer_constrain_callback (ClutterDeviceManager *evdev,
MetaPointerConstrainCallback callback,
gpointer user_data,
GDestroyNotify user_data_notify);
typedef void (* MetaRelativeMotionFilter) (ClutterInputDevice *device,
float x,
float y,
float *dx,
float *dy,
gpointer user_data);
void meta_device_manager_native_set_relative_motion_filter (ClutterDeviceManager *evdev,
MetaRelativeMotionFilter filter,
gpointer user_data);
void meta_device_manager_native_set_keyboard_map (ClutterDeviceManager *evdev,
struct xkb_keymap *keymap);
struct xkb_keymap * meta_device_manager_native_get_keyboard_map (ClutterDeviceManager *evdev);
void meta_device_manager_native_set_keyboard_layout_index (ClutterDeviceManager *evdev,
xkb_layout_index_t idx);
xkb_layout_index_t meta_device_manager_native_get_keyboard_layout_index (ClutterDeviceManager *evdev);
void meta_device_manager_native_set_keyboard_numlock (ClutterDeviceManager *evdev,
gboolean numlock_state);
void meta_device_manager_native_set_keyboard_repeat (ClutterDeviceManager *evdev,
gboolean repeat,
guint32 delay,
guint32 interval);
typedef gboolean (* MetaEvdevFilterFunc) (struct libinput_event *event,
gpointer data);
void meta_device_manager_native_add_filter (MetaEvdevFilterFunc func,
gpointer data,
GDestroyNotify destroy_notify);
void meta_device_manager_native_remove_filter (MetaEvdevFilterFunc func,
gpointer data);
void meta_device_manager_native_warp_pointer (ClutterInputDevice *pointer_device,
guint32 time_,
int x,
int y);
#endif /* META_DEVICE_MANAGER_NATIVE_H */

View File

@ -0,0 +1,208 @@
/*
* Copyright (C) 2015 Red Hat
*
* 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/>.
*
* Authored by:
* Carlos Garnacho <carlosg@gnome.org>
*/
#include "config.h"
#include "backends/native/meta-event-native.h"
#include "backends/native/meta-input-device-native.h"
#include "clutter/clutter-mutter.h"
typedef struct _MetaEventNative MetaEventNative;
struct _MetaEventNative
{
guint32 evcode;
guint64 time_usec;
gboolean has_relative_motion;
double dx;
double dy;
double dx_unaccel;
double dy_unaccel;
};
static MetaEventNative *
meta_event_native_new (void)
{
return g_slice_new0 (MetaEventNative);
}
MetaEventNative *
meta_event_native_copy (MetaEventNative *event_evdev)
{
if (event_evdev != NULL)
return g_slice_dup (MetaEventNative, event_evdev);
return NULL;
}
void
meta_event_native_free (MetaEventNative *event_evdev)
{
if (event_evdev != NULL)
g_slice_free (MetaEventNative, event_evdev);
}
static MetaEventNative *
meta_event_native_ensure_platform_data (ClutterEvent *event)
{
MetaEventNative *event_evdev = _clutter_event_get_platform_data (event);
if (!event_evdev)
{
event_evdev = meta_event_native_new ();
_clutter_event_set_platform_data (event, event_evdev);
}
return event_evdev;
}
void
meta_event_native_set_event_code (ClutterEvent *event,
guint32 evcode)
{
MetaEventNative *event_evdev;
event_evdev = meta_event_native_ensure_platform_data (event);
event_evdev->evcode = evcode;
}
void
meta_event_native_set_time_usec (ClutterEvent *event,
guint64 time_usec)
{
MetaEventNative *event_evdev;
event_evdev = meta_event_native_ensure_platform_data (event);
event_evdev->time_usec = time_usec;
}
void
meta_event_native_set_relative_motion (ClutterEvent *event,
double dx,
double dy,
double dx_unaccel,
double dy_unaccel)
{
MetaEventNative *event_evdev;
event_evdev = meta_event_native_ensure_platform_data (event);
event_evdev->dx = dx;
event_evdev->dy = dy;
event_evdev->dx_unaccel = dx_unaccel;
event_evdev->dy_unaccel = dy_unaccel;
event_evdev->has_relative_motion = TRUE;
}
/**
* meta_event_native_get_event_code:
* @event: a #ClutterEvent
*
* Returns the event code of the original event. See linux/input.h for more
* information.
*
* Returns: The event code.
**/
guint32
meta_event_native_get_event_code (const ClutterEvent *event)
{
MetaEventNative *event_evdev = _clutter_event_get_platform_data (event);
if (event_evdev)
return event_evdev->evcode;
return 0;
}
/**
* meta_event_native_get_time_usec:
* @event: a #ClutterEvent
*
* Returns the time in microsecond granularity, or 0 if unavailable.
*
* Returns: The time in microsecond granularity, or 0 if unavailable.
*/
guint64
meta_event_native_get_time_usec (const ClutterEvent *event)
{
MetaEventNative *event_evdev = _clutter_event_get_platform_data (event);
if (event_evdev)
return event_evdev->time_usec;
return 0;
}
/**
* meta_event_get_pointer_motion
* @event: a #ClutterEvent
*
* If available, the normal and unaccelerated motion deltas are written
* to the dx, dy, dx_unaccel and dy_unaccel and TRUE is returned.
*
* If unavailable, FALSE is returned.
*
* Returns: TRUE on success, otherwise FALSE.
**/
gboolean
meta_event_native_get_relative_motion (const ClutterEvent *event,
double *dx,
double *dy,
double *dx_unaccel,
double *dy_unaccel)
{
MetaEventNative *event_evdev = _clutter_event_get_platform_data (event);
if (event_evdev && event_evdev->has_relative_motion)
{
if (dx)
*dx = event_evdev->dx;
if (dy)
*dy = event_evdev->dy;
if (dx_unaccel)
*dx_unaccel = event_evdev->dx_unaccel;
if (dy_unaccel)
*dy_unaccel = event_evdev->dy_unaccel;
return TRUE;
}
else
return FALSE;
}
/**
* meta_event_native_sequence_get_slot:
* @sequence: a #ClutterEventSequence
*
* Retrieves the touch slot triggered by this @sequence
*
* Returns: the libinput touch slot.
*
* Since: 1.20
* Stability: unstable
**/
int32_t
meta_event_native_sequence_get_slot (const ClutterEventSequence *sequence)
{
if (!sequence)
return -1;
return GPOINTER_TO_INT (sequence) - 1;
}

View File

@ -0,0 +1,50 @@
/*
* Copyright (C) 2015 Red Hat
*
* 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/>.
*
* Authored by:
* Carlos Garnacho <carlosg@gnome.org>
*/
#ifndef META_EVENT_NATIVE_H
#define META_EVENT_NATIVE_H
#include "clutter/clutter.h"
typedef struct _MetaEventNative MetaEventNative;
MetaEventNative * meta_event_native_copy (MetaEventNative *event_evdev);
void meta_event_native_free (MetaEventNative *event_evdev);
guint32 meta_event_native_get_event_code (const ClutterEvent *event);
void meta_event_native_set_event_code (ClutterEvent *event,
guint32 evcode);
guint64 meta_event_native_get_time_usec (const ClutterEvent *event);
void meta_event_native_set_time_usec (ClutterEvent *event,
guint64 time_usec);
void meta_event_native_set_relative_motion (ClutterEvent *event,
double dx,
double dy,
double dx_unaccel,
double dy_unaccel);
gboolean meta_event_native_get_relative_motion (const ClutterEvent *event,
double *dx,
double *dy,
double *dx_unaccel,
double *dy_unaccel);
int32_t meta_event_native_sequence_get_slot (const ClutterEventSequence *sequence);
#endif /* META_EVENT_NATIVE_H */

View File

@ -1,8 +1,4 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2010 Intel Corp.
* Copyright (C) 2014 Jonas Ådahl
*
@ -23,27 +19,19 @@
* Author: Jonas Ådahl <jadahl@gmail.com>
*/
#include "clutter-build-config.h"
#include "config.h"
#include <math.h>
#include <cairo-gobject.h>
#include "clutter/clutter-device-manager-private.h"
#include "clutter/clutter-event-private.h"
#include "clutter-private.h"
#include "clutter-evdev.h"
#include "clutter-input-device-tool-evdev.h"
#include "backends/native/meta-input-device-tool-native.h"
#include "backends/native/meta-input-device-native.h"
#include "backends/native/meta-device-manager-native.h"
#include "backends/native/meta-seat-native.h"
#include "clutter/clutter-mutter.h"
#include "clutter-input-device-evdev.h"
#include "clutter-device-manager-evdev.h"
#include "cairo-gobject.h"
typedef struct _ClutterInputDeviceClass ClutterInputDeviceEvdevClass;
#define clutter_input_device_evdev_get_type _clutter_input_device_evdev_get_type
G_DEFINE_TYPE (ClutterInputDeviceEvdev,
clutter_input_device_evdev,
G_DEFINE_TYPE (MetaInputDeviceNative,
meta_input_device_native,
CLUTTER_TYPE_INPUT_DEVICE)
enum
@ -58,48 +46,48 @@ static GParamSpec *obj_props[N_PROPS] = { 0 };
typedef struct _SlowKeysEventPending
{
ClutterInputDeviceEvdev *device;
MetaInputDeviceNative *device;
ClutterEvent *event;
ClutterEmitInputDeviceEvent emit_event_func;
guint timer;
} SlowKeysEventPending;
static void clear_slow_keys (ClutterInputDeviceEvdev *device);
static void stop_bounce_keys (ClutterInputDeviceEvdev *device);
static void stop_toggle_slowkeys (ClutterInputDeviceEvdev *device);
static void stop_mousekeys_move (ClutterInputDeviceEvdev *device);
static void clear_slow_keys (MetaInputDeviceNative *device);
static void stop_bounce_keys (MetaInputDeviceNative *device);
static void stop_toggle_slowkeys (MetaInputDeviceNative *device);
static void stop_mousekeys_move (MetaInputDeviceNative *device);
static void
clutter_input_device_evdev_finalize (GObject *object)
meta_input_device_native_finalize (GObject *object)
{
ClutterInputDevice *device = CLUTTER_INPUT_DEVICE (object);
ClutterInputDeviceEvdev *device_evdev = CLUTTER_INPUT_DEVICE_EVDEV (object);
ClutterDeviceManagerEvdev *manager_evdev =
CLUTTER_DEVICE_MANAGER_EVDEV (device->device_manager);
MetaInputDeviceNative *device_evdev = META_INPUT_DEVICE_NATIVE (object);
MetaDeviceManagerNative *manager_evdev =
META_DEVICE_MANAGER_NATIVE (device->device_manager);
if (device_evdev->libinput_device)
libinput_device_unref (device_evdev->libinput_device);
clutter_input_device_evdev_release_touch_slots (device_evdev,
g_get_monotonic_time ());
meta_input_device_native_release_touch_slots (device_evdev,
g_get_monotonic_time ());
_clutter_device_manager_evdev_release_device_id (manager_evdev, device);
meta_device_manager_native_release_device_id (manager_evdev, device);
clear_slow_keys (device_evdev);
stop_bounce_keys (device_evdev);
stop_toggle_slowkeys (device_evdev);
stop_mousekeys_move (device_evdev);
G_OBJECT_CLASS (clutter_input_device_evdev_parent_class)->finalize (object);
G_OBJECT_CLASS (meta_input_device_native_parent_class)->finalize (object);
}
static void
clutter_input_device_evdev_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
meta_input_device_native_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
ClutterInputDeviceEvdev *device = CLUTTER_INPUT_DEVICE_EVDEV (object);
MetaInputDeviceNative *device = META_INPUT_DEVICE_NATIVE (object);
switch (prop_id)
{
@ -120,12 +108,12 @@ clutter_input_device_evdev_set_property (GObject *object,
}
static void
clutter_input_device_evdev_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
meta_input_device_native_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
ClutterInputDeviceEvdev *device = CLUTTER_INPUT_DEVICE_EVDEV (object);
MetaInputDeviceNative *device = META_INPUT_DEVICE_NATIVE (object);
switch (prop_id)
{
@ -141,9 +129,9 @@ clutter_input_device_evdev_get_property (GObject *object,
}
static gboolean
clutter_input_device_evdev_keycode_to_evdev (ClutterInputDevice *device,
guint hardware_keycode,
guint *evdev_keycode)
meta_input_device_native_keycode_to_evdev (ClutterInputDevice *device,
guint hardware_keycode,
guint *evdev_keycode)
{
/* The hardware keycodes from the evdev backend are almost evdev
keycodes: we use the evdev keycode file, but xkb rules have an
@ -154,12 +142,12 @@ clutter_input_device_evdev_keycode_to_evdev (ClutterInputDevice *device,
}
static void
clutter_input_device_evdev_update_from_tool (ClutterInputDevice *device,
ClutterInputDeviceTool *tool)
meta_input_device_native_update_from_tool (ClutterInputDevice *device,
ClutterInputDeviceTool *tool)
{
ClutterInputDeviceToolEvdev *evdev_tool;
MetaInputDeviceToolNative *evdev_tool;
evdev_tool = CLUTTER_INPUT_DEVICE_TOOL_EVDEV (tool);
evdev_tool = META_INPUT_DEVICE_TOOL_NATIVE (tool);
g_object_freeze_notify (G_OBJECT (device));
@ -193,47 +181,47 @@ clutter_input_device_evdev_update_from_tool (ClutterInputDevice *device,
}
static gboolean
clutter_input_device_evdev_is_mode_switch_button (ClutterInputDevice *device,
guint group,
guint button)
meta_input_device_native_is_mode_switch_button (ClutterInputDevice *device,
guint group,
guint button)
{
struct libinput_device *libinput_device;
struct libinput_tablet_pad_mode_group *mode_group;
libinput_device = clutter_evdev_input_device_get_libinput_device (device);
libinput_device = meta_input_device_native_get_libinput_device (device);
mode_group = libinput_device_tablet_pad_get_mode_group (libinput_device, group);
return libinput_tablet_pad_mode_group_button_is_toggle (mode_group, button) != 0;
}
static gint
clutter_input_device_evdev_get_group_n_modes (ClutterInputDevice *device,
gint group)
meta_input_device_native_get_group_n_modes (ClutterInputDevice *device,
gint group)
{
struct libinput_device *libinput_device;
struct libinput_tablet_pad_mode_group *mode_group;
libinput_device = clutter_evdev_input_device_get_libinput_device (device);
libinput_device = meta_input_device_native_get_libinput_device (device);
mode_group = libinput_device_tablet_pad_get_mode_group (libinput_device, group);
return libinput_tablet_pad_mode_group_get_num_modes (mode_group);
}
static gboolean
clutter_input_device_evdev_is_grouped (ClutterInputDevice *device,
ClutterInputDevice *other_device)
meta_input_device_native_is_grouped (ClutterInputDevice *device,
ClutterInputDevice *other_device)
{
struct libinput_device *libinput_device, *other_libinput_device;
libinput_device = clutter_evdev_input_device_get_libinput_device (device);
other_libinput_device = clutter_evdev_input_device_get_libinput_device (other_device);
libinput_device = meta_input_device_native_get_libinput_device (device);
other_libinput_device = meta_input_device_native_get_libinput_device (other_device);
return libinput_device_get_device_group (libinput_device) ==
libinput_device_get_device_group (other_libinput_device);
}
static void
clutter_input_device_evdev_bell_notify (void)
meta_input_device_native_bell_notify (void)
{
ClutterBackend *backend;
@ -242,7 +230,7 @@ clutter_input_device_evdev_bell_notify (void)
}
static void
clutter_input_device_evdev_free_pending_slow_key (gpointer data)
meta_input_device_native_free_pending_slow_key (gpointer data)
{
SlowKeysEventPending *slow_keys_event = data;
@ -253,9 +241,9 @@ clutter_input_device_evdev_free_pending_slow_key (gpointer data)
}
static void
clear_slow_keys (ClutterInputDeviceEvdev *device)
clear_slow_keys (MetaInputDeviceNative *device)
{
g_list_free_full (device->slow_keys_list, clutter_input_device_evdev_free_pending_slow_key);
g_list_free_full (device->slow_keys_list, meta_input_device_native_free_pending_slow_key);
g_list_free (device->slow_keys_list);
device->slow_keys_list = NULL;
}
@ -275,7 +263,7 @@ static gboolean
trigger_slow_keys (gpointer data)
{
SlowKeysEventPending *slow_keys_event = data;
ClutterInputDeviceEvdev *device = slow_keys_event->device;
MetaInputDeviceNative *device = slow_keys_event->device;
ClutterKeyEvent *key_event = (ClutterKeyEvent *) slow_keys_event->event;
/* Alter timestamp and emit the event */
@ -285,10 +273,10 @@ trigger_slow_keys (gpointer data)
/* Then remote the pending event */
device->slow_keys_list = g_list_remove (device->slow_keys_list, slow_keys_event);
clutter_input_device_evdev_free_pending_slow_key (slow_keys_event);
meta_input_device_native_free_pending_slow_key (slow_keys_event);
if (device->a11y_flags & CLUTTER_A11Y_SLOW_KEYS_BEEP_ACCEPT)
clutter_input_device_evdev_bell_notify ();
meta_input_device_native_bell_notify ();
return G_SOURCE_REMOVE;
}
@ -305,9 +293,9 @@ find_pending_event_by_keycode (gconstpointer a,
}
static void
start_slow_keys (ClutterEvent *event,
ClutterInputDeviceEvdev *device,
ClutterEmitInputDeviceEvent emit_event_func)
start_slow_keys (ClutterEvent *event,
MetaInputDeviceNative *device,
ClutterEmitInputDeviceEvent emit_event_func)
{
SlowKeysEventPending *slow_keys_event;
ClutterKeyEvent *key_event = (ClutterKeyEvent *) event;
@ -326,13 +314,13 @@ start_slow_keys (ClutterEvent *event,
device->slow_keys_list = g_list_append (device->slow_keys_list, slow_keys_event);
if (device->a11y_flags & CLUTTER_A11Y_SLOW_KEYS_BEEP_PRESS)
clutter_input_device_evdev_bell_notify ();
meta_input_device_native_bell_notify ();
}
static void
stop_slow_keys (ClutterEvent *event,
ClutterInputDeviceEvdev *device,
ClutterEmitInputDeviceEvent emit_event_func)
stop_slow_keys (ClutterEvent *event,
MetaInputDeviceNative *device,
ClutterEmitInputDeviceEvent emit_event_func)
{
GList *item;
@ -343,10 +331,10 @@ stop_slow_keys (ClutterEvent *event,
SlowKeysEventPending *slow_keys_event = item->data;
device->slow_keys_list = g_list_delete_link (device->slow_keys_list, item);
clutter_input_device_evdev_free_pending_slow_key (slow_keys_event);
meta_input_device_native_free_pending_slow_key (slow_keys_event);
if (device->a11y_flags & CLUTTER_A11Y_SLOW_KEYS_BEEP_REJECT)
clutter_input_device_evdev_bell_notify ();
meta_input_device_native_bell_notify ();
return;
}
@ -369,7 +357,7 @@ get_debounce_delay (ClutterInputDevice *device)
static gboolean
clear_bounce_keys (gpointer data)
{
ClutterInputDeviceEvdev *device = data;
MetaInputDeviceNative *device = data;
device->debounce_key = 0;
device->debounce_timer = 0;
@ -378,8 +366,8 @@ clear_bounce_keys (gpointer data)
}
static void
start_bounce_keys (ClutterEvent *event,
ClutterInputDeviceEvdev *device)
start_bounce_keys (ClutterEvent *event,
MetaInputDeviceNative *device)
{
stop_bounce_keys (device);
@ -391,7 +379,7 @@ start_bounce_keys (ClutterEvent *event,
}
static void
stop_bounce_keys (ClutterInputDeviceEvdev *device)
stop_bounce_keys (MetaInputDeviceNative *device)
{
if (device->debounce_timer)
{
@ -401,15 +389,15 @@ stop_bounce_keys (ClutterInputDeviceEvdev *device)
}
static void
notify_bounce_keys_reject (ClutterInputDeviceEvdev *device)
notify_bounce_keys_reject (MetaInputDeviceNative *device)
{
if (device->a11y_flags & CLUTTER_A11Y_BOUNCE_KEYS_BEEP_REJECT)
clutter_input_device_evdev_bell_notify ();
meta_input_device_native_bell_notify ();
}
static gboolean
debounce_key (ClutterEvent *event,
ClutterInputDeviceEvdev *device)
debounce_key (ClutterEvent *event,
MetaInputDeviceNative *device)
{
return (device->debounce_key == ((ClutterKeyEvent *) event)->hardware_keycode);
}
@ -440,7 +428,7 @@ key_event_is_modifier (ClutterEvent *event)
}
static void
notify_stickykeys_mask (ClutterInputDeviceEvdev *device)
notify_stickykeys_mask (MetaInputDeviceNative *device)
{
g_signal_emit_by_name (CLUTTER_INPUT_DEVICE (device)->device_manager,
"kbd-a11y-mods-state-changed",
@ -449,11 +437,11 @@ notify_stickykeys_mask (ClutterInputDeviceEvdev *device)
}
static void
update_internal_xkb_state (ClutterInputDeviceEvdev *device,
xkb_mod_mask_t new_latched_mask,
xkb_mod_mask_t new_locked_mask)
update_internal_xkb_state (MetaInputDeviceNative *device,
xkb_mod_mask_t new_latched_mask,
xkb_mod_mask_t new_locked_mask)
{
ClutterSeatEvdev *seat = device->seat;
MetaSeatNative *seat = device->seat;
xkb_mod_mask_t depressed_mods;
xkb_mod_mask_t latched_mods;
xkb_mod_mask_t locked_mods;
@ -483,12 +471,12 @@ update_internal_xkb_state (ClutterInputDeviceEvdev *device,
}
static void
update_stickykeys_event (ClutterEvent *event,
ClutterInputDeviceEvdev *device,
xkb_mod_mask_t new_latched_mask,
xkb_mod_mask_t new_locked_mask)
update_stickykeys_event (ClutterEvent *event,
MetaInputDeviceNative *device,
xkb_mod_mask_t new_latched_mask,
xkb_mod_mask_t new_locked_mask)
{
ClutterSeatEvdev *seat = device->seat;
MetaSeatNative *seat = device->seat;
xkb_mod_mask_t effective_mods;
xkb_mod_mask_t latched_mods;
xkb_mod_mask_t locked_mods;
@ -508,7 +496,7 @@ update_stickykeys_event (ClutterEvent *event,
}
static void
notify_stickykeys_change (ClutterInputDeviceEvdev *device)
notify_stickykeys_change (MetaInputDeviceNative *device)
{
/* Everytime sticky keys setting is changed, clear the masks */
device->stickykeys_depressed_mask = 0;
@ -521,29 +509,29 @@ notify_stickykeys_change (ClutterInputDeviceEvdev *device)
}
static void
set_stickykeys_off (ClutterInputDeviceEvdev *device)
set_stickykeys_off (MetaInputDeviceNative *device)
{
device->a11y_flags &= ~CLUTTER_A11Y_STICKY_KEYS_ENABLED;
notify_stickykeys_change (device);
}
static void
set_stickykeys_on (ClutterInputDeviceEvdev *device)
set_stickykeys_on (MetaInputDeviceNative *device)
{
device->a11y_flags |= CLUTTER_A11Y_STICKY_KEYS_ENABLED;
notify_stickykeys_change (device);
}
static void
clear_stickykeys_event (ClutterEvent *event,
ClutterInputDeviceEvdev *device)
clear_stickykeys_event (ClutterEvent *event,
MetaInputDeviceNative *device)
{
set_stickykeys_off (device);
update_stickykeys_event (event, device, 0, 0);
}
static void
set_slowkeys_off (ClutterInputDeviceEvdev *device)
set_slowkeys_off (MetaInputDeviceNative *device)
{
device->a11y_flags &= ~CLUTTER_A11Y_SLOW_KEYS_ENABLED;
@ -554,7 +542,7 @@ set_slowkeys_off (ClutterInputDeviceEvdev *device)
}
static void
set_slowkeys_on (ClutterInputDeviceEvdev *device)
set_slowkeys_on (MetaInputDeviceNative *device)
{
device->a11y_flags |= CLUTTER_A11Y_SLOW_KEYS_ENABLED;
@ -565,10 +553,10 @@ set_slowkeys_on (ClutterInputDeviceEvdev *device)
}
static void
handle_stickykeys_press (ClutterEvent *event,
ClutterInputDeviceEvdev *device)
handle_stickykeys_press (ClutterEvent *event,
MetaInputDeviceNative *device)
{
ClutterSeatEvdev *seat = device->seat;
MetaSeatNative *seat = device->seat;
xkb_mod_mask_t depressed_mods;
xkb_mod_mask_t new_latched_mask;
xkb_mod_mask_t new_locked_mask;
@ -613,10 +601,10 @@ handle_stickykeys_press (ClutterEvent *event,
}
static void
handle_stickykeys_release (ClutterEvent *event,
ClutterInputDeviceEvdev *device)
handle_stickykeys_release (ClutterEvent *event,
MetaInputDeviceNative *device)
{
ClutterSeatEvdev *seat = device->seat;
MetaSeatNative *seat = device->seat;
device->stickykeys_depressed_mask =
xkb_state_serialize_mods (seat->xkb, XKB_STATE_MODS_DEPRESSED);
@ -624,7 +612,7 @@ handle_stickykeys_release (ClutterEvent *event,
if (key_event_is_modifier (event))
{
if (device->a11y_flags & CLUTTER_A11Y_STICKY_KEYS_BEEP)
clutter_input_device_evdev_bell_notify ();
meta_input_device_native_bell_notify ();
return;
}
@ -638,12 +626,12 @@ handle_stickykeys_release (ClutterEvent *event,
static gboolean
trigger_toggle_slowkeys (gpointer data)
{
ClutterInputDeviceEvdev *device = data;
MetaInputDeviceNative *device = data;
device->toggle_slowkeys_timer = 0;
if (device->a11y_flags & CLUTTER_A11Y_FEATURE_STATE_CHANGE_BEEP)
clutter_input_device_evdev_bell_notify ();
meta_input_device_native_bell_notify ();
if (device->a11y_flags & CLUTTER_A11Y_SLOW_KEYS_ENABLED)
set_slowkeys_off (device);
@ -654,7 +642,7 @@ trigger_toggle_slowkeys (gpointer data)
}
static void
start_toggle_slowkeys (ClutterInputDeviceEvdev *device)
start_toggle_slowkeys (MetaInputDeviceNative *device)
{
if (device->toggle_slowkeys_timer != 0)
return;
@ -666,7 +654,7 @@ start_toggle_slowkeys (ClutterInputDeviceEvdev *device)
}
static void
stop_toggle_slowkeys (ClutterInputDeviceEvdev *device)
stop_toggle_slowkeys (MetaInputDeviceNative *device)
{
if (device->toggle_slowkeys_timer)
{
@ -676,8 +664,8 @@ stop_toggle_slowkeys (ClutterInputDeviceEvdev *device)
}
static void
handle_enablekeys_press (ClutterEvent *event,
ClutterInputDeviceEvdev *device)
handle_enablekeys_press (ClutterEvent *event,
MetaInputDeviceNative *device)
{
if (event->key.keyval == XKB_KEY_Shift_L || event->key.keyval == XKB_KEY_Shift_R)
{
@ -698,8 +686,8 @@ handle_enablekeys_press (ClutterEvent *event,
}
static void
handle_enablekeys_release (ClutterEvent *event,
ClutterInputDeviceEvdev *device)
handle_enablekeys_release (ClutterEvent *event,
MetaInputDeviceNative *device)
{
if (event->key.keyval == XKB_KEY_Shift_L || event->key.keyval == XKB_KEY_Shift_R)
{
@ -709,7 +697,7 @@ handle_enablekeys_release (ClutterEvent *event,
device->shift_count = 0;
if (device->a11y_flags & CLUTTER_A11Y_FEATURE_STATE_CHANGE_BEEP)
clutter_input_device_evdev_bell_notify ();
meta_input_device_native_bell_notify ();
if (device->a11y_flags & CLUTTER_A11Y_STICKY_KEYS_ENABLED)
set_stickykeys_off (device);
@ -739,7 +727,7 @@ get_button_index (gint button)
}
static void
emulate_button_press (ClutterInputDeviceEvdev *device_evdev)
emulate_button_press (MetaInputDeviceNative *device_evdev)
{
ClutterInputDevice *device = CLUTTER_INPUT_DEVICE (device_evdev);
gint btn = device_evdev->mousekeys_btn;
@ -754,7 +742,7 @@ emulate_button_press (ClutterInputDeviceEvdev *device_evdev)
}
static void
emulate_button_release (ClutterInputDeviceEvdev *device_evdev)
emulate_button_release (MetaInputDeviceNative *device_evdev)
{
ClutterInputDevice *device = CLUTTER_INPUT_DEVICE (device_evdev);
gint btn = device_evdev->mousekeys_btn;
@ -769,7 +757,7 @@ emulate_button_release (ClutterInputDeviceEvdev *device_evdev)
}
static void
emulate_button_click (ClutterInputDeviceEvdev *device)
emulate_button_click (MetaInputDeviceNative *device)
{
emulate_button_press (device);
emulate_button_release (device);
@ -778,8 +766,8 @@ emulate_button_click (ClutterInputDeviceEvdev *device)
#define MOUSEKEYS_CURVE (1.0 + (((double) 50.0) * 0.001))
static void
update_mousekeys_params (ClutterInputDeviceEvdev *device,
ClutterKbdA11ySettings *settings)
update_mousekeys_params (MetaInputDeviceNative *device,
ClutterKbdA11ySettings *settings)
{
/* Prevent us from broken settings values */
device->mousekeys_max_speed = MAX (1, settings->mousekeys_max_speed);
@ -792,8 +780,8 @@ update_mousekeys_params (ClutterInputDeviceEvdev *device,
}
static gdouble
mousekeys_get_speed_factor (ClutterInputDeviceEvdev *device,
gint64 time_us)
mousekeys_get_speed_factor (MetaInputDeviceNative *device,
gint64 time_us)
{
guint32 time;
gint64 delta_t;
@ -832,9 +820,9 @@ mousekeys_get_speed_factor (ClutterInputDeviceEvdev *device,
#undef MOUSEKEYS_CURVE
static void
emulate_pointer_motion (ClutterInputDeviceEvdev *device_evdev,
gint dx,
gint dy)
emulate_pointer_motion (MetaInputDeviceNative *device_evdev,
gint dx,
gint dy)
{
ClutterInputDevice *device = CLUTTER_INPUT_DEVICE (device_evdev);
gdouble dx_motion;
@ -859,16 +847,16 @@ emulate_pointer_motion (ClutterInputDeviceEvdev *device_evdev,
time_us, dx_motion, dy_motion);
}
static gboolean
is_numlock_active (ClutterInputDeviceEvdev *device)
is_numlock_active (MetaInputDeviceNative *device)
{
ClutterSeatEvdev *seat = device->seat;
MetaSeatNative *seat = device->seat;
return xkb_state_mod_name_is_active (seat->xkb,
"Mod2",
XKB_STATE_MODS_LOCKED);
}
static void
enable_mousekeys (ClutterInputDeviceEvdev *device_evdev)
enable_mousekeys (MetaInputDeviceNative *device_evdev)
{
ClutterInputDevice *device = CLUTTER_INPUT_DEVICE (device_evdev);
ClutterDeviceManager *manager = device->device_manager;
@ -888,7 +876,7 @@ enable_mousekeys (ClutterInputDeviceEvdev *device_evdev)
}
static void
disable_mousekeys (ClutterInputDeviceEvdev *device_evdev)
disable_mousekeys (MetaInputDeviceNative *device_evdev)
{
ClutterInputDevice *device = CLUTTER_INPUT_DEVICE (device_evdev);
@ -920,7 +908,7 @@ disable_mousekeys (ClutterInputDeviceEvdev *device_evdev)
static gboolean
trigger_mousekeys_move (gpointer data)
{
ClutterInputDeviceEvdev *device = data;
MetaInputDeviceNative *device = data;
gint dx = 0;
gint dy = 0;
@ -995,7 +983,7 @@ trigger_mousekeys_move (gpointer data)
}
static void
stop_mousekeys_move (ClutterInputDeviceEvdev *device)
stop_mousekeys_move (MetaInputDeviceNative *device)
{
device->mousekeys_first_motion_time = 0;
device->mousekeys_last_motion_time = 0;
@ -1008,8 +996,8 @@ stop_mousekeys_move (ClutterInputDeviceEvdev *device)
}
static void
start_mousekeys_move (ClutterEvent *event,
ClutterInputDeviceEvdev *device)
start_mousekeys_move (ClutterEvent *event,
MetaInputDeviceNative *device)
{
device->last_mousekeys_key = event->key.keyval;
@ -1020,8 +1008,8 @@ start_mousekeys_move (ClutterEvent *event,
}
static gboolean
handle_mousekeys_press (ClutterEvent *event,
ClutterInputDeviceEvdev *device)
handle_mousekeys_press (ClutterEvent *event,
MetaInputDeviceNative *device)
{
if (!(event->key.flags & CLUTTER_EVENT_FLAG_SYNTHETIC))
stop_mousekeys_move (device);
@ -1098,8 +1086,8 @@ handle_mousekeys_press (ClutterEvent *event,
}
static gboolean
handle_mousekeys_release (ClutterEvent *event,
ClutterInputDeviceEvdev *device)
handle_mousekeys_release (ClutterEvent *event,
MetaInputDeviceNative *device)
{
/* Do not handle mousekeys if NumLock is ON */
if (is_numlock_active (device))
@ -1143,11 +1131,11 @@ handle_mousekeys_release (ClutterEvent *event,
}
static void
clutter_input_device_evdev_process_kbd_a11y_event (ClutterEvent *event,
ClutterInputDevice *device,
ClutterEmitInputDeviceEvent emit_event_func)
meta_input_device_native_process_kbd_a11y_event (ClutterEvent *event,
ClutterInputDevice *device,
ClutterEmitInputDeviceEvent emit_event_func)
{
ClutterInputDeviceEvdev *device_evdev = CLUTTER_INPUT_DEVICE_EVDEV (device);
MetaInputDeviceNative *device_evdev = META_INPUT_DEVICE_NATIVE (device);
/* Ignore key events injected from IM */
if (event->key.flags & CLUTTER_EVENT_FLAG_INPUT_METHOD)
@ -1208,8 +1196,8 @@ emit_event:
}
void
clutter_input_device_evdev_apply_kbd_a11y_settings (ClutterInputDeviceEvdev *device,
ClutterKbdA11ySettings *settings)
meta_input_device_native_apply_kbd_a11y_settings (MetaInputDeviceNative *device,
ClutterKbdA11ySettings *settings)
{
ClutterKeyboardA11yFlags changed_flags = (device->a11y_flags ^ settings->controls);
@ -1247,28 +1235,28 @@ clutter_input_device_evdev_apply_kbd_a11y_settings (ClutterInputDeviceEvdev *dev
}
void
clutter_evdev_a11y_maybe_notify_toggle_keys (ClutterInputDeviceEvdev *device)
meta_input_device_native_a11y_maybe_notify_toggle_keys (MetaInputDeviceNative *device)
{
if (device->a11y_flags & CLUTTER_A11Y_TOGGLE_KEYS_ENABLED)
clutter_input_device_evdev_bell_notify ();
meta_input_device_native_bell_notify ();
}
static void
release_device_touch_slot (gpointer value)
{
ClutterTouchState *touch_state = value;
MetaTouchState *touch_state = value;
clutter_seat_evdev_release_touch_state (touch_state->seat, touch_state);
meta_seat_native_release_touch_state (touch_state->seat, touch_state);
}
ClutterTouchState *
clutter_input_device_evdev_acquire_touch_state (ClutterInputDeviceEvdev *device,
int device_slot)
MetaTouchState *
meta_input_device_native_acquire_touch_state (MetaInputDeviceNative *device,
int device_slot)
{
ClutterTouchState *touch_state;
MetaTouchState *touch_state;
touch_state = clutter_seat_evdev_acquire_touch_state (device->seat,
device_slot);
touch_state = meta_seat_native_acquire_touch_state (device->seat,
device_slot);
g_hash_table_insert (device->touches,
GINT_TO_POINTER (device_slot),
touch_state);
@ -1276,36 +1264,37 @@ clutter_input_device_evdev_acquire_touch_state (ClutterInputDeviceEvdev *device,
return touch_state;
}
ClutterTouchState *
clutter_input_device_evdev_lookup_touch_state (ClutterInputDeviceEvdev *device,
int device_slot)
MetaTouchState *
meta_input_device_native_lookup_touch_state (MetaInputDeviceNative *device,
int device_slot)
{
return g_hash_table_lookup (device->touches, GINT_TO_POINTER (device_slot));
}
void
clutter_input_device_evdev_release_touch_state (ClutterInputDeviceEvdev *device,
ClutterTouchState *touch_state)
meta_input_device_native_release_touch_state (MetaInputDeviceNative *device,
MetaTouchState *touch_state)
{
g_hash_table_remove (device->touches,
GINT_TO_POINTER (touch_state->device_slot));
}
static void
clutter_input_device_evdev_class_init (ClutterInputDeviceEvdevClass *klass)
meta_input_device_native_class_init (MetaInputDeviceNativeClass *klass)
{
ClutterInputDeviceClass *device_manager_class = CLUTTER_INPUT_DEVICE_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = clutter_input_device_evdev_finalize;
object_class->set_property = clutter_input_device_evdev_set_property;
object_class->get_property = clutter_input_device_evdev_get_property;
object_class->finalize = meta_input_device_native_finalize;
object_class->set_property = meta_input_device_native_set_property;
object_class->get_property = meta_input_device_native_get_property;
klass->keycode_to_evdev = clutter_input_device_evdev_keycode_to_evdev;
klass->update_from_tool = clutter_input_device_evdev_update_from_tool;
klass->is_mode_switch_button = clutter_input_device_evdev_is_mode_switch_button;
klass->get_group_n_modes = clutter_input_device_evdev_get_group_n_modes;
klass->is_grouped = clutter_input_device_evdev_is_grouped;
klass->process_kbd_a11y_event = clutter_input_device_evdev_process_kbd_a11y_event;
device_manager_class->keycode_to_evdev = meta_input_device_native_keycode_to_evdev;
device_manager_class->update_from_tool = meta_input_device_native_update_from_tool;
device_manager_class->is_mode_switch_button = meta_input_device_native_is_mode_switch_button;
device_manager_class->get_group_n_modes = meta_input_device_native_get_group_n_modes;
device_manager_class->is_grouped = meta_input_device_native_is_grouped;
device_manager_class->process_kbd_a11y_event = meta_input_device_native_process_kbd_a11y_event;
obj_props[PROP_DEVICE_MATRIX] =
g_param_spec_boxed ("device-matrix",
@ -1324,7 +1313,7 @@ clutter_input_device_evdev_class_init (ClutterInputDeviceEvdevClass *klass)
}
static void
clutter_input_device_evdev_init (ClutterInputDeviceEvdev *self)
meta_input_device_native_init (MetaInputDeviceNative *self)
{
cairo_matrix_init_identity (&self->device_matrix);
self->device_aspect_ratio = 0;
@ -1335,7 +1324,7 @@ clutter_input_device_evdev_init (ClutterInputDeviceEvdev *self)
}
/*
* _clutter_input_device_evdev_new:
* meta_input_device_native_new:
* @manager: the device manager
* @seat: the seat the device will belong to
* @libinput_device: the libinput device
@ -1344,23 +1333,23 @@ clutter_input_device_evdev_init (ClutterInputDeviceEvdev *self)
* it with the provided seat.
*/
ClutterInputDevice *
_clutter_input_device_evdev_new (ClutterDeviceManager *manager,
ClutterSeatEvdev *seat,
struct libinput_device *libinput_device)
meta_input_device_native_new (ClutterDeviceManager *manager,
MetaSeatNative *seat,
struct libinput_device *libinput_device)
{
ClutterInputDeviceEvdev *device;
MetaInputDeviceNative *device;
ClutterInputDeviceType type;
ClutterDeviceManagerEvdev *manager_evdev;
MetaDeviceManagerNative *manager_evdev;
gchar *vendor, *product;
gint device_id, n_rings = 0, n_strips = 0, n_groups = 1;
gchar *node_path;
gdouble width, height;
type = _clutter_input_device_evdev_determine_type (libinput_device);
type = meta_input_device_native_determine_type (libinput_device);
vendor = g_strdup_printf ("%.4x", libinput_device_get_id_vendor (libinput_device));
product = g_strdup_printf ("%.4x", libinput_device_get_id_product (libinput_device));
manager_evdev = CLUTTER_DEVICE_MANAGER_EVDEV (manager);
device_id = _clutter_device_manager_evdev_acquire_device_id (manager_evdev);
manager_evdev = META_DEVICE_MANAGER_NATIVE (manager);
device_id = meta_device_manager_native_acquire_device_id (manager_evdev);
node_path = g_strdup_printf ("/dev/input/%s", libinput_device_get_sysname (libinput_device));
if (libinput_device_has_capability (libinput_device,
@ -1371,7 +1360,7 @@ _clutter_input_device_evdev_new (ClutterDeviceManager *manager,
n_groups = libinput_device_tablet_pad_get_num_mode_groups (libinput_device);
}
device = g_object_new (CLUTTER_TYPE_INPUT_DEVICE_EVDEV,
device = g_object_new (META_TYPE_INPUT_DEVICE_NATIVE,
"id", device_id,
"name", libinput_device_get_name (libinput_device),
"device-manager", manager,
@ -1402,7 +1391,7 @@ _clutter_input_device_evdev_new (ClutterDeviceManager *manager,
}
/*
* _clutter_input_device_evdev_new_virtual:
* meta_input_device_native_new_virtual:
* @manager: the device manager
* @seat: the seat the device will belong to
* @type: the input device type
@ -1410,13 +1399,13 @@ _clutter_input_device_evdev_new (ClutterDeviceManager *manager,
* Create a new virtual ClutterInputDevice of the given type.
*/
ClutterInputDevice *
_clutter_input_device_evdev_new_virtual (ClutterDeviceManager *manager,
ClutterSeatEvdev *seat,
ClutterInputDeviceType type,
ClutterInputMode mode)
meta_input_device_native_new_virtual (ClutterDeviceManager *manager,
MetaSeatNative *seat,
ClutterInputDeviceType type,
ClutterInputMode mode)
{
ClutterInputDeviceEvdev *device;
ClutterDeviceManagerEvdev *manager_evdev;
MetaInputDeviceNative *device;
MetaDeviceManagerNative *manager_evdev;
const char *name;
gint device_id;
@ -1436,9 +1425,9 @@ _clutter_input_device_evdev_new_virtual (ClutterDeviceManager *manager,
break;
};
manager_evdev = CLUTTER_DEVICE_MANAGER_EVDEV (manager);
device_id = _clutter_device_manager_evdev_acquire_device_id (manager_evdev);
device = g_object_new (CLUTTER_TYPE_INPUT_DEVICE_EVDEV,
manager_evdev = META_DEVICE_MANAGER_NATIVE (manager);
device_id = meta_device_manager_native_acquire_device_id (manager_evdev);
device = g_object_new (META_TYPE_INPUT_DEVICE_NATIVE,
"id", device_id,
"name", name,
"device-manager", manager,
@ -1452,15 +1441,15 @@ _clutter_input_device_evdev_new_virtual (ClutterDeviceManager *manager,
return CLUTTER_INPUT_DEVICE (device);
}
ClutterSeatEvdev *
_clutter_input_device_evdev_get_seat (ClutterInputDeviceEvdev *device)
MetaSeatNative *
meta_input_device_native_get_seat (MetaInputDeviceNative *device)
{
return device->seat;
}
void
_clutter_input_device_evdev_update_leds (ClutterInputDeviceEvdev *device,
enum libinput_led leds)
meta_input_device_native_update_leds (MetaInputDeviceNative *device,
enum libinput_led leds)
{
if (!device->libinput_device)
return;
@ -1469,7 +1458,7 @@ _clutter_input_device_evdev_update_leds (ClutterInputDeviceEvdev *device,
}
ClutterInputDeviceType
_clutter_input_device_evdev_determine_type (struct libinput_device *ldev)
meta_input_device_native_determine_type (struct libinput_device *ldev)
{
/* This setting is specific to touchpads and alike, only in these
* devices there is this additional layer of touch event interpretation.
@ -1491,7 +1480,7 @@ _clutter_input_device_evdev_determine_type (struct libinput_device *ldev)
}
/**
* clutter_evdev_input_device_get_libinput_device:
* meta_input_device_native_get_libinput_device:
* @device: a #ClutterInputDevice
*
* Retrieves the libinput_device struct held in @device.
@ -1502,44 +1491,24 @@ _clutter_input_device_evdev_determine_type (struct libinput_device *ldev)
* Stability: unstable
**/
struct libinput_device *
clutter_evdev_input_device_get_libinput_device (ClutterInputDevice *device)
meta_input_device_native_get_libinput_device (ClutterInputDevice *device)
{
ClutterInputDeviceEvdev *device_evdev;
MetaInputDeviceNative *device_evdev;
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE_EVDEV (device), NULL);
g_return_val_if_fail (META_IS_INPUT_DEVICE_NATIVE (device), NULL);
device_evdev = CLUTTER_INPUT_DEVICE_EVDEV (device);
device_evdev = META_INPUT_DEVICE_NATIVE (device);
return device_evdev->libinput_device;
}
/**
* clutter_evdev_event_sequence_get_slot:
* @sequence: a #ClutterEventSequence
*
* Retrieves the touch slot triggered by this @sequence
*
* Returns: the libinput touch slot.
*
* Since: 1.20
* Stability: unstable
**/
gint32
clutter_evdev_event_sequence_get_slot (const ClutterEventSequence *sequence)
{
if (!sequence)
return -1;
return GPOINTER_TO_INT (sequence) - 1;
}
void
clutter_input_device_evdev_translate_coordinates (ClutterInputDevice *device,
ClutterStage *stage,
gfloat *x,
gfloat *y)
meta_input_device_native_translate_coordinates (ClutterInputDevice *device,
ClutterStage *stage,
gfloat *x,
gfloat *y)
{
ClutterInputDeviceEvdev *device_evdev = CLUTTER_INPUT_DEVICE_EVDEV (device);
MetaInputDeviceNative *device_evdev = META_INPUT_DEVICE_NATIVE (device);
double min_x = 0, min_y = 0, max_x = 1, max_y = 1;
gdouble stage_width, stage_height;
double x_d, y_d;
@ -1570,22 +1539,22 @@ clutter_input_device_evdev_translate_coordinates (ClutterInputDevice *device,
}
void
clutter_input_device_evdev_release_touch_slots (ClutterInputDeviceEvdev *device_evdev,
uint64_t time_us)
meta_input_device_native_release_touch_slots (MetaInputDeviceNative *device_evdev,
uint64_t time_us)
{
GHashTableIter iter;
ClutterTouchState *touch_state;
MetaTouchState *touch_state;
g_hash_table_iter_init (&iter, device_evdev->touches);
while (g_hash_table_iter_next (&iter, NULL, (gpointer *) &touch_state))
{
clutter_seat_evdev_notify_touch_event (touch_state->seat,
CLUTTER_INPUT_DEVICE (device_evdev),
CLUTTER_TOUCH_CANCEL,
time_us,
touch_state->seat_slot,
touch_state->coords.x,
touch_state->coords.y);
meta_seat_native_notify_touch_event (touch_state->seat,
CLUTTER_INPUT_DEVICE (device_evdev),
CLUTTER_TOUCH_CANCEL,
time_us,
touch_state->seat_slot,
touch_state->coords.x,
touch_state->coords.y);
g_hash_table_iter_remove (&iter);
}
}

View File

@ -0,0 +1,145 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2010 Intel Corp.
* Copyright (C) 2014 Jonas Ådahl
*
* 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: Damien Lespiau <damien.lespiau@intel.com>
* Author: Jonas Ådahl <jadahl@gmail.com>
*/
#ifndef META_INPUT_DEVICE_NATIVE_H
#define META_INPUT_DEVICE_NATIVE_H
#include <glib-object.h>
#include "backends/native/meta-seat-native.h"
#include "clutter/clutter-mutter.h"
#define META_TYPE_INPUT_DEVICE_NATIVE meta_input_device_native_get_type()
#define META_INPUT_DEVICE_NATIVE(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
META_TYPE_INPUT_DEVICE_NATIVE, MetaInputDeviceNative))
#define META_INPUT_DEVICE_NATIVE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), \
META_TYPE_INPUT_DEVICE_NATIVE, MetaInputDeviceNativeClass))
#define META_IS_INPUT_DEVICE_NATIVE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
META_TYPE_INPUT_DEVICE_NATIVE))
#define META_IS_INPUT_DEVICE_NATIVE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
META_TYPE_INPUT_DEVICE_NATIVE))
#define META_INPUT_DEVICE_NATIVE_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
META_TYPE_INPUT_DEVICE_NATIVE, MetaInputDeviceNativeClass))
typedef struct _MetaInputDeviceNative MetaInputDeviceNative;
typedef struct _MetaInputDeviceNativeClass MetaInputDeviceNativeClass;
struct _MetaInputDeviceNative
{
ClutterInputDevice parent;
struct libinput_device *libinput_device;
MetaSeatNative *seat;
ClutterInputDeviceTool *last_tool;
cairo_matrix_t device_matrix;
gdouble device_aspect_ratio; /* w:h */
gdouble output_ratio; /* w:h */
GHashTable *touches;
/* Keyboard a11y */
ClutterKeyboardA11yFlags a11y_flags;
GList *slow_keys_list;
guint debounce_timer;
guint16 debounce_key;
xkb_mod_mask_t stickykeys_depressed_mask;
xkb_mod_mask_t stickykeys_latched_mask;
xkb_mod_mask_t stickykeys_locked_mask;
guint toggle_slowkeys_timer;
guint16 shift_count;
guint32 last_shift_time;
gint mousekeys_btn;
gboolean mousekeys_btn_states[3];
guint32 mousekeys_first_motion_time; /* ms */
guint32 mousekeys_last_motion_time; /* ms */
guint mousekeys_init_delay;
guint mousekeys_accel_time;
guint mousekeys_max_speed;
gdouble mousekeys_curve_factor;
guint move_mousekeys_timer;
guint16 last_mousekeys_key;
};
struct _MetaInputDeviceNativeClass
{
ClutterInputDeviceClass parent_class;
};
GType meta_input_device_native_get_type (void) G_GNUC_CONST;
ClutterInputDevice * meta_input_device_native_new (ClutterDeviceManager *manager,
MetaSeatNative *seat,
struct libinput_device *libinput_device);
ClutterInputDevice * meta_input_device_native_new_virtual (ClutterDeviceManager *manager,
MetaSeatNative *seat,
ClutterInputDeviceType type,
ClutterInputMode mode);
MetaSeatNative * meta_input_device_native_get_seat (MetaInputDeviceNative *device);
void meta_input_device_native_update_leds (MetaInputDeviceNative *device,
enum libinput_led leds);
ClutterInputDeviceType meta_input_device_native_determine_type (struct libinput_device *libinput_device);
void meta_input_device_native_translate_coordinates (ClutterInputDevice *device,
ClutterStage *stage,
gfloat *x,
gfloat *y);
void meta_input_device_native_apply_kbd_a11y_settings (MetaInputDeviceNative *device,
ClutterKbdA11ySettings *settings);
MetaTouchState * meta_input_device_native_acquire_touch_state (MetaInputDeviceNative *device,
int device_slot);
MetaTouchState * meta_input_device_native_lookup_touch_state (MetaInputDeviceNative *device,
int device_slot);
void meta_input_device_native_release_touch_state (MetaInputDeviceNative *device,
MetaTouchState *touch_state);
void meta_input_device_native_release_touch_slots (MetaInputDeviceNative *device_evdev,
uint64_t time_us);
void meta_input_device_native_a11y_maybe_notify_toggle_keys (MetaInputDeviceNative *device_evdev);
struct libinput_device * meta_input_device_native_get_libinput_device (ClutterInputDevice *device);
#endif /* META_INPUT_DEVICE_NATIVE_H */

View File

@ -1,8 +1,4 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright © 2009, 2010, 2011 Intel Corp.
*
* This library is free software; you can redistribute it and/or
@ -21,47 +17,46 @@
* Author: Carlos Garnacho <carlosg@gnome.org>
*/
#include "clutter-build-config.h"
#include "config.h"
#include "clutter-input-device-tool-evdev.h"
#include "clutter-evdev.h"
#include "backends/native/meta-input-device-tool-native.h"
G_DEFINE_TYPE (ClutterInputDeviceToolEvdev, clutter_input_device_tool_evdev,
G_DEFINE_TYPE (MetaInputDeviceToolNative, meta_input_device_tool_native,
CLUTTER_TYPE_INPUT_DEVICE_TOOL)
static void
clutter_input_device_tool_evdev_finalize (GObject *object)
meta_input_device_tool_native_finalize (GObject *object)
{
ClutterInputDeviceToolEvdev *tool = CLUTTER_INPUT_DEVICE_TOOL_EVDEV (object);
MetaInputDeviceToolNative *tool = META_INPUT_DEVICE_TOOL_NATIVE (object);
g_hash_table_unref (tool->button_map);
libinput_tablet_tool_unref (tool->tool);
G_OBJECT_CLASS (clutter_input_device_tool_evdev_parent_class)->finalize (object);
G_OBJECT_CLASS (meta_input_device_tool_native_parent_class)->finalize (object);
}
static void
clutter_input_device_tool_evdev_class_init (ClutterInputDeviceToolEvdevClass *klass)
meta_input_device_tool_native_class_init (MetaInputDeviceToolNativeClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = clutter_input_device_tool_evdev_finalize;
object_class->finalize = meta_input_device_tool_native_finalize;
}
static void
clutter_input_device_tool_evdev_init (ClutterInputDeviceToolEvdev *tool)
meta_input_device_tool_native_init (MetaInputDeviceToolNative *tool)
{
tool->button_map = g_hash_table_new (NULL, NULL);
}
ClutterInputDeviceTool *
clutter_input_device_tool_evdev_new (struct libinput_tablet_tool *tool,
guint64 serial,
ClutterInputDeviceToolType type)
meta_input_device_tool_native_new (struct libinput_tablet_tool *tool,
guint64 serial,
ClutterInputDeviceToolType type)
{
ClutterInputDeviceToolEvdev *evdev_tool;
MetaInputDeviceToolNative *evdev_tool;
evdev_tool = g_object_new (CLUTTER_TYPE_INPUT_DEVICE_TOOL_EVDEV,
evdev_tool = g_object_new (META_TYPE_INPUT_DEVICE_TOOL_NATIVE,
"type", type,
"serial", serial,
"id", libinput_tablet_tool_get_tool_id (tool),
@ -73,18 +68,18 @@ clutter_input_device_tool_evdev_new (struct libinput_tablet_tool *tool,
}
void
clutter_evdev_input_device_tool_set_pressure_curve (ClutterInputDeviceTool *tool,
gdouble curve[4])
meta_input_device_tool_native_set_pressure_curve (ClutterInputDeviceTool *tool,
gdouble curve[4])
{
ClutterInputDeviceToolEvdev *evdev_tool;
MetaInputDeviceToolNative *evdev_tool;
g_return_if_fail (CLUTTER_IS_INPUT_DEVICE_TOOL_EVDEV (tool));
g_return_if_fail (META_IS_INPUT_DEVICE_TOOL_NATIVE (tool));
g_return_if_fail (curve[0] >= 0 && curve[0] <= 1 &&
curve[1] >= 0 && curve[1] <= 1 &&
curve[2] >= 0 && curve[2] <= 1 &&
curve[3] >= 0 && curve[3] <= 1);
evdev_tool = CLUTTER_INPUT_DEVICE_TOOL_EVDEV (tool);
evdev_tool = META_INPUT_DEVICE_TOOL_NATIVE (tool);
evdev_tool->pressure_curve[0] = curve[0];
evdev_tool->pressure_curve[1] = curve[1];
evdev_tool->pressure_curve[2] = curve[2];
@ -92,15 +87,15 @@ clutter_evdev_input_device_tool_set_pressure_curve (ClutterInputDeviceTool *tool
}
void
clutter_evdev_input_device_tool_set_button_code (ClutterInputDeviceTool *tool,
guint button,
guint evcode)
meta_input_device_tool_native_set_button_code (ClutterInputDeviceTool *tool,
guint button,
guint evcode)
{
ClutterInputDeviceToolEvdev *evdev_tool;
MetaInputDeviceToolNative *evdev_tool;
g_return_if_fail (CLUTTER_IS_INPUT_DEVICE_TOOL_EVDEV (tool));
g_return_if_fail (META_IS_INPUT_DEVICE_TOOL_NATIVE (tool));
evdev_tool = CLUTTER_INPUT_DEVICE_TOOL_EVDEV (tool);
evdev_tool = META_INPUT_DEVICE_TOOL_NATIVE (tool);
if (evcode == 0)
{
@ -135,14 +130,14 @@ calculate_bezier_position (gdouble pos,
}
gdouble
clutter_input_device_tool_evdev_translate_pressure (ClutterInputDeviceTool *tool,
gdouble pressure)
meta_input_device_tool_native_translate_pressure (ClutterInputDeviceTool *tool,
gdouble pressure)
{
ClutterInputDeviceToolEvdev *evdev_tool;
MetaInputDeviceToolNative *evdev_tool;
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE_TOOL (tool), pressure);
g_return_val_if_fail (META_IS_INPUT_DEVICE_TOOL_NATIVE (tool), pressure);
evdev_tool = CLUTTER_INPUT_DEVICE_TOOL_EVDEV (tool);
evdev_tool = META_INPUT_DEVICE_TOOL_NATIVE (tool);
return calculate_bezier_position (CLAMP (pressure, 0, 1),
evdev_tool->pressure_curve[0],
@ -152,14 +147,14 @@ clutter_input_device_tool_evdev_translate_pressure (ClutterInputDeviceTool *tool
}
guint
clutter_input_device_tool_evdev_get_button_code (ClutterInputDeviceTool *tool,
guint button)
meta_input_device_tool_native_get_button_code (ClutterInputDeviceTool *tool,
guint button)
{
ClutterInputDeviceToolEvdev *evdev_tool;
MetaInputDeviceToolNative *evdev_tool;
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE_TOOL (tool), 0);
g_return_val_if_fail (META_IS_INPUT_DEVICE_TOOL_NATIVE (tool), 0);
evdev_tool = CLUTTER_INPUT_DEVICE_TOOL_EVDEV (tool);
evdev_tool = META_INPUT_DEVICE_TOOL_NATIVE (tool);
return GPOINTER_TO_UINT (g_hash_table_lookup (evdev_tool->button_map,
GUINT_TO_POINTER (button)));

View File

@ -0,0 +1,86 @@
/*
* Copyright © 2009, 2010, 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: Carlos Garnacho <carlosg@gnome.org>
*/
#ifndef META_INPUT_DEVICE_NATIVE_TOOL_H
#define META_INPUT_DEVICE_NATIVE_TOOL_H
#include <libinput.h>
#include "clutter/clutter.h"
G_BEGIN_DECLS
#define META_TYPE_INPUT_DEVICE_TOOL_NATIVE (meta_input_device_tool_native_get_type ())
#define META_INPUT_DEVICE_TOOL_NATIVE(o) \
(G_TYPE_CHECK_INSTANCE_CAST ((o), \
META_TYPE_INPUT_DEVICE_TOOL_NATIVE, MetaInputDeviceToolNative))
#define META_IS_INPUT_DEVICE_TOOL_NATIVE(o) \
(G_TYPE_CHECK_INSTANCE_TYPE ((o), \
META_TYPE_INPUT_DEVICE_TOOL_NATIVE))
#define META_INPUT_DEVICE_TOOL_NATIVE_CLASS(c) \
(G_TYPE_CHECK_CLASS_CAST ((c), \
META_TYPE_INPUT_DEVICE_TOOL_EVDEV, MetaInputDeviceToolNativeClass))
#define META_IS_INPUT_DEVICE_TOOL_NATIVE_CLASS(c) \
(G_TYPE_CHECK_CLASS_TYPE ((c), \
META_TYPE_INPUT_DEVICE_TOOL_NATIVE))
#define META_INPUT_DEVICE_TOOL_NATIVE_GET_CLASS(o) \
(G_TYPE_INSTANCE_GET_CLASS ((o), \
META_TYPE_INPUT_DEVICE_TOOL_NATIVE, MetaInputDeviceToolNativeClass))
typedef struct _MetaInputDeviceToolNative MetaInputDeviceToolNative;
typedef struct _MetaInputDeviceToolNativeClass MetaInputDeviceToolNativeClass;
struct _MetaInputDeviceToolNative
{
ClutterInputDeviceTool parent_instance;
struct libinput_tablet_tool *tool;
GHashTable *button_map;
gdouble pressure_curve[4];
};
struct _MetaInputDeviceToolNativeClass
{
ClutterInputDeviceToolClass parent_class;
};
GType meta_input_device_tool_native_get_type (void) G_GNUC_CONST;
ClutterInputDeviceTool * meta_input_device_tool_native_new (struct libinput_tablet_tool *tool,
guint64 serial,
ClutterInputDeviceToolType type);
gdouble meta_input_device_tool_native_translate_pressure (ClutterInputDeviceTool *tool,
gdouble pressure);
guint meta_input_device_tool_native_get_button_code (ClutterInputDeviceTool *tool,
guint button);
void meta_input_device_tool_native_set_pressure_curve (ClutterInputDeviceTool *tool,
gdouble curve[4]);
void meta_input_device_tool_native_set_button_code (ClutterInputDeviceTool *tool,
guint button,
guint evcode);
G_END_DECLS
#endif /* META_INPUT_DEVICE_NATIVE_TOOL_H */

View File

@ -28,8 +28,9 @@
#include "backends/meta-logical-monitor.h"
#include "backends/native/meta-backend-native.h"
#include "backends/native/meta-input-device-native.h"
#include "backends/native/meta-input-device-tool-native.h"
#include "backends/native/meta-input-settings-native.h"
#include "clutter/evdev/clutter-evdev.h"
G_DEFINE_TYPE (MetaInputSettingsNative, meta_input_settings_native, META_TYPE_INPUT_SETTINGS)
@ -56,7 +57,7 @@ meta_input_settings_native_set_send_events (MetaInputSettings *settings,
g_assert_not_reached ();
}
libinput_device = clutter_evdev_input_device_get_libinput_device (device);
libinput_device = meta_input_device_native_get_libinput_device (device);
if (!libinput_device)
return;
libinput_device_config_send_events_set_mode (libinput_device, libinput_mode);
@ -81,7 +82,7 @@ meta_input_settings_native_set_speed (MetaInputSettings *settings,
{
struct libinput_device *libinput_device;
libinput_device = clutter_evdev_input_device_get_libinput_device (device);
libinput_device = meta_input_device_native_get_libinput_device (device);
if (!libinput_device)
return;
libinput_device_config_accel_set_speed (libinput_device,
@ -95,7 +96,7 @@ meta_input_settings_native_set_left_handed (MetaInputSettings *settings,
{
struct libinput_device *libinput_device;
libinput_device = clutter_evdev_input_device_get_libinput_device (device);
libinput_device = meta_input_device_native_get_libinput_device (device);
if (!libinput_device)
return;
@ -110,7 +111,7 @@ meta_input_settings_native_set_tap_enabled (MetaInputSettings *settings,
{
struct libinput_device *libinput_device;
libinput_device = clutter_evdev_input_device_get_libinput_device (device);
libinput_device = meta_input_device_native_get_libinput_device (device);
if (!libinput_device)
return;
@ -128,7 +129,7 @@ meta_input_settings_native_set_tap_and_drag_enabled (MetaInputSettings *setting
{
struct libinput_device *libinput_device;
libinput_device = clutter_evdev_input_device_get_libinput_device (device);
libinput_device = meta_input_device_native_get_libinput_device (device);
if (!libinput_device)
return;
@ -146,7 +147,7 @@ meta_input_settings_native_set_disable_while_typing (MetaInputSettings *setting
{
struct libinput_device *libinput_device;
libinput_device = clutter_evdev_input_device_get_libinput_device (device);
libinput_device = meta_input_device_native_get_libinput_device (device);
if (!libinput_device)
return;
@ -165,7 +166,7 @@ meta_input_settings_native_set_invert_scroll (MetaInputSettings *settings,
{
struct libinput_device *libinput_device;
libinput_device = clutter_evdev_input_device_get_libinput_device (device);
libinput_device = meta_input_device_native_get_libinput_device (device);
if (!libinput_device)
return;
@ -200,7 +201,7 @@ meta_input_settings_native_set_edge_scroll (MetaInputSettings *settin
struct libinput_device *libinput_device;
enum libinput_config_scroll_method current, method;
libinput_device = clutter_evdev_input_device_get_libinput_device (device);
libinput_device = meta_input_device_native_get_libinput_device (device);
method = edge_scrolling_enabled ? LIBINPUT_CONFIG_SCROLL_EDGE : LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
current = libinput_device_config_scroll_get_method (libinput_device);
@ -217,7 +218,7 @@ meta_input_settings_native_set_two_finger_scroll (MetaInputSettings *
struct libinput_device *libinput_device;
enum libinput_config_scroll_method current, method;
libinput_device = clutter_evdev_input_device_get_libinput_device (device);
libinput_device = meta_input_device_native_get_libinput_device (device);
method = two_finger_scroll_enabled ? LIBINPUT_CONFIG_SCROLL_2FG : LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
current = libinput_device_config_scroll_get_method (libinput_device);
@ -232,7 +233,7 @@ meta_input_settings_native_has_two_finger_scroll (MetaInputSettings *settings,
{
struct libinput_device *libinput_device;
libinput_device = clutter_evdev_input_device_get_libinput_device (device);
libinput_device = meta_input_device_native_get_libinput_device (device);
if (!libinput_device)
return FALSE;
@ -248,7 +249,7 @@ meta_input_settings_native_set_scroll_button (MetaInputSettings *settings,
enum libinput_config_scroll_method method;
guint evcode;
libinput_device = clutter_evdev_input_device_get_libinput_device (device);
libinput_device = meta_input_device_native_get_libinput_device (device);
if (!libinput_device)
return;
@ -282,7 +283,7 @@ meta_input_settings_native_set_click_method (MetaInputSettings *settin
enum libinput_config_click_method click_method = 0;
struct libinput_device *libinput_device;
libinput_device = clutter_evdev_input_device_get_libinput_device (device);
libinput_device = meta_input_device_native_get_libinput_device (device);
if (!libinput_device)
return;
@ -316,7 +317,7 @@ meta_input_settings_native_set_keyboard_repeat (MetaInputSettings *settings,
{
ClutterDeviceManager *manager = clutter_device_manager_get_default ();
clutter_evdev_set_keyboard_repeat (manager, enabled, delay, interval);
meta_device_manager_native_set_keyboard_repeat (manager, enabled, delay, interval);
}
static void
@ -327,7 +328,7 @@ set_device_accel_profile (ClutterInputDevice *device,
enum libinput_config_accel_profile libinput_profile;
uint32_t profiles;
libinput_device = clutter_evdev_input_device_get_libinput_device (device);
libinput_device = meta_input_device_native_get_libinput_device (device);
switch (profile)
{
@ -363,7 +364,7 @@ has_udev_property (ClutterInputDevice *device,
struct udev_device *udev_device;
struct udev_device *parent_udev_device;
libinput_device = clutter_evdev_input_device_get_libinput_device (device);
libinput_device = meta_input_device_native_get_libinput_device (device);
if (!libinput_device)
return FALSE;
@ -500,7 +501,7 @@ meta_input_settings_native_set_tablet_area (MetaInputSettings *settings,
gfloat matrix[6] = { scale_x, 0., offset_x,
0., scale_y, offset_y };
libinput_device = clutter_evdev_input_device_get_libinput_device (device);
libinput_device = meta_input_device_native_get_libinput_device (device);
if (!libinput_device ||
!libinput_device_config_calibration_has_matrix (libinput_device))
return;
@ -521,7 +522,7 @@ meta_input_settings_native_set_stylus_pressure (MetaInputSettings *settings
pressure_curve[2] = (gdouble) curve[2] / 100;
pressure_curve[3] = (gdouble) curve[3] / 100;
clutter_evdev_input_device_tool_set_pressure_curve (tool, pressure_curve);
meta_input_device_tool_native_set_pressure_curve (tool, pressure_curve);
}
static guint
@ -551,12 +552,12 @@ meta_input_settings_native_set_stylus_button_map (MetaInputSettings *se
GDesktopStylusButtonAction secondary,
GDesktopStylusButtonAction tertiary)
{
clutter_evdev_input_device_tool_set_button_code (tool, CLUTTER_BUTTON_MIDDLE,
action_to_evcode (primary));
clutter_evdev_input_device_tool_set_button_code (tool, CLUTTER_BUTTON_SECONDARY,
action_to_evcode (secondary));
clutter_evdev_input_device_tool_set_button_code (tool, 8, /* Back */
action_to_evcode (tertiary));
meta_input_device_tool_native_set_button_code (tool, CLUTTER_BUTTON_MIDDLE,
action_to_evcode (primary));
meta_input_device_tool_native_set_button_code (tool, CLUTTER_BUTTON_SECONDARY,
action_to_evcode (secondary));
meta_input_device_tool_native_set_button_code (tool, 8, /* Back */
action_to_evcode (tertiary));
}
static void

View File

@ -19,46 +19,46 @@
* Author: Carlos Garnacho <carlosg@gnome.org>
*/
#include "clutter-build-config.h"
#include "config.h"
#include "clutter-device-manager-evdev.h"
#include "clutter-keymap-evdev.h"
#include "backends/native/meta-device-manager-native.h"
#include "backends/native/meta-keymap-native.h"
static const char *option_xkb_layout = "us";
static const char *option_xkb_variant = "";
static const char *option_xkb_options = "";
typedef struct _ClutterKeymapEvdev ClutterKeymapEvdev;
typedef struct _MetaKeymapNative MetaKeymapNative;
struct _ClutterKeymapEvdev
struct _MetaKeymapNative
{
ClutterKeymap parent_instance;
struct xkb_keymap *keymap;
};
G_DEFINE_TYPE (ClutterKeymapEvdev, clutter_keymap_evdev,
G_DEFINE_TYPE (MetaKeymapNative, meta_keymap_native,
CLUTTER_TYPE_KEYMAP)
static void
clutter_keymap_evdev_finalize (GObject *object)
meta_keymap_native_finalize (GObject *object)
{
ClutterKeymapEvdev *keymap = CLUTTER_KEYMAP_EVDEV (object);
MetaKeymapNative *keymap = META_KEYMAP_NATIVE (object);
xkb_keymap_unref (keymap->keymap);
G_OBJECT_CLASS (clutter_keymap_evdev_parent_class)->finalize (object);
G_OBJECT_CLASS (meta_keymap_native_parent_class)->finalize (object);
}
static gboolean
clutter_keymap_evdev_get_num_lock_state (ClutterKeymap *keymap)
meta_keymap_native_get_num_lock_state (ClutterKeymap *keymap)
{
ClutterDeviceManagerEvdev *device_manager;
MetaDeviceManagerNative *device_manager;
struct xkb_state *xkb_state;
device_manager =
CLUTTER_DEVICE_MANAGER_EVDEV (clutter_device_manager_get_default ());
xkb_state = _clutter_device_manager_evdev_get_xkb_state (device_manager);
META_DEVICE_MANAGER_NATIVE (clutter_device_manager_get_default ());
xkb_state = meta_device_manager_native_get_xkb_state (device_manager);
return xkb_state_mod_name_is_active (xkb_state,
XKB_MOD_NAME_NUM,
@ -67,14 +67,14 @@ clutter_keymap_evdev_get_num_lock_state (ClutterKeymap *keymap)
}
static gboolean
clutter_keymap_evdev_get_caps_lock_state (ClutterKeymap *keymap)
meta_keymap_native_get_caps_lock_state (ClutterKeymap *keymap)
{
ClutterDeviceManagerEvdev *device_manager;
MetaDeviceManagerNative *device_manager;
struct xkb_state *xkb_state;
device_manager =
CLUTTER_DEVICE_MANAGER_EVDEV (clutter_device_manager_get_default ());
xkb_state = _clutter_device_manager_evdev_get_xkb_state (device_manager);
META_DEVICE_MANAGER_NATIVE (clutter_device_manager_get_default ());
xkb_state = meta_device_manager_native_get_xkb_state (device_manager);
return xkb_state_mod_name_is_active (xkb_state,
XKB_MOD_NAME_CAPS,
@ -83,19 +83,19 @@ clutter_keymap_evdev_get_caps_lock_state (ClutterKeymap *keymap)
}
static void
clutter_keymap_evdev_class_init (ClutterKeymapEvdevClass *klass)
meta_keymap_native_class_init (MetaKeymapNativeClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
ClutterKeymapClass *keymap_class = CLUTTER_KEYMAP_CLASS (klass);
object_class->finalize = clutter_keymap_evdev_finalize;
object_class->finalize = meta_keymap_native_finalize;
keymap_class->get_num_lock_state = clutter_keymap_evdev_get_num_lock_state;
keymap_class->get_caps_lock_state = clutter_keymap_evdev_get_caps_lock_state;
keymap_class->get_num_lock_state = meta_keymap_native_get_num_lock_state;
keymap_class->get_caps_lock_state = meta_keymap_native_get_caps_lock_state;
}
static void
clutter_keymap_evdev_init (ClutterKeymapEvdev *keymap)
meta_keymap_native_init (MetaKeymapNative *keymap)
{
struct xkb_context *ctx;
struct xkb_rule_names names;
@ -113,8 +113,8 @@ clutter_keymap_evdev_init (ClutterKeymapEvdev *keymap)
}
void
clutter_keymap_evdev_set_keyboard_map (ClutterKeymapEvdev *keymap,
struct xkb_keymap *xkb_keymap)
meta_keymap_native_set_keyboard_map (MetaKeymapNative *keymap,
struct xkb_keymap *xkb_keymap)
{
if (keymap->keymap)
xkb_keymap_unref (keymap->keymap);
@ -122,7 +122,7 @@ clutter_keymap_evdev_set_keyboard_map (ClutterKeymapEvdev *keymap,
}
struct xkb_keymap *
clutter_keymap_evdev_get_keyboard_map (ClutterKeymapEvdev *keymap)
meta_keymap_native_get_keyboard_map (MetaKeymapNative *keymap)
{
return keymap->keymap;
}

View File

@ -19,14 +19,14 @@
* Author: Carlos Garnacho <carlosg@gnome.org>
*/
#include "clutter-xkb-utils.h"
#include "clutter-keymap.h"
#include "backends/native/meta-xkb-utils.h"
#include "clutter/clutter.h"
#define CLUTTER_TYPE_KEYMAP_EVDEV (clutter_keymap_evdev_get_type ())
G_DECLARE_FINAL_TYPE (ClutterKeymapEvdev, clutter_keymap_evdev,
CLUTTER, KEYMAP_EVDEV,
#define META_TYPE_KEYMAP_NATIVE (meta_keymap_native_get_type ())
G_DECLARE_FINAL_TYPE (MetaKeymapNative, meta_keymap_native,
META, KEYMAP_NATIVE,
ClutterKeymap)
void clutter_keymap_evdev_set_keyboard_map (ClutterKeymapEvdev *keymap,
struct xkb_keymap *xkb_keymap);
struct xkb_keymap * clutter_keymap_evdev_get_keyboard_map (ClutterKeymapEvdev *keymap);
void meta_keymap_native_set_keyboard_map (MetaKeymapNative *keymap,
struct xkb_keymap *xkb_keymap);
struct xkb_keymap * meta_keymap_native_get_keyboard_map (MetaKeymapNative *keymap);

View File

@ -24,6 +24,7 @@
#include <gio/gunixfdlist.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
#include <malloc.h>
#include <fcntl.h>
#include <errno.h>
@ -37,9 +38,9 @@
#include "backends/native/dbus-utils.h"
#include "backends/native/meta-backend-native.h"
#include "backends/native/meta-cursor-renderer-native.h"
#include "backends/native/meta-device-manager-native.h"
#include "backends/native/meta-renderer-native.h"
#include "clutter/clutter.h"
#include "clutter/evdev/clutter-evdev.h"
#include "meta-dbus-login1.h"
@ -524,11 +525,11 @@ meta_launcher_new (GError **error)
self->sysfs_fds = g_hash_table_new (NULL, NULL);
self->session_active = TRUE;
clutter_evdev_set_seat_id (self->seat_id);
meta_device_manager_native_set_seat_id (self->seat_id);
clutter_evdev_set_device_callbacks (on_evdev_device_open,
on_evdev_device_close,
self);
meta_device_manager_native_set_device_callbacks (on_evdev_device_open,
on_evdev_device_close,
self);
g_signal_connect (self->session_proxy, "notify::active", G_CALLBACK (on_active_changed), self);

View File

@ -24,18 +24,17 @@
* Author: Jonas Ådahl <jadahl@gmail.com>
*/
#include "clutter-build-config.h"
#include "clutter-seat-evdev.h"
#include "config.h"
#include <linux/input.h>
#include <math.h>
#include "clutter-event-private.h"
#include "clutter-input-device-evdev.h"
#include "clutter-input-device-tool-evdev.h"
#include "clutter-keymap-evdev.h"
#include "clutter-main.h"
#include "backends/native/meta-seat-native.h"
#include "backends/native/meta-event-native.h"
#include "backends/native/meta-input-device-native.h"
#include "backends/native/meta-input-device-tool-native.h"
#include "backends/native/meta-keymap-native.h"
#include "clutter/clutter-mutter.h"
/* Try to keep the pointer inside the stage. Hopefully no one is using
* this backend with stages smaller than this. */
@ -51,8 +50,8 @@
#endif
void
clutter_seat_evdev_set_libinput_seat (ClutterSeatEvdev *seat,
struct libinput_seat *libinput_seat)
meta_seat_native_set_libinput_seat (MetaSeatNative *seat,
struct libinput_seat *libinput_seat)
{
g_assert (seat->libinput_seat == NULL);
@ -62,10 +61,10 @@ clutter_seat_evdev_set_libinput_seat (ClutterSeatEvdev *seat,
}
void
clutter_seat_evdev_sync_leds (ClutterSeatEvdev *seat)
meta_seat_native_sync_leds (MetaSeatNative *seat)
{
GSList *iter;
ClutterInputDeviceEvdev *device_evdev;
MetaInputDeviceNative *device_evdev;
int caps_lock, num_lock, scroll_lock;
enum libinput_led leds = 0;
@ -83,19 +82,19 @@ clutter_seat_evdev_sync_leds (ClutterSeatEvdev *seat)
for (iter = seat->devices; iter; iter = iter->next)
{
device_evdev = iter->data;
_clutter_input_device_evdev_update_leds (device_evdev, leds);
meta_input_device_native_update_leds (device_evdev, leds);
}
}
static void
clutter_touch_state_free (ClutterTouchState *touch_state)
clutter_touch_state_free (MetaTouchState *touch_state)
{
g_slice_free (ClutterTouchState, touch_state);
g_slice_free (MetaTouchState, touch_state);
}
static void
ensure_seat_slot_allocated (ClutterSeatEvdev *seat,
int seat_slot)
ensure_seat_slot_allocated (MetaSeatNative *seat,
int seat_slot)
{
if (seat_slot >= seat->n_alloc_touch_states)
{
@ -105,17 +104,17 @@ ensure_seat_slot_allocated (ClutterSeatEvdev *seat,
seat->n_alloc_touch_states += size_increase;
seat->touch_states = g_realloc_n (seat->touch_states,
seat->n_alloc_touch_states,
sizeof (ClutterTouchState *));
sizeof (MetaTouchState *));
for (i = 0; i < size_increase; i++)
seat->touch_states[seat->n_alloc_touch_states - (i + 1)] = NULL;
}
}
ClutterTouchState *
clutter_seat_evdev_acquire_touch_state (ClutterSeatEvdev *seat,
int device_slot)
MetaTouchState *
meta_seat_native_acquire_touch_state (MetaSeatNative *seat,
int device_slot)
{
ClutterTouchState *touch_state;
MetaTouchState *touch_state;
int seat_slot;
for (seat_slot = 0; seat_slot < seat->n_alloc_touch_states; seat_slot++)
@ -126,8 +125,8 @@ clutter_seat_evdev_acquire_touch_state (ClutterSeatEvdev *seat,
ensure_seat_slot_allocated (seat, seat_slot);
touch_state = g_slice_new0 (ClutterTouchState);
*touch_state = (ClutterTouchState) {
touch_state = g_slice_new0 (MetaTouchState);
*touch_state = (MetaTouchState) {
.seat = seat,
.seat_slot = seat_slot,
.device_slot = device_slot,
@ -139,32 +138,32 @@ clutter_seat_evdev_acquire_touch_state (ClutterSeatEvdev *seat,
}
void
clutter_seat_evdev_release_touch_state (ClutterSeatEvdev *seat,
ClutterTouchState *touch_state)
meta_seat_native_release_touch_state (MetaSeatNative *seat,
MetaTouchState *touch_state)
{
g_clear_pointer (&seat->touch_states[touch_state->seat_slot],
clutter_touch_state_free);
}
ClutterSeatEvdev *
clutter_seat_evdev_new (ClutterDeviceManagerEvdev *manager_evdev)
MetaSeatNative *
meta_seat_native_new (MetaDeviceManagerNative *manager_evdev)
{
ClutterDeviceManager *manager = CLUTTER_DEVICE_MANAGER (manager_evdev);
ClutterSeatEvdev *seat;
MetaSeatNative *seat;
ClutterInputDevice *device;
ClutterStage *stage;
ClutterKeymap *keymap;
struct xkb_keymap *xkb_keymap;
seat = g_new0 (ClutterSeatEvdev, 1);
seat = g_new0 (MetaSeatNative, 1);
if (!seat)
return NULL;
seat->manager_evdev = manager_evdev;
device = _clutter_input_device_evdev_new_virtual (
device = meta_input_device_native_new_virtual (
manager, seat, CLUTTER_POINTER_DEVICE,
CLUTTER_INPUT_MODE_MASTER);
stage = _clutter_device_manager_evdev_get_stage (manager_evdev);
stage = meta_device_manager_native_get_stage (manager_evdev);
_clutter_input_device_set_stage (device, stage);
seat->pointer_x = INITIAL_POINTER_X;
seat->pointer_y = INITIAL_POINTER_Y;
@ -174,7 +173,7 @@ clutter_seat_evdev_new (ClutterDeviceManagerEvdev *manager_evdev)
_clutter_device_manager_add_device (manager, device);
seat->core_pointer = device;
device = _clutter_input_device_evdev_new_virtual (
device = meta_input_device_native_new_virtual (
manager, seat, CLUTTER_KEYBOARD_DEVICE,
CLUTTER_INPUT_MODE_MASTER);
_clutter_input_device_set_stage (device, stage);
@ -186,7 +185,7 @@ clutter_seat_evdev_new (ClutterDeviceManagerEvdev *manager_evdev)
seat->repeat_interval = 33; /* ms */
keymap = clutter_backend_get_keymap (clutter_get_default_backend ());
xkb_keymap = clutter_keymap_evdev_get_keyboard_map (CLUTTER_KEYMAP_EVDEV (keymap));
xkb_keymap = meta_keymap_native_get_keyboard_map (META_KEYMAP_NATIVE (keymap));
if (xkb_keymap)
{
@ -204,7 +203,7 @@ clutter_seat_evdev_new (ClutterDeviceManagerEvdev *manager_evdev)
}
void
clutter_seat_evdev_clear_repeat_timer (ClutterSeatEvdev *seat)
meta_seat_native_clear_repeat_timer (MetaSeatNative *seat)
{
if (seat->repeat_timer)
{
@ -217,24 +216,24 @@ clutter_seat_evdev_clear_repeat_timer (ClutterSeatEvdev *seat)
static gboolean
keyboard_repeat (gpointer data)
{
ClutterSeatEvdev *seat = data;
MetaSeatNative *seat = data;
GSource *source;
/* There might be events queued in libinput that could cancel the
repeat timer. */
_clutter_device_manager_evdev_dispatch (seat->manager_evdev);
meta_device_manager_native_dispatch (seat->manager_evdev);
if (!seat->repeat_timer)
return G_SOURCE_REMOVE;
g_return_val_if_fail (seat->repeat_device != NULL, G_SOURCE_REMOVE);
source = g_main_context_find_source_by_id (NULL, seat->repeat_timer);
clutter_seat_evdev_notify_key (seat,
seat->repeat_device,
g_source_get_time (source),
seat->repeat_key,
AUTOREPEAT_VALUE,
FALSE);
meta_seat_native_notify_key (seat,
seat->repeat_device,
g_source_get_time (source),
seat->repeat_key,
AUTOREPEAT_VALUE,
FALSE);
return G_SOURCE_CONTINUE;
}
@ -246,9 +245,9 @@ queue_event (ClutterEvent *event)
}
static int
update_button_count (ClutterSeatEvdev *seat,
uint32_t button,
uint32_t state)
update_button_count (MetaSeatNative *seat,
uint32_t button,
uint32_t state)
{
if (state)
{
@ -265,12 +264,12 @@ update_button_count (ClutterSeatEvdev *seat,
}
void
clutter_seat_evdev_notify_key (ClutterSeatEvdev *seat,
ClutterInputDevice *device,
uint64_t time_us,
uint32_t key,
uint32_t state,
gboolean update_keys)
meta_seat_native_notify_key (MetaSeatNative *seat,
ClutterInputDevice *device,
uint64_t time_us,
uint32_t key,
uint32_t state,
gboolean update_keys)
{
ClutterStage *stage;
ClutterEvent *event = NULL;
@ -291,17 +290,17 @@ clutter_seat_evdev_notify_key (ClutterSeatEvdev *seat,
stage = _clutter_input_device_get_stage (device);
if (stage == NULL)
{
clutter_seat_evdev_clear_repeat_timer (seat);
meta_seat_native_clear_repeat_timer (seat);
return;
}
event = _clutter_key_event_new_from_evdev (device,
seat->core_keyboard,
stage,
seat->xkb,
seat->button_state,
us2ms (time_us), key, state);
_clutter_evdev_event_set_event_code (event, key);
event = meta_key_event_new_from_evdev (device,
seat->core_keyboard,
stage,
seat->xkb,
seat->button_state,
us2ms (time_us), key, state);
meta_event_native_set_event_code (event, key);
/* We must be careful and not pass multiple releases to xkb, otherwise it gets
confused and locks the modifiers */
@ -325,8 +324,8 @@ clutter_seat_evdev_notify_key (ClutterSeatEvdev *seat,
backend = clutter_get_default_backend ();
g_signal_emit_by_name (clutter_backend_get_keymap (backend), "state-changed");
clutter_seat_evdev_sync_leds (seat);
clutter_evdev_a11y_maybe_notify_toggle_keys (CLUTTER_INPUT_DEVICE_EVDEV (seat->core_keyboard));
meta_seat_native_sync_leds (seat);
meta_input_device_native_a11y_maybe_notify_toggle_keys (META_INPUT_DEVICE_NATIVE (seat->core_keyboard));
}
if (state == 0 || /* key release */
@ -334,7 +333,7 @@ clutter_seat_evdev_notify_key (ClutterSeatEvdev *seat,
!xkb_keymap_key_repeats (xkb_state_get_keymap (seat->xkb),
event->key.hardware_keycode))
{
clutter_seat_evdev_clear_repeat_timer (seat);
meta_seat_native_clear_repeat_timer (seat);
return;
}
@ -351,7 +350,7 @@ clutter_seat_evdev_notify_key (ClutterSeatEvdev *seat,
{
guint32 interval;
clutter_seat_evdev_clear_repeat_timer (seat);
meta_seat_native_clear_repeat_timer (seat);
seat->repeat_device = g_object_ref (device);
if (seat->repeat_count == 1)
@ -373,7 +372,7 @@ clutter_seat_evdev_notify_key (ClutterSeatEvdev *seat,
}
static ClutterEvent *
new_absolute_motion_event (ClutterSeatEvdev *seat,
new_absolute_motion_event (MetaSeatNative *seat,
ClutterInputDevice *input_device,
guint64 time_us,
gfloat x,
@ -386,17 +385,19 @@ new_absolute_motion_event (ClutterSeatEvdev *seat,
event = clutter_event_new (CLUTTER_MOTION);
if (clutter_input_device_get_device_type (input_device) != CLUTTER_TABLET_DEVICE)
_clutter_device_manager_evdev_constrain_pointer (seat->manager_evdev,
seat->core_pointer,
time_us,
seat->pointer_x,
seat->pointer_y,
&x, &y);
{
meta_device_manager_native_constrain_pointer (seat->manager_evdev,
seat->core_pointer,
time_us,
seat->pointer_x,
seat->pointer_y,
&x, &y);
}
_clutter_evdev_event_set_time_usec (event, time_us);
meta_event_native_set_time_usec (event, time_us);
event->motion.time = us2ms (time_us);
event->motion.stage = stage;
_clutter_xkb_translate_state (event, seat->xkb, seat->button_state);
meta_xkb_translate_state (event, seat->xkb, seat->button_state);
event->motion.x = x;
event->motion.y = y;
event->motion.axes = axes;
@ -405,8 +406,8 @@ new_absolute_motion_event (ClutterSeatEvdev *seat,
if (clutter_input_device_get_device_type (input_device) == CLUTTER_TABLET_DEVICE)
{
ClutterInputDeviceEvdev *device_evdev =
CLUTTER_INPUT_DEVICE_EVDEV (input_device);
MetaInputDeviceNative *device_evdev =
META_INPUT_DEVICE_NATIVE (input_device);
clutter_event_set_device_tool (event, device_evdev->last_tool);
clutter_event_set_device (event, input_device);
@ -428,13 +429,13 @@ new_absolute_motion_event (ClutterSeatEvdev *seat,
}
void
clutter_seat_evdev_notify_relative_motion (ClutterSeatEvdev *seat,
ClutterInputDevice *input_device,
uint64_t time_us,
float dx,
float dy,
float dx_unaccel,
float dy_unaccel)
meta_seat_native_notify_relative_motion (MetaSeatNative *seat,
ClutterInputDevice *input_device,
uint64_t time_us,
float dx,
float dy,
float dx_unaccel,
float dy_unaccel)
{
gfloat new_x, new_y;
ClutterEvent *event;
@ -444,31 +445,32 @@ clutter_seat_evdev_notify_relative_motion (ClutterSeatEvdev *seat,
if (!_clutter_input_device_get_stage (input_device))
return;
_clutter_device_manager_evdev_filter_relative_motion (seat->manager_evdev,
input_device,
seat->pointer_x,
seat->pointer_y,
&dx,
&dy);
meta_device_manager_native_filter_relative_motion (seat->manager_evdev,
input_device,
seat->pointer_x,
seat->pointer_y,
&dx,
&dy);
new_x = seat->pointer_x + dx;
new_y = seat->pointer_y + dy;
event = new_absolute_motion_event (seat, input_device,
time_us, new_x, new_y, NULL);
_clutter_evdev_event_set_relative_motion (event,
dx, dy,
dx_unaccel, dy_unaccel);
meta_event_native_set_relative_motion (event,
dx, dy,
dx_unaccel, dy_unaccel);
queue_event (event);
}
void clutter_seat_evdev_notify_absolute_motion (ClutterSeatEvdev *seat,
ClutterInputDevice *input_device,
uint64_t time_us,
float x,
float y,
double *axes)
void
meta_seat_native_notify_absolute_motion (MetaSeatNative *seat,
ClutterInputDevice *input_device,
uint64_t time_us,
float x,
float y,
double *axes)
{
ClutterEvent *event;
@ -478,13 +480,13 @@ void clutter_seat_evdev_notify_absolute_motion (ClutterSeatEvdev *seat,
}
void
clutter_seat_evdev_notify_button (ClutterSeatEvdev *seat,
ClutterInputDevice *input_device,
uint64_t time_us,
uint32_t button,
uint32_t state)
meta_seat_native_notify_button (MetaSeatNative *seat,
ClutterInputDevice *input_device,
uint64_t time_us,
uint32_t button,
uint32_t state)
{
ClutterInputDeviceEvdev *device_evdev = (ClutterInputDeviceEvdev *) input_device;
MetaInputDeviceNative *device_evdev = (MetaInputDeviceNative *) input_device;
ClutterStage *stage;
ClutterEvent *event = NULL;
gint button_nr;
@ -561,10 +563,10 @@ clutter_seat_evdev_notify_button (ClutterSeatEvdev *seat,
seat->button_state &= ~maskmap[button_nr - 1];
}
_clutter_evdev_event_set_time_usec (event, time_us);
meta_event_native_set_time_usec (event, time_us);
event->button.time = us2ms (time_us);
event->button.stage = CLUTTER_STAGE (stage);
_clutter_xkb_translate_state (event, seat->xkb, seat->button_state);
meta_xkb_translate_state (event, seat->xkb, seat->button_state);
event->button.button = button_nr;
if (clutter_input_device_get_device_type (input_device) == CLUTTER_TABLET_DEVICE)
@ -589,13 +591,13 @@ clutter_seat_evdev_notify_button (ClutterSeatEvdev *seat,
/* Apply the button event code as per the tool mapping */
guint mapped_button;
mapped_button = clutter_input_device_tool_evdev_get_button_code (device_evdev->last_tool,
button_nr);
mapped_button = meta_input_device_tool_native_get_button_code (device_evdev->last_tool,
button_nr);
if (mapped_button != 0)
button = mapped_button;
}
_clutter_evdev_event_set_event_code (event, button);
meta_event_native_set_event_code (event, button);
if (clutter_input_device_get_device_type (input_device) == CLUTTER_TABLET_DEVICE)
{
@ -621,8 +623,8 @@ notify_scroll (ClutterInputDevice *input_device,
ClutterScrollFinishFlags flags,
gboolean emulated)
{
ClutterInputDeviceEvdev *device_evdev;
ClutterSeatEvdev *seat;
MetaInputDeviceNative *device_evdev;
MetaSeatNative *seat;
ClutterStage *stage;
ClutterEvent *event = NULL;
gdouble scroll_factor;
@ -633,15 +635,15 @@ notify_scroll (ClutterInputDevice *input_device,
if (stage == NULL)
return;
device_evdev = CLUTTER_INPUT_DEVICE_EVDEV (input_device);
seat = _clutter_input_device_evdev_get_seat (device_evdev);
device_evdev = META_INPUT_DEVICE_NATIVE (input_device);
seat = meta_input_device_native_get_seat (device_evdev);
event = clutter_event_new (CLUTTER_SCROLL);
_clutter_evdev_event_set_time_usec (event, time_us);
meta_event_native_set_time_usec (event, time_us);
event->scroll.time = us2ms (time_us);
event->scroll.stage = CLUTTER_STAGE (stage);
_clutter_xkb_translate_state (event, seat->xkb, seat->button_state);
meta_xkb_translate_state (event, seat->xkb, seat->button_state);
/* libinput pointer axis events are in pointer motion coordinate space.
* To convert to Xi2 discrete step coordinate space, multiply the factor
@ -671,8 +673,8 @@ notify_discrete_scroll (ClutterInputDevice *input_device,
ClutterScrollSource scroll_source,
gboolean emulated)
{
ClutterInputDeviceEvdev *device_evdev;
ClutterSeatEvdev *seat;
MetaInputDeviceNative *device_evdev;
MetaSeatNative *seat;
ClutterStage *stage;
ClutterEvent *event = NULL;
@ -685,15 +687,15 @@ notify_discrete_scroll (ClutterInputDevice *input_device,
if (stage == NULL)
return;
device_evdev = CLUTTER_INPUT_DEVICE_EVDEV (input_device);
seat = _clutter_input_device_evdev_get_seat (device_evdev);
device_evdev = META_INPUT_DEVICE_NATIVE (input_device);
seat = meta_input_device_native_get_seat (device_evdev);
event = clutter_event_new (CLUTTER_SCROLL);
_clutter_evdev_event_set_time_usec (event, time_us);
meta_event_native_set_time_usec (event, time_us);
event->scroll.time = us2ms (time_us);
event->scroll.stage = CLUTTER_STAGE (stage);
_clutter_xkb_translate_state (event, seat->xkb, seat->button_state);
meta_xkb_translate_state (event, seat->xkb, seat->button_state);
event->scroll.direction = direction;
@ -709,7 +711,7 @@ notify_discrete_scroll (ClutterInputDevice *input_device,
}
static void
check_notify_discrete_scroll (ClutterSeatEvdev *seat,
check_notify_discrete_scroll (MetaSeatNative *seat,
ClutterInputDevice *device,
uint64_t time_us,
ClutterScrollSource scroll_source)
@ -740,13 +742,13 @@ check_notify_discrete_scroll (ClutterSeatEvdev *seat,
}
void
clutter_seat_evdev_notify_scroll_continuous (ClutterSeatEvdev *seat,
ClutterInputDevice *input_device,
uint64_t time_us,
double dx,
double dy,
ClutterScrollSource scroll_source,
ClutterScrollFinishFlags finish_flags)
meta_seat_native_notify_scroll_continuous (MetaSeatNative *seat,
ClutterInputDevice *input_device,
uint64_t time_us,
double dx,
double dy,
ClutterScrollSource scroll_source,
ClutterScrollFinishFlags finish_flags)
{
if (finish_flags & CLUTTER_SCROLL_FINISHED_HORIZONTAL)
seat->accum_scroll_dx = 0;
@ -781,12 +783,12 @@ discrete_to_direction (double discrete_dx,
}
void
clutter_seat_evdev_notify_discrete_scroll (ClutterSeatEvdev *seat,
ClutterInputDevice *input_device,
uint64_t time_us,
double discrete_dx,
double discrete_dy,
ClutterScrollSource scroll_source)
meta_seat_native_notify_discrete_scroll (MetaSeatNative *seat,
ClutterInputDevice *input_device,
uint64_t time_us,
double discrete_dx,
double discrete_dy,
ClutterScrollSource scroll_source)
{
notify_scroll (input_device, time_us,
discrete_dx * DISCRETE_SCROLL_STEP,
@ -800,13 +802,13 @@ clutter_seat_evdev_notify_discrete_scroll (ClutterSeatEvdev *seat,
}
void
clutter_seat_evdev_notify_touch_event (ClutterSeatEvdev *seat,
ClutterInputDevice *input_device,
ClutterEventType evtype,
uint64_t time_us,
int slot,
double x,
double y)
meta_seat_native_notify_touch_event (MetaSeatNative *seat,
ClutterInputDevice *input_device,
ClutterEventType evtype,
uint64_t time_us,
int slot,
double x,
double y)
{
ClutterStage *stage;
ClutterEvent *event = NULL;
@ -819,18 +821,18 @@ clutter_seat_evdev_notify_touch_event (ClutterSeatEvdev *seat,
event = clutter_event_new (evtype);
_clutter_evdev_event_set_time_usec (event, time_us);
meta_event_native_set_time_usec (event, time_us);
event->touch.time = us2ms (time_us);
event->touch.stage = CLUTTER_STAGE (stage);
event->touch.x = x;
event->touch.y = y;
clutter_input_device_evdev_translate_coordinates (input_device, stage,
&event->touch.x,
&event->touch.y);
meta_input_device_native_translate_coordinates (input_device, stage,
&event->touch.x,
&event->touch.y);
/* "NULL" sequences are special cased in clutter */
event->touch.sequence = GINT_TO_POINTER (MAX (1, slot + 1));
_clutter_xkb_translate_state (event, seat->xkb, seat->button_state);
meta_xkb_translate_state (event, seat->xkb, seat->button_state);
if (evtype == CLUTTER_TOUCH_BEGIN ||
evtype == CLUTTER_TOUCH_UPDATE)
@ -843,7 +845,7 @@ clutter_seat_evdev_notify_touch_event (ClutterSeatEvdev *seat,
}
void
clutter_seat_evdev_free (ClutterSeatEvdev *seat)
meta_seat_native_free (MetaSeatNative *seat)
{
GSList *iter;
@ -858,7 +860,7 @@ clutter_seat_evdev_free (ClutterSeatEvdev *seat)
xkb_state_unref (seat->xkb);
clutter_seat_evdev_clear_repeat_timer (seat);
meta_seat_native_clear_repeat_timer (seat);
if (seat->libinput_seat)
libinput_seat_unref (seat->libinput_seat);
@ -867,8 +869,8 @@ clutter_seat_evdev_free (ClutterSeatEvdev *seat)
}
ClutterInputDevice *
clutter_seat_evdev_get_device (ClutterSeatEvdev *seat,
gint id)
meta_seat_native_get_device (MetaSeatNative *seat,
gint id)
{
ClutterInputDevice *device;
GSList *l;
@ -885,8 +887,8 @@ clutter_seat_evdev_get_device (ClutterSeatEvdev *seat,
}
void
clutter_seat_evdev_set_stage (ClutterSeatEvdev *seat,
ClutterStage *stage)
meta_seat_native_set_stage (MetaSeatNative *seat,
ClutterStage *stage)
{
GSList *l;

View File

@ -0,0 +1,160 @@
/*
* Copyright (C) 2010 Intel Corp.
* Copyright (C) 2014 Jonas Ådahl
* Copyright (C) 2016 Red Hat Inc.
*
* 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: Damien Lespiau <damien.lespiau@intel.com>
* Author: Jonas Ådahl <jadahl@gmail.com>
*/
#ifndef META_SEAT_NATIVE_H
#define META_SEAT_NATIVE_H
#include <libinput.h>
#include <linux/input-event-codes.h>
#include "backends/native/meta-device-manager-native.h"
#include "backends/native/meta-xkb-utils.h"
#include "clutter/clutter.h"
typedef struct _MetaTouchState MetaTouchState;
typedef struct _MetaSeatNative MetaSeatNative;
struct _MetaTouchState
{
MetaSeatNative *seat;
int device_slot;
int seat_slot;
ClutterPoint coords;
};
struct _MetaSeatNative
{
struct libinput_seat *libinput_seat;
MetaDeviceManagerNative *manager_evdev;
GSList *devices;
ClutterInputDevice *core_pointer;
ClutterInputDevice *core_keyboard;
MetaTouchState **touch_states;
int n_alloc_touch_states;
struct xkb_state *xkb;
xkb_led_index_t caps_lock_led;
xkb_led_index_t num_lock_led;
xkb_led_index_t scroll_lock_led;
xkb_layout_index_t layout_idx;
uint32_t button_state;
int button_count[KEY_CNT];
/* keyboard repeat */
gboolean repeat;
guint32 repeat_delay;
guint32 repeat_interval;
guint32 repeat_key;
guint32 repeat_count;
guint32 repeat_timer;
ClutterInputDevice *repeat_device;
gfloat pointer_x;
gfloat pointer_y;
/* Emulation of discrete scroll events out of smooth ones */
gfloat accum_scroll_dx;
gfloat accum_scroll_dy;
};
void meta_seat_native_notify_key (MetaSeatNative *seat,
ClutterInputDevice *device,
uint64_t time_us,
uint32_t key,
uint32_t state,
gboolean update_keys);
void meta_seat_native_notify_relative_motion (MetaSeatNative *seat_evdev,
ClutterInputDevice *input_device,
uint64_t time_us,
float dx,
float dy,
float dx_unaccel,
float dy_unaccel);
void meta_seat_native_notify_absolute_motion (MetaSeatNative *seat_evdev,
ClutterInputDevice *input_device,
uint64_t time_us,
float x,
float y,
double *axes);
void meta_seat_native_notify_button (MetaSeatNative *seat,
ClutterInputDevice *input_device,
uint64_t time_us,
uint32_t button,
uint32_t state);
void meta_seat_native_notify_scroll_continuous (MetaSeatNative *seat,
ClutterInputDevice *input_device,
uint64_t time_us,
double dx,
double dy,
ClutterScrollSource source,
ClutterScrollFinishFlags flags);
void meta_seat_native_notify_discrete_scroll (MetaSeatNative *seat,
ClutterInputDevice *input_device,
uint64_t time_us,
double discrete_dx,
double discrete_dy,
ClutterScrollSource source);
void meta_seat_native_notify_touch_event (MetaSeatNative *seat,
ClutterInputDevice *input_device,
ClutterEventType evtype,
uint64_t time_us,
int slot,
double x,
double y);
void meta_seat_native_set_libinput_seat (MetaSeatNative *seat,
struct libinput_seat *libinput_seat);
void meta_seat_native_sync_leds (MetaSeatNative *seat);
ClutterInputDevice * meta_seat_native_get_device (MetaSeatNative *seat,
gint id);
MetaTouchState * meta_seat_native_acquire_touch_state (MetaSeatNative *seat,
int device_slot);
void meta_seat_native_release_touch_state (MetaSeatNative *seat,
MetaTouchState *touch_state);
MetaTouchState * meta_seat_native_get_touch (MetaSeatNative *seat,
guint32 id);
void meta_seat_native_set_stage (MetaSeatNative *seat,
ClutterStage *stage);
void meta_seat_native_clear_repeat_timer (MetaSeatNative *seat);
MetaSeatNative * meta_seat_native_new (MetaDeviceManagerNative *manager_evdev);
void meta_seat_native_free (MetaSeatNative *seat);
#endif /* META_SEAT_NATIVE_H */

View File

@ -1,8 +1,4 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2016 Red Hat Inc.
*
* This library is free software; you can redistribute it and/or
@ -21,17 +17,16 @@
* Author: Jonas Ådahl <jadahl@gmail.com>
*/
#include "clutter-build-config.h"
#include "config.h"
#include <glib-object.h>
#include <linux/input.h>
#include "clutter-private.h"
#include "clutter-virtual-input-device.h"
#include "evdev/clutter-input-device-evdev.h"
#include "evdev/clutter-keymap-evdev.h"
#include "evdev/clutter-seat-evdev.h"
#include "evdev/clutter-virtual-input-device-evdev.h"
#include "backends/native/meta-input-device-native.h"
#include "backends/native/meta-keymap-native.h"
#include "backends/native/meta-seat-native.h"
#include "backends/native/meta-virtual-input-device-native.h"
#include "clutter/clutter-mutter.h"
enum
{
@ -44,17 +39,17 @@ enum
static GParamSpec *obj_props[PROP_LAST];
struct _ClutterVirtualInputDeviceEvdev
struct _MetaVirtualInputDeviceNative
{
ClutterVirtualInputDevice parent;
ClutterInputDevice *device;
ClutterSeatEvdev *seat;
MetaSeatNative *seat;
int button_count[KEY_CNT];
};
G_DEFINE_TYPE (ClutterVirtualInputDeviceEvdev,
clutter_virtual_input_device_evdev,
G_DEFINE_TYPE (MetaVirtualInputDeviceNative,
meta_virtual_input_device_native,
CLUTTER_TYPE_VIRTUAL_INPUT_DEVICE)
typedef enum _EvdevButtonType
@ -65,9 +60,9 @@ typedef enum _EvdevButtonType
} EvdevButtonType;
static int
update_button_count (ClutterVirtualInputDeviceEvdev *virtual_evdev,
uint32_t button,
uint32_t state)
update_button_count (MetaVirtualInputDeviceNative *virtual_evdev,
uint32_t button,
uint32_t state)
{
if (state)
return ++virtual_evdev->button_count[button];
@ -114,8 +109,8 @@ get_button_type (uint16_t code)
static void
release_pressed_buttons (ClutterVirtualInputDevice *virtual_device)
{
ClutterVirtualInputDeviceEvdev *virtual_evdev =
CLUTTER_VIRTUAL_INPUT_DEVICE_EVDEV (virtual_device);
MetaVirtualInputDeviceNative *virtual_evdev =
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
int code;
uint64_t time_us;
@ -147,41 +142,41 @@ release_pressed_buttons (ClutterVirtualInputDevice *virtual_device)
}
static void
clutter_virtual_input_device_evdev_notify_relative_motion (ClutterVirtualInputDevice *virtual_device,
uint64_t time_us,
double dx,
double dy)
meta_virtual_input_device_native_notify_relative_motion (ClutterVirtualInputDevice *virtual_device,
uint64_t time_us,
double dx,
double dy)
{
ClutterVirtualInputDeviceEvdev *virtual_evdev =
CLUTTER_VIRTUAL_INPUT_DEVICE_EVDEV (virtual_device);
MetaVirtualInputDeviceNative *virtual_evdev =
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
if (time_us == CLUTTER_CURRENT_TIME)
time_us = g_get_monotonic_time ();
clutter_seat_evdev_notify_relative_motion (virtual_evdev->seat,
virtual_evdev->device,
time_us,
dx, dy,
dx, dy);
meta_seat_native_notify_relative_motion (virtual_evdev->seat,
virtual_evdev->device,
time_us,
dx, dy,
dx, dy);
}
static void
clutter_virtual_input_device_evdev_notify_absolute_motion (ClutterVirtualInputDevice *virtual_device,
uint64_t time_us,
double x,
double y)
meta_virtual_input_device_native_notify_absolute_motion (ClutterVirtualInputDevice *virtual_device,
uint64_t time_us,
double x,
double y)
{
ClutterVirtualInputDeviceEvdev *virtual_evdev =
CLUTTER_VIRTUAL_INPUT_DEVICE_EVDEV (virtual_device);
MetaVirtualInputDeviceNative *virtual_evdev =
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
if (time_us == CLUTTER_CURRENT_TIME)
time_us = g_get_monotonic_time ();
clutter_seat_evdev_notify_absolute_motion (virtual_evdev->seat,
virtual_evdev->device,
time_us,
x, y,
NULL);
meta_seat_native_notify_absolute_motion (virtual_evdev->seat,
virtual_evdev->device,
time_us,
x, y,
NULL);
}
static int
@ -205,13 +200,13 @@ translate_to_evdev_button (int clutter_button)
}
static void
clutter_virtual_input_device_evdev_notify_button (ClutterVirtualInputDevice *virtual_device,
uint64_t time_us,
uint32_t button,
ClutterButtonState button_state)
meta_virtual_input_device_native_notify_button (ClutterVirtualInputDevice *virtual_device,
uint64_t time_us,
uint32_t button,
ClutterButtonState button_state)
{
ClutterVirtualInputDeviceEvdev *virtual_evdev =
CLUTTER_VIRTUAL_INPUT_DEVICE_EVDEV (virtual_device);
MetaVirtualInputDeviceNative *virtual_evdev =
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
int button_count;
int evdev_button;
@ -236,21 +231,21 @@ clutter_virtual_input_device_evdev_notify_button (ClutterVirtualInputDevice *vir
return;
}
clutter_seat_evdev_notify_button (virtual_evdev->seat,
virtual_evdev->device,
time_us,
evdev_button,
button_state);
meta_seat_native_notify_button (virtual_evdev->seat,
virtual_evdev->device,
time_us,
evdev_button,
button_state);
}
static void
clutter_virtual_input_device_evdev_notify_key (ClutterVirtualInputDevice *virtual_device,
uint64_t time_us,
uint32_t key,
ClutterKeyState key_state)
meta_virtual_input_device_native_notify_key (ClutterVirtualInputDevice *virtual_device,
uint64_t time_us,
uint32_t key,
ClutterKeyState key_state)
{
ClutterVirtualInputDeviceEvdev *virtual_evdev =
CLUTTER_VIRTUAL_INPUT_DEVICE_EVDEV (virtual_device);
MetaVirtualInputDeviceNative *virtual_evdev =
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
int key_count;
if (time_us == CLUTTER_CURRENT_TIME)
@ -271,12 +266,12 @@ clutter_virtual_input_device_evdev_notify_key (ClutterVirtualInputDevice *virtua
return;
}
clutter_seat_evdev_notify_key (virtual_evdev->seat,
virtual_evdev->device,
time_us,
key,
key_state,
TRUE);
meta_seat_native_notify_key (virtual_evdev->seat,
virtual_evdev->device,
time_us,
key,
key_state,
TRUE);
}
static gboolean
@ -285,8 +280,8 @@ pick_keycode_for_keyval_in_current_group (ClutterVirtualInputDevice *virtual_dev
guint *keycode_out,
guint *level_out)
{
ClutterVirtualInputDeviceEvdev *virtual_evdev =
CLUTTER_VIRTUAL_INPUT_DEVICE_EVDEV (virtual_device);
MetaVirtualInputDeviceNative *virtual_evdev =
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
ClutterKeymap *keymap;
struct xkb_keymap *xkb_keymap;
struct xkb_state *state;
@ -294,7 +289,7 @@ pick_keycode_for_keyval_in_current_group (ClutterVirtualInputDevice *virtual_dev
xkb_keycode_t min_keycode, max_keycode;
keymap = clutter_backend_get_keymap (clutter_get_default_backend ());
xkb_keymap = clutter_keymap_evdev_get_keyboard_map (CLUTTER_KEYMAP_EVDEV (keymap));
xkb_keymap = meta_keymap_native_get_keyboard_map (META_KEYMAP_NATIVE (keymap));
state = virtual_evdev->seat->xkb;
layout = xkb_state_serialize_layout (state, XKB_STATE_LAYOUT_EFFECTIVE);
@ -331,8 +326,8 @@ apply_level_modifiers (ClutterVirtualInputDevice *virtual_device,
uint32_t level,
uint32_t key_state)
{
ClutterVirtualInputDeviceEvdev *virtual_evdev =
CLUTTER_VIRTUAL_INPUT_DEVICE_EVDEV (virtual_device);
MetaVirtualInputDeviceNative *virtual_evdev =
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
guint keysym, keycode, evcode;
if (level == 0)
@ -358,22 +353,22 @@ apply_level_modifiers (ClutterVirtualInputDevice *virtual_device,
clutter_input_device_keycode_to_evdev (virtual_evdev->device,
keycode, &evcode);
clutter_seat_evdev_notify_key (virtual_evdev->seat,
virtual_evdev->device,
time_us,
evcode,
key_state,
TRUE);
meta_seat_native_notify_key (virtual_evdev->seat,
virtual_evdev->device,
time_us,
evcode,
key_state,
TRUE);
}
static void
clutter_virtual_input_device_evdev_notify_keyval (ClutterVirtualInputDevice *virtual_device,
uint64_t time_us,
uint32_t keyval,
ClutterKeyState key_state)
meta_virtual_input_device_native_notify_keyval (ClutterVirtualInputDevice *virtual_device,
uint64_t time_us,
uint32_t keyval,
ClutterKeyState key_state)
{
ClutterVirtualInputDeviceEvdev *virtual_evdev =
CLUTTER_VIRTUAL_INPUT_DEVICE_EVDEV (virtual_device);
MetaVirtualInputDeviceNative *virtual_evdev =
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
int key_count;
guint keycode = 0, level = 0, evcode = 0;
@ -408,12 +403,12 @@ clutter_virtual_input_device_evdev_notify_keyval (ClutterVirtualInputDevice *vir
if (key_state)
apply_level_modifiers (virtual_device, time_us, level, key_state);
clutter_seat_evdev_notify_key (virtual_evdev->seat,
virtual_evdev->device,
time_us,
evcode,
key_state,
TRUE);
meta_seat_native_notify_key (virtual_evdev->seat,
virtual_evdev->device,
time_us,
evcode,
key_state,
TRUE);
if (!key_state)
apply_level_modifiers (virtual_device, time_us, level, key_state);
@ -449,13 +444,13 @@ direction_to_discrete (ClutterScrollDirection direction,
}
static void
clutter_virtual_input_device_evdev_notify_discrete_scroll (ClutterVirtualInputDevice *virtual_device,
uint64_t time_us,
ClutterScrollDirection direction,
ClutterScrollSource scroll_source)
meta_virtual_input_device_native_notify_discrete_scroll (ClutterVirtualInputDevice *virtual_device,
uint64_t time_us,
ClutterScrollDirection direction,
ClutterScrollSource scroll_source)
{
ClutterVirtualInputDeviceEvdev *virtual_evdev =
CLUTTER_VIRTUAL_INPUT_DEVICE_EVDEV (virtual_device);
MetaVirtualInputDeviceNative *virtual_evdev =
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
double discrete_dx = 0.0, discrete_dy = 0.0;
if (time_us == CLUTTER_CURRENT_TIME)
@ -463,139 +458,139 @@ clutter_virtual_input_device_evdev_notify_discrete_scroll (ClutterVirtualInputDe
direction_to_discrete (direction, &discrete_dx, &discrete_dy);
clutter_seat_evdev_notify_discrete_scroll (virtual_evdev->seat,
virtual_evdev->device,
time_us,
discrete_dx, discrete_dy,
scroll_source);
meta_seat_native_notify_discrete_scroll (virtual_evdev->seat,
virtual_evdev->device,
time_us,
discrete_dx, discrete_dy,
scroll_source);
}
static void
clutter_virtual_input_device_evdev_notify_scroll_continuous (ClutterVirtualInputDevice *virtual_device,
uint64_t time_us,
double dx,
double dy,
ClutterScrollSource scroll_source,
ClutterScrollFinishFlags finish_flags)
meta_virtual_input_device_native_notify_scroll_continuous (ClutterVirtualInputDevice *virtual_device,
uint64_t time_us,
double dx,
double dy,
ClutterScrollSource scroll_source,
ClutterScrollFinishFlags finish_flags)
{
ClutterVirtualInputDeviceEvdev *virtual_evdev =
CLUTTER_VIRTUAL_INPUT_DEVICE_EVDEV (virtual_device);
MetaVirtualInputDeviceNative *virtual_evdev =
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
if (time_us == CLUTTER_CURRENT_TIME)
time_us = g_get_monotonic_time ();
clutter_seat_evdev_notify_scroll_continuous (virtual_evdev->seat,
virtual_evdev->device,
time_us,
dx, dy,
scroll_source,
CLUTTER_SCROLL_FINISHED_NONE);
meta_seat_native_notify_scroll_continuous (virtual_evdev->seat,
virtual_evdev->device,
time_us,
dx, dy,
scroll_source,
CLUTTER_SCROLL_FINISHED_NONE);
}
static void
clutter_virtual_input_device_evdev_notify_touch_down (ClutterVirtualInputDevice *virtual_device,
meta_virtual_input_device_native_notify_touch_down (ClutterVirtualInputDevice *virtual_device,
uint64_t time_us,
int device_slot,
double x,
double y)
{
MetaVirtualInputDeviceNative *virtual_evdev =
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
MetaInputDeviceNative *device_evdev =
META_INPUT_DEVICE_NATIVE (virtual_evdev->device);
MetaTouchState *touch_state;
if (time_us == CLUTTER_CURRENT_TIME)
time_us = g_get_monotonic_time ();
touch_state = meta_input_device_native_acquire_touch_state (device_evdev,
device_slot);
if (!touch_state)
return;
touch_state->coords.x = x;
touch_state->coords.y = y;
meta_seat_native_notify_touch_event (virtual_evdev->seat,
virtual_evdev->device,
CLUTTER_TOUCH_BEGIN,
time_us,
touch_state->seat_slot,
touch_state->coords.x,
touch_state->coords.y);
}
static void
meta_virtual_input_device_native_notify_touch_motion (ClutterVirtualInputDevice *virtual_device,
uint64_t time_us,
int device_slot,
double x,
double y)
{
ClutterVirtualInputDeviceEvdev *virtual_evdev =
CLUTTER_VIRTUAL_INPUT_DEVICE_EVDEV (virtual_device);
ClutterInputDeviceEvdev *device_evdev =
CLUTTER_INPUT_DEVICE_EVDEV (virtual_evdev->device);
ClutterTouchState *touch_state;
MetaVirtualInputDeviceNative *virtual_evdev =
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
MetaInputDeviceNative *device_evdev =
META_INPUT_DEVICE_NATIVE (virtual_evdev->device);
MetaTouchState *touch_state;
if (time_us == CLUTTER_CURRENT_TIME)
time_us = g_get_monotonic_time ();
touch_state = clutter_input_device_evdev_acquire_touch_state (device_evdev,
device_slot);
touch_state = meta_input_device_native_lookup_touch_state (device_evdev,
device_slot);
if (!touch_state)
return;
touch_state->coords.x = x;
touch_state->coords.y = y;
clutter_seat_evdev_notify_touch_event (virtual_evdev->seat,
virtual_evdev->device,
CLUTTER_TOUCH_BEGIN,
time_us,
touch_state->seat_slot,
touch_state->coords.x,
touch_state->coords.y);
meta_seat_native_notify_touch_event (virtual_evdev->seat,
virtual_evdev->device,
CLUTTER_TOUCH_BEGIN,
time_us,
touch_state->seat_slot,
touch_state->coords.x,
touch_state->coords.y);
}
static void
clutter_virtual_input_device_evdev_notify_touch_motion (ClutterVirtualInputDevice *virtual_device,
uint64_t time_us,
int device_slot,
double x,
double y)
meta_virtual_input_device_native_notify_touch_up (ClutterVirtualInputDevice *virtual_device,
uint64_t time_us,
int device_slot)
{
ClutterVirtualInputDeviceEvdev *virtual_evdev =
CLUTTER_VIRTUAL_INPUT_DEVICE_EVDEV (virtual_device);
ClutterInputDeviceEvdev *device_evdev =
CLUTTER_INPUT_DEVICE_EVDEV (virtual_evdev->device);
ClutterTouchState *touch_state;
MetaVirtualInputDeviceNative *virtual_evdev =
META_VIRTUAL_INPUT_DEVICE_NATIVE (virtual_device);
MetaInputDeviceNative *device_evdev =
META_INPUT_DEVICE_NATIVE (virtual_evdev->device);
MetaTouchState *touch_state;
if (time_us == CLUTTER_CURRENT_TIME)
time_us = g_get_monotonic_time ();
touch_state = clutter_input_device_evdev_lookup_touch_state (device_evdev,
device_slot);
touch_state = meta_input_device_native_lookup_touch_state (device_evdev,
device_slot);
if (!touch_state)
return;
touch_state->coords.x = x;
touch_state->coords.y = y;
meta_seat_native_notify_touch_event (virtual_evdev->seat,
virtual_evdev->device,
CLUTTER_TOUCH_BEGIN,
time_us,
touch_state->seat_slot,
touch_state->coords.x,
touch_state->coords.y);
clutter_seat_evdev_notify_touch_event (virtual_evdev->seat,
virtual_evdev->device,
CLUTTER_TOUCH_BEGIN,
time_us,
touch_state->seat_slot,
touch_state->coords.x,
touch_state->coords.y);
meta_input_device_native_release_touch_state (device_evdev, touch_state);
}
static void
clutter_virtual_input_device_evdev_notify_touch_up (ClutterVirtualInputDevice *virtual_device,
uint64_t time_us,
int device_slot)
meta_virtual_input_device_native_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
ClutterVirtualInputDeviceEvdev *virtual_evdev =
CLUTTER_VIRTUAL_INPUT_DEVICE_EVDEV (virtual_device);
ClutterInputDeviceEvdev *device_evdev =
CLUTTER_INPUT_DEVICE_EVDEV (virtual_evdev->device);
ClutterTouchState *touch_state;
if (time_us == CLUTTER_CURRENT_TIME)
time_us = g_get_monotonic_time ();
touch_state = clutter_input_device_evdev_lookup_touch_state (device_evdev,
device_slot);
if (!touch_state)
return;
clutter_seat_evdev_notify_touch_event (virtual_evdev->seat,
virtual_evdev->device,
CLUTTER_TOUCH_BEGIN,
time_us,
touch_state->seat_slot,
touch_state->coords.x,
touch_state->coords.y);
clutter_input_device_evdev_release_touch_state (device_evdev, touch_state);
}
static void
clutter_virtual_input_device_evdev_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
ClutterVirtualInputDeviceEvdev *virtual_evdev =
CLUTTER_VIRTUAL_INPUT_DEVICE_EVDEV (object);
MetaVirtualInputDeviceNative *virtual_evdev =
META_VIRTUAL_INPUT_DEVICE_NATIVE (object);
switch (prop_id)
{
@ -609,13 +604,13 @@ clutter_virtual_input_device_evdev_get_property (GObject *object,
}
static void
clutter_virtual_input_device_evdev_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
meta_virtual_input_device_native_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
ClutterVirtualInputDeviceEvdev *virtual_evdev =
CLUTTER_VIRTUAL_INPUT_DEVICE_EVDEV (object);
MetaVirtualInputDeviceNative *virtual_evdev =
META_VIRTUAL_INPUT_DEVICE_NATIVE (object);
switch (prop_id)
{
@ -629,12 +624,12 @@ clutter_virtual_input_device_evdev_set_property (GObject *object,
}
static void
clutter_virtual_input_device_evdev_constructed (GObject *object)
meta_virtual_input_device_native_constructed (GObject *object)
{
ClutterVirtualInputDevice *virtual_device =
CLUTTER_VIRTUAL_INPUT_DEVICE (object);
ClutterVirtualInputDeviceEvdev *virtual_evdev =
CLUTTER_VIRTUAL_INPUT_DEVICE_EVDEV (object);
MetaVirtualInputDeviceNative *virtual_evdev =
META_VIRTUAL_INPUT_DEVICE_NATIVE (object);
ClutterDeviceManager *manager;
ClutterInputDeviceType device_type;
ClutterStage *stage;
@ -643,63 +638,63 @@ clutter_virtual_input_device_evdev_constructed (GObject *object)
device_type = clutter_virtual_input_device_get_device_type (virtual_device);
virtual_evdev->device =
_clutter_input_device_evdev_new_virtual (manager,
virtual_evdev->seat,
device_type,
CLUTTER_INPUT_MODE_SLAVE);
meta_input_device_native_new_virtual (manager,
virtual_evdev->seat,
device_type,
CLUTTER_INPUT_MODE_SLAVE);
stage = _clutter_device_manager_evdev_get_stage (CLUTTER_DEVICE_MANAGER_EVDEV (manager));
stage = meta_device_manager_native_get_stage (META_DEVICE_MANAGER_NATIVE (manager));
_clutter_input_device_set_stage (virtual_evdev->device, stage);
}
static void
clutter_virtual_input_device_evdev_finalize (GObject *object)
meta_virtual_input_device_native_finalize (GObject *object)
{
ClutterVirtualInputDevice *virtual_device =
CLUTTER_VIRTUAL_INPUT_DEVICE (object);
ClutterVirtualInputDeviceEvdev *virtual_evdev =
CLUTTER_VIRTUAL_INPUT_DEVICE_EVDEV (object);
MetaVirtualInputDeviceNative *virtual_evdev =
META_VIRTUAL_INPUT_DEVICE_NATIVE (object);
GObjectClass *object_class;
release_pressed_buttons (virtual_device);
g_clear_object (&virtual_evdev->device);
object_class =
G_OBJECT_CLASS (clutter_virtual_input_device_evdev_parent_class);
G_OBJECT_CLASS (meta_virtual_input_device_native_parent_class);
object_class->finalize (object);
}
static void
clutter_virtual_input_device_evdev_init (ClutterVirtualInputDeviceEvdev *virtual_device_evdev)
meta_virtual_input_device_native_init (MetaVirtualInputDeviceNative *virtual_device_evdev)
{
}
static void
clutter_virtual_input_device_evdev_class_init (ClutterVirtualInputDeviceEvdevClass *klass)
meta_virtual_input_device_native_class_init (MetaVirtualInputDeviceNativeClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
ClutterVirtualInputDeviceClass *virtual_input_device_class =
CLUTTER_VIRTUAL_INPUT_DEVICE_CLASS (klass);
object_class->get_property = clutter_virtual_input_device_evdev_get_property;
object_class->set_property = clutter_virtual_input_device_evdev_set_property;
object_class->constructed = clutter_virtual_input_device_evdev_constructed;
object_class->finalize = clutter_virtual_input_device_evdev_finalize;
object_class->get_property = meta_virtual_input_device_native_get_property;
object_class->set_property = meta_virtual_input_device_native_set_property;
object_class->constructed = meta_virtual_input_device_native_constructed;
object_class->finalize = meta_virtual_input_device_native_finalize;
virtual_input_device_class->notify_relative_motion = clutter_virtual_input_device_evdev_notify_relative_motion;
virtual_input_device_class->notify_absolute_motion = clutter_virtual_input_device_evdev_notify_absolute_motion;
virtual_input_device_class->notify_button = clutter_virtual_input_device_evdev_notify_button;
virtual_input_device_class->notify_key = clutter_virtual_input_device_evdev_notify_key;
virtual_input_device_class->notify_keyval = clutter_virtual_input_device_evdev_notify_keyval;
virtual_input_device_class->notify_discrete_scroll = clutter_virtual_input_device_evdev_notify_discrete_scroll;
virtual_input_device_class->notify_scroll_continuous = clutter_virtual_input_device_evdev_notify_scroll_continuous;
virtual_input_device_class->notify_touch_down = clutter_virtual_input_device_evdev_notify_touch_down;
virtual_input_device_class->notify_touch_motion = clutter_virtual_input_device_evdev_notify_touch_motion;
virtual_input_device_class->notify_touch_up = clutter_virtual_input_device_evdev_notify_touch_up;
virtual_input_device_class->notify_relative_motion = meta_virtual_input_device_native_notify_relative_motion;
virtual_input_device_class->notify_absolute_motion = meta_virtual_input_device_native_notify_absolute_motion;
virtual_input_device_class->notify_button = meta_virtual_input_device_native_notify_button;
virtual_input_device_class->notify_key = meta_virtual_input_device_native_notify_key;
virtual_input_device_class->notify_keyval = meta_virtual_input_device_native_notify_keyval;
virtual_input_device_class->notify_discrete_scroll = meta_virtual_input_device_native_notify_discrete_scroll;
virtual_input_device_class->notify_scroll_continuous = meta_virtual_input_device_native_notify_scroll_continuous;
virtual_input_device_class->notify_touch_down = meta_virtual_input_device_native_notify_touch_down;
virtual_input_device_class->notify_touch_motion = meta_virtual_input_device_native_notify_touch_motion;
virtual_input_device_class->notify_touch_up = meta_virtual_input_device_native_notify_touch_up;
obj_props[PROP_SEAT] = g_param_spec_pointer ("seat",
P_("ClutterSeatEvdev"),
P_("ClutterSeatEvdev"),
P_("Seat"),
P_("Seat"),
CLUTTER_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_properties (object_class, PROP_LAST, obj_props);

View File

@ -1,8 +1,4 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2016 Red Hat Inc.
*
* This library is free software; you can redistribute it and/or
@ -21,15 +17,15 @@
* Author: Jonas Ådahl <jadahl@gmail.com>
*/
#ifndef __CLUTTER_VIRTUAL_INPUT_DEVICE_EVDEV_H__
#define __CLUTTER_VIRTUAL_INPUT_DEVICE_EVDEV_H__
#ifndef META_VIRTUAL_INPUT_DEVICE_NATIVE_H
#define META_VIRTUAL_INPUT_DEVICE_NATIVE_H
#include "clutter-virtual-input-device.h"
#include "clutter/clutter-virtual-input-device.h"
#define CLUTTER_TYPE_VIRTUAL_INPUT_DEVICE_EVDEV (clutter_virtual_input_device_evdev_get_type ())
G_DECLARE_FINAL_TYPE (ClutterVirtualInputDeviceEvdev,
clutter_virtual_input_device_evdev,
CLUTTER, VIRTUAL_INPUT_DEVICE_EVDEV,
#define META_TYPE_VIRTUAL_INPUT_DEVICE_NATIVE (meta_virtual_input_device_native_get_type ())
G_DECLARE_FINAL_TYPE (MetaVirtualInputDeviceNative,
meta_virtual_input_device_native,
META, VIRTUAL_INPUT_DEVICE_NATIVE,
ClutterVirtualInputDevice)
#endif /* __CLUTTER_VIRTUAL_INPUT_DEVICE_EVDEV_H__ */
#endif /* META_VIRTUAL_INPUT_DEVICE_NATIVE_H */

View File

@ -1,8 +1,4 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2010 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
@ -23,11 +19,11 @@
* Damien Lespiau <damien.lespiau@intel.com>
*/
#include "clutter-build-config.h"
#include "config.h"
#include "clutter-keysyms.h"
#include "clutter-event-private.h"
#include "clutter-xkb-utils.h"
#include "backends/native/meta-xkb-utils.h"
#include "clutter/clutter-keysyms.h"
#include "clutter/clutter-mutter.h"
/*
* _clutter_event_new_from_evdev: Create a new Clutter ClutterKeyEvent
@ -44,14 +40,14 @@
* Return value: the new #ClutterEvent
*/
ClutterEvent *
_clutter_key_event_new_from_evdev (ClutterInputDevice *device,
ClutterInputDevice *core_device,
ClutterStage *stage,
struct xkb_state *xkb_state,
uint32_t button_state,
uint32_t _time,
xkb_keycode_t key,
uint32_t state)
meta_key_event_new_from_evdev (ClutterInputDevice *device,
ClutterInputDevice *core_device,
ClutterStage *stage,
struct xkb_state *xkb_state,
uint32_t button_state,
uint32_t _time,
xkb_keycode_t key,
uint32_t state)
{
ClutterEvent *event;
xkb_keysym_t sym;
@ -78,7 +74,7 @@ _clutter_key_event_new_from_evdev (ClutterInputDevice *device,
event->key.stage = stage;
event->key.time = _time;
_clutter_xkb_translate_state (event, xkb_state, button_state);
meta_xkb_translate_state (event, xkb_state, button_state);
event->key.hardware_keycode = key;
event->key.keyval = sym;
clutter_event_set_device (event, core_device);
@ -102,9 +98,9 @@ _clutter_key_event_new_from_evdev (ClutterInputDevice *device,
}
void
_clutter_xkb_translate_state (ClutterEvent *event,
struct xkb_state *state,
uint32_t button_state)
meta_xkb_translate_state (ClutterEvent *event,
struct xkb_state *state,
uint32_t button_state)
{
_clutter_event_set_state_full (event,
button_state,

View File

@ -0,0 +1,40 @@
/*
* Copyright (C) 2010 Intel Corporation.
*
* 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/>.
* Authors:
* Damien Lespiau <damien.lespiau@intel.com>
*/
#ifndef META_XKB_UTILS_H
#define META_XKB_UTILS_H
#include <xkbcommon/xkbcommon.h>
#include "clutter/clutter.h"
ClutterEvent * meta_key_event_new_from_evdev (ClutterInputDevice *device,
ClutterInputDevice *core_keyboard,
ClutterStage *stage,
struct xkb_state *xkb_state,
uint32_t button_state,
uint32_t _time,
uint32_t key,
uint32_t state);
void meta_xkb_translate_state (ClutterEvent *event,
struct xkb_state *xkb_state,
uint32_t button_state);
#endif /* META_XKB_UTILS_H */

View File

@ -125,6 +125,8 @@ if have_native_backend
gudev_dep,
libgbm_dep,
logind_provider_dep,
libudev_dep,
xkbcommon_dep,
]
endif
@ -599,16 +601,26 @@ if have_native_backend
'backends/native/meta-crtc-kms.h',
'backends/native/meta-cursor-renderer-native.c',
'backends/native/meta-cursor-renderer-native.h',
'backends/native/meta-device-manager-native.c',
'backends/native/meta-device-manager-native.h',
'backends/native/meta-drm-buffer-dumb.c',
'backends/native/meta-drm-buffer-dumb.h',
'backends/native/meta-drm-buffer-gbm.c',
'backends/native/meta-drm-buffer-gbm.h',
'backends/native/meta-drm-buffer.c',
'backends/native/meta-drm-buffer.h',
'backends/native/meta-event-native.c',
'backends/native/meta-event-native.h',
'backends/native/meta-gpu-kms.c',
'backends/native/meta-gpu-kms.h',
'backends/native/meta-input-device-native.c',
'backends/native/meta-input-device-native.h',
'backends/native/meta-input-device-tool-native.c',
'backends/native/meta-input-device-tool-native.h',
'backends/native/meta-input-settings-native.c',
'backends/native/meta-input-settings-native.h',
'backends/native/meta-keymap-native.c',
'backends/native/meta-keymap-native.h',
'backends/native/meta-launcher.c',
'backends/native/meta-launcher.h',
'backends/native/meta-monitor-manager-kms.c',
@ -647,10 +659,16 @@ if have_native_backend
'backends/native/meta-renderer-native-gles3.c',
'backends/native/meta-renderer-native-gles3.h',
'backends/native/meta-renderer-native.h',
'backends/native/meta-seat-native.c',
'backends/native/meta-seat-native.h',
'backends/native/meta-stage-native.c',
'backends/native/meta-stage-native.h',
'backends/native/meta-udev.c',
'backends/native/meta-udev.h',
'backends/native/meta-virtual-input-device-native.c',
'backends/native/meta-virtual-input-device-native.h',
'backends/native/meta-xkb-utils.c',
'backends/native/meta-xkb-utils.h',
]
endif

View File

@ -56,12 +56,12 @@
#include <unistd.h>
#include "backends/meta-backend-private.h"
#include "clutter/evdev/clutter-evdev.h"
#include "core/display-private.h"
#include "wayland/meta-wayland-private.h"
#ifdef HAVE_NATIVE_BACKEND
#include "backends/native/meta-backend-native.h"
#include "backends/native/meta-event-native.h"
#endif
#define GSD_KEYBOARD_SCHEMA "org.gnome.settings-daemon.peripherals.keyboard"
@ -531,7 +531,7 @@ default_grab_key (MetaWaylandKeyboardGrab *grab,
#ifdef HAVE_NATIVE_BACKEND
if (META_IS_BACKEND_NATIVE (backend))
code = clutter_evdev_event_get_event_code (event);
code = meta_event_native_get_event_code (event);
if (code == 0)
#endif
code = evdev_code (&event->key);

View File

@ -51,7 +51,6 @@
#include "backends/meta-cursor-tracker-private.h"
#include "backends/meta-cursor.h"
#include "clutter/clutter.h"
#include "clutter/evdev/clutter-evdev.h"
#include "cogl/cogl-wayland-server.h"
#include "cogl/cogl.h"
#include "compositor/meta-surface-actor-wayland.h"
@ -67,6 +66,7 @@
#ifdef HAVE_NATIVE_BACKEND
#include "backends/native/meta-backend-native.h"
#include "backends/native/meta-event-native.h"
#endif
#include "relative-pointer-unstable-v1-server-protocol.h"
@ -302,7 +302,7 @@ meta_wayland_pointer_send_relative_motion (MetaWaylandPointer *pointer,
return;
#ifdef HAVE_NATIVE_BACKEND
time_us = clutter_evdev_event_get_time_usec (event);
time_us = meta_event_native_get_time_usec (event);
if (time_us == 0)
#endif
time_us = clutter_event_get_time (event) * 1000ULL;
@ -376,7 +376,7 @@ meta_wayland_pointer_send_button (MetaWaylandPointer *pointer,
#ifdef HAVE_NATIVE_BACKEND
MetaBackend *backend = meta_get_backend ();
if (META_IS_BACKEND_NATIVE (backend))
button = clutter_evdev_event_get_event_code (event);
button = meta_event_native_get_event_code (event);
else
#endif
{

View File

@ -34,7 +34,8 @@
#ifdef HAVE_NATIVE_BACKEND
#include "backends/native/meta-backend-native.h"
#include "clutter/evdev/clutter-evdev.h"
#include "backends/native/meta-event-native.h"
#include "backends/native/meta-input-device-native.h"
#endif
#include "tablet-unstable-v2-server-protocol.h"
@ -131,7 +132,7 @@ meta_wayland_tablet_pad_group_has_button (MetaWaylandTabletPadGroup *group,
struct libinput_tablet_pad_mode_group *mode_group;
guint n_group;
libinput_device = clutter_evdev_input_device_get_libinput_device (group->pad->device);
libinput_device = meta_input_device_native_get_libinput_device (group->pad->device);
n_group = g_list_index (group->pad->groups, group);
mode_group = libinput_device_tablet_pad_get_mode_group (libinput_device, n_group);

View File

@ -38,8 +38,9 @@
#include "wayland/meta-wayland-tablet.h"
#ifdef HAVE_NATIVE_BACKEND
#include <libinput.h>
#include "backends/native/meta-backend-native.h"
#include "clutter/evdev/clutter-evdev.h"
#include "backends/native/meta-input-device-native.h"
#endif
#include "tablet-unstable-v2-server-protocol.h"
@ -69,7 +70,7 @@ group_rings_strips (MetaWaylandTabletPad *pad)
struct libinput_device *libinput_device = NULL;
if (META_IS_BACKEND_NATIVE (backend))
libinput_device = clutter_evdev_input_device_get_libinput_device (pad->device);
libinput_device = meta_input_device_native_get_libinput_device (pad->device);
#endif
for (n_group = 0, g = pad->groups; g; g = g->next)
@ -153,7 +154,7 @@ meta_wayland_tablet_pad_new (ClutterInputDevice *device,
{
struct libinput_device *libinput_device;
libinput_device = clutter_evdev_input_device_get_libinput_device (device);
libinput_device = meta_input_device_native_get_libinput_device (device);
pad->n_buttons = libinput_device_tablet_pad_get_num_buttons (libinput_device);
}
#endif

View File

@ -34,7 +34,6 @@
#ifdef HAVE_NATIVE_BACKEND
#include "backends/native/meta-backend-native.h"
#include "clutter/evdev/clutter-evdev.h"
#endif
#include "tablet-unstable-v2-server-protocol.h"

View File

@ -28,7 +28,6 @@
#include <glib.h>
#include <wayland-server.h>
#include "clutter/evdev/clutter-evdev.h"
#include "wayland/meta-wayland-private.h"
#include "wayland/meta-wayland-tablet-cursor-surface.h"
#include "compositor/meta-surface-actor-wayland.h"
@ -41,6 +40,7 @@
#include <linux/input-event-codes.h>
#include "backends/native/meta-backend-native.h"
#include "backends/native/meta-event-native.h"
#endif
#include "tablet-unstable-v2-server-protocol.h"
@ -720,7 +720,7 @@ broadcast_button (MetaWaylandTabletTool *tool,
MetaBackend *backend = meta_get_backend ();
if (META_IS_BACKEND_NATIVE (backend))
{
button = clutter_evdev_event_get_event_code (event);
button = meta_event_native_get_event_code (event);
}
else
#endif

View File

@ -27,11 +27,13 @@
#include <string.h>
#include "compositor/meta-surface-actor-wayland.h"
#include "clutter/evdev/clutter-evdev.h"
#include "wayland/meta-wayland-private.h"
#ifdef HAVE_NATIVE_BACKEND
#include <libinput.h>
#include "backends/native/meta-backend-native.h"
#include "backends/native/meta-device-manager-native.h"
#include "backends/native/meta-event-native.h"
#endif
G_DEFINE_TYPE (MetaWaylandTouch, meta_wayland_touch,
@ -186,7 +188,7 @@ touch_get_info (MetaWaylandTouch *touch,
if (!touch_info && create)
{
touch_info = g_new0 (MetaWaylandTouchInfo, 1);
touch_info->slot = clutter_evdev_event_sequence_get_slot (sequence);
touch_info->slot = meta_event_native_sequence_get_slot (sequence);
g_hash_table_insert (touch->touches, sequence, touch_info);
}
@ -412,7 +414,7 @@ check_send_frame_event (MetaWaylandTouch *touch,
if (META_IS_BACKEND_NATIVE (backend))
{
sequence = clutter_event_get_event_sequence (event);
slot = clutter_evdev_event_sequence_get_slot (sequence);
slot = meta_event_native_sequence_get_slot (sequence);
touch->frame_slots &= ~(1 << slot);
if (touch->frame_slots == 0)
@ -568,7 +570,7 @@ meta_wayland_touch_enable (MetaWaylandTouch *touch)
#ifdef HAVE_NATIVE_BACKEND
MetaBackend *backend = meta_get_backend ();
if (META_IS_BACKEND_NATIVE (backend))
clutter_evdev_add_filter (evdev_filter_func, touch, NULL);
meta_device_manager_native_add_filter (evdev_filter_func, touch, NULL);
#endif
}
@ -578,7 +580,7 @@ meta_wayland_touch_disable (MetaWaylandTouch *touch)
#ifdef HAVE_NATIVE_BACKEND
MetaBackend *backend = meta_get_backend ();
if (META_IS_BACKEND_NATIVE (backend))
clutter_evdev_remove_filter (evdev_filter_func, touch);
meta_device_manager_native_remove_filter (evdev_filter_func, touch);
#endif
meta_wayland_touch_cancel (touch);