2.44.1
[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 #ifdef HAVE_X11
28 #include <X11/Xlib.h>
29 #endif
30 #include <dbus/dbus.h>
31
32 typedef struct _SpiDEController SpiDEController;
33
34 #include "registry.h"
35 #include "de-types.h"
36
37 G_BEGIN_DECLS
38
39 #define SPI_DEVICE_EVENT_CONTROLLER_TYPE        (spi_device_event_controller_get_type ())
40 #define SPI_DEVICE_EVENT_CONTROLLER(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_DEVICE_EVENT_CONTROLLER_TYPE, SpiDEController))
41 #define SPI_DEVICE_EVENT_CONTROLLER_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST((k), SPI_DEVICE_EVENT_CONTROLLER_TYPE, SpiDEControllerClass))
42 #define SPI_IS_DEVICE_EVENT_CONTROLLER(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), SPI_DEVICE_EVENT_CONTROLLER_TYPE))
43 #define SPI_IS_DEVICE_EVENT_CONTROLLER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SPI_DEVICE_EVENT_CONTROLLER_TYPE))
44 #define SPI_DEVICE_EVENT_CONTROLLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SPI_DEVICE_EVENT_CONTROLLER_TYPE, SpiDEControllerClass))
45
46 struct _SpiDEController {
47         GObject parent;
48         DBusConnection *bus;
49         SpiRegistry    *registry;
50         GList          *key_listeners;
51         GList          *mouse_listeners;
52         GList          *keygrabs_list;
53         GQueue *message_queue;
54         guint message_queue_idle;
55 };
56
57 typedef enum {
58   SPI_DEVICE_TYPE_KBD,
59   SPI_DEVICE_TYPE_MOUSE,
60   SPI_DEVICE_TYPE_LAST_DEFINED
61 } SpiDeviceTypeCategory;
62
63 typedef struct {
64   char *bus_name;
65   char *path;
66   SpiDeviceTypeCategory type;
67   gulong types;
68 } DEControllerListener;
69
70 typedef struct {
71   DEControllerListener listener;
72
73  GSList *keys;
74   Accessibility_ControllerEventMask mask;
75   Accessibility_EventListenerMode  *mode;       
76 } DEControllerKeyListener;
77
78 typedef struct
79 {
80   gint (*get_keycode) (SpiDEController *controller,
81                        gint keysym,
82                        gchar *key_str,
83                        gboolean fix,
84                        guint *modmask);
85
86   guint (*mouse_check) (SpiDEController *controller, 
87                         gint *x,
88                         gint *y,
89                         gboolean *moved);
90
91   gboolean (*register_global_keygrabs) (SpiDEController         *controller,
92                                         DEControllerKeyListener *key_listener);
93
94   void (*deregister_global_keygrabs) (SpiDEController         *controller,
95                                       DEControllerKeyListener *key_listener);
96
97   gboolean (*synth_keycode_press) (SpiDEController *controller,
98                                    guint keycode);
99
100   gboolean (*synth_keycode_release) (SpiDEController *controller,
101                                    guint keycode);
102
103   gboolean (*lock_modifiers) (SpiDEController *controller,
104                               unsigned modifiers);
105
106   gboolean (*unlock_modifiers) (SpiDEController *controller,
107                                 unsigned modifiers);
108
109   gboolean (*synth_keystring) (SpiDEController *controller,
110                                guint synth_type,
111                                gint keycode,
112                                const char *keystring);
113
114   gboolean (*grab_key) (SpiDEController *controller,
115                         guint key_val,
116                         Accessibility_ControllerEventMask mod_mask);
117
118   void (*ungrab_key) (SpiDEController *controller,
119                       guint key_val,
120                       Accessibility_ControllerEventMask mod_mask);
121
122   void (*emit_modifier_event) (SpiDEController *controller,
123                                guint prev_mask,
124                                guint current_mask);
125
126   void (*generate_mouse_event) (SpiDEController *controller,
127                                 gint x,
128                                 gint y,
129                                 const char *eventName);
130
131   void (*init) (SpiDEController *controller);
132   void (*finalize) (SpiDEController *controller);
133 } SpiDEControllerPlat;
134
135 typedef struct {
136   GObjectClass parent_class;
137   SpiDEControllerPlat plat;
138 } SpiDEControllerClass;
139
140 GType            spi_device_event_controller_get_type (void);
141 SpiDEController *spi_device_event_controller_new      (SpiRegistry    *registry,
142                                                        DBusConnection *bus);
143
144 gboolean spi_clear_error_state (void);
145
146 void spi_device_event_controller_start_poll_mouse (SpiRegistry *registry);
147 void spi_device_event_controller_stop_poll_mouse (void);
148
149 void spi_remove_device_listeners (SpiDEController *controller, const char *bus_name);
150
151 SpiDEController *spi_registry_dec_new (SpiRegistry *reg, DBusConnection *bus);
152
153 gboolean
154 spi_controller_notify_mouselisteners (SpiDEController                 *controller,
155                                       const Accessibility_DeviceEvent *event);
156
157 gboolean
158 spi_controller_notify_keylisteners (SpiDEController                 *controller,
159                                     Accessibility_DeviceEvent       *key_event,
160                                     dbus_bool_t                    is_system_global);
161
162 gboolean spi_controller_update_key_grabs               (SpiDEController           *controller,
163                                                                Accessibility_DeviceEvent *recv);
164
165 gboolean spi_dec_synth_keysym (SpiDEController *controller, long keysym);
166
167 void spi_dec_dbus_emit(SpiDEController *controller, const char *interface, const char *name, const char *minor, int a1, int a2);
168
169 #ifdef HAVE_X11
170 void spi_dec_setup_x11 (SpiDEControllerClass *klass);
171 #endif
172
173 long ucs2keysym (long ucs);
174 long keysym2ucs(long keysym);
175
176 G_END_DECLS
177
178 #endif /* DEVICEEVENTCONTROLLER_H_ */