native: Implement ClutterSeat
We had the MetaSeatNative struct around, so use it as the base of this Clutter object. A few responsibilities were drawn from ClutterDeviceManager. https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
This commit is contained in:
parent
1611979fa8
commit
5bb3d86884
13 changed files with 2435 additions and 2525 deletions
|
@ -58,6 +58,7 @@
|
|||
#include "backends/native/meta-launcher.h"
|
||||
#include "backends/native/meta-monitor-manager-kms.h"
|
||||
#include "backends/native/meta-renderer-native.h"
|
||||
#include "backends/native/meta-seat-native.h"
|
||||
#include "backends/native/meta-stage-native.h"
|
||||
#include "cogl/cogl-trace.h"
|
||||
#include "core/meta-border.h"
|
||||
|
@ -340,15 +341,18 @@ meta_backend_native_create_clutter_backend (MetaBackend *backend)
|
|||
static void
|
||||
meta_backend_native_post_init (MetaBackend *backend)
|
||||
{
|
||||
ClutterDeviceManager *manager = clutter_device_manager_get_default ();
|
||||
ClutterBackend *clutter_backend = clutter_get_default_backend ();
|
||||
ClutterSeat *seat = clutter_backend_get_default_seat (clutter_backend);
|
||||
MetaSettings *settings = meta_backend_get_settings (backend);
|
||||
|
||||
META_BACKEND_CLASS (meta_backend_native_parent_class)->post_init (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));
|
||||
meta_seat_native_set_pointer_constrain_callback (META_SEAT_NATIVE (seat),
|
||||
pointer_constrain_callback,
|
||||
NULL, NULL);
|
||||
meta_seat_native_set_relative_motion_filter (META_SEAT_NATIVE (seat),
|
||||
relative_motion_filter,
|
||||
meta_backend_get_monitor_manager (backend));
|
||||
|
||||
if (meta_settings_is_experimental_feature_enabled (settings,
|
||||
META_EXPERIMENTAL_FEATURE_RT_SCHEDULER))
|
||||
|
@ -413,7 +417,7 @@ meta_backend_native_warp_pointer (MetaBackend *backend,
|
|||
guint32 time_ = 0;
|
||||
|
||||
/* Warp the input device pointer state. */
|
||||
meta_device_manager_native_warp_pointer (device, time_, x, y);
|
||||
meta_seat_native_warp_pointer (device, time_, x, y);
|
||||
|
||||
/* Warp displayed pointer cursor. */
|
||||
meta_cursor_tracker_update_position (cursor_tracker, x, y);
|
||||
|
@ -796,11 +800,14 @@ meta_backend_native_pause (MetaBackendNative *native)
|
|||
meta_backend_get_monitor_manager (backend);
|
||||
MetaMonitorManagerKms *monitor_manager_kms =
|
||||
META_MONITOR_MANAGER_KMS (monitor_manager);
|
||||
ClutterBackend *clutter_backend = clutter_get_default_backend ();
|
||||
MetaSeatNative *seat =
|
||||
META_SEAT_NATIVE (clutter_backend_get_default_seat (clutter_backend));
|
||||
|
||||
COGL_TRACE_BEGIN_SCOPED (MetaBackendNativePause,
|
||||
"Backend (pause)");
|
||||
|
||||
meta_device_manager_native_release_devices ();
|
||||
meta_seat_native_release_devices (seat);
|
||||
clutter_stage_freeze_updates (stage);
|
||||
|
||||
disconnect_udev_device_added_handler (native);
|
||||
|
@ -819,6 +826,9 @@ void meta_backend_native_resume (MetaBackendNative *native)
|
|||
MetaInputSettings *input_settings;
|
||||
MetaIdleMonitor *idle_monitor;
|
||||
ClutterDeviceManager *device_manager;
|
||||
ClutterBackend *clutter_backend = clutter_get_default_backend ();
|
||||
MetaSeatNative *seat =
|
||||
META_SEAT_NATIVE (clutter_backend_get_default_seat (clutter_backend));
|
||||
|
||||
COGL_TRACE_BEGIN_SCOPED (MetaBackendNativeResume,
|
||||
"Backend (resume)");
|
||||
|
@ -827,7 +837,7 @@ void meta_backend_native_resume (MetaBackendNative *native)
|
|||
|
||||
connect_udev_device_added_handler (native);
|
||||
|
||||
meta_device_manager_native_reclaim_devices ();
|
||||
meta_seat_native_reclaim_devices (seat);
|
||||
clutter_stage_thaw_updates (stage);
|
||||
|
||||
clutter_actor_queue_redraw (CLUTTER_ACTOR (stage));
|
||||
|
|
|
@ -47,4 +47,6 @@ MetaUdev * meta_backend_native_get_udev (MetaBackendNative *native);
|
|||
|
||||
MetaKms * meta_backend_native_get_kms (MetaBackendNative *native);
|
||||
|
||||
void meta_backend_native_set_seat_id (const gchar *seat_id);
|
||||
|
||||
#endif /* META_BACKEND_NATIVE_H */
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include "backends/meta-renderer.h"
|
||||
#include "backends/native/meta-device-manager-native.h"
|
||||
#include "backends/native/meta-keymap-native.h"
|
||||
#include "backends/native/meta-seat-native.h"
|
||||
#include "backends/native/meta-stage-native.h"
|
||||
#include "clutter/clutter.h"
|
||||
#include "core/bell.h"
|
||||
|
@ -55,11 +56,14 @@ struct _MetaClutterBackendNative
|
|||
{
|
||||
ClutterBackendEglNative parent;
|
||||
|
||||
MetaSeatNative *main_seat;
|
||||
MetaStageNative *stage_native;
|
||||
MetaKeymapNative *keymap;
|
||||
MetaDeviceManagerNative *device_manager;
|
||||
};
|
||||
|
||||
static gchar *evdev_seat_id;
|
||||
|
||||
G_DEFINE_TYPE (MetaClutterBackendNative, meta_clutter_backend_native,
|
||||
CLUTTER_TYPE_BACKEND_EGL_NATIVE)
|
||||
|
||||
|
@ -127,11 +131,23 @@ static void
|
|||
meta_clutter_backend_native_init_events (ClutterBackend *backend)
|
||||
{
|
||||
MetaClutterBackendNative *backend_native = META_CLUTTER_BACKEND_NATIVE (backend);
|
||||
const gchar *seat_id = evdev_seat_id ? evdev_seat_id : "seat0";
|
||||
|
||||
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);
|
||||
backend_native->main_seat = g_object_new (META_TYPE_SEAT_NATIVE,
|
||||
"backend", backend,
|
||||
"seat-id", seat_id,
|
||||
NULL);
|
||||
backend_native->device_manager =
|
||||
meta_device_manager_native_new (backend, backend_native->main_seat);
|
||||
}
|
||||
|
||||
static ClutterSeat *
|
||||
meta_clutter_backend_native_get_default_seat (ClutterBackend *backend)
|
||||
{
|
||||
MetaClutterBackendNative *backend_native = META_CLUTTER_BACKEND_NATIVE (backend);
|
||||
|
||||
return CLUTTER_SEAT (backend_native->main_seat);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -150,4 +166,20 @@ meta_clutter_backend_native_class_init (MetaClutterBackendNativeClass *klass)
|
|||
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;
|
||||
clutter_backend_class->get_default_seat = meta_clutter_backend_native_get_default_seat;
|
||||
}
|
||||
|
||||
/**
|
||||
* meta_cluter_backend_native_set_seat_id:
|
||||
* @seat_id: The seat ID
|
||||
*
|
||||
* Sets the seat to assign to the libinput context.
|
||||
*
|
||||
* For reliable effects, this function must be called before clutter_init().
|
||||
*/
|
||||
void
|
||||
meta_clutter_backend_native_set_seat_id (const gchar *seat_id)
|
||||
{
|
||||
g_free (evdev_seat_id);
|
||||
evdev_seat_id = g_strdup (seat_id);
|
||||
}
|
||||
|
|
|
@ -38,4 +38,6 @@ G_DECLARE_FINAL_TYPE (MetaClutterBackendNative, meta_clutter_backend_native,
|
|||
|
||||
MetaStageNative * meta_clutter_backend_native_get_stage_native (ClutterBackend *backend);
|
||||
|
||||
void meta_clutter_backend_native_set_seat_id (const gchar *seat_id);
|
||||
|
||||
#endif /* META_CLUTTER_BACKEND_NATIVE_H */
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -23,6 +23,7 @@
|
|||
#include <libinput.h>
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
|
||||
#include "backends/native/meta-seat-native.h"
|
||||
#include "clutter/clutter-mutter.h"
|
||||
|
||||
#define META_TYPE_DEVICE_MANAGER_NATIVE (meta_device_manager_native_get_type ())
|
||||
|
@ -50,115 +51,11 @@ struct _MetaDeviceManagerNativeClass
|
|||
|
||||
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);
|
||||
MetaDeviceManagerNative * meta_device_manager_native_new (ClutterBackend *backend,
|
||||
MetaSeatNative *seat);
|
||||
|
||||
struct xkb_state * meta_device_manager_native_get_xkb_state (MetaDeviceManagerNative *manager_evdev);
|
||||
|
||||
static inline uint64_t
|
||||
us (uint64_t us)
|
||||
{
|
||||
return us;
|
||||
}
|
||||
|
||||
static inline uint64_t
|
||||
ms2us (uint64_t ms)
|
||||
{
|
||||
return us (ms * 1000);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
us2ms (uint64_t us)
|
||||
{
|
||||
return (uint32_t) (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,
|
||||
uint32_t 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);
|
||||
|
||||
|
@ -177,18 +74,4 @@ void meta_device_manager_native_set_keyboard_repeat (ClutterDeviceManager *evdev
|
|||
uint32_t delay,
|
||||
uint32_t 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,
|
||||
uint32_t time_,
|
||||
int x,
|
||||
int y);
|
||||
|
||||
#endif /* META_DEVICE_MANAGER_NATIVE_H */
|
||||
|
|
|
@ -62,8 +62,8 @@ meta_input_device_native_finalize (GObject *object)
|
|||
{
|
||||
ClutterInputDevice *device = CLUTTER_INPUT_DEVICE (object);
|
||||
MetaInputDeviceNative *device_evdev = META_INPUT_DEVICE_NATIVE (object);
|
||||
MetaDeviceManagerNative *manager_evdev =
|
||||
META_DEVICE_MANAGER_NATIVE (device->device_manager);
|
||||
ClutterBackend *backend;
|
||||
ClutterSeat *seat;
|
||||
|
||||
if (device_evdev->libinput_device)
|
||||
libinput_device_unref (device_evdev->libinput_device);
|
||||
|
@ -71,7 +71,9 @@ meta_input_device_native_finalize (GObject *object)
|
|||
meta_input_device_native_release_touch_slots (device_evdev,
|
||||
g_get_monotonic_time ());
|
||||
|
||||
meta_device_manager_native_release_device_id (manager_evdev, device);
|
||||
backend = clutter_get_default_backend ();
|
||||
seat = clutter_backend_get_default_seat (backend);
|
||||
meta_seat_native_release_device_id (META_SEAT_NATIVE (seat), device);
|
||||
|
||||
clear_slow_keys (device_evdev);
|
||||
stop_bounce_keys (device_evdev);
|
||||
|
@ -1320,13 +1322,11 @@ meta_input_device_native_init (MetaInputDeviceNative *self)
|
|||
* it with the provided seat.
|
||||
*/
|
||||
ClutterInputDevice *
|
||||
meta_input_device_native_new (ClutterDeviceManager *manager,
|
||||
MetaSeatNative *seat,
|
||||
meta_input_device_native_new (MetaSeatNative *seat,
|
||||
struct libinput_device *libinput_device)
|
||||
{
|
||||
MetaInputDeviceNative *device;
|
||||
ClutterInputDeviceType type;
|
||||
MetaDeviceManagerNative *manager_evdev;
|
||||
char *vendor, *product;
|
||||
int device_id, n_rings = 0, n_strips = 0, n_groups = 1;
|
||||
char *node_path;
|
||||
|
@ -1335,8 +1335,7 @@ meta_input_device_native_new (ClutterDeviceManager *manager,
|
|||
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 = META_DEVICE_MANAGER_NATIVE (manager);
|
||||
device_id = meta_device_manager_native_acquire_device_id (manager_evdev);
|
||||
device_id = meta_seat_native_acquire_device_id (seat);
|
||||
node_path = g_strdup_printf ("/dev/input/%s", libinput_device_get_sysname (libinput_device));
|
||||
|
||||
if (libinput_device_has_capability (libinput_device,
|
||||
|
@ -1350,7 +1349,6 @@ meta_input_device_native_new (ClutterDeviceManager *manager,
|
|||
device = g_object_new (META_TYPE_INPUT_DEVICE_NATIVE,
|
||||
"id", device_id,
|
||||
"name", libinput_device_get_name (libinput_device),
|
||||
"device-manager", manager,
|
||||
"device-type", type,
|
||||
"device-mode", CLUTTER_INPUT_MODE_SLAVE,
|
||||
"enabled", TRUE,
|
||||
|
@ -1360,6 +1358,7 @@ meta_input_device_native_new (ClutterDeviceManager *manager,
|
|||
"n-strips", n_strips,
|
||||
"n-mode-groups", n_groups,
|
||||
"device-node", node_path,
|
||||
"seat", seat,
|
||||
NULL);
|
||||
|
||||
device->seat = seat;
|
||||
|
@ -1379,20 +1378,17 @@ meta_input_device_native_new (ClutterDeviceManager *manager,
|
|||
|
||||
/*
|
||||
* meta_input_device_native_new_virtual:
|
||||
* @manager: the device manager
|
||||
* @seat: the seat the device will belong to
|
||||
* @type: the input device type
|
||||
*
|
||||
* Create a new virtual ClutterInputDevice of the given type.
|
||||
*/
|
||||
ClutterInputDevice *
|
||||
meta_input_device_native_new_virtual (ClutterDeviceManager *manager,
|
||||
MetaSeatNative *seat,
|
||||
meta_input_device_native_new_virtual (MetaSeatNative *seat,
|
||||
ClutterInputDeviceType type,
|
||||
ClutterInputMode mode)
|
||||
{
|
||||
MetaInputDeviceNative *device;
|
||||
MetaDeviceManagerNative *manager_evdev;
|
||||
const char *name;
|
||||
int device_id;
|
||||
|
||||
|
@ -1412,15 +1408,14 @@ meta_input_device_native_new_virtual (ClutterDeviceManager *manager,
|
|||
break;
|
||||
};
|
||||
|
||||
manager_evdev = META_DEVICE_MANAGER_NATIVE (manager);
|
||||
device_id = meta_device_manager_native_acquire_device_id (manager_evdev);
|
||||
device_id = meta_seat_native_acquire_device_id (seat);
|
||||
device = g_object_new (META_TYPE_INPUT_DEVICE_NATIVE,
|
||||
"id", device_id,
|
||||
"name", name,
|
||||
"device-manager", manager,
|
||||
"device-type", type,
|
||||
"device-mode", mode,
|
||||
"enabled", TRUE,
|
||||
"seat", seat,
|
||||
NULL);
|
||||
|
||||
device->seat = seat;
|
||||
|
|
|
@ -101,12 +101,10 @@ struct _MetaInputDeviceNativeClass
|
|||
|
||||
GType meta_input_device_native_get_type (void) G_GNUC_CONST;
|
||||
|
||||
ClutterInputDevice * meta_input_device_native_new (ClutterDeviceManager *manager,
|
||||
MetaSeatNative *seat,
|
||||
ClutterInputDevice * meta_input_device_native_new (MetaSeatNative *seat,
|
||||
struct libinput_device *libinput_device);
|
||||
|
||||
ClutterInputDevice * meta_input_device_native_new_virtual (ClutterDeviceManager *manager,
|
||||
MetaSeatNative *seat,
|
||||
ClutterInputDevice * meta_input_device_native_new_virtual (MetaSeatNative *seat,
|
||||
ClutterInputDeviceType type,
|
||||
ClutterInputMode mode);
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "backends/meta-backend-private.h"
|
||||
#include "backends/native/dbus-utils.h"
|
||||
#include "backends/native/meta-backend-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-renderer-native.h"
|
||||
|
@ -525,11 +526,11 @@ meta_launcher_new (GError **error)
|
|||
self->sysfs_fds = g_hash_table_new (NULL, NULL);
|
||||
self->session_active = TRUE;
|
||||
|
||||
meta_device_manager_native_set_seat_id (self->seat_id);
|
||||
meta_clutter_backend_native_set_seat_id (self->seat_id);
|
||||
|
||||
meta_device_manager_native_set_device_callbacks (on_evdev_device_open,
|
||||
on_evdev_device_close,
|
||||
self);
|
||||
meta_seat_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);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -26,12 +26,42 @@
|
|||
#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;
|
||||
typedef struct _MetaEventSource MetaEventSource;
|
||||
|
||||
/**
|
||||
* 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,
|
||||
uint32_t time,
|
||||
float prev_x,
|
||||
float prev_y,
|
||||
float *x,
|
||||
float *y,
|
||||
gpointer user_data);
|
||||
typedef void (* MetaRelativeMotionFilter) (ClutterInputDevice *device,
|
||||
float x,
|
||||
float y,
|
||||
float *dx,
|
||||
float *dy,
|
||||
gpointer user_data);
|
||||
|
||||
struct _MetaTouchState
|
||||
{
|
||||
|
@ -44,8 +74,12 @@ struct _MetaTouchState
|
|||
|
||||
struct _MetaSeatNative
|
||||
{
|
||||
ClutterSeat parent_instance;
|
||||
|
||||
char *seat_id;
|
||||
MetaEventSource *event_source;
|
||||
struct libinput *libinput;
|
||||
struct libinput_seat *libinput_seat;
|
||||
MetaDeviceManagerNative *manager_evdev;
|
||||
|
||||
GSList *devices;
|
||||
|
||||
|
@ -63,6 +97,23 @@ struct _MetaSeatNative
|
|||
uint32_t button_state;
|
||||
int button_count[KEY_CNT];
|
||||
|
||||
ClutterStage *stage;
|
||||
ClutterStageManager *stage_manager;
|
||||
gulong stage_added_handler;
|
||||
gulong stage_removed_handler;
|
||||
|
||||
int device_id_next;
|
||||
GList *free_device_ids;
|
||||
|
||||
MetaPointerConstrainCallback constrain_callback;
|
||||
gpointer constrain_data;
|
||||
GDestroyNotify constrain_data_notify;
|
||||
|
||||
MetaRelativeMotionFilter relative_motion_filter;
|
||||
gpointer relative_motion_filter_user_data;
|
||||
|
||||
GSList *event_filters;
|
||||
|
||||
/* keyboard repeat */
|
||||
gboolean repeat;
|
||||
uint32_t repeat_delay;
|
||||
|
@ -78,8 +129,32 @@ struct _MetaSeatNative
|
|||
/* Emulation of discrete scroll events out of smooth ones */
|
||||
float accum_scroll_dx;
|
||||
float accum_scroll_dy;
|
||||
|
||||
gboolean released;
|
||||
};
|
||||
|
||||
#define META_TYPE_SEAT_NATIVE meta_seat_native_get_type ()
|
||||
G_DECLARE_FINAL_TYPE (MetaSeatNative, meta_seat_native,
|
||||
META, SEAT_NATIVE, ClutterSeat)
|
||||
|
||||
static inline uint64_t
|
||||
us (uint64_t us)
|
||||
{
|
||||
return us;
|
||||
}
|
||||
|
||||
static inline uint64_t
|
||||
ms2us (uint64_t ms)
|
||||
{
|
||||
return us (ms * 1000);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
us2ms (uint64_t us)
|
||||
{
|
||||
return (uint32_t) (us / 1000);
|
||||
}
|
||||
|
||||
void meta_seat_native_notify_key (MetaSeatNative *seat,
|
||||
ClutterInputDevice *device,
|
||||
uint64_t time_us,
|
||||
|
@ -145,16 +220,81 @@ MetaTouchState * meta_seat_native_acquire_touch_state (MetaSeatNative *seat,
|
|||
void meta_seat_native_release_touch_state (MetaSeatNative *seat,
|
||||
MetaTouchState *touch_state);
|
||||
|
||||
MetaTouchState * meta_seat_native_get_touch (MetaSeatNative *seat,
|
||||
uint32_t id);
|
||||
|
||||
void meta_seat_native_set_stage (MetaSeatNative *seat,
|
||||
ClutterStage *stage);
|
||||
ClutterStage * meta_seat_native_get_stage (MetaSeatNative *seat);
|
||||
|
||||
void meta_seat_native_clear_repeat_timer (MetaSeatNative *seat);
|
||||
|
||||
MetaSeatNative * meta_seat_native_new (MetaDeviceManagerNative *manager_evdev);
|
||||
gint meta_seat_native_acquire_device_id (MetaSeatNative *seat);
|
||||
void meta_seat_native_release_device_id (MetaSeatNative *seat,
|
||||
ClutterInputDevice *device);
|
||||
|
||||
void meta_seat_native_free (MetaSeatNative *seat);
|
||||
void meta_seat_native_update_xkb_state (MetaSeatNative *seat);
|
||||
|
||||
void meta_seat_native_constrain_pointer (MetaSeatNative *seat,
|
||||
ClutterInputDevice *core_pointer,
|
||||
uint64_t time_us,
|
||||
float x,
|
||||
float y,
|
||||
float *new_x,
|
||||
float *new_y);
|
||||
|
||||
void meta_seat_native_filter_relative_motion (MetaSeatNative *seat,
|
||||
ClutterInputDevice *device,
|
||||
float x,
|
||||
float y,
|
||||
float *dx,
|
||||
float *dy);
|
||||
|
||||
void meta_seat_native_dispatch (MetaSeatNative *seat);
|
||||
|
||||
/**
|
||||
* 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_seat_native_set_device_callbacks (MetaOpenDeviceCallback open_callback,
|
||||
MetaCloseDeviceCallback close_callback,
|
||||
gpointer user_data);
|
||||
|
||||
void meta_seat_native_release_devices (MetaSeatNative *seat);
|
||||
void meta_seat_native_reclaim_devices (MetaSeatNative *seat);
|
||||
|
||||
void meta_seat_native_set_pointer_constrain_callback (MetaSeatNative *seat,
|
||||
MetaPointerConstrainCallback callback,
|
||||
gpointer user_data,
|
||||
GDestroyNotify user_data_notify);
|
||||
|
||||
void meta_seat_native_set_relative_motion_filter (MetaSeatNative *seat,
|
||||
MetaRelativeMotionFilter filter,
|
||||
gpointer user_data);
|
||||
|
||||
typedef gboolean (* MetaEvdevFilterFunc) (struct libinput_event *event,
|
||||
gpointer data);
|
||||
|
||||
void meta_seat_native_add_filter (MetaSeatNative *seat,
|
||||
MetaEvdevFilterFunc func,
|
||||
gpointer data,
|
||||
GDestroyNotify destroy_notify);
|
||||
void meta_seat_native_remove_filter (MetaSeatNative *seat,
|
||||
MetaEvdevFilterFunc func,
|
||||
gpointer data);
|
||||
|
||||
void meta_seat_native_warp_pointer (ClutterInputDevice *pointer_device,
|
||||
uint32_t time_,
|
||||
int x,
|
||||
int y);
|
||||
|
||||
#endif /* META_SEAT_NATIVE_H */
|
||||
|
|
|
@ -630,20 +630,17 @@ meta_virtual_input_device_native_constructed (GObject *object)
|
|||
CLUTTER_VIRTUAL_INPUT_DEVICE (object);
|
||||
MetaVirtualInputDeviceNative *virtual_evdev =
|
||||
META_VIRTUAL_INPUT_DEVICE_NATIVE (object);
|
||||
ClutterDeviceManager *manager;
|
||||
ClutterInputDeviceType device_type;
|
||||
ClutterStage *stage;
|
||||
|
||||
manager = clutter_virtual_input_device_get_manager (virtual_device);
|
||||
device_type = clutter_virtual_input_device_get_device_type (virtual_device);
|
||||
|
||||
virtual_evdev->device =
|
||||
meta_input_device_native_new_virtual (manager,
|
||||
virtual_evdev->seat,
|
||||
meta_input_device_native_new_virtual (virtual_evdev->seat,
|
||||
device_type,
|
||||
CLUTTER_INPUT_MODE_SLAVE);
|
||||
|
||||
stage = meta_device_manager_native_get_stage (META_DEVICE_MANAGER_NATIVE (manager));
|
||||
stage = meta_seat_native_get_stage (virtual_evdev->seat);
|
||||
_clutter_input_device_set_stage (virtual_evdev->device, stage);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "backends/native/meta-backend-native.h"
|
||||
#include "backends/native/meta-device-manager-native.h"
|
||||
#include "backends/native/meta-event-native.h"
|
||||
#include "backends/native/meta-seat-native.h"
|
||||
#endif
|
||||
|
||||
G_DEFINE_TYPE (MetaWaylandTouch, meta_wayland_touch,
|
||||
|
@ -570,7 +571,13 @@ meta_wayland_touch_enable (MetaWaylandTouch *touch)
|
|||
#ifdef HAVE_NATIVE_BACKEND
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
if (META_IS_BACKEND_NATIVE (backend))
|
||||
meta_device_manager_native_add_filter (evdev_filter_func, touch, NULL);
|
||||
{
|
||||
ClutterBackend *backend = clutter_get_default_backend ();
|
||||
ClutterSeat *seat = clutter_backend_get_default_seat (backend);
|
||||
|
||||
meta_seat_native_add_filter (META_SEAT_NATIVE (seat),
|
||||
evdev_filter_func, touch, NULL);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -580,7 +587,13 @@ meta_wayland_touch_disable (MetaWaylandTouch *touch)
|
|||
#ifdef HAVE_NATIVE_BACKEND
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
if (META_IS_BACKEND_NATIVE (backend))
|
||||
meta_device_manager_native_remove_filter (evdev_filter_func, touch);
|
||||
{
|
||||
ClutterBackend *backend = clutter_get_default_backend ();
|
||||
ClutterSeat *seat = clutter_backend_get_default_seat (backend);
|
||||
|
||||
meta_seat_native_remove_filter (META_SEAT_NATIVE (seat),
|
||||
evdev_filter_func, touch);
|
||||
}
|
||||
#endif
|
||||
|
||||
meta_wayland_touch_cancel (touch);
|
||||
|
|
Loading…
Add table
Reference in a new issue