backends/native: Spin MetaSeatImpl off MetaSeatNative

Move most of the functional bits (those meant to run on a standalone
thread) to a MetaSeatImpl object. This object is managed by the MetaSeatImpl
and not exposed outside the friend MetaSeatNative/MetaInputDeviceNative/
MetaInputSettings classes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
This commit is contained in:
Carlos Garnacho 2020-08-07 15:13:51 +02:00 committed by Marge Bot
parent 2ceac4a296
commit 59059e1730
12 changed files with 3461 additions and 2967 deletions

View File

@ -22,5 +22,6 @@
#define META_BACKEND_NATIVE_TYPES_H #define META_BACKEND_NATIVE_TYPES_H
typedef struct _MetaBackendNative MetaBackendNative; typedef struct _MetaBackendNative MetaBackendNative;
typedef struct _MetaSeatNative MetaSeatNative;
#endif /* META_BACKEND_NATIVE_TYPES_H */ #endif /* META_BACKEND_NATIVE_TYPES_H */

View File

@ -215,7 +215,7 @@ meta_input_device_native_is_grouped (ClutterInputDevice *device,
static void static void
meta_input_device_native_bell_notify (MetaInputDeviceNative *device) meta_input_device_native_bell_notify (MetaInputDeviceNative *device)
{ {
clutter_seat_bell_notify (CLUTTER_SEAT (device->seat)); clutter_seat_bell_notify (CLUTTER_SEAT (device->seat_impl->seat_native));
} }
static void static void
@ -416,7 +416,7 @@ key_event_is_modifier (ClutterEvent *event)
static void static void
notify_stickykeys_mask (MetaInputDeviceNative *device) notify_stickykeys_mask (MetaInputDeviceNative *device)
{ {
g_signal_emit_by_name (device->seat, g_signal_emit_by_name (device->seat_impl->seat_native,
"kbd-a11y-mods-state-changed", "kbd-a11y-mods-state-changed",
device->stickykeys_latched_mask, device->stickykeys_latched_mask,
device->stickykeys_locked_mask); device->stickykeys_locked_mask);
@ -427,15 +427,17 @@ update_internal_xkb_state (MetaInputDeviceNative *device,
xkb_mod_mask_t new_latched_mask, xkb_mod_mask_t new_latched_mask,
xkb_mod_mask_t new_locked_mask) xkb_mod_mask_t new_locked_mask)
{ {
MetaSeatNative *seat = device->seat; MetaSeatImpl *seat_impl = device->seat_impl;
xkb_mod_mask_t depressed_mods; xkb_mod_mask_t depressed_mods;
xkb_mod_mask_t latched_mods; xkb_mod_mask_t latched_mods;
xkb_mod_mask_t locked_mods; xkb_mod_mask_t locked_mods;
xkb_mod_mask_t group_mods; xkb_mod_mask_t group_mods;
struct xkb_state *xkb_state;
depressed_mods = xkb_state_serialize_mods (seat->xkb, XKB_STATE_MODS_DEPRESSED); xkb_state = meta_seat_impl_get_xkb_state (seat_impl);
latched_mods = xkb_state_serialize_mods (seat->xkb, XKB_STATE_MODS_LATCHED); depressed_mods = xkb_state_serialize_mods (xkb_state, XKB_STATE_MODS_DEPRESSED);
locked_mods = xkb_state_serialize_mods (seat->xkb, XKB_STATE_MODS_LOCKED); latched_mods = xkb_state_serialize_mods (xkb_state, XKB_STATE_MODS_LATCHED);
locked_mods = xkb_state_serialize_mods (xkb_state, XKB_STATE_MODS_LOCKED);
latched_mods &= ~device->stickykeys_latched_mask; latched_mods &= ~device->stickykeys_latched_mask;
locked_mods &= ~device->stickykeys_locked_mask; locked_mods &= ~device->stickykeys_locked_mask;
@ -446,9 +448,9 @@ update_internal_xkb_state (MetaInputDeviceNative *device,
latched_mods |= device->stickykeys_latched_mask; latched_mods |= device->stickykeys_latched_mask;
locked_mods |= device->stickykeys_locked_mask; locked_mods |= device->stickykeys_locked_mask;
group_mods = xkb_state_serialize_layout (seat->xkb, XKB_STATE_LAYOUT_EFFECTIVE); group_mods = xkb_state_serialize_layout (xkb_state, XKB_STATE_LAYOUT_EFFECTIVE);
xkb_state_update_mask (seat->xkb, xkb_state_update_mask (xkb_state,
depressed_mods, depressed_mods,
latched_mods, latched_mods,
locked_mods, locked_mods,
@ -462,23 +464,25 @@ update_stickykeys_event (ClutterEvent *event,
xkb_mod_mask_t new_latched_mask, xkb_mod_mask_t new_latched_mask,
xkb_mod_mask_t new_locked_mask) xkb_mod_mask_t new_locked_mask)
{ {
MetaSeatNative *seat = device->seat; MetaSeatImpl *seat_impl = device->seat_impl;
xkb_mod_mask_t effective_mods; xkb_mod_mask_t effective_mods;
xkb_mod_mask_t latched_mods; xkb_mod_mask_t latched_mods;
xkb_mod_mask_t locked_mods; xkb_mod_mask_t locked_mods;
struct xkb_state *xkb_state;
update_internal_xkb_state (device, new_latched_mask, new_locked_mask); update_internal_xkb_state (device, new_latched_mask, new_locked_mask);
effective_mods = xkb_state_serialize_mods (seat->xkb, XKB_STATE_MODS_EFFECTIVE); xkb_state = meta_seat_impl_get_xkb_state (seat_impl);
latched_mods = xkb_state_serialize_mods (seat->xkb, XKB_STATE_MODS_LATCHED); effective_mods = xkb_state_serialize_mods (xkb_state, XKB_STATE_MODS_EFFECTIVE);
locked_mods = xkb_state_serialize_mods (seat->xkb, XKB_STATE_MODS_LOCKED); latched_mods = xkb_state_serialize_mods (xkb_state, XKB_STATE_MODS_LATCHED);
locked_mods = xkb_state_serialize_mods (xkb_state, XKB_STATE_MODS_LOCKED);
_clutter_event_set_state_full (event, _clutter_event_set_state_full (event,
seat->button_state, seat_impl->button_state,
device->stickykeys_depressed_mask, device->stickykeys_depressed_mask,
latched_mods, latched_mods,
locked_mods, locked_mods,
effective_mods | seat->button_state); effective_mods | seat_impl->button_state);
} }
static void static void
@ -542,10 +546,11 @@ static void
handle_stickykeys_press (ClutterEvent *event, handle_stickykeys_press (ClutterEvent *event,
MetaInputDeviceNative *device) MetaInputDeviceNative *device)
{ {
MetaSeatNative *seat = device->seat; MetaSeatImpl *seat_impl = device->seat_impl;
xkb_mod_mask_t depressed_mods; xkb_mod_mask_t depressed_mods;
xkb_mod_mask_t new_latched_mask; xkb_mod_mask_t new_latched_mask;
xkb_mod_mask_t new_locked_mask; xkb_mod_mask_t new_locked_mask;
struct xkb_state *xkb_state;
if (!key_event_is_modifier (event)) if (!key_event_is_modifier (event))
return; return;
@ -557,7 +562,8 @@ handle_stickykeys_press (ClutterEvent *event,
return; return;
} }
depressed_mods = xkb_state_serialize_mods (seat->xkb, XKB_STATE_MODS_DEPRESSED); xkb_state = meta_seat_impl_get_xkb_state (seat_impl);
depressed_mods = xkb_state_serialize_mods (xkb_state, XKB_STATE_MODS_DEPRESSED);
/* Ignore the lock modifier mask, that one cannot be sticky, yet the /* Ignore the lock modifier mask, that one cannot be sticky, yet the
* CAPS_LOCK key itself counts as a modifier as it might be remapped * CAPS_LOCK key itself counts as a modifier as it might be remapped
* to some other modifier which can be sticky. * to some other modifier which can be sticky.
@ -590,10 +596,12 @@ static void
handle_stickykeys_release (ClutterEvent *event, handle_stickykeys_release (ClutterEvent *event,
MetaInputDeviceNative *device) MetaInputDeviceNative *device)
{ {
MetaSeatNative *seat = device->seat; MetaSeatImpl *seat_impl = device->seat_impl;
struct xkb_state *xkb_state;
xkb_state = meta_seat_impl_get_xkb_state (seat_impl);
device->stickykeys_depressed_mask = device->stickykeys_depressed_mask =
xkb_state_serialize_mods (seat->xkb, XKB_STATE_MODS_DEPRESSED); xkb_state_serialize_mods (xkb_state, XKB_STATE_MODS_DEPRESSED);
if (key_event_is_modifier (event)) if (key_event_is_modifier (event))
{ {
@ -831,8 +839,12 @@ emulate_pointer_motion (MetaInputDeviceNative *device_evdev,
static gboolean static gboolean
is_numlock_active (MetaInputDeviceNative *device) is_numlock_active (MetaInputDeviceNative *device)
{ {
MetaSeatNative *seat = device->seat; MetaSeatImpl *seat_impl = device->seat_impl;
return xkb_state_mod_name_is_active (seat->xkb, struct xkb_state *xkb_state;
xkb_state = meta_seat_impl_get_xkb_state (seat_impl);
return xkb_state_mod_name_is_active (xkb_state,
"Mod2", "Mod2",
XKB_STATE_MODS_LOCKED); XKB_STATE_MODS_LOCKED);
} }
@ -852,7 +864,7 @@ enable_mousekeys (MetaInputDeviceNative *device_evdev)
return; return;
device->accessibility_virtual_device = device->accessibility_virtual_device =
clutter_seat_create_virtual_device (CLUTTER_SEAT (device_evdev->seat), clutter_seat_create_virtual_device (clutter_input_device_get_seat (device),
CLUTTER_POINTER_DEVICE); CLUTTER_POINTER_DEVICE);
} }
@ -1269,7 +1281,7 @@ meta_input_device_native_init (MetaInputDeviceNative *self)
* it with the provided seat. * it with the provided seat.
*/ */
ClutterInputDevice * ClutterInputDevice *
meta_input_device_native_new (MetaSeatNative *seat, meta_input_device_native_new (MetaSeatImpl *seat_impl,
struct libinput_device *libinput_device) struct libinput_device *libinput_device)
{ {
MetaInputDeviceNative *device; MetaInputDeviceNative *device;
@ -1302,10 +1314,10 @@ meta_input_device_native_new (MetaSeatNative *seat,
"n-strips", n_strips, "n-strips", n_strips,
"n-mode-groups", n_groups, "n-mode-groups", n_groups,
"device-node", node_path, "device-node", node_path,
"seat", seat, "seat", seat_impl->seat_native,
NULL); NULL);
device->seat = seat; device->seat_impl = seat_impl;
device->libinput_device = libinput_device; device->libinput_device = libinput_device;
libinput_device_set_user_data (libinput_device, device); libinput_device_set_user_data (libinput_device, device);
@ -1328,7 +1340,7 @@ meta_input_device_native_new (MetaSeatNative *seat,
* Create a new virtual ClutterInputDevice of the given type. * Create a new virtual ClutterInputDevice of the given type.
*/ */
ClutterInputDevice * ClutterInputDevice *
meta_input_device_native_new_virtual (MetaSeatNative *seat, meta_input_device_native_new_virtual (MetaSeatImpl *seat_impl,
ClutterInputDeviceType type, ClutterInputDeviceType type,
ClutterInputMode mode) ClutterInputMode mode)
{ {
@ -1355,18 +1367,18 @@ meta_input_device_native_new_virtual (MetaSeatNative *seat,
"name", name, "name", name,
"device-type", type, "device-type", type,
"device-mode", mode, "device-mode", mode,
"seat", seat, "seat", seat_impl->seat_native,
NULL); NULL);
device->seat = seat; device->seat_impl = seat_impl;
return CLUTTER_INPUT_DEVICE (device); return CLUTTER_INPUT_DEVICE (device);
} }
MetaSeatNative * MetaSeatImpl *
meta_input_device_native_get_seat (MetaInputDeviceNative *device) meta_input_device_native_get_seat_impl (MetaInputDeviceNative *device)
{ {
return device->seat; return device->seat_impl;
} }
void void

View File

@ -69,7 +69,7 @@ struct _MetaInputDeviceNative
ClutterInputDevice parent; ClutterInputDevice parent;
struct libinput_device *libinput_device; struct libinput_device *libinput_device;
MetaSeatNative *seat; MetaSeatImpl *seat_impl;
ClutterInputDeviceTool *last_tool; ClutterInputDeviceTool *last_tool;
cairo_matrix_t device_matrix; cairo_matrix_t device_matrix;
@ -111,14 +111,14 @@ struct _MetaInputDeviceNativeClass
GType meta_input_device_native_get_type (void) G_GNUC_CONST; GType meta_input_device_native_get_type (void) G_GNUC_CONST;
ClutterInputDevice * meta_input_device_native_new (MetaSeatNative *seat, ClutterInputDevice * meta_input_device_native_new (MetaSeatImpl *seat_impl,
struct libinput_device *libinput_device); struct libinput_device *libinput_device);
ClutterInputDevice * meta_input_device_native_new_virtual (MetaSeatNative *seat, ClutterInputDevice * meta_input_device_native_new_virtual (MetaSeatImpl *seat_impl,
ClutterInputDeviceType type, ClutterInputDeviceType type,
ClutterInputMode mode); ClutterInputMode mode);
MetaSeatNative * meta_input_device_native_get_seat (MetaInputDeviceNative *device); MetaSeatImpl * meta_input_device_native_get_seat_impl (MetaInputDeviceNative *device);
void meta_input_device_native_update_leds (MetaInputDeviceNative *device, void meta_input_device_native_update_leds (MetaInputDeviceNative *device,
enum libinput_led leds); enum libinput_led leds);

View File

@ -412,8 +412,8 @@ meta_input_settings_native_set_keyboard_repeat (MetaInputSettings *settings,
ClutterSeat *seat; ClutterSeat *seat;
seat = clutter_backend_get_default_seat (clutter_get_default_backend ()); seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
meta_seat_native_set_keyboard_repeat (META_SEAT_NATIVE (seat), meta_seat_impl_set_keyboard_repeat (META_SEAT_NATIVE (seat)->impl,
enabled, delay, interval); enabled, delay, interval);
} }
static void static void

View File

@ -58,7 +58,7 @@ meta_keymap_native_get_num_lock_state (ClutterKeymap *keymap)
ClutterSeat *seat; ClutterSeat *seat;
seat = clutter_backend_get_default_seat (clutter_get_default_backend ()); seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
xkb_state = meta_seat_native_get_xkb_state (META_SEAT_NATIVE (seat)); xkb_state = meta_seat_impl_get_xkb_state (META_SEAT_NATIVE (seat)->impl);
return xkb_state_mod_name_is_active (xkb_state, return xkb_state_mod_name_is_active (xkb_state,
XKB_MOD_NAME_NUM, XKB_MOD_NAME_NUM,
@ -73,7 +73,7 @@ meta_keymap_native_get_caps_lock_state (ClutterKeymap *keymap)
ClutterSeat *seat; ClutterSeat *seat;
seat = clutter_backend_get_default_seat (clutter_get_default_backend ()); seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
xkb_state = meta_seat_native_get_xkb_state (META_SEAT_NATIVE (seat)); xkb_state = meta_seat_impl_get_xkb_state (META_SEAT_NATIVE (seat)->impl);
return xkb_state_mod_name_is_active (xkb_state, return xkb_state_mod_name_is_active (xkb_state,
XKB_MOD_NAME_CAPS, XKB_MOD_NAME_CAPS,

View File

@ -51,7 +51,9 @@ struct _MetaLauncher
Login1Seat *seat_proxy; Login1Seat *seat_proxy;
char *seat_id; char *seat_id;
GHashTable *sysfs_fds; struct {
GHashTable *sysfs_fds;
} impl;
gboolean session_active; gboolean session_active;
}; };
@ -410,7 +412,7 @@ on_evdev_device_open (const char *path,
return -1; return -1;
} }
g_hash_table_add (self->sysfs_fds, GINT_TO_POINTER (fd)); g_hash_table_add (self->impl.sysfs_fds, GINT_TO_POINTER (fd));
return fd; return fd;
} }
@ -423,10 +425,10 @@ on_evdev_device_close (int fd,
{ {
MetaLauncher *self = user_data; MetaLauncher *self = user_data;
if (g_hash_table_lookup (self->sysfs_fds, GINT_TO_POINTER (fd))) if (g_hash_table_lookup (self->impl.sysfs_fds, GINT_TO_POINTER (fd)))
{ {
/* /sys/ paths just need close() here */ /* /sys/ paths just need close() here */
g_hash_table_remove (self->sysfs_fds, GINT_TO_POINTER (fd)); g_hash_table_remove (self->impl.sysfs_fds, GINT_TO_POINTER (fd));
close (fd); close (fd);
return; return;
} }
@ -523,14 +525,14 @@ meta_launcher_new (GError **error)
self->session_proxy = g_object_ref (session_proxy); self->session_proxy = g_object_ref (session_proxy);
self->seat_proxy = g_object_ref (seat_proxy); self->seat_proxy = g_object_ref (seat_proxy);
self->seat_id = g_steal_pointer (&seat_id); self->seat_id = g_steal_pointer (&seat_id);
self->sysfs_fds = g_hash_table_new (NULL, NULL); self->impl.sysfs_fds = g_hash_table_new (NULL, NULL);
self->session_active = TRUE; self->session_active = TRUE;
meta_clutter_backend_native_set_seat_id (self->seat_id); meta_clutter_backend_native_set_seat_id (self->seat_id);
meta_seat_native_set_device_callbacks (on_evdev_device_open, meta_seat_impl_set_device_callbacks (on_evdev_device_open,
on_evdev_device_close, on_evdev_device_close,
self); self);
g_signal_connect (self->session_proxy, "notify::active", G_CALLBACK (on_active_changed), self); g_signal_connect (self->session_proxy, "notify::active", G_CALLBACK (on_active_changed), self);
@ -545,10 +547,11 @@ meta_launcher_new (GError **error)
void void
meta_launcher_free (MetaLauncher *self) meta_launcher_free (MetaLauncher *self)
{ {
meta_seat_impl_set_device_callbacks (NULL, NULL, NULL);
g_free (self->seat_id); g_free (self->seat_id);
g_object_unref (self->seat_proxy); g_object_unref (self->seat_proxy);
g_object_unref (self->session_proxy); g_object_unref (self->session_proxy);
g_hash_table_destroy (self->sysfs_fds); g_hash_table_destroy (self->impl.sysfs_fds);
g_slice_free (MetaLauncher, self); g_slice_free (MetaLauncher, self);
} }

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,242 @@
/*
* 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_IMPL_H
#define META_SEAT_IMPL_H
#include <gudev/gudev.h>
#include <libinput.h>
#include <linux/input-event-codes.h>
#include "backends/meta-viewport-info.h"
#include "backends/native/meta-backend-native-types.h"
#include "backends/native/meta-barrier-native.h"
#include "backends/native/meta-cursor-renderer-native.h"
#include "backends/native/meta-keymap-native.h"
#include "backends/native/meta-pointer-constraint-native.h"
#include "backends/native/meta-xkb-utils.h"
#include "clutter/clutter.h"
typedef struct _MetaTouchState MetaTouchState;
typedef struct _MetaSeatImpl MetaSeatImpl;
typedef struct _MetaEventSource MetaEventSource;
struct _MetaTouchState
{
MetaSeatImpl *seat_impl;
int device_slot;
int seat_slot;
graphene_point_t coords;
};
struct _MetaSeatImpl
{
GObject parent_instance;
MetaSeatNative *seat_native;
char *seat_id;
MetaEventSource *event_source;
struct libinput *libinput;
GSList *devices;
ClutterInputDevice *core_pointer;
ClutterInputDevice *core_keyboard;
GHashTable *touch_states;
GHashTable *cursor_renderers;
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];
MetaBarrierManagerNative *barrier_manager;
MetaPointerConstraintImpl *pointer_constraint;
MetaKeymapNative *keymap;
MetaViewportInfo *viewports;
GUdevClient *udev_client;
gboolean tablet_mode_switch_state;
gboolean has_touchscreen;
gboolean has_tablet_switch;
gboolean touch_mode;
/* keyboard repeat */
gboolean repeat;
uint32_t repeat_delay;
uint32_t repeat_interval;
uint32_t repeat_key;
uint32_t repeat_count;
uint32_t repeat_timer;
ClutterInputDevice *repeat_device;
float pointer_x;
float pointer_y;
/* Emulation of discrete scroll events out of smooth ones */
float accum_scroll_dx;
float accum_scroll_dy;
gboolean released;
};
#define META_TYPE_SEAT_IMPL meta_seat_impl_get_type ()
G_DECLARE_FINAL_TYPE (MetaSeatImpl, meta_seat_impl,
META, SEAT_IMPL, GObject)
MetaSeatImpl * meta_seat_impl_new (MetaSeatNative *seat_native,
const char *seat_id);
void meta_seat_impl_notify_key (MetaSeatImpl *seat_impl,
ClutterInputDevice *device,
uint64_t time_us,
uint32_t key,
uint32_t state,
gboolean update_keys);
void meta_seat_impl_notify_relative_motion (MetaSeatImpl *seat_impl,
ClutterInputDevice *input_device,
uint64_t time_us,
float dx,
float dy,
float dx_unaccel,
float dy_unaccel);
void meta_seat_impl_notify_absolute_motion (MetaSeatImpl *seat_impl,
ClutterInputDevice *input_device,
uint64_t time_us,
float x,
float y,
double *axes);
void meta_seat_impl_notify_button (MetaSeatImpl *seat_impl,
ClutterInputDevice *input_device,
uint64_t time_us,
uint32_t button,
uint32_t state);
void meta_seat_impl_notify_scroll_continuous (MetaSeatImpl *seat_impl,
ClutterInputDevice *input_device,
uint64_t time_us,
double dx,
double dy,
ClutterScrollSource source,
ClutterScrollFinishFlags flags);
void meta_seat_impl_notify_discrete_scroll (MetaSeatImpl *seat_impl,
ClutterInputDevice *input_device,
uint64_t time_us,
double discrete_dx,
double discrete_dy,
ClutterScrollSource source);
void meta_seat_impl_notify_touch_event (MetaSeatImpl *seat_impl,
ClutterInputDevice *input_device,
ClutterEventType evtype,
uint64_t time_us,
int slot,
double x,
double y);
void meta_seat_impl_sync_leds (MetaSeatImpl *seat_impl);
MetaTouchState * meta_seat_impl_acquire_touch_state (MetaSeatImpl *seat_impl,
int seat_slot);
MetaTouchState * meta_seat_impl_lookup_touch_state (MetaSeatImpl *seat_impl,
int seat_slot);
void meta_seat_impl_release_touch_state (MetaSeatImpl *seat_impl,
int seat_slot);
void meta_seat_impl_update_xkb_state (MetaSeatImpl *seat_impl);
/**
* 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_impl_set_device_callbacks (MetaOpenDeviceCallback open_callback,
MetaCloseDeviceCallback close_callback,
gpointer user_data);
void meta_seat_impl_release_devices (MetaSeatImpl *seat_impl);
void meta_seat_impl_reclaim_devices (MetaSeatImpl *seat_impl);
struct xkb_state * meta_seat_impl_get_xkb_state (MetaSeatImpl *seat_impl);
void meta_seat_impl_set_keyboard_map (MetaSeatImpl *seat_impl,
struct xkb_keymap *keymap);
struct xkb_keymap * meta_seat_impl_get_keyboard_map (MetaSeatImpl *seat_impl);
void meta_seat_impl_set_keyboard_layout_index (MetaSeatImpl *seat_impl,
xkb_layout_index_t idx);
xkb_layout_index_t meta_seat_impl_get_keyboard_layout_index (MetaSeatImpl *seat_impl);
void meta_seat_impl_set_keyboard_numlock (MetaSeatImpl *seat_impl,
gboolean numlock_state);
void meta_seat_impl_set_keyboard_repeat (MetaSeatImpl *seat_impl,
gboolean repeat,
uint32_t delay,
uint32_t interval);
MetaBarrierManagerNative * meta_seat_impl_get_barrier_manager (MetaSeatImpl *seat_impl);
void meta_seat_impl_set_pointer_constraint (MetaSeatImpl *seat_impl,
MetaPointerConstraintImpl *constraint_impl);
void meta_seat_impl_set_viewports (MetaSeatImpl *seat_impl,
MetaViewportInfo *viewports);
void meta_seat_impl_warp_pointer (MetaSeatImpl *seat_impl,
int x,
int y);
gboolean meta_seat_impl_query_state (MetaSeatImpl *seat_impl,
ClutterInputDevice *device,
ClutterEventSequence *sequence,
graphene_point_t *coords,
ClutterModifierType *modifiers);
ClutterInputDevice * meta_seat_impl_get_pointer (MetaSeatImpl *seat_impl);
ClutterInputDevice * meta_seat_impl_get_keyboard (MetaSeatImpl *seat_impl);
GSList * meta_seat_impl_get_devices (MetaSeatImpl *seat_impl);
MetaKeymapNative * meta_seat_impl_get_keymap (MetaSeatImpl *seat_impl);
#endif /* META_SEAT_IMPL_H */

File diff suppressed because it is too large Load Diff

View File

@ -32,83 +32,31 @@
#include "backends/native/meta-cursor-renderer-native.h" #include "backends/native/meta-cursor-renderer-native.h"
#include "backends/native/meta-keymap-native.h" #include "backends/native/meta-keymap-native.h"
#include "backends/native/meta-pointer-constraint-native.h" #include "backends/native/meta-pointer-constraint-native.h"
#include "backends/native/meta-seat-impl.h"
#include "backends/native/meta-xkb-utils.h" #include "backends/native/meta-xkb-utils.h"
#include "clutter/clutter.h" #include "clutter/clutter.h"
typedef struct _MetaTouchState MetaTouchState;
typedef struct _MetaSeatNative MetaSeatNative; typedef struct _MetaSeatNative MetaSeatNative;
typedef struct _MetaEventSource MetaEventSource;
struct _MetaTouchState
{
MetaSeatNative *seat;
int device_slot;
int seat_slot;
graphene_point_t coords;
};
struct _MetaSeatNative struct _MetaSeatNative
{ {
ClutterSeat parent_instance; ClutterSeat parent_instance;
MetaSeatImpl *impl;
char *seat_id; char *seat_id;
MetaEventSource *event_source;
struct libinput *libinput;
struct libinput_seat *libinput_seat;
GSList *devices; GList *devices;
ClutterInputDevice *core_pointer; ClutterInputDevice *core_pointer;
ClutterInputDevice *core_keyboard; ClutterInputDevice *core_keyboard;
GHashTable *touch_states;
guint virtual_touch_slot_base; guint virtual_touch_slot_base;
GHashTable *reserved_virtual_slots; GHashTable *reserved_virtual_slots;
GHashTable *cursor_renderers;
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];
int device_id_next;
GList *free_device_ids;
MetaBarrierManagerNative *barrier_manager;
MetaPointerConstraintImpl *pointer_constraint;
MetaKeymapNative *keymap; MetaKeymapNative *keymap;
MetaCursorRenderer *cursor_renderer; MetaCursorRenderer *cursor_renderer;
GHashTable *tablet_cursors; GHashTable *tablet_cursors;
MetaViewportInfo *viewports;
GUdevClient *udev_client;
guint tablet_mode_switch_state : 1;
guint has_touchscreen : 1;
guint has_tablet_switch : 1;
guint touch_mode : 1;
/* keyboard repeat */
gboolean repeat;
uint32_t repeat_delay;
uint32_t repeat_interval;
uint32_t repeat_key;
uint32_t repeat_count;
uint32_t repeat_timer;
ClutterInputDevice *repeat_device;
float pointer_x;
float pointer_y;
/* Emulation of discrete scroll events out of smooth ones */
float accum_scroll_dx;
float accum_scroll_dy;
gboolean released; gboolean released;
}; };
@ -116,95 +64,11 @@ struct _MetaSeatNative
G_DECLARE_FINAL_TYPE (MetaSeatNative, meta_seat_native, G_DECLARE_FINAL_TYPE (MetaSeatNative, meta_seat_native,
META, SEAT_NATIVE, ClutterSeat) META, SEAT_NATIVE, ClutterSeat)
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, void meta_seat_native_set_libinput_seat (MetaSeatNative *seat,
struct libinput_seat *libinput_seat); struct libinput_seat *libinput_seat);
void meta_seat_native_sync_leds (MetaSeatNative *seat); void meta_seat_native_sync_leds (MetaSeatNative *seat);
MetaTouchState * meta_seat_native_acquire_touch_state (MetaSeatNative *seat,
int seat_slot);
MetaTouchState * meta_seat_native_lookup_touch_state (MetaSeatNative *seat,
int seat_slot);
void meta_seat_native_release_touch_state (MetaSeatNative *seat,
int seat_slot);
void meta_seat_native_clear_repeat_timer (MetaSeatNative *seat);
gint meta_seat_native_acquire_device_id (MetaSeatNative *seat);
void meta_seat_native_release_device_id (MetaSeatNative *seat,
ClutterInputDevice *device);
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: * MetaOpenDeviceCallback:
* @path: the device path * @path: the device path
@ -228,8 +92,6 @@ void meta_seat_native_set_device_callbacks (MetaOpenDeviceCallback open_callba
void meta_seat_native_release_devices (MetaSeatNative *seat); void meta_seat_native_release_devices (MetaSeatNative *seat);
void meta_seat_native_reclaim_devices (MetaSeatNative *seat); void meta_seat_native_reclaim_devices (MetaSeatNative *seat);
struct xkb_state * meta_seat_native_get_xkb_state (MetaSeatNative *seat);
void meta_seat_native_set_keyboard_map (MetaSeatNative *seat, void meta_seat_native_set_keyboard_map (MetaSeatNative *seat,
struct xkb_keymap *keymap); struct xkb_keymap *keymap);

View File

@ -131,19 +131,19 @@ release_pressed_buttons (ClutterVirtualInputDevice *virtual_device)
switch (get_button_type (code)) switch (get_button_type (code))
{ {
case EVDEV_BUTTON_TYPE_KEY: case EVDEV_BUTTON_TYPE_KEY:
meta_seat_native_notify_key (virtual_evdev->seat, meta_seat_impl_notify_key (virtual_evdev->seat->impl,
virtual_evdev->device, virtual_evdev->device,
time_us, time_us,
code, code,
CLUTTER_KEY_STATE_RELEASED, CLUTTER_KEY_STATE_RELEASED,
TRUE); TRUE);
break; break;
case EVDEV_BUTTON_TYPE_BUTTON: case EVDEV_BUTTON_TYPE_BUTTON:
meta_seat_native_notify_button (virtual_evdev->seat, meta_seat_impl_notify_button (virtual_evdev->seat->impl,
virtual_evdev->device, virtual_evdev->device,
time_us, time_us,
code, code,
CLUTTER_BUTTON_STATE_RELEASED); CLUTTER_BUTTON_STATE_RELEASED);
break; break;
case EVDEV_BUTTON_TYPE_NONE: case EVDEV_BUTTON_TYPE_NONE:
g_assert_not_reached (); g_assert_not_reached ();
@ -167,11 +167,11 @@ meta_virtual_input_device_native_notify_relative_motion (ClutterVirtualInputDevi
if (time_us == CLUTTER_CURRENT_TIME) if (time_us == CLUTTER_CURRENT_TIME)
time_us = g_get_monotonic_time (); time_us = g_get_monotonic_time ();
meta_seat_native_notify_relative_motion (virtual_evdev->seat, meta_seat_impl_notify_relative_motion (virtual_evdev->seat->impl,
virtual_evdev->device, virtual_evdev->device,
time_us, time_us,
dx, dy, dx, dy,
dx, dy); dx, dy);
} }
static void static void
@ -188,11 +188,11 @@ meta_virtual_input_device_native_notify_absolute_motion (ClutterVirtualInputDevi
if (time_us == CLUTTER_CURRENT_TIME) if (time_us == CLUTTER_CURRENT_TIME)
time_us = g_get_monotonic_time (); time_us = g_get_monotonic_time ();
meta_seat_native_notify_absolute_motion (virtual_evdev->seat, meta_seat_impl_notify_absolute_motion (virtual_evdev->seat->impl,
virtual_evdev->device, virtual_evdev->device,
time_us, time_us,
x, y, x, y,
NULL); NULL);
} }
static int static int
@ -254,11 +254,11 @@ meta_virtual_input_device_native_notify_button (ClutterVirtualInputDevice *virtu
button_state == CLUTTER_BUTTON_STATE_PRESSED ? "press" : "release", button_state == CLUTTER_BUTTON_STATE_PRESSED ? "press" : "release",
evdev_button, virtual_device); evdev_button, virtual_device);
meta_seat_native_notify_button (virtual_evdev->seat, meta_seat_impl_notify_button (virtual_evdev->seat->impl,
virtual_evdev->device, virtual_evdev->device,
time_us, time_us,
evdev_button, evdev_button,
button_state); button_state);
} }
static void static void
@ -296,12 +296,12 @@ meta_virtual_input_device_native_notify_key (ClutterVirtualInputDevice *virtual_
key_state == CLUTTER_KEY_STATE_PRESSED ? "press" : "release", key_state == CLUTTER_KEY_STATE_PRESSED ? "press" : "release",
key, virtual_device); key, virtual_device);
meta_seat_native_notify_key (virtual_evdev->seat, meta_seat_impl_notify_key (virtual_evdev->seat->impl,
virtual_evdev->device, virtual_evdev->device,
time_us, time_us,
key, key,
key_state, key_state,
TRUE); TRUE);
} }
static gboolean static gboolean
@ -322,7 +322,7 @@ pick_keycode_for_keyval_in_current_group (ClutterVirtualInputDevice *virtual_dev
backend = clutter_get_default_backend (); backend = clutter_get_default_backend ();
keymap = clutter_seat_get_keymap (clutter_backend_get_default_seat (backend)); keymap = clutter_seat_get_keymap (clutter_backend_get_default_seat (backend));
xkb_keymap = meta_keymap_native_get_keyboard_map (META_KEYMAP_NATIVE (keymap)); xkb_keymap = meta_keymap_native_get_keyboard_map (META_KEYMAP_NATIVE (keymap));
state = virtual_evdev->seat->xkb; state = meta_seat_impl_get_xkb_state (virtual_evdev->seat->impl);
layout = xkb_state_serialize_layout (state, XKB_STATE_LAYOUT_EFFECTIVE); layout = xkb_state_serialize_layout (state, XKB_STATE_LAYOUT_EFFECTIVE);
min_keycode = xkb_keymap_min_keycode (xkb_keymap); min_keycode = xkb_keymap_min_keycode (xkb_keymap);
@ -391,12 +391,12 @@ apply_level_modifiers (ClutterVirtualInputDevice *virtual_device,
key_state == CLUTTER_KEY_STATE_PRESSED ? "press" : "release", key_state == CLUTTER_KEY_STATE_PRESSED ? "press" : "release",
evcode, virtual_device); evcode, virtual_device);
meta_seat_native_notify_key (virtual_evdev->seat, meta_seat_impl_notify_key (virtual_evdev->seat->impl,
virtual_evdev->device, virtual_evdev->device,
time_us, time_us,
evcode, evcode,
key_state, key_state,
TRUE); TRUE);
} }
static void static void
@ -449,12 +449,12 @@ meta_virtual_input_device_native_notify_keyval (ClutterVirtualInputDevice *virtu
if (key_state) if (key_state)
apply_level_modifiers (virtual_device, time_us, level, key_state); apply_level_modifiers (virtual_device, time_us, level, key_state);
meta_seat_native_notify_key (virtual_evdev->seat, meta_seat_impl_notify_key (virtual_evdev->seat->impl,
virtual_evdev->device, virtual_evdev->device,
time_us, time_us,
evcode, evcode,
key_state, key_state,
TRUE); TRUE);
if (!key_state) if (!key_state)
apply_level_modifiers (virtual_device, time_us, level, key_state); apply_level_modifiers (virtual_device, time_us, level, key_state);
@ -506,11 +506,11 @@ meta_virtual_input_device_native_notify_discrete_scroll (ClutterVirtualInputDevi
direction_to_discrete (direction, &discrete_dx, &discrete_dy); direction_to_discrete (direction, &discrete_dx, &discrete_dy);
meta_seat_native_notify_discrete_scroll (virtual_evdev->seat, meta_seat_impl_notify_discrete_scroll (virtual_evdev->seat->impl,
virtual_evdev->device, virtual_evdev->device,
time_us, time_us,
discrete_dx, discrete_dy, discrete_dx, discrete_dy,
scroll_source); scroll_source);
} }
static void static void
@ -529,12 +529,12 @@ meta_virtual_input_device_native_notify_scroll_continuous (ClutterVirtualInputDe
if (time_us == CLUTTER_CURRENT_TIME) if (time_us == CLUTTER_CURRENT_TIME)
time_us = g_get_monotonic_time (); time_us = g_get_monotonic_time ();
meta_seat_native_notify_scroll_continuous (virtual_evdev->seat, meta_seat_impl_notify_scroll_continuous (virtual_evdev->seat->impl,
virtual_evdev->device, virtual_evdev->device,
time_us, time_us,
dx, dy, dx, dy,
scroll_source, scroll_source,
CLUTTER_SCROLL_FINISHED_NONE); CLUTTER_SCROLL_FINISHED_NONE);
} }
static void static void
@ -555,21 +555,21 @@ meta_virtual_input_device_native_notify_touch_down (ClutterVirtualInputDevice *v
time_us = g_get_monotonic_time (); time_us = g_get_monotonic_time ();
seat_slot = virtual_evdev->slot_base + (guint) device_slot; seat_slot = virtual_evdev->slot_base + (guint) device_slot;
touch_state = meta_seat_native_acquire_touch_state (virtual_evdev->seat, touch_state = meta_seat_impl_acquire_touch_state (virtual_evdev->seat->impl,
seat_slot); seat_slot);
if (!touch_state) if (!touch_state)
return; return;
touch_state->coords.x = x; touch_state->coords.x = x;
touch_state->coords.y = y; touch_state->coords.y = y;
meta_seat_native_notify_touch_event (virtual_evdev->seat, meta_seat_impl_notify_touch_event (virtual_evdev->seat->impl,
virtual_evdev->device, virtual_evdev->device,
CLUTTER_TOUCH_BEGIN, CLUTTER_TOUCH_BEGIN,
time_us, time_us,
touch_state->seat_slot, touch_state->seat_slot,
touch_state->coords.x, touch_state->coords.x,
touch_state->coords.y); touch_state->coords.y);
} }
static void static void
@ -590,21 +590,21 @@ meta_virtual_input_device_native_notify_touch_motion (ClutterVirtualInputDevice
time_us = g_get_monotonic_time (); time_us = g_get_monotonic_time ();
seat_slot = virtual_evdev->slot_base + (guint) device_slot; seat_slot = virtual_evdev->slot_base + (guint) device_slot;
touch_state = meta_seat_native_lookup_touch_state (virtual_evdev->seat, touch_state = meta_seat_impl_lookup_touch_state (virtual_evdev->seat->impl,
seat_slot); seat_slot);
if (!touch_state) if (!touch_state)
return; return;
touch_state->coords.x = x; touch_state->coords.x = x;
touch_state->coords.y = y; touch_state->coords.y = y;
meta_seat_native_notify_touch_event (virtual_evdev->seat, meta_seat_impl_notify_touch_event (virtual_evdev->seat->impl,
virtual_evdev->device, virtual_evdev->device,
CLUTTER_TOUCH_BEGIN, CLUTTER_TOUCH_BEGIN,
time_us, time_us,
touch_state->seat_slot, touch_state->seat_slot,
touch_state->coords.x, touch_state->coords.x,
touch_state->coords.y); touch_state->coords.y);
} }
static void static void
@ -623,21 +623,21 @@ meta_virtual_input_device_native_notify_touch_up (ClutterVirtualInputDevice *vir
time_us = g_get_monotonic_time (); time_us = g_get_monotonic_time ();
seat_slot = virtual_evdev->slot_base + (guint) device_slot; seat_slot = virtual_evdev->slot_base + (guint) device_slot;
touch_state = meta_seat_native_lookup_touch_state (virtual_evdev->seat, touch_state = meta_seat_impl_lookup_touch_state (virtual_evdev->seat->impl,
seat_slot); seat_slot);
if (!touch_state) if (!touch_state)
return; return;
meta_seat_native_notify_touch_event (virtual_evdev->seat, meta_seat_impl_notify_touch_event (virtual_evdev->seat->impl,
virtual_evdev->device, virtual_evdev->device,
CLUTTER_TOUCH_BEGIN, CLUTTER_TOUCH_BEGIN,
time_us, time_us,
touch_state->seat_slot, touch_state->seat_slot,
touch_state->coords.x, touch_state->coords.x,
touch_state->coords.y); touch_state->coords.y);
meta_seat_native_release_touch_state (virtual_evdev->seat, meta_seat_impl_release_touch_state (virtual_evdev->seat->impl,
touch_state->seat_slot); touch_state->seat_slot);
} }
static void static void
@ -702,7 +702,7 @@ meta_virtual_input_device_native_constructed (GObject *object)
device_type, virtual_device); device_type, virtual_device);
virtual_evdev->device = virtual_evdev->device =
meta_input_device_native_new_virtual (virtual_evdev->seat, meta_input_device_native_new_virtual (virtual_evdev->seat->impl,
device_type, device_type,
CLUTTER_INPUT_MODE_PHYSICAL); CLUTTER_INPUT_MODE_PHYSICAL);

View File

@ -705,6 +705,8 @@ if have_native_backend
'backends/native/meta-renderer-native-gles3.c', 'backends/native/meta-renderer-native-gles3.c',
'backends/native/meta-renderer-native-gles3.h', 'backends/native/meta-renderer-native-gles3.h',
'backends/native/meta-renderer-native.h', 'backends/native/meta-renderer-native.h',
'backends/native/meta-seat-impl.c',
'backends/native/meta-seat-impl.h',
'backends/native/meta-seat-native.c', 'backends/native/meta-seat-native.c',
'backends/native/meta-seat-native.h', 'backends/native/meta-seat-native.h',
'backends/native/meta-stage-native.c', 'backends/native/meta-stage-native.c',