2
* Copyright (C) 2002-2006 Sergey V. Udaltsov <svu@gnome.org>
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2 of the License, or (at your option) any later version.
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Lesser General Public License for more details.
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this library; if not, write to the
16
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
* Boston, MA 02111-1307, USA.
20
#ifndef __XKL_ENGINE_H__
21
#define __XKL_ENGINE_H__
25
#include <glib-object.h>
31
typedef struct _XklEngine XklEngine;
32
typedef struct _XklEnginePrivate XklEnginePrivate;
33
typedef struct _XklEngineClass XklEngineClass;
35
#define XKL_TYPE_ENGINE (xkl_engine_get_type ())
36
#define XKL_ENGINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XKL_TYPE_ENGINE, XklEngine))
37
#define XKL_ENGINE_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), XKL_TYPE_ENGINE, XklEngineClass))
38
#define XKL_IS_ENGINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XKL_TYPE_ENGINE))
39
#define XKL_IS_ENGINE_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), XKL_TYPE_ENGINE))
40
#define XKL_ENGINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), XKL_TYPE_ENGINE, XklEngineClass))
43
* The type of the keyboard state change
44
* @GROUP_CHANGED: Group was changed
45
* @INDICATORS_CHANGED: Indicators were changed
50
} XklEngineStateChange;
53
* A set of flags used to indicate the capabilities of the active backend
54
* @XKLF_CAN_TOGGLE_INDICATORS: Backend allows to toggls indicators on/off
55
* @XKLF_CAN_OUTPUT_CONFIG_AS_ASCII: Backend allows writing ASCII representation of the configuration
56
* @XKLF_CAN_OUTPUT_CONFIG_AS_BINARY: Backend allows writing binary representation of the configuration
57
* @XKLF_MULTIPLE_LAYOUTS_SUPPORTED: Backend supports multiple layouts
58
* @XKLF_REQUIRES_MANUAL_LAYOUT_MANAGEMENT: Backend requires manual configuration, some daemon should do
59
* xkl_start_listen(engine,XKLL_MANAGE_LAYOUTS);
60
* @XKLF_DEVICE_DISCOVERY: Backend supports device discovery, can notify
63
XKLF_CAN_TOGGLE_INDICATORS = 1 << 0,
64
XKLF_CAN_OUTPUT_CONFIG_AS_ASCII = 1 << 1,
65
XKLF_CAN_OUTPUT_CONFIG_AS_BINARY = 1 << 2,
66
XKLF_MULTIPLE_LAYOUTS_SUPPORTED = 1 << 3,
67
XKLF_REQUIRES_MANUAL_LAYOUT_MANAGEMENT = 1 << 4,
68
XKLF_DEVICE_DISCOVERY = 1 << 5
72
* XKB state. Can be global or per-window
80
* set of active indicators
86
* The main Xklavier engine class
90
* The superclass object
96
XklEnginePrivate *priv;
100
* The XklEngine class, derived from GObject
102
struct _XklEngineClass {
106
GObjectClass parent_class;
109
* XklEngine::config-notify:
110
* @engine: the object on which the signal is emitted
112
* Used for notifying application of the XKB configuration change.
114
void (*config_notify) (XklEngine * engine);
117
* XklEngine::new_window_notify:
118
* @engine: the object on which the signal is emitted
120
* @parent: new window's parent
122
* Used for notifying application of new window creation (actually,
125
* Returns: the initial group id for the window (-1 to use the default value)
127
gint(*new_window_notify) (XklEngine * engine, Window win,
130
* XklEngine::state_notify
131
* @engine: the object on which the signal is emitted
132
* @change_type: mask of changes
134
* @restore: whether this state is restored from
135
* saved state of set as new.
137
* Used for notifying application of the window state change.
139
void (*state_notify) (XklEngine * engine,
140
XklEngineStateChange change_type,
141
gint group, gboolean restore);
144
* XklEngine::new_device_notify
145
* @engine: the object on which the signal is emitted
147
* Used for notifying application of the new keyboard attached
149
void (*new_device_notify) (XklEngine * engine);
155
* xkl_engine_get_type:
157
* Get type info for XklEngine
159
* Returns: GType for XklEngine
161
extern GType xkl_engine_get_type(void);
165
* xkl_engine_get_instance:
166
* @display: the X display used by the application
168
* Get the instance of the XklEngine. Within a process, there is always once instance.
170
* Returns: the singleton instance
172
extern XklEngine *xkl_engine_get_instance(Display * display);
176
* xkl_engine_get_backend_name:
177
* @engine: the engine
179
* What kind of backend is used
181
* Returns: some string id of the backend
183
extern const gchar *xkl_engine_get_backend_name(XklEngine *
187
* xkl_engine_get_features:
188
* @engine: the engine
190
* Provides information regarding available backend features
191
* (combination of XKLF_* constants)
193
* Returns: ORed XKLF_* constants
195
extern guint xkl_engine_get_features(XklEngine * engine);
198
* xkl_engine_get_max_num_groups:
199
* @engine: the engine
201
* Provides the information on maximum number of simultaneously supported
204
* Returns: maximum number of the groups in configuration,
205
* 0 if no restrictions.
207
extern guint xkl_engine_get_max_num_groups(XklEngine * engine);
210
* The listener action modes:
211
* @XKLL_MANAGE_WINDOW_STATES: The listener process should handle the per-window states
212
* and all the related activity
213
* @XKLL_TRACK_KEYBOARD_STATE: Just track the state and pass it to the application above.
214
* @XKLL_MANAGE_LAYOUTS: The listener process should help backend to maintain the configuration
215
* (manually switch layouts etc).
218
XKLL_MANAGE_WINDOW_STATES = 0x01,
219
XKLL_TRACK_KEYBOARD_STATE = 0x02,
220
XKLL_MANAGE_LAYOUTS = 0x04,
221
} XklEngineListenModes;
224
* xkl_engine_start_listen:
225
* @engine: the engine
226
* @flags: any combination of XKLL_* constants
228
* Starts listening for XKB-related events
232
extern gint xkl_engine_start_listen(XklEngine * engine,
236
* xkl_engine_stop_listen:
237
* @engine: the engine
238
* @flags: any combination of XKLL_* constants
240
* Stops listening for XKB-related events
243
extern gint xkl_engine_stop_listen(XklEngine * engine,
247
* xkl_engine_pause_listen:
248
* @engine: the engine
250
* Temporary pauses listening for XKB-related events
254
extern gint xkl_engine_pause_listen(XklEngine * engine);
257
* xkl_engine_resume_listen:
258
* @engine: the engine
260
* Resumes listening for XKB-related events
264
extern gint xkl_engine_resume_listen(XklEngine * engine);
267
* xkl_engine_grab_key:
268
* @engine: the engine
270
* @modifiers: bitmask of modifiers
274
* Returns: TRUE on success
276
extern gboolean xkl_engine_grab_key(XklEngine * engine,
277
gint keycode, guint modifiers);
280
* xkl_engine_ungrab_key:
281
* @engine: the engine
283
* @modifiers: bitmask of modifiers
287
* Returns: TRUE on success
289
extern gboolean xkl_engine_ungrab_key(XklEngine * engine,
294
* xkl_engine_filter_events:
295
* @engine: the engine
296
* @evt: delivered X event
298
* Processes X events. Should be included into the main event cycle of an
299
* application. One of the most important functions.
301
* Returns: 0 if the event it processed - 1 otherwise
303
extern gint xkl_engine_filter_events(XklEngine * engine,
307
* xkl_engine_allow_one_switch_to_secondary_group:
308
* @engine: the engine
310
* Allows to switch (once) to the secondary group
314
xkl_engine_allow_one_switch_to_secondary_group(XklEngine *
318
* xkl_engine_get_current_window:
319
* @engine: the engine
321
* Returns: currently focused window
323
extern Window xkl_engine_get_current_window(XklEngine * engine);
326
* xkl_engine_get_current_state:
327
* @engine: the engine
329
* Returns: current state of the keyboard.
330
* Returned value is a statically allocated buffer, should not be freed.
332
extern XklState *xkl_engine_get_current_state(XklEngine * engine);
335
* xkl_engine_get_window_title:
336
* @engine: the engine
339
* Returns: the window title of some window or NULL.
340
* If not NULL, it should be freed with XFree
342
extern gchar *xkl_engine_get_window_title(XklEngine * engine,
346
* xkl_engine_get_state:
347
* @engine: the engine
348
* @win: window to query
349
* @state_out: structure to store the state
351
* Finds the state for a given window (for its "App window").
353
* Returns: TRUE on success, otherwise FALSE
354
* (the error message can be obtained using xkl_GetLastError).
356
extern gboolean xkl_engine_get_state(XklEngine * engine,
358
XklState * state_out);
361
* xkl_engine_delete_state:
362
* @engine: the engine
363
* @win: target window
365
* Drops the state of a given window (of its "App window").
367
extern void xkl_engine_delete_state(XklEngine * engine,
371
* xkl_engine_save_state:
372
* @engine: the engine
373
* @win: target window
374
* @state: new state of the window
376
* Stores ths state for a given window
378
extern void xkl_engine_save_state(XklEngine * engine, Window win,
382
* xkl_engine_set_window_transparent:
383
* @engine: the engine
384
* @win: window do set the flag for.
385
* @transparent: if true, the windows is transparent.
387
* Sets the "transparent" flag. It means focus switching onto
388
* this window will never change the state.
390
extern void xkl_engine_set_window_transparent(XklEngine *
397
* xkl_engine_is_window_transparent:
398
* @engine: the engine
399
* @win: window to get the transparent flag from.
401
* Returns: TRUE if the window is "transparent"
403
extern gboolean xkl_engine_is_window_transparent(XklEngine
408
* xkl_engine_is_window_from_same_toplevel_window:
409
* @engine: the engine
410
* @win1: first window
411
* @win2: second window
413
* Checks whether 2 windows have the same topmost window
415
* Returns: TRUE is windows are in the same application
418
xkl_engine_is_window_from_same_toplevel_window(XklEngine *
424
* xkl_engine_get_num_groups:
425
* @engine: the engine
427
* Returns: the total number of groups in the current configuration
430
extern guint xkl_engine_get_num_groups(XklEngine * engine);
433
* xkl_engine_get_groups_names:
434
* @engine: the engine
436
* Returns: the array of group names for the current XKB configuration
438
* This array is static, should not be freed
440
extern const gchar **xkl_engine_get_groups_names(XklEngine *
444
* xkl_engine_get_indicators_names:
445
* @engine: the engine
447
* Returns: the array of indicator names for the current XKB configuration
449
* This array is static, should not be freed
451
extern const gchar **xkl_engine_get_indicators_names(XklEngine *
455
* xkl_engine_get_next_group:
456
* @engine: the engine
458
* Calculates next group id. Does not change the state of anything.
460
* Returns: next group id
462
extern gint xkl_engine_get_next_group(XklEngine * engine);
465
* xkl_engine_get_prev_group:
466
* @engine: the engine
468
* Calculates prev group id. Does not change the state of anything.
470
* Returns: prev group id
472
extern gint xkl_engine_get_prev_group(XklEngine * engine);
475
* xkl_engine_get_current_window_group:
476
* @engine: the engine
478
* Returns: saved group id of the current window.
480
extern gint xkl_engine_get_current_window_group(XklEngine *
484
* xkl_engine_lock_group:
485
* @engine: the engine
486
* @group: group number for locking
488
* Locks the group. Can be used after xkl_GetXXXGroup functions
490
extern void xkl_engine_lock_group(XklEngine * engine, gint group);
493
* xkl_engine_set_group_per_toplevel_window:
494
* @engine: the engine
495
* @is_global: new parameter value
497
* Sets the configuration parameter: group per application
499
extern void xkl_engine_set_group_per_toplevel_window(XklEngine *
505
* xkl_engine_is_group_per_toplevel_window:
506
* @engine: the engine
508
* Returns: the value of the parameter: group per application
510
extern gboolean xkl_engine_is_group_per_toplevel_window(XklEngine *
514
* xkl_engine_set_indicators_handling:
515
* @engine: the engine
516
* @whether_handle: new parameter value
518
* Sets the configuration parameter: perform indicators handling
520
extern void xkl_engine_set_indicators_handling(XklEngine * engine,
525
* xkl_engine_get_indicators_handling:
526
* @engine: the engine
528
* Returns: the value of the parameter: perform indicator handling
530
extern gboolean xkl_engine_get_indicators_handling(XklEngine *
534
* xkl_engine_set_secondary_groups_mask:
535
* @engine: the engine
536
* @mask: new group mask
538
* Sets the secondary groups (one bit per group).
539
* Secondary groups require explicit "allowance" for switching
541
extern void xkl_engine_set_secondary_groups_mask(XklEngine *
546
* xkl_engine_get_secondary_groups_mask:
547
* @engine: the engine
549
* Returns: the secondary group mask
551
extern guint xkl_engine_get_secondary_groups_mask(XklEngine *
555
* xkl_engine_set_default_group:
556
* @engine: the engine
557
* @group: default group
559
* Configures the default group set on window creation.
560
* If -1, no default group is used
562
extern void xkl_engine_set_default_group(XklEngine * engine,
566
* xkl_engine_get_default_group:
567
* @engine: the engine
569
* Returns the default group set on window creation
570
* If -1, no default group is used
572
* Returns: the default group
574
extern gint xkl_engine_get_default_group(XklEngine * engine);
578
#endif /* __cplusplus */