/* * 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 . * * Author: Damien Lespiau * Author: Jonas Ådahl */ #ifndef META_SEAT_NATIVE_H #define META_SEAT_NATIVE_H #include #include #include #include "backends/meta-viewport-info.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 _MetaSeatNative MetaSeatNative; typedef struct _MetaEventSource MetaEventSource; struct _MetaTouchState { MetaSeatNative *seat; int device_slot; int seat_slot; graphene_point_t coords; }; struct _MetaSeatNative { ClutterSeat parent_instance; char *seat_id; MetaEventSource *event_source; struct libinput *libinput; struct libinput_seat *libinput_seat; GSList *devices; ClutterInputDevice *core_pointer; ClutterInputDevice *core_keyboard; GHashTable *touch_states; guint virtual_touch_slot_base; 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; MetaCursorRenderer *cursor_renderer; 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; }; #define META_TYPE_SEAT_NATIVE meta_seat_native_get_type () G_DECLARE_FINAL_TYPE (MetaSeatNative, meta_seat_native, 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, struct libinput_seat *libinput_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: * @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); struct xkb_state * meta_seat_native_get_xkb_state (MetaSeatNative *seat); void meta_seat_native_set_keyboard_map (MetaSeatNative *seat, struct xkb_keymap *keymap); struct xkb_keymap * meta_seat_native_get_keyboard_map (MetaSeatNative *seat); void meta_seat_native_set_keyboard_layout_index (MetaSeatNative *seat, xkb_layout_index_t idx); xkb_layout_index_t meta_seat_native_get_keyboard_layout_index (MetaSeatNative *seat); void meta_seat_native_set_keyboard_numlock (MetaSeatNative *seat, gboolean numlock_state); void meta_seat_native_set_keyboard_repeat (MetaSeatNative *seat, gboolean repeat, uint32_t delay, uint32_t interval); void meta_seat_native_release_touch_slots (MetaSeatNative *seat, guint base_slot); MetaBarrierManagerNative * meta_seat_native_get_barrier_manager (MetaSeatNative *seat); void meta_seat_native_set_pointer_constraint (MetaSeatNative *seat, MetaPointerConstraintImpl *constraint_impl); MetaCursorRenderer * meta_seat_native_maybe_ensure_cursor_renderer (MetaSeatNative *seat, ClutterInputDevice *device); void meta_seat_native_set_viewports (MetaSeatNative *seat, MetaViewportInfo *viewports); #endif /* META_SEAT_NATIVE_H */