2020-08-07 09:13:51 -04:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
|
2020-11-20 17:53:46 -05:00
|
|
|
#ifndef META_INPUT_THREAD_H_INSIDE
|
|
|
|
#error "This header cannot be included directly. Use "backends/native/meta-input-thread.h""
|
|
|
|
#endif /* META_INPUT_THREAD_H_INSIDE */
|
|
|
|
|
2020-08-07 09:13:51 -04:00
|
|
|
#include <gudev/gudev.h>
|
|
|
|
#include <libinput.h>
|
|
|
|
#include <linux/input-event-codes.h>
|
|
|
|
|
2020-08-11 11:11:51 -04:00
|
|
|
#include "backends/meta-input-settings-private.h"
|
2020-08-07 09:13:51 -04:00
|
|
|
#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;
|
|
|
|
|
2020-08-12 12:04:34 -04:00
|
|
|
GMainContext *main_context;
|
2020-08-12 09:37:43 -04:00
|
|
|
GMainContext *input_context;
|
2020-08-12 12:04:34 -04:00
|
|
|
GMainLoop *input_loop;
|
|
|
|
GThread *input_thread;
|
|
|
|
GMutex init_mutex;
|
|
|
|
GCond init_cond;
|
|
|
|
|
2020-08-07 09:13:51 -04:00
|
|
|
MetaSeatNative *seat_native;
|
|
|
|
char *seat_id;
|
|
|
|
MetaEventSource *event_source;
|
|
|
|
struct libinput *libinput;
|
2020-08-12 04:43:48 -04:00
|
|
|
GRWLock state_lock;
|
2020-08-07 09:13:51 -04:00
|
|
|
|
|
|
|
GSList *devices;
|
2020-11-19 06:04:46 -05:00
|
|
|
GHashTable *tools;
|
2020-08-07 09:13:51 -04:00
|
|
|
|
|
|
|
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;
|
2020-08-11 12:33:07 -04:00
|
|
|
MetaInputSettings *input_settings;
|
2020-08-07 09:13:51 -04:00
|
|
|
|
|
|
|
MetaViewportInfo *viewports;
|
|
|
|
|
|
|
|
GUdevClient *udev_client;
|
|
|
|
gboolean tablet_mode_switch_state;
|
|
|
|
gboolean has_touchscreen;
|
|
|
|
gboolean has_tablet_switch;
|
|
|
|
gboolean touch_mode;
|
2020-08-12 12:04:34 -04:00
|
|
|
gboolean input_thread_initialized;
|
2020-08-07 09:13:51 -04:00
|
|
|
|
|
|
|
/* keyboard repeat */
|
|
|
|
gboolean repeat;
|
|
|
|
uint32_t repeat_delay;
|
|
|
|
uint32_t repeat_interval;
|
|
|
|
uint32_t repeat_key;
|
|
|
|
uint32_t repeat_count;
|
|
|
|
ClutterInputDevice *repeat_device;
|
2020-08-12 12:04:34 -04:00
|
|
|
GSource *repeat_source;
|
2020-08-07 09:13:51 -04:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2021-01-14 10:07:40 -05:00
|
|
|
void meta_seat_impl_destroy (MetaSeatImpl *seat_impl);
|
|
|
|
|
2020-08-12 09:37:43 -04:00
|
|
|
void meta_seat_impl_run_input_task (MetaSeatImpl *seat_impl,
|
|
|
|
GTask *task,
|
|
|
|
GSourceFunc dispatch_func);
|
|
|
|
|
2020-11-19 19:36:19 -05:00
|
|
|
void meta_seat_impl_notify_key_in_impl (MetaSeatImpl *seat_impl,
|
|
|
|
ClutterInputDevice *device,
|
2020-08-07 09:13:51 -04:00
|
|
|
uint64_t time_us,
|
2020-11-19 19:36:19 -05:00
|
|
|
uint32_t key,
|
|
|
|
uint32_t state,
|
|
|
|
gboolean update_keys);
|
|
|
|
|
|
|
|
void meta_seat_impl_notify_relative_motion_in_impl (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_in_impl (MetaSeatImpl *seat_impl,
|
|
|
|
ClutterInputDevice *input_device,
|
|
|
|
uint64_t time_us,
|
|
|
|
float x,
|
|
|
|
float y,
|
|
|
|
double *axes);
|
|
|
|
|
|
|
|
void meta_seat_impl_notify_button_in_impl (MetaSeatImpl *seat_impl,
|
|
|
|
ClutterInputDevice *input_device,
|
|
|
|
uint64_t time_us,
|
|
|
|
uint32_t button,
|
|
|
|
uint32_t state);
|
|
|
|
|
|
|
|
void meta_seat_impl_notify_scroll_continuous_in_impl (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_in_impl (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_in_impl (MetaSeatImpl *seat_impl,
|
|
|
|
ClutterInputDevice *input_device,
|
|
|
|
ClutterEventType evtype,
|
|
|
|
uint64_t time_us,
|
|
|
|
int slot,
|
|
|
|
double x,
|
|
|
|
double y);
|
|
|
|
|
|
|
|
void meta_seat_impl_sync_leds_in_impl (MetaSeatImpl *seat_impl);
|
|
|
|
|
|
|
|
MetaTouchState * meta_seat_impl_acquire_touch_state_in_impl (MetaSeatImpl *seat_impl,
|
|
|
|
int seat_slot);
|
|
|
|
MetaTouchState * meta_seat_impl_lookup_touch_state_in_impl (MetaSeatImpl *seat_impl,
|
|
|
|
int seat_slot);
|
|
|
|
void meta_seat_impl_release_touch_state_in_impl (MetaSeatImpl *seat_impl,
|
|
|
|
int seat_slot);
|
|
|
|
|
|
|
|
void meta_seat_impl_update_xkb_state_in_impl (MetaSeatImpl *seat_impl);
|
2020-08-07 09:13:51 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
|
2020-11-19 19:36:19 -05:00
|
|
|
struct xkb_state * meta_seat_impl_get_xkb_state_in_impl (MetaSeatImpl *seat_impl);
|
2020-08-07 09:13:51 -04:00
|
|
|
|
2020-11-19 19:36:19 -05:00
|
|
|
void meta_seat_impl_set_keyboard_map (MetaSeatImpl *seat_impl,
|
|
|
|
struct xkb_keymap *keymap);
|
2020-08-07 09:13:51 -04:00
|
|
|
|
|
|
|
void meta_seat_impl_set_keyboard_layout_index (MetaSeatImpl *seat_impl,
|
|
|
|
xkb_layout_index_t idx);
|
|
|
|
|
2020-11-19 19:36:19 -05:00
|
|
|
void meta_seat_impl_set_keyboard_repeat_in_impl (MetaSeatImpl *seat_impl,
|
|
|
|
gboolean repeat,
|
|
|
|
uint32_t delay,
|
|
|
|
uint32_t interval);
|
2020-08-07 09:13:51 -04:00
|
|
|
|
|
|
|
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);
|
2020-11-19 19:36:19 -05:00
|
|
|
GSList * meta_seat_impl_get_devices_in_impl (MetaSeatImpl *seat_impl);
|
2020-08-07 09:13:51 -04:00
|
|
|
|
|
|
|
MetaKeymapNative * meta_seat_impl_get_keymap (MetaSeatImpl *seat_impl);
|
|
|
|
|
2020-11-19 19:36:19 -05:00
|
|
|
void meta_seat_impl_notify_kbd_a11y_flags_changed_in_impl (MetaSeatImpl *seat_impl,
|
|
|
|
MetaKeyboardA11yFlags new_flags,
|
|
|
|
MetaKeyboardA11yFlags what_changed);
|
|
|
|
void meta_seat_impl_notify_kbd_a11y_mods_state_changed_in_impl (MetaSeatImpl *seat_impl,
|
|
|
|
xkb_mod_mask_t new_latched_mods,
|
|
|
|
xkb_mod_mask_t new_locked_mods);
|
|
|
|
void meta_seat_impl_notify_bell_in_impl (MetaSeatImpl *seat_impl);
|
2020-08-11 11:11:51 -04:00
|
|
|
|
2020-08-11 12:33:07 -04:00
|
|
|
MetaInputSettings * meta_seat_impl_get_input_settings (MetaSeatImpl *seat_impl);
|
|
|
|
|
2020-08-07 09:13:51 -04:00
|
|
|
#endif /* META_SEAT_IMPL_H */
|