Protecting against potential NULL pointer dereference
[platform/upstream/at-spi2-core.git] / atspi / atspi-device.h
1 /*
2  * AT-SPI - Assistive Technology Service Provider Interface
3  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4  *
5  * Copyright 2020 SUSE LLC.
6  *           
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  */
23
24 #ifndef _ATSPI_DEVICE_H_
25 #define _ATSPI_DEVICE_H_
26
27 #include "glib-object.h"
28
29 #include "atspi-types.h"
30
31 G_BEGIN_DECLS
32
33 #define ATSPI_TYPE_DEVICE                        (atspi_device_get_type ())
34 #define ATSPI_DEVICE(obj)                        (G_TYPE_CHECK_INSTANCE_CAST ((obj), ATSPI_TYPE_DEVICE, AtspiDevice))
35 #define ATSPI_DEVICE_CLASS(klass)                (G_TYPE_CHECK_CLASS_CAST ((klass), ATSPI_TYPE_DEVICE, AtspiDeviceClass))
36 #define ATSPI_IS_DEVICE(obj)                     (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ATSPI_TYPE_DEVICE))
37 #define ATSPI_IS_DEVICE_CLASS(klass)             (G_TYPE_CHECK_CLASS_TYPE ((klass), ATSPI_TYPE_DEVICE))
38 #define ATSPI_DEVICE_GET_CLASS(obj)              (G_TYPE_INSTANCE_GET_CLASS ((obj), ATSPI_TYPE_DEVICE, AtspiDeviceClass))
39
40 typedef struct _AtspiDevice AtspiDevice;
41 struct _AtspiDevice
42 {
43   GObject parent;
44 };
45
46 typedef struct _AtspiDeviceClass AtspiDeviceClass;
47 struct _AtspiDeviceClass
48 {
49   GObjectClass parent_class;
50
51   void (*add_key_grab) (AtspiDevice *device, AtspiKeyDefinition *kd);
52   void (*remove_key_grab) (AtspiDevice *device, guint id);
53   guint (*map_modifier) (AtspiDevice *device, gint keycode);
54   void (*unmap_modifier) (AtspiDevice *device, gint keycode);
55   guint (*get_modifier) (AtspiDevice *device, gint keycode);
56   gboolean (*grab_keyboard) (AtspiDevice *device);
57   void (*ungrab_keyboard) (AtspiDevice *device);
58   guint (*get_locked_modifiers) (AtspiDevice *device);
59 };
60
61 GType atspi_device_get_type (void);
62
63 /**
64  * AtspiKeyCallback:
65  * @device: the device.
66  * @pressed: TRUE if the key is being pressed, FALSE if being released.
67  * @keycode: the hardware code for the key.
68  * @keysym: the keysym for the key.
69  * @modifiers: a bitflag indicating which key modifiers are active.
70  * @keystring: the text corresponding to the keypress.
71  * @user_data: (closure): user-supplied data
72  *
73  * A callback that will be invoked when a key is pressed.
74  */
75 typedef void (*AtspiKeyCallback) (AtspiDevice *device, gboolean pressed, guint keycode, guint keysym, guint modifiers, const gchar *keystring, void *user_data);
76
77 AtspiDevice *atspi_device_new ();
78
79 gboolean atspi_device_notify_key (AtspiDevice *device, gboolean pressed, int keycode, int keysym, gint state, gchar *text);
80
81 guint atspi_device_add_key_grab (AtspiDevice *device, AtspiKeyDefinition *kd, AtspiKeyCallback callback, void *user_data, GDestroyNotify callback_destroyed);
82
83 void atspi_device_remove_key_grab (AtspiDevice *device, guint id);
84
85 void atspi_device_add_key_watcher (AtspiDevice *device, AtspiKeyCallback callback, void *user_data, GDestroyNotify callback_destroyed);
86
87 AtspiKeyDefinition *atspi_device_get_grab_by_id (AtspiDevice *device, guint id);
88
89 guint atspi_device_map_modifier (AtspiDevice *device, gint keycode);
90
91 void atspi_device_unmap_modifier (AtspiDevice *device, gint keycode);
92
93 guint atspi_device_get_modifier (AtspiDevice *device, gint keycode);
94
95 guint atspi_device_get_locked_modifiers (AtspiDevice *device);
96
97 gboolean atspi_device_grab_keyboard (AtspiDevice *device);
98
99 void atspi_device_ungrab_keyboard (AtspiDevice *device);
100
101 G_END_DECLS
102
103 #endif  /* _ATSPI_DEVICE_H_ */