| 1 | /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */ |
| 2 | /* vim:set et sts=4: */ |
| 3 | /* ibus - The Input Bus |
| 4 | * Copyright (C) 2018 Takao Fujiwara <takao.fujiwara1@gmail.com> |
| 5 | * Copyright (C) 2018 Red Hat, Inc. |
| 6 | * |
| 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public |
| 9 | * License as published by the Free Software Foundation; either |
| 10 | * version 2.1 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Lesser General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public |
| 18 | * License along with this library; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
| 20 | * USA |
| 21 | */ |
| 22 | |
| 23 | #if !defined (__IBUS_H_INSIDE__) && !defined (IBUS_COMPILATION) |
| 24 | #error "Only <ibus.h> can be included directly" |
| 25 | #endif |
| 26 | |
| 27 | #ifndef __IBUS_X_EVENT_H_ |
| 28 | #define __IBUS_X_EVENT_H_ |
| 29 | |
| 30 | /** |
| 31 | * SECTION: ibusxevent |
| 32 | * @short_description: Extension Event wrapper object |
| 33 | * @title: IBusExtensionEvent |
| 34 | * @stability: Unstable |
| 35 | * |
| 36 | * An IBusXEvent provides a wrapper of XEvent. |
| 37 | * |
| 38 | * see_also: #IBusComponent, #IBusEngineDesc |
| 39 | */ |
| 40 | |
| 41 | #include "ibusserializable.h" |
| 42 | |
| 43 | /* |
| 44 | * Type macros. |
| 45 | */ |
| 46 | |
| 47 | /* define GOBJECT macros */ |
| 48 | #define IBUS_TYPE_EXTENSION_EVENT \ |
| 49 | (ibus_extension_event_get_type ()) |
| 50 | #define IBUS_EXTENSION_EVENT(obj) \ |
| 51 | (G_TYPE_CHECK_INSTANCE_CAST ((obj), \ |
| 52 | IBUS_TYPE_EXTENSION_EVENT, \ |
| 53 | IBusExtensionEvent)) |
| 54 | #define IBUS_EXTENSION_EVENT_CLASS(klass) \ |
| 55 | (G_TYPE_CHECK_CLASS_CAST ((klass), \ |
| 56 | IBUS_TYPE_EXTENSION_EVENT, \ |
| 57 | IBusExtensionEventClass)) |
| 58 | #define IBUS_IS_EXTENSION_EVENT(obj) \ |
| 59 | (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IBUS_TYPE_EXTENSION_EVENT)) |
| 60 | #define IBUS_IS_EXTENSION_EVENT_CLASS(klass) \ |
| 61 | (G_TYPE_CHECK_CLASS_TYPE ((klass), IBUS_TYPE_EXTENSION_EVENT)) |
| 62 | #define IBUS_EXTENSION_EVENT_GET_CLASS(obj) \ |
| 63 | (G_TYPE_INSTANCE_GET_CLASS ((obj), \ |
| 64 | IBUS_TYPE_EXTENSION_EVENT, \ |
| 65 | IBusExtensionEventClass)) |
| 66 | |
| 67 | #define IBUS_TYPE_X_EVENT \ |
| 68 | (ibus_x_event_get_type ()) |
| 69 | #define IBUS_X_EVENT(obj) \ |
| 70 | (G_TYPE_CHECK_INSTANCE_CAST ((obj), IBUS_TYPE_X_EVENT, IBusXEvent)) |
| 71 | #define IBUS_X_EVENT_CLASS(klass) \ |
| 72 | (G_TYPE_CHECK_CLASS_CAST ((klass), IBUS_TYPE_X_EVENT, IBusXEventClass)) |
| 73 | #define IBUS_IS_X_EVENT(obj) \ |
| 74 | (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IBUS_TYPE_X_EVENT)) |
| 75 | #define IBUS_IS_X_EVENT_CLASS(klass) \ |
| 76 | (G_TYPE_CHECK_CLASS_TYPE ((klass), IBUS_TYPE_X_EVENT)) |
| 77 | #define IBUS_X_EVENT_GET_CLASS(obj) \ |
| 78 | (G_TYPE_INSTANCE_GET_CLASS ((obj), IBUS_TYPE_X_EVENT, IBusXEventClass)) |
| 79 | |
| 80 | G_BEGIN_DECLS |
| 81 | |
| 82 | typedef struct _IBusProcessKeyEventData IBusProcessKeyEventData; |
| 83 | typedef struct _IBusExtensionEvent IBusExtensionEvent; |
| 84 | typedef struct _IBusExtensionEventClass IBusExtensionEventClass; |
| 85 | typedef struct _IBusExtensionEventPrivate IBusExtensionEventPrivate; |
| 86 | typedef struct _IBusXEvent IBusXEvent; |
| 87 | typedef struct _IBusXEventClass IBusXEventClass; |
| 88 | typedef struct _IBusXEventPrivate IBusXEventPrivate; |
| 89 | |
| 90 | /** |
| 91 | * IBusProcessKeyEventData: |
| 92 | * |
| 93 | * IBuProcessKeyEventData properties. |
| 94 | */ |
| 95 | struct _IBusProcessKeyEventData { |
| 96 | /*< public >*/ |
| 97 | guint keyval; |
| 98 | guint keycode; |
| 99 | guint state; |
| 100 | }; |
| 101 | |
| 102 | /** |
| 103 | * IBusExtensionEvent: |
| 104 | * |
| 105 | * IBusExtensionEvent properties. |
| 106 | */ |
| 107 | struct _IBusExtensionEvent { |
| 108 | /*< private >*/ |
| 109 | IBusSerializable parent; |
| 110 | IBusExtensionEventPrivate *priv; |
| 111 | |
| 112 | /* instance members */ |
| 113 | /*< public >*/ |
| 114 | }; |
| 115 | |
| 116 | struct _IBusExtensionEventClass { |
| 117 | /*< private >*/ |
| 118 | IBusSerializableClass parent; |
| 119 | |
| 120 | /* class members */ |
| 121 | /*< public >*/ |
| 122 | |
| 123 | /*< private >*/ |
| 124 | /* padding */ |
| 125 | gpointer pdummy[10]; |
| 126 | }; |
| 127 | |
| 128 | |
| 129 | GType ibus_extension_event_get_type (void); |
| 130 | |
| 131 | /** |
| 132 | * ibus_extension_event_new: |
| 133 | * @first_property_name: Name of the first property. |
| 134 | * @...: the NULL-terminated arguments of the properties and values. |
| 135 | * |
| 136 | * Create a new #IBusExtensionEvent. |
| 137 | * |
| 138 | * Returns: A newly allocated #IBusExtensionEvent. E.g. |
| 139 | * ibus_extension_event_new ("name", "emoji", "is-enabled", TRUE, NULL); |
| 140 | */ |
| 141 | IBusExtensionEvent *ibus_extension_event_new (const gchar |
| 142 | *first_property_name, |
| 143 | ...); |
| 144 | |
| 145 | /** |
| 146 | * ibus_extension_event_get_version: |
| 147 | * @event: An #IBusExtensionEvent. |
| 148 | * |
| 149 | * Returns: Version of #IBusExtensionEvent |
| 150 | */ |
| 151 | guint ibus_extension_event_get_version (IBusExtensionEvent *event); |
| 152 | |
| 153 | /** |
| 154 | * ibus_extension_event_get_purpose: |
| 155 | * @event: An #IBusExtensionEvent. |
| 156 | * |
| 157 | * Returns: name of the extension for #IBusXEvent |
| 158 | */ |
| 159 | const gchar * ibus_extension_event_get_name (IBusExtensionEvent *event); |
| 160 | |
| 161 | /** |
| 162 | * ibus_extension_event_is_enabled: |
| 163 | * @event: An #IBusExtensionEvent. |
| 164 | * |
| 165 | * Returns: %TRUE if the extension is enabled for #IBusExtensionEvent |
| 166 | */ |
| 167 | gboolean ibus_extension_event_is_enabled (IBusExtensionEvent *event); |
| 168 | |
| 169 | /** |
| 170 | * ibus_extension_event_is_extension: |
| 171 | * @event: An #IBusExtensionEvent. |
| 172 | * |
| 173 | * Returns: %TRUE if the #IBusExtensionEvent is called by an extension. |
| 174 | * %FALSE if the #IBusExtensionEvent is called by an active engine or |
| 175 | * panel. |
| 176 | * If this value is %TRUE, the event is send to ibus-daemon, an active |
| 177 | * engine. If it's %FALSE, the event is sned to ibus-daemon, panels. |
| 178 | */ |
| 179 | gboolean ibus_extension_event_is_extension |
| 180 | (IBusExtensionEvent *event); |
| 181 | |
| 182 | /** |
| 183 | * ibus_extension_event_get_params: |
| 184 | * @event: An #IBusExtensionEvent. |
| 185 | * |
| 186 | * Returns: Parameters to enable the extension for #IBusXEvent |
| 187 | */ |
| 188 | const gchar * ibus_extension_event_get_params (IBusExtensionEvent *event); |
| 189 | |
| 190 | |
| 191 | |
| 192 | typedef enum { |
| 193 | IBUS_X_EVENT_NOTHING = -1, |
| 194 | IBUS_X_EVENT_KEY_PRESS = 0, |
| 195 | IBUS_X_EVENT_KEY_RELEASE = 1, |
| 196 | IBUS_X_EVENT_OTHER = 2, |
| 197 | IBUS_X_EVENT_EVENT_LAST /* helper variable for decls */ |
| 198 | } IBusXEventType; |
| 199 | |
| 200 | /** |
| 201 | * IBusXEvent: |
| 202 | * @type: event type |
| 203 | * |
| 204 | * IBusXEvent properties. |
| 205 | */ |
| 206 | struct _IBusXEvent { |
| 207 | /*< private >*/ |
| 208 | IBusSerializable parent; |
| 209 | IBusXEventPrivate *priv; |
| 210 | |
| 211 | /* instance members */ |
| 212 | /*< public >*/ |
| 213 | IBusXEventType event_type; |
| 214 | guint window; |
| 215 | gint8 send_event; |
| 216 | gulong serial; |
| 217 | }; |
| 218 | |
| 219 | struct _IBusXEventClass { |
| 220 | /*< private >*/ |
| 221 | IBusSerializableClass parent; |
| 222 | |
| 223 | /* class members */ |
| 224 | /*< public >*/ |
| 225 | |
| 226 | /*< private >*/ |
| 227 | /* padding */ |
| 228 | gpointer pdummy[10]; |
| 229 | }; |
| 230 | |
| 231 | GType ibus_x_event_get_type (void); |
| 232 | |
| 233 | /** |
| 234 | * ibus_x_event_new: |
| 235 | * @first_property_name: Name of the first property. |
| 236 | * @...: the NULL-terminated arguments of the properties and values. |
| 237 | * |
| 238 | * Create a new #IBusXEvent. |
| 239 | * |
| 240 | * Returns: A newly allocated #IBusXEvent. E.g. |
| 241 | * ibus_x_event_new ("event-type", IBUS_X_EVENT_KEY_PRESS, NULL); |
| 242 | */ |
| 243 | IBusXEvent * ibus_x_event_new (const gchar |
| 244 | *first_property_name, |
| 245 | ...); |
| 246 | |
| 247 | /** |
| 248 | * ibus_x_event_get_version: |
| 249 | * @event: An #IBusXEvent. |
| 250 | * |
| 251 | * Returns: Version of #IBusXEvent |
| 252 | */ |
| 253 | guint ibus_x_event_get_version (IBusXEvent *event); |
| 254 | |
| 255 | /** |
| 256 | * ibus_x_event_get_event_type: |
| 257 | * @event: An #IBusXEvent. |
| 258 | * |
| 259 | * Returns: IBusXEventType of #IBusXEvent |
| 260 | */ |
| 261 | IBusXEventType ibus_x_event_get_event_type (IBusXEvent *event); |
| 262 | |
| 263 | /** |
| 264 | * ibus_x_event_get_window: |
| 265 | * @event: An #IBusXEvent. |
| 266 | * |
| 267 | * Returns: XID of #IBusXEvent |
| 268 | */ |
| 269 | guint32 ibus_x_event_get_window (IBusXEvent *event); |
| 270 | |
| 271 | /** |
| 272 | * ibus_x_event_get_send_event: |
| 273 | * @event: An #IBusXEvent. |
| 274 | * |
| 275 | * Returns: send_event of #IBusXEvent |
| 276 | */ |
| 277 | gint8 ibus_x_event_get_send_event (IBusXEvent *event); |
| 278 | |
| 279 | /** |
| 280 | * ibus_x_event_get_serial: |
| 281 | * @event: An #IBusXEvent. |
| 282 | * |
| 283 | * Returns: serial of #IBusXEvent |
| 284 | */ |
| 285 | gulong ibus_x_event_get_serial (IBusXEvent *event); |
| 286 | |
| 287 | /** |
| 288 | * ibus_x_event_get_time: |
| 289 | * @event: An #IBusXEvent. |
| 290 | * |
| 291 | * Returns: time of #IBusXEvent |
| 292 | */ |
| 293 | guint32 ibus_x_event_get_time (IBusXEvent *event); |
| 294 | |
| 295 | /** |
| 296 | * ibus_x_event_get_state: |
| 297 | * @event: An #IBusXEvent. |
| 298 | * |
| 299 | * Returns: state of #IBusXEvent |
| 300 | */ |
| 301 | guint ibus_x_event_get_state (IBusXEvent *event); |
| 302 | |
| 303 | /** |
| 304 | * ibus_x_event_get_keyval: |
| 305 | * @event: An #IBusXEvent. |
| 306 | * |
| 307 | * Returns: keyval of #IBusXEvent |
| 308 | */ |
| 309 | guint ibus_x_event_get_keyval (IBusXEvent *event); |
| 310 | |
| 311 | /** |
| 312 | * ibus_x_event_get_length: |
| 313 | * @event: An #IBusXEvent. |
| 314 | * |
| 315 | * Returns: length of #IBusXEvent |
| 316 | */ |
| 317 | gint ibus_x_event_get_length (IBusXEvent *event); |
| 318 | |
| 319 | /** |
| 320 | * ibus_x_event_get_string: |
| 321 | * @event: An #IBusXEvent. |
| 322 | * |
| 323 | * Returns: string of #IBusXEvent |
| 324 | */ |
| 325 | const gchar * ibus_x_event_get_string (IBusXEvent *event); |
| 326 | |
| 327 | /** |
| 328 | * ibus_x_event_get_hardware_keycode: |
| 329 | * @event: An #IBusXEvent. |
| 330 | * |
| 331 | * Returns: hardware keycode of #IBusXEvent |
| 332 | */ |
| 333 | guint16 ibus_x_event_get_hardware_keycode |
| 334 | (IBusXEvent *event); |
| 335 | |
| 336 | /** |
| 337 | * ibus_x_event_get_group: |
| 338 | * @event: An #IBusXEvent. |
| 339 | * |
| 340 | * Returns: group of #IBusXEvent |
| 341 | */ |
| 342 | guint8 ibus_x_event_get_group (IBusXEvent *event); |
| 343 | |
| 344 | /** |
| 345 | * ibus_x_event_get_is_modifier: |
| 346 | * @event: An #IBusXEvent. |
| 347 | * |
| 348 | * Returns: is_modifier of #IBusXEvent |
| 349 | */ |
| 350 | gboolean ibus_x_event_get_is_modifier |
| 351 | (IBusXEvent *event); |
| 352 | |
| 353 | /** |
| 354 | * ibus_x_event_get_subwindow: |
| 355 | * @event: An #IBusXEvent. |
| 356 | * |
| 357 | * Returns: subwindow of #IBusXEvent |
| 358 | */ |
| 359 | guint32 ibus_x_event_get_subwindow (IBusXEvent *event); |
| 360 | |
| 361 | /** |
| 362 | * ibus_x_event_get_root: |
| 363 | * @event: An #IBusXEvent. |
| 364 | * |
| 365 | * Returns: root window of #IBusXEvent |
| 366 | */ |
| 367 | guint32 ibus_x_event_get_root (IBusXEvent *event); |
| 368 | |
| 369 | /** |
| 370 | * ibus_x_event_get_x: |
| 371 | * @event: An #IBusXEvent. |
| 372 | * |
| 373 | * Returns: x of #IBusXEvent |
| 374 | */ |
| 375 | gint ibus_x_event_get_x (IBusXEvent *event); |
| 376 | |
| 377 | /** |
| 378 | * ibus_x_event_get_y: |
| 379 | * @event: An #IBusXEvent. |
| 380 | * |
| 381 | * Returns: y of #IBusXEvent |
| 382 | */ |
| 383 | gint ibus_x_event_get_y (IBusXEvent *event); |
| 384 | |
| 385 | /** |
| 386 | * ibus_x_event_get_x_root: |
| 387 | * @event: An #IBusXEvent. |
| 388 | * |
| 389 | * Returns: x-root of #IBusXEvent |
| 390 | */ |
| 391 | gint ibus_x_event_get_x_root (IBusXEvent *event); |
| 392 | |
| 393 | /** |
| 394 | * ibus_x_event_get_y_root: |
| 395 | * @event: An #IBusXEvent. |
| 396 | * |
| 397 | * Returns: y-root of #IBusXEvent |
| 398 | */ |
| 399 | gint ibus_x_event_get_y_root (IBusXEvent *event); |
| 400 | |
| 401 | /** |
| 402 | * ibus_x_event_get_same_screen: |
| 403 | * @event: An #IBusXEvent. |
| 404 | * |
| 405 | * Returns: same_screen of #IBusXEvent |
| 406 | */ |
| 407 | gboolean ibus_x_event_get_same_screen |
| 408 | (IBusXEvent *event); |
| 409 | |
| 410 | /** |
| 411 | * ibus_x_event_get_purpose: |
| 412 | * @event: An #IBusXEvent. |
| 413 | * |
| 414 | * Returns: purpose of #IBusXEvent |
| 415 | */ |
| 416 | const gchar * ibus_x_event_get_purpose (IBusXEvent *event); |
| 417 | |
| 418 | G_END_DECLS |
| 419 | #endif |
| 420 | |