2.51.90
[platform/upstream/at-spi2-core.git] / registryd / deviceeventcontroller.h
1 /*
2  * AT-SPI - Assistive Technology Service Provider Interface
3  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4  *
5  * Copyright 2001, 2002 Sun Microsystems Inc.,
6  * Copyright 2001, 2002 Ximian, Inc.
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 SPI_DEVICE_EVENT_CONTROLLER_H_
25 #define SPI_DEVICE_EVENT_CONTROLLER_H_
26
27 #include <dbus/dbus.h>
28
29 typedef struct _SpiDEController SpiDEController;
30
31 #include "de-types.h"
32 #include "registry.h"
33
34 G_BEGIN_DECLS
35
36 #define SPI_DEVICE_EVENT_CONTROLLER_TYPE (spi_device_event_controller_get_type ())
37 #define SPI_DEVICE_EVENT_CONTROLLER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_DEVICE_EVENT_CONTROLLER_TYPE, SpiDEController))
38 #define SPI_DEVICE_EVENT_CONTROLLER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), SPI_DEVICE_EVENT_CONTROLLER_TYPE, SpiDEControllerClass))
39 #define SPI_IS_DEVICE_EVENT_CONTROLLER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SPI_DEVICE_EVENT_CONTROLLER_TYPE))
40 #define SPI_IS_DEVICE_EVENT_CONTROLLER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SPI_DEVICE_EVENT_CONTROLLER_TYPE))
41 #define SPI_DEVICE_EVENT_CONTROLLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SPI_DEVICE_EVENT_CONTROLLER_TYPE, SpiDEControllerClass))
42
43 struct _SpiDEController
44 {
45   GObject parent;
46   DBusConnection *bus;
47   GList *key_listeners;
48   GList *mouse_listeners;
49   GList *keygrabs_list;
50   GQueue *message_queue;
51   guint message_queue_idle;
52
53   guint mouse_mask_state;
54   gboolean have_mouse_event_listener;
55 };
56
57 typedef enum
58 {
59   SPI_DEVICE_TYPE_KBD,
60   SPI_DEVICE_TYPE_LAST_DEFINED
61 } SpiDeviceTypeCategory;
62
63 typedef struct
64 {
65   char *bus_name;
66   char *path;
67   SpiDeviceTypeCategory type;
68   gulong types;
69 } DEControllerListener;
70
71 typedef struct
72 {
73   DEControllerListener listener;
74
75   GSList *keys;
76   Accessibility_ControllerEventMask mask;
77   Accessibility_EventListenerMode *mode;
78 } DEControllerKeyListener;
79
80 typedef struct
81 {
82   gint (*get_keycode) (SpiDEController *controller,
83                        gint keysym,
84                        gchar *key_str,
85                        gboolean fix,
86                        guint *modmask);
87
88   guint (*mouse_check) (SpiDEController *controller,
89                         gint *x,
90                         gint *y,
91                         gboolean *moved);
92
93   gboolean (*register_global_keygrabs) (SpiDEController *controller,
94                                         DEControllerKeyListener *key_listener);
95
96   void (*deregister_global_keygrabs) (SpiDEController *controller,
97                                       DEControllerKeyListener *key_listener);
98
99   gboolean (*synth_keycode_press) (SpiDEController *controller,
100                                    guint keycode);
101
102   gboolean (*synth_keycode_release) (SpiDEController *controller,
103                                      guint keycode);
104
105   gboolean (*lock_modifiers) (SpiDEController *controller,
106                               unsigned modifiers);
107
108   gboolean (*unlock_modifiers) (SpiDEController *controller,
109                                 unsigned modifiers);
110
111   gboolean (*synth_keystring) (SpiDEController *controller,
112                                guint synth_type,
113                                gint keycode,
114                                const char *keystring);
115
116   gboolean (*grab_key) (SpiDEController *controller,
117                         guint key_val,
118                         Accessibility_ControllerEventMask mod_mask);
119
120   void (*ungrab_key) (SpiDEController *controller,
121                       guint key_val,
122                       Accessibility_ControllerEventMask mod_mask);
123
124   void (*emit_modifier_event) (SpiDEController *controller,
125                                guint prev_mask,
126                                guint current_mask);
127
128   void (*generate_mouse_event) (SpiDEController *controller,
129                                 gint x,
130                                 gint y,
131                                 const char *eventName);
132
133   void (*init) (SpiDEController *controller);
134   void (*finalize) (SpiDEController *controller);
135 } SpiDEControllerPlat;
136
137 typedef struct
138 {
139   GObjectClass parent_class;
140   SpiDEControllerPlat plat;
141 } SpiDEControllerClass;
142
143 GType spi_device_event_controller_get_type (void);
144
145 void spi_device_event_controller_start_poll_mouse (SpiDEController *dec);
146 void spi_device_event_controller_stop_poll_mouse (SpiDEController *dec);
147
148 void spi_remove_device_listeners (SpiDEController *controller, const char *bus_name);
149
150 SpiDEController *spi_registry_dec_new (DBusConnection *bus);
151
152 gboolean
153 spi_controller_notify_keylisteners (SpiDEController *controller,
154                                     Accessibility_DeviceEvent *key_event,
155                                     dbus_bool_t is_system_global);
156
157 gboolean spi_controller_update_key_grabs (SpiDEController *controller,
158                                           Accessibility_DeviceEvent *recv);
159
160 gboolean spi_dec_synth_keysym (SpiDEController *controller, long keysym);
161
162 void spi_dec_dbus_emit (SpiDEController *controller, const char *interface, const char *name, const char *minor, int a1, int a2);
163
164 G_END_DECLS
165
166 #endif /* DEVICEEVENTCONTROLLER_H_ */