diff options
author | Mike Gorse <mgorse@suse.com> | 2021-01-11 13:32:06 -0600 |
---|---|---|
committer | Mike Gorse <mgorse@suse.com> | 2021-01-11 13:32:06 -0600 |
commit | 7bd1ad706c92a9342e5078238ce4380e544aa967 (patch) | |
tree | f09ab765bb97dbcdd0cba047254768da7614eb02 /atspi/atspi-device.h | |
parent | befced84236ec782d3a41d8cc06ceb3fdb61ae75 (diff) | |
download | at-spi2-core-7bd1ad706c92a9342e5078238ce4380e544aa967.tar.gz |
Add device API
This is intended to replace the registry-based method for capturing
keystrokes. It is needed because gtk 4 no longer sends key notifications
in a way that atk-bridge can process them. Unlike the original API, key
grabs are separated from key notifications. Clients wishing to consume
keystrokes must proactively register a grab for the given key. Currently,
there is a backend for X11 and an unfinished legacy back end using the old
registry-based method. Hopefully, there will be a mutter/wayland back end in
the future, but we need to define a protocol there first.
Diffstat (limited to 'atspi/atspi-device.h')
-rw-r--r-- | atspi/atspi-device.h | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/atspi/atspi-device.h b/atspi/atspi-device.h new file mode 100644 index 00000000..a246842a --- /dev/null +++ b/atspi/atspi-device.h @@ -0,0 +1,103 @@ +/* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) + * + * Copyright 2020 SUSE LLC. + * + * + * 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.1 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, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef _ATSPI_DEVICE_H_ +#define _ATSPI_DEVICE_H_ + +#include "glib-object.h" + +#include "atspi-types.h" + +G_BEGIN_DECLS + +#define ATSPI_TYPE_DEVICE (atspi_device_get_type ()) +#define ATSPI_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATSPI_TYPE_DEVICE, AtspiDevice)) +#define ATSPI_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ATSPI_TYPE_DEVICE, AtspiDeviceClass)) +#define ATSPI_IS_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATSPI_TYPE_DEVICE)) +#define ATSPI_IS_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), ATSPI_TYPE_DEVICE)) +#define ATSPI_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), ATSPI_TYPE_DEVICE, AtspiDeviceClass)) + +typedef struct _AtspiDevice AtspiDevice; +struct _AtspiDevice +{ + GObject parent; +}; + +typedef struct _AtspiDeviceClass AtspiDeviceClass; +struct _AtspiDeviceClass +{ + GObjectClass parent_class; + + void (*add_key_grab) (AtspiDevice *device, AtspiKeyDefinition *kd); + void (*remove_key_grab) (AtspiDevice *device, guint id); + guint (*map_modifier) (AtspiDevice *device, gint keycode); + void (*unmap_modifier) (AtspiDevice *device, gint keycode); + guint (*get_modifier) (AtspiDevice *device, gint keycode); + gboolean (*grab_keyboard) (AtspiDevice *device); + void (*ungrab_keyboard) (AtspiDevice *device); + guint (*get_locked_modifiers) (AtspiDevice *device); +}; + +GType atspi_device_get_type (void); + +/** + * AtspiKeyCallback: + * @device: the device. + * @pressed: TRUE if the key is being pressed, FALSE if being released. + * @keycode: the hardware code for the key. + * @keysym: the keysym for the key. + * @modifiers: a bitflag indicating which key modifiers are active. + * @keystring: the text corresponding to the keypress. + * @user_data: (closure): user-supplied data + * + * A callback that will be invoked when a key is pressed. + */ +typedef void (*AtspiKeyCallback) (AtspiDevice *device, gboolean pressed, guint keycode, guint keysym, guint modifiers, const gchar *keystring, void *user_data); + +AtspiDevice *atspi_device_new (); + +gboolean atspi_device_notify_key (AtspiDevice *device, gboolean pressed, int keycode, int keysym, gint state, gchar *text); + +guint atspi_device_add_key_grab (AtspiDevice *device, AtspiKeyDefinition *kd, AtspiKeyCallback callback, void *user_data, GDestroyNotify callback_destroyed); + +void atspi_device_remove_key_grab (AtspiDevice *device, guint id); + +void atspi_device_add_key_watcher (AtspiDevice *device, AtspiKeyCallback callback, void *user_data, GDestroyNotify callback_destroyed); + +AtspiKeyDefinition *atspi_device_get_grab_by_id (AtspiDevice *device, guint id); + +guint atspi_device_map_modifier (AtspiDevice *device, gint keycode); + +void atspi_device_unmap_modifier (AtspiDevice *device, gint keycode); + +guint atspi_device_get_modifier (AtspiDevice *device, gint keycode); + +guint atspi_device_get_locked_modifiers (AtspiDevice *device); + +gboolean atspi_device_grab_keyboard (AtspiDevice *device); + +void atspi_device_ungrab_keyboard (AtspiDevice *device); + +G_END_DECLS + +#endif /* _ATSPI_DEVICE_H_ */ |