summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Udaltsov <svu@gnome.org>2006-03-02 23:18:08 +0000
committerSergey Udaltsov <svu@gnome.org>2006-03-02 23:18:08 +0000
commit248435602449c8fec408013070a7f6b21a021e76 (patch)
tree8c1c89ac5878a7bc00f4db189bce1f81acc40fb6
parent266a49bc3c94588faa5f2130414f36e0496ce75c (diff)
downloadlibxklavier-248435602449c8fec408013070a7f6b21a021e76.tar.gz
splitting the headers per-class
-rw-r--r--libxklavier/Makefile.am3
-rw-r--r--libxklavier/xkl_config_item.h121
-rw-r--r--libxklavier/xkl_config_rec.h213
-rw-r--r--libxklavier/xkl_config_registry.h235
-rw-r--r--libxklavier/xkl_engine.h479
-rw-r--r--libxklavier/xklavier.c172
-rw-r--r--libxklavier/xklavier.h467
-rw-r--r--libxklavier/xklavier_config.c47
-rw-r--r--libxklavier/xklavier_config.h519
-rw-r--r--libxklavier/xklavier_config_xkb.c18
-rw-r--r--libxklavier/xklavier_config_xmm.c7
-rw-r--r--libxklavier/xklavier_evt.c188
-rw-r--r--libxklavier/xklavier_evt_xkb.c11
-rw-r--r--libxklavier/xklavier_evt_xmm.c9
-rw-r--r--libxklavier/xklavier_private.h11
-rw-r--r--libxklavier/xklavier_props.c58
-rw-r--r--libxklavier/xklavier_toplevel.c53
-rw-r--r--libxklavier/xklavier_util.c39
-rw-r--r--libxklavier/xklavier_xkb.c81
-rwxr-xr-xlibxklavier/xklavier_xmm.c69
-rw-r--r--tests/test_config.c13
-rw-r--r--tests/test_monitor.c1
22 files changed, 1485 insertions, 1329 deletions
diff --git a/libxklavier/Makefile.am b/libxklavier/Makefile.am
index 0b27b31..68bd7cd 100644
--- a/libxklavier/Makefile.am
+++ b/libxklavier/Makefile.am
@@ -25,7 +25,8 @@ lib_LTLIBRARIES = libxklavier.la
noinst_HEADERS = xklavier_private.h xklavier_private_xkb.h xklavier_private_xmm.h
xklavierincdir = $(includedir)/libxklavier
-xklavierinc_HEADERS = xklavier.h xklavier_config.h
+xklavierinc_HEADERS = xklavier.h xkl_config_registry.h xkl_engine.h \
+ xkl_config_rec.h xkl_config_item.h
libxklavier_la_SOURCES = xklavier.c xklavier_evt.c xklavier_config.c \
xklavier_xkb.c xklavier_evt_xkb.c xklavier_config_xkb.c xklavier_toplevel.c \
diff --git a/libxklavier/xkl_config_item.h b/libxklavier/xkl_config_item.h
new file mode 100644
index 0000000..8e35bca
--- /dev/null
+++ b/libxklavier/xkl_config_item.h
@@ -0,0 +1,121 @@
+/**
+ * @file xkl_config_item.h
+ */
+
+#ifndef __XKL_CONFIG_ITEM_H__
+#define __XKL_CONFIG_ITEM_H__
+
+#include <glib-object.h>
+
+/**
+ * Maximum name length, including '\'0' character
+ */
+#define XKL_MAX_CI_NAME_LENGTH 32
+
+/**
+ * Maximum short description length, including '\\0' character.
+ * Important: this length is in bytes, so for unicode (UTF-8 encoding in
+ * XML file) the actual maximum length can be smaller.
+ */
+#define XKL_MAX_CI_SHORT_DESC_LENGTH 10
+
+/**
+ * Maximum description length, including '\\0' character.
+ * Important: this length is in bytes, so for unicode (UTF-8 encoding in
+ * XML file) the actual maximum length can be smaller.
+ */
+#define XKL_MAX_CI_DESC_LENGTH 192
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+ typedef struct _XklConfigItem XklConfigItem;
+ typedef struct _XklConfigItemClass XklConfigItemClass;
+
+#define XKL_TYPE_CONFIG_ITEM (xkl_config_item_get_type ())
+#define XKL_CONFIG_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XKL_TYPE_CONFIG_ITEM, XklConfigItem))
+#define XKL_CONFIG_ITEM_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), XKL_CONFIG_ITEM, XklConfigItemClass))
+#define XKL_IS_CONFIG_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XKL_TYPE_CONFIG_ITEM))
+#define XKL_IS_CONFIG_ITEM_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), XKL_TYPE_CONFIG_ITEM))
+#define XKL_CONFIG_ITEM_GET_CLASS (G_TYPE_INSTANCE_GET_CLASS ((obj), XKL_TYPE_CONFIG_ITEM, XklConfigItemClass))
+
+#endif // DOXYGEN_SHOULD_SKIP_THIS
+
+/**
+ * The configuration item. Corresponds to XML element "configItem".
+ */
+ struct _XklConfigItem {
+/**
+ * The superclass object
+ */
+ GObject parent;
+/**
+ * The configuration item name. Corresponds to XML element "name".
+ */
+ gchar name[XKL_MAX_CI_NAME_LENGTH];
+
+/**
+ * The configuration item short description. Corresponds to XML element "shortDescription".
+ */
+ gchar short_description[XKL_MAX_CI_DESC_LENGTH];
+
+/**
+ * The configuration item description. Corresponds to XML element "description".
+ */
+ gchar description[XKL_MAX_CI_DESC_LENGTH];
+ };
+
+/**
+ * The XklConfigItem class, derived from GObject
+ */
+ struct _XklConfigItemClass {
+ /**
+ * The superclass
+ */
+ GObjectClass parent_class;
+ };
+/**
+ * Get type info for XklConfigItem
+ * @return GType for XklConfigItem
+ */
+ extern GType xkl_config_item_get_type(void);
+
+/**
+ * Create new XklConfigItem
+ * @return new instance
+ */
+ extern XklConfigItem *xkl_config_item_new(void);
+
+/**
+ * @defgroup enum XKB configuration elements enumeration functions
+ * @{
+ */
+
+/**
+ * Callback type used for enumerating keyboard models, layouts, variants, options
+ * @param item is the item from registry
+ * @param data is anything which can be stored into the pointer
+ */
+ typedef void (*ConfigItemProcessFunc) (const XklConfigItem * item,
+ gpointer data);
+
+/**
+ * Callback type used for enumerating keyboard option groups
+ * @param item is the item from registry
+ * @param allow_multiple_selection is a flag whether this group allows multiple selection
+ * @param data is anything which can be stored into the pointer
+ */
+ typedef void (*GroupProcessFunc) (const XklConfigItem * item,
+ gboolean
+ allow_multiple_selection,
+ gpointer data);
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif
diff --git a/libxklavier/xkl_config_rec.h b/libxklavier/xkl_config_rec.h
new file mode 100644
index 0000000..1daf4dd
--- /dev/null
+++ b/libxklavier/xkl_config_rec.h
@@ -0,0 +1,213 @@
+/**
+ * @file xkl_config_rec.h
+ */
+
+#ifndef __XKL_CONFIG_REC_H__
+#define __XKL_CONFIG_REC_H__
+
+#include <glib-object.h>
+#include <libxklavier/xkl_engine.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+ typedef struct _XklConfigRec XklConfigRec;
+ typedef struct _XklConfigRecClass XklConfigRecClass;
+
+#define XKL_TYPE_CONFIG_REC (xkl_config_rec_get_type ())
+#define XKL_CONFIG_REC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XKL_TYPE_CONFIG_REC, XklConfigRec))
+#define XKL_CONFIG_REC_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), XKL_CONFIG_REC, XklConfigRecClass))
+#define XKL_IS_CONFIG_REC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XKL_TYPE_CONFIG_REC))
+#define XKL_IS_CONFIG_REC_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), XKL_TYPE_CONFIG_REC))
+#define XKL_CONFIG_REC_GET_CLASS (G_TYPE_INSTANCE_GET_CLASS ((obj), XKL_TYPE_CONFIG_REC, XklConfigRecClass))
+
+#endif // DOXYGEN_SHOULD_SKIP_THIS
+
+/**
+ * Basic configuration params
+ */
+ struct _XklConfigRec {
+/**
+ * The superclass object
+ */
+ GObject parent;
+/**
+ * The keyboard model
+ */
+ gchar *model;
+/**
+ * The array of keyboard layouts
+ */
+ gchar **layouts;
+/**
+ * The array of keyboard layout variants (if any)
+ */
+ gchar **variants;
+/**
+ * The array of keyboard layout options
+ */
+ gchar **options;
+ };
+
+/**
+ * The XklConfigRec class, derived from GObject
+ */
+ struct _XklConfigRecClass {
+ /**
+ * The superclass
+ */
+ GObjectClass parent_class;
+ };
+
+/**
+ * Get type info for XConfigRec
+ * @return GType for XConfigRec
+ */
+ extern GType xkl_config_rec_get_type(void);
+
+/**
+ * Create new XklConfigRec
+ * @return new instance
+ */
+ extern XklConfigRec *xkl_config_rec_new(void);
+
+/**
+ * @defgroup activation XKB configuration activation
+ * @{
+ */
+
+/**
+ * Activates some XKB configuration
+ * @param data is a valid XKB configuration
+ * description. Can be NULL
+ * @return TRUE on success
+ * @see XklSetKeyAsSwitcher
+ * At the moment, accepts only _ONE_ layout. Later probably I'll improve this..
+ */
+ extern gboolean xkl_config_rec_activate(const XklConfigRec * data,
+ XklEngine * engine);
+
+/**
+ * Loads the current XKB configuration (from X server)
+ * @param data is a buffer for XKB configuration
+ * @return TRUE on success
+ */
+ extern gboolean xkl_config_rec_get_from_server(XklConfigRec * data,
+ XklEngine * engine);
+
+/**
+ * Loads the current XKB configuration (from backup)
+ * @param data is a buffer for XKB configuration
+ * @return TRUE on success
+ * @see XklBackupNamesProp
+ */
+ extern gboolean xkl_config_rec_get_from_backup(XklConfigRec * data,
+ XklEngine * engine);
+
+/**
+ * Writes some XKB configuration into XKM/XKB file
+ * @param file_name is a name of the file to create
+ * @param data is a valid XKB configuration
+ * description. Can be NULL
+ * @param binary is a flag indicating whether the output file should be binary
+ * @return TRUE on success
+ */
+ extern gboolean xkl_config_rec_write_to_file(XklEngine * engine,
+ const gchar *
+ file_name,
+ const XklConfigRec *
+ data,
+ const gboolean
+ binary);
+
+/** @} */
+
+/**
+ * @defgroup props Saving and restoring XKB configuration into X root window properties
+ * Generalizes XkbRF_GetNamesProp and XkbRF_SetNamesProp.
+ * @{
+ */
+
+/**
+ * Gets the XKB configuration from any root window property
+ * @param rules_atom_name is an atom name of the root window property to read
+ * @param rules_file_out is a pointer to hold the file name
+ * @param config_out is a buffer to hold the result -
+ * all records are allocated using standard malloc
+ * @return TRUE on success
+ */
+ extern gboolean
+ xkl_config_rec_get_from_root_window_property(XklConfigRec *
+ config_out,
+ Atom
+ rules_atom_name,
+ gchar **
+ rules_file_out,
+ XklEngine *
+ engine);
+
+/**
+ * Saves the XKB configuration into any root window property
+ * @param rules_atom_name is an atom name of the root window property to write
+ * @param rules_file is a rules file name
+ * @param config is a configuration to save
+ * @return TRUE on success
+ */
+ extern gboolean xkl_config_rec_set_to_root_window_property(const
+ XklConfigRec
+ *
+ config,
+ Atom
+ rules_atom_name,
+ gchar *
+ rules_file,
+ XklEngine
+ *
+ engine);
+
+/**
+ * Backups current XKB configuration into some property -
+ * if this property is not defined yet.
+ * @return TRUE on success
+ */
+ extern gboolean xkl_backup_names_prop(XklEngine * engine);
+
+/**
+ * Restores XKB from the property saved by xkl_backup_names_prop
+ * @return TRUE on success
+ * @see xkl_backup_names_prop
+ */
+ extern gboolean xkl_restore_names_prop(XklEngine * engine);
+
+/** @} */
+
+/**
+ * @defgroup xklconfig XklConfigRec management utilities
+ * Little utilities for managing XklConfigRec.
+ * @{
+ */
+
+/**
+ * Resets the record (equal to Destroy and Init)
+ * @param data is a record to reset
+ */
+ extern void xkl_config_rec_reset(XklConfigRec * data);
+
+/**
+ * Compares the records
+ * @param data1 is a record to compare
+ * @param data2 is another record
+ * @return TRUE if records are same
+ */
+ extern gboolean xkl_config_rec_equals(XklConfigRec * data1,
+ XklConfigRec * data2);
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif
diff --git a/libxklavier/xkl_config_registry.h b/libxklavier/xkl_config_registry.h
new file mode 100644
index 0000000..b13d24b
--- /dev/null
+++ b/libxklavier/xkl_config_registry.h
@@ -0,0 +1,235 @@
+/**
+ * @file xkl_config_registry.h
+ */
+
+#ifndef __XKL_CONFIG_REGISTRY_H__
+#define __XKL_CONFIG_REGISTRY_H__
+
+#include <glib-object.h>
+#include <libxklavier/xkl_engine.h>
+#include <libxklavier/xkl_config_item.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+ typedef struct _XklConfigRegistry XklConfigRegistry;
+ typedef struct _XklConfigRegistryPrivate XklConfigRegistryPrivate;
+ typedef struct _XklConfigRegistryClass XklConfigRegistryClass;
+
+#define XKL_TYPE_CONFIG_REGISTRY (xkl_config_registry_get_type ())
+#define XKL_CONFIG_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XKL_TYPE_CONFIG_REGISTRY, XklConfigRegistry))
+#define XKL_CONFIG_REGISTRY_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), XKL_CONFIG_REGISTRY, XklConfigRegistryClass))
+#define XKL_IS_CONFIG_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XKL_TYPE_CONFIG_REGISTRY))
+#define XKL_IS_CONFIG_REGISTRY_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), XKL_TYPE_CONFIG_REGISTRY))
+#define XKL_CONFIG_REGISTRY_GET_CLASS (G_TYPE_INSTANCE_GET_CLASS ((obj), XKL_TYPE_CONFIG_REGISTRY, XklConfigRegistryClass))
+
+#endif // DOXYGEN_SHOULD_SKIP_THIS
+
+/**
+ * The configuration manager. Corresponds to XML element "configItem".
+ */
+ struct _XklConfigRegistry {
+/**
+ * The superclass object
+ */
+ GObject parent;
+
+ XklConfigRegistryPrivate *priv;
+ };
+
+/**
+ * The XklConfigRegistry class, derived from GObject
+ */
+ struct _XklConfigRegistryClass {
+ /**
+ * The superclass
+ */
+ GObjectClass parent_class;
+ };
+/**
+ * Get type info for XConfig
+ * @return GType for XConfig
+ */
+ extern GType xkl_config_registry_get_type(void);
+
+/**
+ * Create new XklConfig
+ * @return new instance
+ */
+ extern XklConfigRegistry
+ * xkl_config_registry_get_instance(XklEngine * engine);
+
+/**
+ * @defgroup xklconfiginitterm XKB configuration handling initialization and termination
+ * @{
+ */
+
+/**
+ * Loads XML configuration registry
+ * @param file_name file name to load
+ * @return true on success
+ */
+ extern gboolean
+ xkl_config_registry_load_from_file(XklConfigRegistry * config,
+ const gchar * file_name);
+
+/**
+ * Loads XML configuration registry
+ * @return true on success
+ */
+ extern gboolean xkl_config_registry_load(XklConfigRegistry *
+ config);
+
+/**
+ * Frees XML configuration registry
+ */
+ extern void xkl_config_registry_free(XklConfigRegistry * config);
+/** @} */
+
+/**
+ * @defgroup enum XKB configuration elements enumeration functions
+ * @{
+ */
+
+/**
+ * Enumerates keyboard models from the XML configuration registry
+ * @param func is a callback to call for every model
+ * @param data is anything which can be stored into the pointer
+ */
+ extern void xkl_config_registry_enum_models(XklConfigRegistry *
+ config,
+ ConfigItemProcessFunc
+ func, gpointer data);
+
+/**
+ * Enumerates keyboard layouts from the XML configuration registry
+ * @param func is a callback to call for every layout
+ * @param data is anything which can be stored into the pointer
+ */
+ extern void xkl_config_registry_enum_layouts(XklConfigRegistry *
+ config,
+ ConfigItemProcessFunc
+ func, gpointer data);
+
+/**
+ * Enumerates keyboard layout variants from the XML configuration registry
+ * @param layout_name is the layout name for which variants will be listed
+ * @param func is a callback to call for every layout variant
+ * @param data is anything which can be stored into the pointer
+ */
+ extern void
+ xkl_config_registry_enum_layout_variants(XklConfigRegistry *
+ config,
+ const gchar *
+ layout_name,
+ ConfigItemProcessFunc
+ func, gpointer data);
+
+/**
+ * Enumerates keyboard option groups from the XML configuration registry
+ * @param func is a callback to call for every option group
+ * @param data is anything which can be stored into the pointer
+ */
+ extern void
+ xkl_config_registry_enum_option_groups(XklConfigRegistry *
+ config,
+ GroupProcessFunc func,
+ gpointer data);
+
+/**
+ * Enumerates keyboard options from the XML configuration registry
+ * @param option_group_name is the option group name for which variants
+ * will be listed
+ * @param func is a callback to call for every option
+ * @param data is anything which can be stored into the pointer
+ */
+ extern void xkl_config_registry_enum_options(XklConfigRegistry *
+ config,
+ const gchar *
+ option_group_name,
+ ConfigItemProcessFunc
+ func, gpointer data);
+
+/** @} */
+
+/**
+ * @defgroup lookup XKB configuration element lookup functions
+ * @{
+ */
+
+/**
+ * Loads a keyboard model information from the XML configuration registry.
+ * @param item is a pointer to a XklConfigItem containing the name of the
+ * keyboard model. On successfull return, the descriptions are filled.
+ * @return TRUE if appropriate element was found and loaded
+ */
+ extern gboolean xkl_config_registry_find_model(XklConfigRegistry *
+ config,
+ XklConfigItem *
+ item);
+
+/**
+ * Loads a keyboard layout information from the XML configuration registry.
+ * @param item is a pointer to a XklConfigItem containing the name of the
+ * keyboard layout. On successfull return, the descriptions are filled.
+ * @return TRUE if appropriate element was found and loaded
+ */
+ extern gboolean xkl_config_registry_find_layout(XklConfigRegistry *
+ config,
+ XklConfigItem *
+ item);
+
+/**
+ * Loads a keyboard layout variant information from the XML configuration
+ * registry.
+ * @param layout_name is a name of the parent layout
+ * @param item is a pointer to a XklConfigItem containing the name of the
+ * keyboard layout variant. On successfull return, the descriptions are filled.
+ * @return TRUE if appropriate element was found and loaded
+ */
+ extern gboolean xkl_config_registry_find_variant(XklConfigRegistry
+ * config,
+ const char
+ *layout_name,
+ XklConfigItem *
+ item);
+
+/**
+ * Loads a keyboard option group information from the XML configuration
+ * registry.
+ * @param item is a pointer to a XklConfigItem containing the name of the
+ * keyboard option group. On successfull return, the descriptions are filled.
+ * @param allow_multiple_selection is a pointer to some gboolean variable to fill
+ * the corresponding attribute of XML element "group".
+ * @return TRUE if appropriate element was found and loaded
+ */
+ extern gboolean
+ xkl_config_registry_find_option_group(XklConfigRegistry *
+ config,
+ XklConfigItem * item,
+ gboolean *
+ allow_multiple_selection);
+
+/**
+ * Loads a keyboard option information from the XML configuration
+ * registry.
+ * @param option_group_name is a name of the option group
+ * @param item is a pointer to a XklConfigItem containing the name of the
+ * keyboard option. On successfull return, the descriptions are filled.
+ * @return TRUE if appropriate element was found and loaded
+ */
+ extern gboolean xkl_config_registry_find_option(XklConfigRegistry *
+ config,
+ const gchar *
+ option_group_name,
+ XklConfigItem *
+ item);
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif
diff --git a/libxklavier/xkl_engine.h b/libxklavier/xkl_engine.h
new file mode 100644
index 0000000..2211b76
--- /dev/null
+++ b/libxklavier/xkl_engine.h
@@ -0,0 +1,479 @@
+/**
+ * @file xkl_engine.h
+ */
+
+#ifndef __XKL_ENGINE_H__
+#define __XKL_ENGINE_H__
+
+#include <X11/Xlib.h>
+
+#include <glib-object.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+
+ typedef struct _XklEngine XklEngine;
+ typedef struct _XklEnginePrivate XklEnginePrivate;
+ typedef struct _XklEngineClass XklEngineClass;
+
+#define XKL_TYPE_ENGINE (xkl_engine_get_type ())
+#define XKL_ENGINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XKL_TYPE_ENGINE, XklEngine))
+#define XKL_ENGINE_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), XKL_ENGINE, XklEngineClass))
+#define XKL_IS_ENGINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XKL_TYPE_ENGINE))
+#define XKL_IS_ENGINE_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), XKL_TYPE_ENGINE))
+#define XKL_ENGINE_GET_CLASS (G_TYPE_INSTANCE_GET_CLASS ((obj), XKL_TYPE_ENGINE, XklEngineClass))
+
+#endif // DOXYGEN_SHOULD_SKIP_THIS
+
+
+ typedef enum {
+/**
+ * Group was changed
+ */
+ GROUP_CHANGED,
+/**
+ * Indicators were changed
+ */
+ INDICATORS_CHANGED
+ } XklStateChange;
+
+/**
+ * Backend allows to toggls indicators on/off
+ */
+#define XKLF_CAN_TOGGLE_INDICATORS 0x01
+
+/**
+ * Backend allows to write ascii representation of the configuration
+ */
+#define XKLF_CAN_OUTPUT_CONFIG_AS_ASCII 0x02
+
+/**
+ * Backend allows to write binary representation of the configuration
+ */
+#define XKLF_CAN_OUTPUT_CONFIG_AS_BINARY 0x04
+
+/**
+ * Backend supports multiple layouts
+ */
+#define XKLF_MULTIPLE_LAYOUTS_SUPPORTED 0x08
+
+/**
+ * Backend requires manual configuration,
+ * some daemon should do
+ * xkl_StartListen( XKLL_MANAGE_LAYOUTS );
+ */
+#define XKLF_REQUIRES_MANUAL_LAYOUT_MANAGEMENT 0x10
+
+/**
+ * XKB state. Can be global or per-window
+ */
+ typedef struct {
+/** selected group */
+ gint32 group;
+/** set of active indicators */
+ guint32 indicators;
+ } XklState;
+
+/**
+ * The main Xklavier engine class
+ */
+ struct _XklEngine {
+/**
+ * The superclass object
+ */
+ GObject parent;
+/**
+ * Private data
+ */
+ XklEnginePrivate *priv;
+ };
+
+/**
+ * The XklEngine class, derived from GObject
+ */
+ struct _XklEngineClass {
+/**
+ * The superclass
+ */
+ GObjectClass parent_class;
+
+/**
+ * Used for notifying application of the XKB configuration change.
+ */
+ void (*config_notify) (XklEngine * engine);
+
+/**
+ * Used for notifying application of new window creation (actually,
+ * registration).
+ * @param win is a new window
+ * @param parent is a new window's parent
+ * @return the initial group id for the window (-1 to use the default value)
+ */
+ gint(*new_window_notify) (XklEngine * engine, Window win,
+ Window parent);
+/**
+ * Used for notifying application of the window state change.
+ * @param changeType is a mask of changes
+ * @param group is a new group
+ * @param restore is indicator of whether this state is restored from
+ * saved state of set as new.
+ */
+ void (*state_notify) (XklEngine * engine,
+ XklStateChange changeType,
+ gint group, gboolean restore);
+
+ };
+
+
+/**
+ * Get type info for XklEngine
+ * @return GType for XklEngine
+ */
+ extern GType xkl_engine_get_type(void);
+
+
+/**
+ * Get the instance of the XklEngine. Within a process, there is always once instance
+ * @return the singleton instance
+ */
+ extern XklEngine *xkl_engine_get_instance(Display * display);
+
+
+/**
+ * What kind of backend if used
+ * @return some string id of the backend
+ */
+ extern const gchar *xkl_engine_get_backend_name(XklEngine *
+ engine);
+
+/**
+ * Provides information regarding available backend features
+ * (combination of XKLF_* constants)
+ * @return ORed XKLF_* constants
+ */
+ extern guint xkl_engine_get_features(XklEngine * engine);
+
+/**
+ * Provides the information on maximum number of simultaneously supported
+ * groups (layouts)
+ * @return maximum number of the groups in configuration,
+ * 0 if no restrictions.
+ */
+ extern unsigned xkl_engine_get_max_num_groups(XklEngine * engine);
+
+/**
+ * @defgroup xkbevents XKB event handling and management
+ * @{
+ */
+
+/**
+ * The listener process should handle the per-window states
+ * and all the related activity
+ */
+#define XKLL_MANAGE_WINDOW_STATES 0x01
+
+/**
+ * Just track the state and pass it to the application above.
+ */
+#define XKLL_TRACK_KEYBOARD_STATE 0x02
+
+/**
+ * The listener process should help backend to maintain the configuration
+ * (manually switch layouts etc).
+ */
+#define XKLL_MANAGE_LAYOUTS 0x04
+
+/**
+ * Starts listening for XKB-related events
+ * @param what any combination of XKLL_* constants
+ * @return 0
+ */
+ extern gint xkl_engine_start_listen(XklEngine * engine,
+ guint what);
+
+/**
+ * Stops listening for XKB-related events
+ * @return 0
+ */
+ extern gint xkl_engine_stop_listen(XklEngine * engine);
+
+/**
+ * Temporary pauses listening for XKB-related events
+ * @return 0
+ */
+ extern gint xkl_engine_pause_listen(XklEngine * engine);
+
+/**
+ * Resumes listening for XKB-related events
+ * @return 0
+ */
+ extern gint xkl_engine_resume_listen(XklEngine * engine);
+
+/**
+ * Grabs some key
+ * @param keycode is a keycode
+ * @param modifiers is a bitmask of modifiers
+ * @return True on success
+ */
+ extern gboolean xkl_engine_grab_key(XklEngine * engine,
+ gint keycode,
+ unsigned modifiers);
+
+/**
+ * Ungrabs some key
+ * @param keycode is a keycode
+ * @param modifiers is a bitmask of modifiers
+ * @return True on success
+ */
+ extern gboolean xkl_engine_ungrab_key(XklEngine * engine,
+ gint keycode,
+ unsigned modifiers);
+
+/**
+ * Processes X events. Should be included into the main event cycle of an
+ * application. One of the most important functions.
+ * @param evt is delivered X event
+ * @return 0 if the event it processed - 1 otherwise
+ * @see xkl_StartListen
+ */
+ extern gint xkl_engine_filter_events(XklEngine * engine,
+ XEvent * evt);
+
+/**
+ * Allows to switch (once) to the secondary group
+ */
+ extern void
+ xkl_engine_allow_one_switch_to_secondary_group(XklEngine *
+ engine);
+
+/** @} */
+
+/**
+ * @defgroup currents Current state of the library
+ * @{
+ */
+
+/**
+ * @return currently focused window
+ */
+ extern Window xkl_engine_get_current_window(XklEngine * engine);
+
+/**
+ * @return current state of the keyboard (in XKB terms).
+ * Returned value is a statically allocated buffer, should not be freed.
+ */
+ extern XklState *xkl_engine_get_current_state(XklEngine * engine);
+
+/** @} */
+
+/**
+ * @defgroup wininfo Per-window information
+ * @{
+ */
+
+/**
+ * @return the window title of some window or NULL.
+ * If not NULL, it should be freed with XFree
+ */
+ extern gchar *xkl_engine_get_window_title(XklEngine * engine,
+ Window w);
+
+/**
+ * Finds the state for a given window (for its "App window").
+ * @param win is a target window
+ * @param state_out is a structure to store the state
+ * @return True on success, otherwise False
+ * (the error message can be obtained using xkl_GetLastError).
+ */
+ extern gboolean xkl_engine_get_state(XklEngine * engine,
+ Window win,
+ XklState * state_out);
+
+/**
+ * Drops the state of a given window (of its "App window").
+ * @param win is a target window
+ */
+ extern void xkl_engine_delete_state(XklEngine * engine,
+ Window win);
+
+/**
+ * Stores ths state for a given window
+ * @param win is a target window
+ * @param state is a new state of the window
+ */
+ extern void xkl_engine_save_state(XklEngine * engine, Window win,
+ XklState * state);
+
+/**
+ * Sets the "transparent" flag. It means focus switching onto
+ * this window will never change the state.
+ * @param win is the window do set the flag for.
+ * @param transparent - if true, the windows is transparent.
+ * @see xkl_IsTranspatent
+ */
+ extern void xkl_engine_set_window_transparent(XklEngine * engine,
+ Window win,
+ gboolean
+ transparent);
+
+/**
+ * Returns "transparent" flag.
+ * @param win is the window to get the transparent flag from.
+ * @see xkl_SetTranspatent
+ */
+ extern gboolean xkl_engine_is_window_transparent(XklEngine *
+ engine,
+ Window win);
+
+/**
+ * Checks whether 2 windows have the same topmost window
+ * @param win1 is first window
+ * @param win2 is second window
+ * @return True is windows are in the same application
+ */
+ extern gboolean
+ xkl_engine_is_window_from_same_toplevel_window(XklEngine *
+ engine,
+ Window win1,
+ Window win2);
+
+/** @} */
+
+/**
+ * @defgroup xkbinfo Various XKB configuration info
+ * @{
+ */
+
+/**
+ * @return the total number of groups in the current XKB configuration
+ * (keyboard)
+ */
+ extern unsigned xkl_engine_get_num_groups(XklEngine * engine);
+
+/**
+ * @return the array of group names for the current XKB configuration
+ * (keyboard).
+ * This array is static, should not be freed
+ */
+ extern const gchar **xkl_engine_get_groups_names(XklEngine *
+ engine);
+
+/**
+ * @return the array of indicator names for the current XKB configuration
+ * (keyboard).
+ * This array is static, should not be freed
+ */
+ extern const gchar **xkl_engine_get_indicators_names(XklEngine *
+ engine);
+
+/** @} */
+
+/**
+ * @defgroup xkbgroup XKB group calculation and change
+ * @{
+ */
+
+/**
+ * Calculates next group id. Does not change the state of anything.
+ * @return next group id
+ */
+ extern gint xkl_engine_get_next_group(XklEngine * engine);
+
+/**
+ * Calculates prev group id. Does not change the state of anything.
+ * @return prev group id
+ */
+ extern gint xkl_engine_get_prev_group(XklEngine * engine);
+
+/**
+ * @return saved group id of the current window.
+ * Does not change the state of anything.
+ */
+ extern gint xkl_engine_get_current_window_group(XklEngine *
+ engine);
+
+/**
+ * Locks the group. Can be used after xkl_GetXXXGroup functions
+ * @param group is a group number for locking
+ * @see xkl_GetNextGroup
+ * @see xkl_GetPrevGroup
+ * @see xkl_GetRestoreGroup
+ */
+ extern void xkl_engine_lock_group(XklEngine * engine, gint group);
+
+/** @} */
+
+/**
+ * @defgroup settings Settings for event processing
+ * @{
+ */
+
+/**
+ * Sets the configuration parameter: group per application
+ * @param isGlobal is a new parameter value
+ */
+ extern void xkl_engine_set_group_per_toplevel_window(XklEngine *
+ engine,
+ gboolean
+ isGlobal);
+
+/**
+ * @return the value of the parameter: group per application
+ */
+ extern gboolean xkl_engine_is_group_per_toplevel_window(XklEngine *
+ engine);
+
+/**
+ * Sets the configuration parameter: perform indicators handling
+ * @param whetherHandle is a new parameter value
+ */
+ extern void xkl_engine_set_indicators_handling(XklEngine * engine,
+ gboolean
+ whetherHandle);
+
+/**
+ * @return the value of the parameter: perform indicator handling
+ */
+ extern gboolean xkl_engine_get_indicators_handling(XklEngine *
+ engine);
+
+/**
+ * Sets the secondary groups (one bit per group).
+ * Secondary groups require explicit "allowance" for switching
+ * @param mask is a new group mask
+ * @see xkl_allow_one_switch_to_secondary_group
+ */
+ extern void xkl_engine_set_secondary_groups_mask(XklEngine *
+ engine,
+ guint mask);
+
+/**
+ * @return the secondary group mask
+ */
+ extern guint xkl_engine_get_secondary_groups_mask(XklEngine *
+ engine);
+
+/**
+ * Configures the default group set on window creation.
+ * If -1, no default group is used
+ * @param group the default group
+ */
+ extern void xkl_engine_group_set_default(XklEngine * engine,
+ gint group);
+
+/**
+ * Returns the default group set on window creation
+ * If -1, no default group is used
+ * @return the default group
+ */
+ extern gint xkl_engine_group_get_default(XklEngine * engine);
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif
diff --git a/libxklavier/xklavier.c b/libxklavier/xklavier.c
index 74b0011..0857c99 100644
--- a/libxklavier/xklavier.c
+++ b/libxklavier/xklavier.c
@@ -15,18 +15,19 @@ gint xkl_debug_level = 0;
static XklLogAppender log_appender = xkl_default_log_appender;
+const gchar *xkl_last_error_message;
void
xkl_engine_set_indicators_handling(XklEngine * engine,
gboolean whether_handle)
{
- engine->priv->handle_indicators = whether_handle;
+ xkl_engine_priv(engine, handle_indicators) = whether_handle;
}
gboolean
xkl_engine_get_indicators_handling(XklEngine * engine)
{
- return engine->priv->handle_indicators;
+ return xkl_engine_priv(engine, handle_indicators);
}
void
@@ -39,13 +40,13 @@ void
xkl_engine_set_group_per_toplevel_window(XklEngine * engine,
gboolean is_set)
{
- engine->priv->group_per_toplevel_window = is_set;
+ xkl_engine_priv(engine, group_per_toplevel_window) = is_set;
}
gboolean
xkl_engine_is_group_per_toplevel_window(XklEngine * engine)
{
- return engine->priv->group_per_toplevel_window;
+ return xkl_engine_priv(engine, group_per_toplevel_window);
}
static void
@@ -54,8 +55,9 @@ xkl_engine_set_switch_to_secondary_group(XklEngine * engine, gboolean val)
CARD32 propval = (CARD32) val;
Display *dpy = xkl_engine_get_display(engine);
XChangeProperty(dpy,
- engine->priv->root_window,
- engine->priv->atoms[XKLAVIER_ALLOW_SECONDARY],
+ xkl_engine_priv(engine, root_window),
+ xkl_engine_priv(engine,
+ atoms)[XKLAVIER_ALLOW_SECONDARY],
XA_INTEGER, 32, PropModeReplace,
(unsigned char *) &propval, 1);
XSync(dpy, False);
@@ -82,12 +84,11 @@ xkl_engine_is_one_switch_to_secondary_group_allowed(XklEngine * engine)
result =
XGetWindowProperty(xkl_engine_get_display(engine),
- engine->priv->root_window,
- engine->priv->
- atoms[XKLAVIER_ALLOW_SECONDARY], 0L, 1L,
- False, XA_INTEGER, &actual_type,
- &actual_format, &actual_items,
- &bytes_remaining, &propval);
+ xkl_engine_priv(engine, root_window),
+ xkl_engine_priv(engine, atoms)
+ [XKLAVIER_ALLOW_SECONDARY], 0L, 1L, False,
+ XA_INTEGER, &actual_type, &actual_format,
+ &actual_items, &bytes_remaining, &propval);
if (Success == result) {
if (actual_format == 32 && actual_items == 1) {
@@ -110,25 +111,25 @@ xkl_engine_one_switch_to_secondary_group_performed(XklEngine * engine)
void
xkl_engine_set_default_group(XklEngine * engine, gint group)
{
- engine->priv->default_group = group;
+ xkl_engine_priv(engine, default_group) = group;
}
gint
xkl_engine_get_default_group(XklEngine * engine)
{
- return engine->priv->default_group;
+ return xkl_engine_priv(engine, default_group);
}
void
xkl_engine_set_secondary_groups_mask(XklEngine * engine, guint mask)
{
- engine->priv->secondary_groups_mask = mask;
+ xkl_engine_priv(engine, secondary_groups_mask) = mask;
}
guint
xkl_engine_get_secondary_groups_mask(XklEngine * engine)
{
- return engine->priv->secondary_groups_mask;
+ return xkl_engine_priv(engine, secondary_groups_mask);
}
void
@@ -140,11 +141,11 @@ xkl_set_log_appender(XklLogAppender func)
gint
xkl_engine_start_listen(XklEngine * engine, guint what)
{
- engine->priv->listener_type = what;
+ xkl_engine_priv(engine, listener_type) = what;
if (!
- (engine->priv->
- features & XKLF_REQUIRES_MANUAL_LAYOUT_MANAGEMENT)
+ (xkl_engine_priv(engine, features) &
+ XKLF_REQUIRES_MANUAL_LAYOUT_MANAGEMENT)
&& (what & XKLL_MANAGE_LAYOUTS))
xkl_debug(0,
"The backend does not require manual layout management - "
@@ -178,31 +179,31 @@ xkl_engine_get_instance(Display * display)
the_engine = XKL_ENGINE(g_object_new(xkl_engine_get_type(), NULL));
- the_engine->priv->display = display;
+ xkl_engine_priv(the_engine, display) = display;
int scr;
- the_engine->priv->default_error_handler =
+ xkl_engine_priv(the_engine, default_error_handler) =
XSetErrorHandler((XErrorHandler) xkl_process_error);
Display *dpy = xkl_engine_get_display(the_engine);
scr = DefaultScreen(dpy);
- the_engine->priv->root_window = RootWindow(dpy, scr);
+ xkl_engine_priv(the_engine, root_window) = RootWindow(dpy, scr);
- the_engine->priv->skip_one_restore = FALSE;
- the_engine->priv->default_group = -1;
- the_engine->priv->secondary_groups_mask = 0L;
- the_engine->priv->prev_toplvl_win = 0;
+ xkl_engine_priv(the_engine, skip_one_restore) = FALSE;
+ xkl_engine_priv(the_engine, default_group) = -1;
+ xkl_engine_priv(the_engine, secondary_groups_mask) = 0L;
+ xkl_engine_priv(the_engine, prev_toplvl_win) = 0;
- the_engine->priv->atoms[WM_NAME] =
+ xkl_engine_priv(the_engine, atoms)[WM_NAME] =
XInternAtom(dpy, "WM_NAME", False);
- the_engine->priv->atoms[WM_STATE] =
+ xkl_engine_priv(the_engine, atoms)[WM_STATE] =
XInternAtom(dpy, "WM_STATE", False);
- the_engine->priv->atoms[XKLAVIER_STATE] =
+ xkl_engine_priv(the_engine, atoms)[XKLAVIER_STATE] =
XInternAtom(dpy, "XKLAVIER_STATE", False);
- the_engine->priv->atoms[XKLAVIER_TRANSPARENT] =
+ xkl_engine_priv(the_engine, atoms)[XKLAVIER_TRANSPARENT] =
XInternAtom(dpy, "XKLAVIER_TRANSPARENT", False);
- the_engine->priv->atoms[XKLAVIER_ALLOW_SECONDARY] =
+ xkl_engine_priv(the_engine, atoms)[XKLAVIER_ALLOW_SECONDARY] =
XInternAtom(dpy, "XKLAVIER_ALLOW_SECONDARY", False);
xkl_engine_one_switch_to_secondary_group_performed(the_engine);
@@ -230,7 +231,7 @@ xkl_engine_get_instance(Display * display)
xkl_engine_get_backend_name(the_engine));
} else {
xkl_debug(0, "All backends failed, last result: %d\n", rv);
- the_engine->priv->display = NULL;
+ xkl_engine_priv(the_engine, display) = NULL;
g_object_unref(G_OBJECT(the_engine));
the_engine = NULL;
return NULL;
@@ -261,21 +262,21 @@ xkl_engine_grab_key(XklEngine * engine, gint keycode, guint modifiers)
if (0 == keycode)
return FALSE;
- engine->priv->last_error_code = Success;
+ xkl_engine_priv(engine, last_error_code) = Success;
ret_code =
- XGrabKey(dpy, keycode, modifiers, engine->priv->root_window,
- TRUE, GrabModeAsync, GrabModeAsync);
+ XGrabKey(dpy, keycode, modifiers,
+ xkl_engine_priv(engine, root_window), TRUE,
+ GrabModeAsync, GrabModeAsync);
XSync(dpy, False);
xkl_debug(100, "XGrabKey recode %d/error %d\n",
- ret_code, engine->priv->last_error_code);
+ ret_code, xkl_engine_priv(engine, last_error_code));
- ret_code = (engine->priv->last_error_code == Success);
+ ret_code = (xkl_engine_priv(engine, last_error_code) == Success);
if (!ret_code)
- engine->priv->last_error_message =
- "Could not grab the key";
+ xkl_last_error_message = "Could not grab the key";
return ret_code;
}
@@ -288,40 +289,43 @@ xkl_engine_ungrab_key(XklEngine * engine, gint keycode, guint modifiers)
return Success == XUngrabKey(xkl_engine_get_display(engine),
keycode, 0,
- engine->priv->root_window);
+ xkl_engine_priv(engine, root_window));
}
gint
xkl_engine_get_next_group(XklEngine * engine)
{
gint n = xkl_engine_get_num_groups(engine);
- return (engine->priv->curr_state.group + 1) % n;
+ return (xkl_engine_priv(engine, curr_state).group + 1) % n;
}
gint
xkl_engine_get_prev_group(XklEngine * engine)
{
gint n = xkl_engine_get_num_groups(engine);
- return (engine->priv->curr_state.group + n - 1) % n;
+ return (xkl_engine_priv(engine, curr_state).group + n - 1) % n;
}
gint
xkl_engine_get_current_window_group(XklEngine * engine)
{
XklState state;
- if (engine->priv->curr_toplvl_win == (Window) NULL) {
+ if (xkl_engine_priv(engine, curr_toplvl_win) == (Window) NULL) {
xkl_debug(150, "cannot restore without current client\n");
} else
if (xkl_engine_get_toplevel_window_state
- (engine, engine->priv->curr_toplvl_win, &state)) {
+ (engine, xkl_engine_priv(engine, curr_toplvl_win),
+ &state)) {
return state.group;
} else
xkl_debug(150,
"Unbelievable: current client " WINID_FORMAT
", '%s' has no group\n",
- engine->priv->curr_toplvl_win,
- xkl_get_debug_window_title(engine, engine->priv->
- curr_toplvl_win));
+ xkl_engine_priv(engine, curr_toplvl_win),
+ xkl_get_debug_window_title(engine,
+ xkl_engine_priv
+ (engine,
+ curr_toplvl_win)));
return 0;
}
@@ -365,11 +369,14 @@ xkl_engine_load_window_tree(XklEngine * engine)
int revert;
gboolean retval = TRUE, have_toplevel_win;
- if (engine->priv->listener_type & XKLL_MANAGE_WINDOW_STATES)
+ if (xkl_engine_priv(engine, listener_type) &
+ XKLL_MANAGE_WINDOW_STATES)
retval =
xkl_engine_load_subtree(engine,
- engine->priv->root_window, 0,
- &engine->priv->curr_state);
+ xkl_engine_priv(engine,
+ root_window),
+ 0, &xkl_engine_priv(engine,
+ curr_state));
XGetInputFocus(xkl_engine_get_display(engine), &focused, &revert);
@@ -378,27 +385,32 @@ xkl_engine_load_window_tree(XklEngine * engine)
have_toplevel_win =
xkl_engine_find_toplevel_window(engine, focused,
- &engine->priv->
- curr_toplvl_win);
+ &xkl_engine_priv(engine,
+ curr_toplvl_win));
if (have_toplevel_win) {
gboolean have_state =
xkl_engine_get_toplevel_window_state(engine,
- engine->priv->
- curr_toplvl_win,
- &engine->priv->
- curr_state);
+ xkl_engine_priv
+ (engine,
+ curr_toplvl_win),
+ &xkl_engine_priv
+ (engine,
+ curr_state));
xkl_debug(160,
"initial toplevel: " WINID_FORMAT
", '%s' %s state %d/%X\n",
- engine->priv->curr_toplvl_win,
- xkl_get_debug_window_title(engine, engine->priv->
- curr_toplvl_win),
+ xkl_engine_priv(engine, curr_toplvl_win),
+ xkl_get_debug_window_title(engine,
+ xkl_engine_priv
+ (engine,
+ curr_toplvl_win)),
(have_state ? "with" : "without"),
- (have_state ? engine->priv->curr_state.
- group : -1),
- (have_state ? engine->priv->curr_state.
- indicators : -1));
+ (have_state ?
+ xkl_engine_priv(engine, curr_state).group : -1),
+ (have_state ?
+ xkl_engine_priv(engine,
+ curr_state).indicators : -1));
} else {
xkl_debug(160,
"Could not find initial app. "
@@ -440,7 +452,7 @@ xkl_default_log_appender(const gchar file[], const gchar function[],
void
xkl_engine_select_input(XklEngine * engine, Window win, gulong mask)
{
- if (engine->priv->root_window == win)
+ if (xkl_engine_priv(engine, root_window) == win)
xkl_debug(160,
"Someone is looking for %lx on root window ***\n",
mask);
@@ -469,19 +481,20 @@ xkl_engine_try_call_state_func(XklEngine * engine,
XklStateChange change_type,
XklState * old_state)
{
- gint group = engine->priv->curr_state.group;
+ gint group = xkl_engine_priv(engine, curr_state).group;
gboolean restore = old_state->group == group;
xkl_debug(150,
"change_type: %d, group: %d, secondary_group_mask: %X, allowsecondary: %d\n",
- change_type, group, engine->priv->secondary_groups_mask,
+ change_type, group, xkl_engine_priv(engine,
+ secondary_groups_mask),
xkl_engine_is_one_switch_to_secondary_group_allowed
(engine));
if (change_type == GROUP_CHANGED) {
if (!restore) {
- if ((engine->priv->
- secondary_groups_mask & (1 << group)) != 0
+ if ((xkl_engine_priv(engine, secondary_groups_mask)
+ & (1 << group)) != 0
&&
!xkl_engine_is_one_switch_to_secondary_group_allowed
(engine)) {
@@ -508,7 +521,7 @@ void
xkl_engine_ensure_vtable_inited(XklEngine * engine)
{
char *p;
- if (engine->priv->backend_id == NULL) {
+ if (xkl_engine_priv(engine, backend_id) == NULL) {
xkl_debug(0, "ERROR: XKL VTable is NOT initialized.\n");
/* force the crash! */
p = NULL;
@@ -519,13 +532,13 @@ xkl_engine_ensure_vtable_inited(XklEngine * engine)
const gchar *
xkl_engine_get_backend_name(XklEngine * engine)
{
- return engine->priv->backend_id;
+ return xkl_engine_priv(engine, backend_id);
}
guint
xkl_engine_get_features(XklEngine * engine)
{
- return engine->priv->features;
+ return xkl_engine_priv(engine, features);
}
void
@@ -550,14 +563,14 @@ const gchar **
xkl_engine_groups_get_names(XklEngine * engine)
{
xkl_engine_ensure_vtable_inited(engine);
- return (*engine->priv->get_groups_names) (engine);
+ return xkl_engine_vcall(engine, get_groups_names) (engine);
}
guint
xkl_engine_get_num_groups(XklEngine * engine)
{
xkl_engine_ensure_vtable_inited(engine);
- return (*engine->priv->get_num_groups) (engine);
+ return xkl_engine_vcall(engine, get_num_groups) (engine);
}
void
@@ -578,11 +591,14 @@ gint
xkl_engine_resume_listen(XklEngine * engine)
{
xkl_engine_ensure_vtable_inited(engine);
- xkl_debug(150, "listenerType: %x\n", engine->priv->listener_type);
+ xkl_debug(150, "listenerType: %x\n",
+ xkl_engine_priv(engine, listener_type));
if (xkl_engine_vcall(engine, resume_listen) (engine))
return 1;
- xkl_engine_select_input_merging(engine, engine->priv->root_window,
+ xkl_engine_select_input_merging(engine,
+ xkl_engine_priv(engine,
+ root_window),
SubstructureNotifyMask |
PropertyChangeMask);
@@ -611,7 +627,7 @@ guint
xkl_engine_get_max_num_groups(XklEngine * engine)
{
xkl_engine_ensure_vtable_inited(engine);
- return (*engine->priv->get_max_num_groups) (engine);
+ return xkl_engine_vcall(engine, get_max_num_groups) (engine);
}
XklEngine *
@@ -633,8 +649,8 @@ xkl_engine_finalize(GObject * obj)
{
XklEngine *engine = (XklEngine *) obj;
- XSetErrorHandler((XErrorHandler) engine->priv->
- default_error_handler);
+ XSetErrorHandler((XErrorHandler)
+ xkl_engine_priv(engine, default_error_handler));
xkl_engine_free_all_info(engine);
diff --git a/libxklavier/xklavier.h b/libxklavier/xklavier.h
index dfe3dfe..b9a6a55 100644
--- a/libxklavier/xklavier.h
+++ b/libxklavier/xklavier.h
@@ -11,470 +11,15 @@
#include <glib-object.h>
+#include <libxklavier/xkl_engine.h>
+#include <libxklavier/xkl_config_rec.h>
+#include <libxklavier/xkl_config_item.h>
+#include <libxklavier/xkl_config_registry.h>
+
#ifdef __cplusplus
extern "C" {
#endif
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
-
- typedef struct _XklEngine XklEngine;
- typedef struct _XklEnginePrivate XklEnginePrivate;
- typedef struct _XklEngineClass XklEngineClass;
-
-#define XKL_TYPE_ENGINE (xkl_engine_get_type ())
-#define XKL_ENGINE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XKL_TYPE_ENGINE, XklEngine))
-#define XKL_ENGINE_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), XKL_ENGINE, XklEngineClass))
-#define XKL_IS_ENGINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XKL_TYPE_ENGINE))
-#define XKL_IS_ENGINE_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), XKL_TYPE_ENGINE))
-#define XKL_ENGINE_GET_CLASS (G_TYPE_INSTANCE_GET_CLASS ((obj), XKL_TYPE_ENGINE, XklEngineClass))
-
-#endif // DOXYGEN_SHOULD_SKIP_THIS
-
-
- typedef enum {
-/**
- * Group was changed
- */
- GROUP_CHANGED,
-/**
- * Indicators were changed
- */
- INDICATORS_CHANGED
- } XklStateChange;
-
-/**
- * Backend allows to toggls indicators on/off
- */
-#define XKLF_CAN_TOGGLE_INDICATORS 0x01
-
-/**
- * Backend allows to write ascii representation of the configuration
- */
-#define XKLF_CAN_OUTPUT_CONFIG_AS_ASCII 0x02
-
-/**
- * Backend allows to write binary representation of the configuration
- */
-#define XKLF_CAN_OUTPUT_CONFIG_AS_BINARY 0x04
-
-/**
- * Backend supports multiple layouts
- */
-#define XKLF_MULTIPLE_LAYOUTS_SUPPORTED 0x08
-
-/**
- * Backend requires manual configuration,
- * some daemon should do
- * xkl_StartListen( XKLL_MANAGE_LAYOUTS );
- */
-#define XKLF_REQUIRES_MANUAL_LAYOUT_MANAGEMENT 0x10
-
-/**
- * XKB state. Can be global or per-window
- */
- typedef struct {
-/** selected group */
- gint32 group;
-/** set of active indicators */
- guint32 indicators;
- } XklState;
-
-/**
- * The main Xklavier engine class
- */
- struct _XklEngine {
-/**
- * The superclass object
- */
- GObject parent;
-/**
- * Private data
- */
- XklEnginePrivate *priv;
- };
-
-/**
- * The XklEngine class, derived from GObject
- */
- struct _XklEngineClass {
-/**
- * The superclass
- */
- GObjectClass parent_class;
-
-/**
- * Used for notifying application of the XKB configuration change.
- */
- void (*config_notify) (XklEngine * engine);
-
-/**
- * Used for notifying application of new window creation (actually,
- * registration).
- * @param win is a new window
- * @param parent is a new window's parent
- * @return the initial group id for the window (-1 to use the default value)
- */
- gint(*new_window_notify) (XklEngine * engine, Window win,
- Window parent);
-/**
- * Used for notifying application of the window state change.
- * @param changeType is a mask of changes
- * @param group is a new group
- * @param restore is indicator of whether this state is restored from
- * saved state of set as new.
- */
- void (*state_notify) (XklEngine * engine,
- XklStateChange changeType,
- gint group, gboolean restore);
-
- };
-
-
-/**
- * Get type info for XklEngine
- * @return GType for XklEngine
- */
- extern GType xkl_engine_get_type(void);
-
-
-/**
- * Get the instance of the XklEngine. Within a process, there is always once instance
- * @return the singleton instance
- */
- extern XklEngine *xkl_engine_get_instance(Display * display);
-
-
-/**
- * What kind of backend if used
- * @return some string id of the backend
- */
- extern const gchar *xkl_engine_get_backend_name(XklEngine *
- engine);
-
-/**
- * Provides information regarding available backend features
- * (combination of XKLF_* constants)
- * @return ORed XKLF_* constants
- */
- extern guint xkl_engine_get_features(XklEngine * engine);
-
-/**
- * Provides the information on maximum number of simultaneously supported
- * groups (layouts)
- * @return maximum number of the groups in configuration,
- * 0 if no restrictions.
- */
- extern unsigned xkl_engine_get_max_num_groups(XklEngine * engine);
-
-/**
- * @defgroup xkbevents XKB event handling and management
- * @{
- */
-
-/**
- * The listener process should handle the per-window states
- * and all the related activity
- */
-#define XKLL_MANAGE_WINDOW_STATES 0x01
-
-/**
- * Just track the state and pass it to the application above.
- */
-#define XKLL_TRACK_KEYBOARD_STATE 0x02
-
-/**
- * The listener process should help backend to maintain the configuration
- * (manually switch layouts etc).
- */
-#define XKLL_MANAGE_LAYOUTS 0x04
-
-/**
- * Starts listening for XKB-related events
- * @param what any combination of XKLL_* constants
- * @return 0
- */
- extern gint xkl_engine_start_listen(XklEngine * engine,
- guint what);
-
-/**
- * Stops listening for XKB-related events
- * @return 0
- */
- extern gint xkl_engine_stop_listen(XklEngine * engine);
-
-/**
- * Temporary pauses listening for XKB-related events
- * @return 0
- */
- extern gint xkl_engine_pause_listen(XklEngine * engine);
-
-/**
- * Resumes listening for XKB-related events
- * @return 0
- */
- extern gint xkl_engine_resume_listen(XklEngine * engine);
-
-/**
- * Grabs some key
- * @param keycode is a keycode
- * @param modifiers is a bitmask of modifiers
- * @return True on success
- */
- extern gboolean xkl_engine_grab_key(XklEngine * engine,
- gint keycode,
- unsigned modifiers);
-
-/**
- * Ungrabs some key
- * @param keycode is a keycode
- * @param modifiers is a bitmask of modifiers
- * @return True on success
- */
- extern gboolean xkl_engine_ungrab_key(XklEngine * engine,
- gint keycode,
- unsigned modifiers);
-
-/**
- * Processes X events. Should be included into the main event cycle of an
- * application. One of the most important functions.
- * @param evt is delivered X event
- * @return 0 if the event it processed - 1 otherwise
- * @see xkl_StartListen
- */
- extern gint xkl_engine_filter_events(XklEngine * engine,
- XEvent * evt);
-
-/**
- * Allows to switch (once) to the secondary group
- */
- extern void
- xkl_engine_allow_one_switch_to_secondary_group(XklEngine *
- engine);
-
-/** @} */
-
-/**
- * @defgroup currents Current state of the library
- * @{
- */
-
-/**
- * @return currently focused window
- */
- extern Window xkl_engine_get_current_window(XklEngine * engine);
-
-/**
- * @return current state of the keyboard (in XKB terms).
- * Returned value is a statically allocated buffer, should not be freed.
- */
- extern XklState *xkl_engine_get_current_state(XklEngine * engine);
-
-/** @} */
-
-/**
- * @defgroup wininfo Per-window information
- * @{
- */
-
-/**
- * @return the window title of some window or NULL.
- * If not NULL, it should be freed with XFree
- */
- extern gchar *xkl_engine_get_window_title(XklEngine * engine,
- Window w);
-
-/**
- * Finds the state for a given window (for its "App window").
- * @param win is a target window
- * @param state_out is a structure to store the state
- * @return True on success, otherwise False
- * (the error message can be obtained using xkl_GetLastError).
- */
- extern gboolean xkl_engine_get_state(XklEngine * engine,
- Window win,
- XklState * state_out);
-
-/**
- * Drops the state of a given window (of its "App window").
- * @param win is a target window
- */
- extern void xkl_engine_delete_state(XklEngine * engine,
- Window win);
-
-/**
- * Stores ths state for a given window
- * @param win is a target window
- * @param state is a new state of the window
- */
- extern void xkl_engine_save_state(XklEngine * engine, Window win,
- XklState * state);
-
-/**
- * Sets the "transparent" flag. It means focus switching onto
- * this window will never change the state.
- * @param win is the window do set the flag for.
- * @param transparent - if true, the windows is transparent.
- * @see xkl_IsTranspatent
- */
- extern void xkl_engine_set_window_transparent(XklEngine * engine,
- Window win,
- gboolean
- transparent);
-
-/**
- * Returns "transparent" flag.
- * @param win is the window to get the transparent flag from.
- * @see xkl_SetTranspatent
- */
- extern gboolean xkl_engine_is_window_transparent(XklEngine *
- engine,
- Window win);
-
-/**
- * Checks whether 2 windows have the same topmost window
- * @param win1 is first window
- * @param win2 is second window
- * @return True is windows are in the same application
- */
- extern gboolean
- xkl_engine_is_window_from_same_toplevel_window(XklEngine *
- engine,
- Window win1,
- Window win2);
-
-/** @} */
-
-/**
- * @defgroup xkbinfo Various XKB configuration info
- * @{
- */
-
-/**
- * @return the total number of groups in the current XKB configuration
- * (keyboard)
- */
- extern unsigned xkl_engine_get_num_groups(XklEngine * engine);
-
-/**
- * @return the array of group names for the current XKB configuration
- * (keyboard).
- * This array is static, should not be freed
- */
- extern const gchar **xkl_engine_get_groups_names(XklEngine *
- engine);
-
-/**
- * @return the array of indicator names for the current XKB configuration
- * (keyboard).
- * This array is static, should not be freed
- */
- extern const gchar **xkl_engine_get_indicators_names(XklEngine *
- engine);
-
-/** @} */
-
-/**
- * @defgroup xkbgroup XKB group calculation and change
- * @{
- */
-
-/**
- * Calculates next group id. Does not change the state of anything.
- * @return next group id
- */
- extern gint xkl_engine_get_next_group(XklEngine * engine);
-
-/**
- * Calculates prev group id. Does not change the state of anything.
- * @return prev group id
- */
- extern gint xkl_engine_get_prev_group(XklEngine * engine);
-
-/**
- * @return saved group id of the current window.
- * Does not change the state of anything.
- */
- extern gint xkl_engine_get_current_window_group(XklEngine *
- engine);
-
-/**
- * Locks the group. Can be used after xkl_GetXXXGroup functions
- * @param group is a group number for locking
- * @see xkl_GetNextGroup
- * @see xkl_GetPrevGroup
- * @see xkl_GetRestoreGroup
- */
- extern void xkl_engine_lock_group(XklEngine * engine, gint group);
-
-/** @} */
-
-/**
- * @defgroup settings Settings for event processing
- * @{
- */
-
-/**
- * Sets the configuration parameter: group per application
- * @param isGlobal is a new parameter value
- */
- extern void xkl_engine_set_group_per_toplevel_window(XklEngine *
- engine,
- gboolean
- isGlobal);
-
-/**
- * @return the value of the parameter: group per application
- */
- extern gboolean xkl_engine_is_group_per_toplevel_window(XklEngine *
- engine);
-
-/**
- * Sets the configuration parameter: perform indicators handling
- * @param whetherHandle is a new parameter value
- */
- extern void xkl_engine_set_indicators_handling(XklEngine * engine,
- gboolean
- whetherHandle);
-
-/**
- * @return the value of the parameter: perform indicator handling
- */
- extern gboolean xkl_engine_get_indicators_handling(XklEngine *
- engine);
-
-/**
- * Sets the secondary groups (one bit per group).
- * Secondary groups require explicit "allowance" for switching
- * @param mask is a new group mask
- * @see xkl_allow_one_switch_to_secondary_group
- */
- extern void xkl_engine_set_secondary_groups_mask(XklEngine *
- engine,
- guint mask);
-
-/**
- * @return the secondary group mask
- */
- extern guint xkl_engine_get_secondary_groups_mask(XklEngine *
- engine);
-
-/**
- * Configures the default group set on window creation.
- * If -1, no default group is used
- * @param group the default group
- */
- extern void xkl_engine_group_set_default(XklEngine * engine,
- gint group);
-
-/**
- * Returns the default group set on window creation
- * If -1, no default group is used
- * @return the default group
- */
- extern gint xkl_engine_group_get_default(XklEngine * engine);
-
-/** @} */
-
/**
* @defgroup debugerr Debugging, error processing
* @{
@@ -483,7 +28,7 @@ extern "C" {
/**
* @return the text message (statically allocated) of the last error
*/
- extern const gchar *xkl_engine_get_last_error(XklEngine * engine);
+ extern const gchar *xkl_get_last_error(void);
/**
* Output (optionally) some debug info
diff --git a/libxklavier/xklavier_config.c b/libxklavier/xklavier_config.c
index 9386390..01cdd21 100644
--- a/libxklavier/xklavier_config.c
+++ b/libxklavier/xklavier_config.c
@@ -17,7 +17,7 @@ static xmlXPathCompExprPtr layouts_xpath;
static xmlXPathCompExprPtr option_groups_xpath;
#define xkl_config_registry_is_initialized(config) \
- ( (config)->priv->xpath_context != NULL )
+ ( xkl_config_priv(config,xpath_context) != NULL )
static xmlChar *
xkl_node_get_xml_lang_attr(xmlNodePtr nptr)
@@ -179,7 +179,8 @@ xkl_config_registry_enum_simple(XklConfigRegistry * config,
if (!xkl_config_registry_is_initialized(config))
return;
xpath_obj = xmlXPathCompiledEval(xpath_comp_expr,
- config->priv->xpath_context);
+ xkl_config_priv(config,
+ xpath_context));
if (xpath_obj != NULL) {
xkl_config_registry_enum_from_node_set(config,
xpath_obj->
@@ -201,7 +202,7 @@ xkl_config_registry_enum_direct(XklConfigRegistry * config,
return;
snprintf(xpath_expr, sizeof xpath_expr, format, value);
xpath_obj = xmlXPathEval((unsigned char *) xpath_expr,
- config->priv->xpath_context);
+ xkl_config_priv(config, xpath_context));
if (xpath_obj != NULL) {
xkl_config_registry_enum_from_node_set(config,
xpath_obj->
@@ -227,7 +228,7 @@ xkl_config_registry_find_object(XklConfigRegistry * config,
snprintf(xpath_expr, sizeof xpath_expr, format, arg1, pitem->name);
xpath_obj = xmlXPathEval((unsigned char *) xpath_expr,
- config->priv->xpath_context);
+ xkl_config_priv(config, xpath_context));
if (xpath_obj == NULL)
return FALSE;
@@ -300,7 +301,8 @@ xkl_engine_get_ruleset_name(XklEngine * engine,
/* first call */
gchar *rf = NULL;
if (!xkl_config_rec_get_from_root_window_property
- (NULL, engine->priv->base_config_atom, &rf, engine)
+ (NULL, xkl_engine_priv(engine, base_config_atom), &rf,
+ engine)
|| (rf == NULL)) {
g_strlcpy(rules_set_name, default_ruleset,
sizeof rules_set_name);
@@ -333,7 +335,7 @@ xkl_config_registry_get_instance(XklEngine * engine)
XKL_CONFIG_REGISTRY(g_object_new
(xkl_config_registry_get_type(), NULL));
- the_config->priv->engine = engine;
+ xkl_config_priv(the_config, engine) = engine;
xmlXPathInit();
models_xpath = xmlXPathCompile((unsigned char *)
@@ -354,15 +356,14 @@ gboolean
xkl_config_registry_load_from_file(XklConfigRegistry * config,
const gchar * file_name)
{
- config->priv->doc = xmlParseFile(file_name);
- if (config->priv->doc == NULL) {
- config->priv->xpath_context = NULL;
- xkl_config_registry_get_engine(config)->priv->
- last_error_message =
+ xkl_config_priv(config, doc) = xmlParseFile(file_name);
+ if (xkl_config_priv(config, doc) == NULL) {
+ xkl_config_priv(config, xpath_context) = NULL;
+ xkl_last_error_message =
"Could not parse XKB configuration registry";
} else
- config->priv->xpath_context =
- xmlXPathNewContext(config->priv->doc);
+ xkl_config_priv(config, xpath_context) =
+ xmlXPathNewContext(xkl_config_priv(config, doc));
return xkl_config_registry_is_initialized(config);
}
@@ -370,10 +371,11 @@ void
xkl_config_registry_free(XklConfigRegistry * config)
{
if (xkl_config_registry_is_initialized(config)) {
- xmlXPathFreeContext(config->priv->xpath_context);
- xmlFreeDoc(config->priv->doc);
- config->priv->xpath_context = NULL;
- config->priv->doc = NULL;
+ xmlXPathFreeContext(xkl_config_priv
+ (config, xpath_context));
+ xmlFreeDoc(xkl_config_priv(config, doc));
+ xkl_config_priv(config, xpath_context) = NULL;
+ xkl_config_priv(config, doc) = NULL;
}
}
@@ -415,7 +417,7 @@ xkl_config_registry_enum_option_groups(XklConfigRegistry * config,
return;
xpath_obj =
xmlXPathCompiledEval(option_groups_xpath,
- config->priv->xpath_context);
+ xkl_config_priv(config, xpath_context));
if (xpath_obj != NULL) {
xmlNodeSetPtr nodes = xpath_obj->nodesetval;
xmlNodePtr *pnode = nodes->nodeTab;
@@ -554,11 +556,12 @@ xkl_config_rec_write_to_file(XklEngine * engine, const gchar * file_name,
const gboolean binary)
{
if ((!binary &&
- !(engine->priv->features & XKLF_CAN_OUTPUT_CONFIG_AS_ASCII))
+ !(xkl_engine_priv(engine, features) &
+ XKLF_CAN_OUTPUT_CONFIG_AS_ASCII))
|| (binary
- && !(engine->priv->
- features & XKLF_CAN_OUTPUT_CONFIG_AS_BINARY))) {
- engine->priv->last_error_message =
+ && !(xkl_engine_priv(engine, features) &
+ XKLF_CAN_OUTPUT_CONFIG_AS_BINARY))) {
+ xkl_last_error_message =
"Function not supported at backend";
return FALSE;
}
diff --git a/libxklavier/xklavier_config.h b/libxklavier/xklavier_config.h
deleted file mode 100644
index e172acc..0000000
--- a/libxklavier/xklavier_config.h
+++ /dev/null
@@ -1,519 +0,0 @@
-/**
- * @file xklavier_config.h
- */
-
-#ifndef __XKLAVIER_CONFIG_H__
-#define __XKLAVIER_CONFIG_H__
-
-#include <glib-object.h>
-#include <libxklavier/xklavier.h>
-
-/**
- * Maximum name length, including '\'0' character
- */
-#define XKL_MAX_CI_NAME_LENGTH 32
-
-/**
- * Maximum short description length, including '\\0' character.
- * Important: this length is in bytes, so for unicode (UTF-8 encoding in
- * XML file) the actual maximum length can be smaller.
- */
-#define XKL_MAX_CI_SHORT_DESC_LENGTH 10
-
-/**
- * Maximum description length, including '\\0' character.
- * Important: this length is in bytes, so for unicode (UTF-8 encoding in
- * XML file) the actual maximum length can be smaller.
- */
-#define XKL_MAX_CI_DESC_LENGTH 192
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
-
- typedef struct _XklConfigRegistry XklConfigRegistry;
- typedef struct _XklConfigRegistryPrivate XklConfigRegistryPrivate;
- typedef struct _XklConfigRegistryClass XklConfigRegistryClass;
-
- typedef struct _XklConfigItem XklConfigItem;
- typedef struct _XklConfigItemClass XklConfigItemClass;
-
- typedef struct _XklConfigRec XklConfigRec;
- typedef struct _XklConfigRecClass XklConfigRecClass;
-
-#define XKL_TYPE_CONFIG_REGISTRY (xkl_config_registry_get_type ())
-#define XKL_CONFIG_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XKL_TYPE_CONFIG_REGISTRY, XklConfigRegistry))
-#define XKL_CONFIG_REGISTRY_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), XKL_CONFIG_REGISTRY, XklConfigRegistryClass))
-#define XKL_IS_CONFIG_REGISTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XKL_TYPE_CONFIG_REGISTRY))
-#define XKL_IS_CONFIG_REGISTRY_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), XKL_TYPE_CONFIG_REGISTRY))
-#define XKL_CONFIG_REGISTRY_GET_CLASS (G_TYPE_INSTANCE_GET_CLASS ((obj), XKL_TYPE_CONFIG_REGISTRY, XklConfigRegistryClass))
-
-#define XKL_TYPE_CONFIG_ITEM (xkl_config_item_get_type ())
-#define XKL_CONFIG_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XKL_TYPE_CONFIG_ITEM, XklConfigItem))
-#define XKL_CONFIG_ITEM_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), XKL_CONFIG_ITEM, XklConfigItemClass))
-#define XKL_IS_CONFIG_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XKL_TYPE_CONFIG_ITEM))
-#define XKL_IS_CONFIG_ITEM_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), XKL_TYPE_CONFIG_ITEM))
-#define XKL_CONFIG_ITEM_GET_CLASS (G_TYPE_INSTANCE_GET_CLASS ((obj), XKL_TYPE_CONFIG_ITEM, XklConfigItemClass))
-
-#define XKL_TYPE_CONFIG_REC (xkl_config_rec_get_type ())
-#define XKL_CONFIG_REC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XKL_TYPE_CONFIG_REC, XklConfigRec))
-#define XKL_CONFIG_REC_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), XKL_CONFIG_REC, XklConfigRecClass))
-#define XKL_IS_CONFIG_REC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XKL_TYPE_CONFIG_REC))
-#define XKL_IS_CONFIG_REC_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), XKL_TYPE_CONFIG_REC))
-#define XKL_CONFIG_REC_GET_CLASS (G_TYPE_INSTANCE_GET_CLASS ((obj), XKL_TYPE_CONFIG_REC, XklConfigRecClass))
-
-#endif // DOXYGEN_SHOULD_SKIP_THIS
-
-/**
- * The configuration manager. Corresponds to XML element "configItem".
- */
- struct _XklConfigRegistry {
-/**
- * The superclass object
- */
- GObject parent;
-
- XklConfigRegistryPrivate *priv;
- };
-
-/**
- * The XklConfigRegistry class, derived from GObject
- */
- struct _XklConfigRegistryClass {
- /**
- * The superclass
- */
- GObjectClass parent_class;
- };
-/**
- * Get type info for XConfig
- * @return GType for XConfig
- */
- extern GType xkl_config_registry_get_type(void);
-
-/**
- * Create new XklConfig
- * @return new instance
- */
- extern XklConfigRegistry
- * xkl_config_registry_get_instance(XklEngine * engine);
-
-
-
-/**
- * The configuration item. Corresponds to XML element "configItem".
- */
- struct _XklConfigItem {
-/**
- * The superclass object
- */
- GObject parent;
-/**
- * The configuration item name. Corresponds to XML element "name".
- */
- gchar name[XKL_MAX_CI_NAME_LENGTH];
-
-/**
- * The configuration item short description. Corresponds to XML element "shortDescription".
- */
- gchar short_description[XKL_MAX_CI_DESC_LENGTH];
-
-/**
- * The configuration item description. Corresponds to XML element "description".
- */
- gchar description[XKL_MAX_CI_DESC_LENGTH];
- };
-
-/**
- * The XklConfigItem class, derived from GObject
- */
- struct _XklConfigItemClass {
- /**
- * The superclass
- */
- GObjectClass parent_class;
- };
-/**
- * Get type info for XklConfigItem
- * @return GType for XklConfigItem
- */
- extern GType xkl_config_item_get_type(void);
-
-/**
- * Create new XklConfigItem
- * @return new instance
- */
- extern XklConfigItem *xkl_config_item_new(void);
-
-/**
- * Basic configuration params
- */
- struct _XklConfigRec {
-/**
- * The superclass object
- */
- GObject parent;
-/**
- * The keyboard model
- */
- gchar *model;
-/**
- * The array of keyboard layouts
- */
- gchar **layouts;
-/**
- * The array of keyboard layout variants (if any)
- */
- gchar **variants;
-/**
- * The array of keyboard layout options
- */
- gchar **options;
- };
-
-/**
- * The XklConfigRec class, derived from GObject
- */
- struct _XklConfigRecClass {
- /**
- * The superclass
- */
- GObjectClass parent_class;
- };
-
-/**
- * Get type info for XConfigRec
- * @return GType for XConfigRec
- */
- extern GType xkl_config_rec_get_type(void);
-
-/**
- * Create new XklConfigRec
- * @return new instance
- */
- extern XklConfigRec *xkl_config_rec_new(void);
-
-/**
- * @defgroup xklconfiginitterm XKB configuration handling initialization and termination
- * @{
- */
-
-/**
- * Loads XML configuration registry
- * @param file_name file name to load
- * @return true on success
- */
- extern gboolean
- xkl_config_registry_load_from_file(XklConfigRegistry * config,
- const gchar * file_name);
-
-/**
- * Loads XML configuration registry
- * @return true on success
- */
- extern gboolean xkl_config_registry_load(XklConfigRegistry *
- config);
-
-/**
- * Frees XML configuration registry
- */
- extern void xkl_config_registry_free(XklConfigRegistry * config);
-/** @} */
-
-/**
- * @defgroup enum XKB configuration elements enumeration functions
- * @{
- */
-
-/**
- * Callback type used for enumerating keyboard models, layouts, variants, options
- * @param item is the item from registry
- * @param data is anything which can be stored into the pointer
- */
- typedef void (*ConfigItemProcessFunc) (const XklConfigItem * item,
- gpointer data);
-
-/**
- * Callback type used for enumerating keyboard option groups
- * @param item is the item from registry
- * @param allow_multiple_selection is a flag whether this group allows multiple selection
- * @param data is anything which can be stored into the pointer
- */
- typedef void (*GroupProcessFunc) (const XklConfigItem * item,
- gboolean
- allow_multiple_selection,
- gpointer data);
-/**
- * Enumerates keyboard models from the XML configuration registry
- * @param func is a callback to call for every model
- * @param data is anything which can be stored into the pointer
- */
- extern void xkl_config_registry_enum_models(XklConfigRegistry *
- config,
- ConfigItemProcessFunc
- func, gpointer data);
-
-/**
- * Enumerates keyboard layouts from the XML configuration registry
- * @param func is a callback to call for every layout
- * @param data is anything which can be stored into the pointer
- */
- extern void xkl_config_registry_enum_layouts(XklConfigRegistry *
- config,
- ConfigItemProcessFunc
- func, gpointer data);
-
-/**
- * Enumerates keyboard layout variants from the XML configuration registry
- * @param layout_name is the layout name for which variants will be listed
- * @param func is a callback to call for every layout variant
- * @param data is anything which can be stored into the pointer
- */
- extern void
- xkl_config_registry_enum_layout_variants(XklConfigRegistry *
- config,
- const gchar *
- layout_name,
- ConfigItemProcessFunc
- func, gpointer data);
-
-/**
- * Enumerates keyboard option groups from the XML configuration registry
- * @param func is a callback to call for every option group
- * @param data is anything which can be stored into the pointer
- */
- extern void
- xkl_config_registry_enum_option_groups(XklConfigRegistry *
- config,
- GroupProcessFunc func,
- gpointer data);
-
-/**
- * Enumerates keyboard options from the XML configuration registry
- * @param option_group_name is the option group name for which variants
- * will be listed
- * @param func is a callback to call for every option
- * @param data is anything which can be stored into the pointer
- */
- extern void xkl_config_registry_enum_options(XklConfigRegistry *
- config,
- const gchar *
- option_group_name,
- ConfigItemProcessFunc
- func, gpointer data);
-
-/** @} */
-
-/**
- * @defgroup lookup XKB configuration element lookup functions
- * @{
- */
-
-/**
- * Loads a keyboard model information from the XML configuration registry.
- * @param item is a pointer to a XklConfigItem containing the name of the
- * keyboard model. On successfull return, the descriptions are filled.
- * @return TRUE if appropriate element was found and loaded
- */
- extern gboolean xkl_config_registry_find_model(XklConfigRegistry *
- config,
- XklConfigItem *
- item);
-
-/**
- * Loads a keyboard layout information from the XML configuration registry.
- * @param item is a pointer to a XklConfigItem containing the name of the
- * keyboard layout. On successfull return, the descriptions are filled.
- * @return TRUE if appropriate element was found and loaded
- */
- extern gboolean xkl_config_registry_find_layout(XklConfigRegistry *
- config,
- XklConfigItem *
- item);
-
-/**
- * Loads a keyboard layout variant information from the XML configuration
- * registry.
- * @param layout_name is a name of the parent layout
- * @param item is a pointer to a XklConfigItem containing the name of the
- * keyboard layout variant. On successfull return, the descriptions are filled.
- * @return TRUE if appropriate element was found and loaded
- */
- extern gboolean xkl_config_registry_find_variant(XklConfigRegistry
- * config,
- const char
- *layout_name,
- XklConfigItem *
- item);
-
-/**
- * Loads a keyboard option group information from the XML configuration
- * registry.
- * @param item is a pointer to a XklConfigItem containing the name of the
- * keyboard option group. On successfull return, the descriptions are filled.
- * @param allow_multiple_selection is a pointer to some gboolean variable to fill
- * the corresponding attribute of XML element "group".
- * @return TRUE if appropriate element was found and loaded
- */
- extern gboolean
- xkl_config_registry_find_option_group(XklConfigRegistry *
- config,
- XklConfigItem * item,
- gboolean *
- allow_multiple_selection);
-
-/**
- * Loads a keyboard option information from the XML configuration
- * registry.
- * @param option_group_name is a name of the option group
- * @param item is a pointer to a XklConfigItem containing the name of the
- * keyboard option. On successfull return, the descriptions are filled.
- * @return TRUE if appropriate element was found and loaded
- */
- extern gboolean xkl_config_registry_find_option(XklConfigRegistry *
- config,
- const gchar *
- option_group_name,
- XklConfigItem *
- item);
-/** @} */
-
-/**
- * @defgroup activation XKB configuration activation
- * @{
- */
-
-/**
- * Activates some XKB configuration
- * @param data is a valid XKB configuration
- * description. Can be NULL
- * @return TRUE on success
- * @see XklSetKeyAsSwitcher
- * At the moment, accepts only _ONE_ layout. Later probably I'll improve this..
- */
- extern gboolean xkl_config_rec_activate(const XklConfigRec * data,
- XklEngine * engine);
-
-/**
- * Loads the current XKB configuration (from X server)
- * @param data is a buffer for XKB configuration
- * @return TRUE on success
- */
- extern gboolean xkl_config_rec_get_from_server(XklConfigRec * data,
- XklEngine * engine);
-
-/**
- * Loads the current XKB configuration (from backup)
- * @param data is a buffer for XKB configuration
- * @return TRUE on success
- * @see XklBackupNamesProp
- */
- extern gboolean xkl_config_rec_get_from_backup(XklConfigRec * data,
- XklEngine * engine);
-
-/**
- * Writes some XKB configuration into XKM/XKB file
- * @param file_name is a name of the file to create
- * @param data is a valid XKB configuration
- * description. Can be NULL
- * @param binary is a flag indicating whether the output file should be binary
- * @return TRUE on success
- */
- extern gboolean xkl_config_rec_write_to_file(XklEngine * engine,
- const gchar *
- file_name,
- const XklConfigRec *
- data,
- const gboolean
- binary);
-
-/** @} */
-
-/**
- * @defgroup props Saving and restoring XKB configuration into X root window properties
- * Generalizes XkbRF_GetNamesProp and XkbRF_SetNamesProp.
- * @{
- */
-
-/**
- * Gets the XKB configuration from any root window property
- * @param rules_atom_name is an atom name of the root window property to read
- * @param rules_file_out is a pointer to hold the file name
- * @param config_out is a buffer to hold the result -
- * all records are allocated using standard malloc
- * @return TRUE on success
- */
- extern gboolean
- xkl_config_rec_get_from_root_window_property(XklConfigRec *
- config_out,
- Atom
- rules_atom_name,
- gchar **
- rules_file_out,
- XklEngine *
- engine);
-
-/**
- * Saves the XKB configuration into any root window property
- * @param rules_atom_name is an atom name of the root window property to write
- * @param rules_file is a rules file name
- * @param config is a configuration to save
- * @return TRUE on success
- */
- extern gboolean xkl_config_rec_set_to_root_window_property(const
- XklConfigRec
- *
- config,
- Atom
- rules_atom_name,
- gchar *
- rules_file,
- XklEngine
- *
- engine);
-
-/**
- * Backups current XKB configuration into some property -
- * if this property is not defined yet.
- * @return TRUE on success
- */
- extern gboolean xkl_backup_names_prop(XklEngine * engine);
-
-/**
- * Restores XKB from the property saved by xkl_backup_names_prop
- * @return TRUE on success
- * @see xkl_backup_names_prop
- */
- extern gboolean xkl_restore_names_prop(XklEngine * engine);
-
-/** @} */
-
-/**
- * @defgroup xklconfig XklConfigRec management utilities
- * Little utilities for managing XklConfigRec.
- * @{
- */
-
-/**
- * Resets the record (equal to Destroy and Init)
- * @param data is a record to reset
- */
- extern void xkl_config_rec_reset(XklConfigRec * data);
-
-/**
- * Compares the records
- * @param data1 is a record to compare
- * @param data2 is another record
- * @return TRUE if records are same
- */
- extern gboolean xkl_config_rec_equals(XklConfigRec * data1,
- XklConfigRec * data2);
-
-/** @} */
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-#endif
diff --git a/libxklavier/xklavier_config_xkb.c b/libxklavier/xklavier_config_xkb.c
index 566163b..99ec294 100644
--- a/libxklavier/xklavier_config_xkb.c
+++ b/libxklavier/xklavier_config_xkb.c
@@ -42,7 +42,7 @@ xkl_rules_set_load(XklEngine * engine)
char *locale = NULL;
if (rf == NULL) {
- engine->priv->last_error_message =
+ xkl_last_error_message =
"Could not find the XKB rules set";
return NULL;
}
@@ -55,7 +55,7 @@ xkl_rules_set_load(XklEngine * engine)
rules_set = XkbRF_Load(file_name, locale, True, True);
if (rules_set == NULL) {
- engine->priv->last_error_message = "Could not load rules";
+ xkl_last_error_message = "Could not load rules";
return NULL;
}
return rules_set;
@@ -138,7 +138,7 @@ xkl_xkb_config_native_prepare(XklEngine * engine,
g_free(xkl_var_defs.options);
if (!got_components) {
- engine->priv->last_error_message =
+ xkl_last_error_message =
"Could not translate rules into components";
/* Just cleanup the stuff in case of failure */
xkl_xkb_config_native_cleanup(engine, component_names_ptr);
@@ -464,7 +464,8 @@ xkl_xkb_activate_config_rec(XklEngine * engine, const XklConfigRec * data)
TRUE);
if (xkb != NULL) {
if (xkl_config_rec_set_to_root_window_property
- (data, engine->priv->base_config_atom,
+ (data,
+ xkl_engine_priv(engine, base_config_atom),
xkl_engine_get_ruleset_name(engine,
XKB_DEFAULT_RULESET),
engine))
@@ -472,11 +473,11 @@ xkl_xkb_activate_config_rec(XklEngine * engine, const XklConfigRec * data)
because PrepareBeforeKbd did it for us */
rv = TRUE;
else
- engine->priv->last_error_message =
+ xkl_last_error_message =
"Could not set names property";
XkbFreeKeyboard(xkb, XkbAllComponentsMask, True);
} else {
- engine->priv->last_error_message =
+ xkl_last_error_message =
"Could not load keyboard description";
}
xkl_xkb_config_native_cleanup(engine, &component_names);
@@ -498,8 +499,7 @@ xkl_xkb_write_config_rec_to_file(XklEngine * engine, const char *file_name,
XkbFileInfo dump_info;
if (output == NULL) {
- engine->priv->last_error_message =
- "Could not open the XKB file";
+ xkl_last_error_message = "Could not open the XKB file";
return FALSE;
}
@@ -523,7 +523,7 @@ xkl_xkb_write_config_rec_to_file(XklEngine * engine, const char *file_name,
XkbFreeKeyboard(xkb, XkbGBN_AllComponentsMask,
True);
} else
- engine->priv->last_error_message =
+ xkl_last_error_message =
"Could not load keyboard description";
xkl_xkb_config_native_cleanup(engine, &component_names);
}
diff --git a/libxklavier/xklavier_config_xmm.c b/libxklavier/xklavier_config_xmm.c
index ba637df..3106ae2 100644
--- a/libxklavier/xklavier_config_xmm.c
+++ b/libxklavier/xklavier_config_xmm.c
@@ -39,7 +39,7 @@ xkl_xmm_load_config_registry(XklConfigRegistry * config)
rf);
if (stat(file_name, &stat_buf) != 0) {
- engine->priv->last_error_message = "No rules file found";
+ xkl_last_error_message = "No rules file found";
return FALSE;
}
@@ -51,8 +51,9 @@ xkl_xmm_activate_config_rec(XklEngine * engine, const XklConfigRec * data)
{
gboolean rv;
rv = xkl_config_rec_set_to_root_window_property(data,
- engine->priv->
- base_config_atom,
+ xkl_engine_priv
+ (engine,
+ base_config_atom),
current_xmm_rules,
engine);
if (rv)
diff --git a/libxklavier/xklavier_evt.c b/libxklavier/xklavier_evt.c
index d0b9a21..c9801ba 100644
--- a/libxklavier/xklavier_evt.c
+++ b/libxklavier/xklavier_evt.c
@@ -76,7 +76,9 @@ xkl_engine_process_focus_in_evt(XklEngine * engine,
Window toplevel_win;
XklState selected_window_state;
- if (!(engine->priv->listener_type & XKLL_MANAGE_WINDOW_STATES))
+ if (!
+ (xkl_engine_priv(engine, listener_type) &
+ XKLL_MANAGE_WINDOW_STATES))
return;
win = fev->window;
@@ -106,13 +108,15 @@ xkl_engine_process_focus_in_evt(XklEngine * engine,
if (xkl_engine_get_toplevel_window_state
(engine, toplevel_win, &selected_window_state)) {
- if (engine->priv->curr_toplvl_win != toplevel_win) {
+ if (xkl_engine_priv(engine, curr_toplvl_win) !=
+ toplevel_win) {
gboolean old_win_transparent, new_win_transparent;
XklState tmp_state;
old_win_transparent =
xkl_engine_is_toplevel_window_transparent
- (engine, engine->priv->curr_toplvl_win);
+ (engine,
+ xkl_engine_priv(engine, curr_toplvl_win));
if (old_win_transparent)
xkl_debug(150,
"Leaving transparent window\n");
@@ -124,9 +128,9 @@ xkl_engine_process_focus_in_evt(XklEngine * engine,
*/
if (!old_win_transparent &&
xkl_engine_get_toplevel_window_state(engine,
- engine->
- priv->
- curr_toplvl_win,
+ xkl_engine_priv
+ (engine,
+ curr_toplvl_win),
&tmp_state))
{
xkl_engine_update_current_state(engine,
@@ -137,14 +141,16 @@ xkl_engine_process_focus_in_evt(XklEngine * engine,
"Loading current (previous) state from the current (previous) window");
}
- engine->priv->curr_toplvl_win = toplevel_win;
+ xkl_engine_priv(engine, curr_toplvl_win) =
+ toplevel_win;
xkl_debug(150,
"CurClient:changed to " WINID_FORMAT
- ", '%s'\n",
- engine->priv->curr_toplvl_win,
+ ", '%s'\n", xkl_engine_priv(engine,
+ curr_toplvl_win),
xkl_get_debug_window_title(engine,
- engine->priv->
- curr_toplvl_win));
+ xkl_engine_priv
+ (engine,
+ curr_toplvl_win)));
new_win_transparent =
xkl_engine_is_toplevel_window_transparent
@@ -157,11 +163,14 @@ xkl_engine_process_focus_in_evt(XklEngine * engine,
== !new_win_transparent) {
/* We skip restoration only if we return to the same app window */
gboolean do_skip = FALSE;
- if (engine->priv->skip_one_restore) {
- engine->priv->skip_one_restore =
+ if (xkl_engine_priv
+ (engine, skip_one_restore)) {
+ xkl_engine_priv(engine,
+ skip_one_restore) =
FALSE;
if (toplevel_win ==
- engine->priv->prev_toplvl_win)
+ xkl_engine_priv(engine,
+ prev_toplvl_win))
do_skip = TRUE;
}
@@ -171,15 +180,19 @@ xkl_engine_process_focus_in_evt(XklEngine * engine,
"saving the current group into the window state\n");
xkl_engine_save_toplevel_window_state
(engine, toplevel_win,
- &engine->priv->curr_state);
+ &xkl_engine_priv(engine,
+ curr_state));
} else {
- if (engine->priv->curr_state.
- group !=
+ if (xkl_engine_priv
+ (engine,
+ curr_state).group !=
selected_window_state.group) {
xkl_debug(150,
"Restoring the group from %d to %d after gaining focus\n",
- engine->priv->
- curr_state.group,
+ xkl_engine_priv
+ (engine,
+ curr_state).
+ group,
selected_window_state.
group);
/**
@@ -209,14 +222,15 @@ xkl_engine_process_focus_in_evt(XklEngine * engine,
}
}
- if ((engine->priv->
- features & XKLF_CAN_TOGGLE_INDICATORS)
+ if ((xkl_engine_priv(engine, features) &
+ XKLF_CAN_TOGGLE_INDICATORS)
&&
xkl_engine_get_indicators_handling
(engine)) {
xkl_debug(150,
"Restoring the indicators from %X to %X after gaining focus\n",
- engine->priv->curr_state.
+ xkl_engine_priv(engine,
+ curr_state).
indicators,
selected_window_state.
indicators);
@@ -229,12 +243,15 @@ xkl_engine_process_focus_in_evt(XklEngine * engine,
} else
xkl_debug(150,
"Not restoring the indicators %X after gaining focus: indicator handling is not enabled\n",
- engine->priv->curr_state.
+ xkl_engine_priv(engine,
+ curr_state).
indicators);
} else
xkl_debug(150,
"Not restoring the group %d after gaining focus: global layout (xor transparent window)\n",
- engine->priv->curr_state.group);
+ xkl_engine_priv(engine,
+ curr_state).
+ group);
} else
xkl_debug(150,
"Same app window - just do nothing\n");
@@ -243,21 +260,25 @@ xkl_engine_process_focus_in_evt(XklEngine * engine,
if (xkl_engine_if_window_has_wm_state(engine, win)) {
xkl_debug(150,
"But it does have wm_state so we'll add it\n");
- engine->priv->curr_toplvl_win = toplevel_win;
+ xkl_engine_priv(engine, curr_toplvl_win) =
+ toplevel_win;
xkl_debug(150,
"CurClient:changed to " WINID_FORMAT
- ", '%s'\n",
- engine->priv->curr_toplvl_win,
+ ", '%s'\n", xkl_engine_priv(engine,
+ curr_toplvl_win),
xkl_get_debug_window_title(engine,
- engine->priv->
- curr_toplvl_win));
+ xkl_engine_priv
+ (engine,
+ curr_toplvl_win)));
xkl_engine_add_toplevel_window(engine,
- engine->priv->
- curr_toplvl_win,
+ xkl_engine_priv
+ (engine,
+ curr_toplvl_win),
(Window) NULL,
FALSE,
- &engine->priv->
- curr_state);
+ &xkl_engine_priv
+ (engine,
+ curr_state));
} else
xkl_debug(150,
"And it does have wm_state either\n");
@@ -271,7 +292,9 @@ void
xkl_engine_process_focus_out_evt(XklEngine * engine,
XFocusChangeEvent * fev)
{
- if (!(engine->priv->listener_type & XKLL_MANAGE_WINDOW_STATES))
+ if (!
+ (xkl_engine_priv(engine, listener_type) &
+ XKLL_MANAGE_WINDOW_STATES))
return;
if (fev->mode != NotifyNormal) {
@@ -293,12 +316,12 @@ xkl_engine_process_focus_out_evt(XklEngine * engine,
* This is useful for secondary groups switching from the transparent control
* window.
*/
- engine->priv->skip_one_restore = TRUE;
+ xkl_engine_priv(engine, skip_one_restore) = TRUE;
} else {
Window p;
if (xkl_engine_find_toplevel_window
(engine, fev->window, &p))
- engine->priv->prev_toplvl_win = p;
+ xkl_engine_priv(engine, prev_toplvl_win) = p;
}
}
@@ -329,8 +352,9 @@ xkl_engine_process_property_evt(XklEngine * engine, XPropertyEvent * pev)
}
}
- if (engine->priv->listener_type & XKLL_MANAGE_WINDOW_STATES) {
- if (pev->atom == engine->priv->atoms[WM_STATE]) {
+ if (xkl_engine_priv(engine, listener_type) &
+ XKLL_MANAGE_WINDOW_STATES) {
+ if (pev->atom == xkl_engine_priv(engine, atoms)[WM_STATE]) {
gboolean has_xkl_state =
xkl_engine_get_state(engine, pev->window,
NULL);
@@ -343,7 +367,8 @@ xkl_engine_process_property_evt(XklEngine * engine, XPropertyEvent * pev)
xkl_engine_add_toplevel_window
(engine, pev->window, (Window)
NULL, FALSE,
- &engine->priv->curr_state);
+ &xkl_engine_priv(engine,
+ curr_state));
}
} else { /* ev->xproperty.state == PropertyDelete, either client or WM can remove it, ICCCM 4.1.3.1 */
xkl_debug(160,
@@ -360,8 +385,10 @@ xkl_engine_process_property_evt(XklEngine * engine, XPropertyEvent * pev)
}
}
} else
- if (pev->atom == engine->priv->base_config_atom
- && pev->window == engine->priv->root_window) {
+ if (pev->atom ==
+ xkl_engine_priv(engine, base_config_atom)
+ && pev->window == xkl_engine_priv(engine,
+ root_window)) {
if (pev->state == PropertyNewValue) {
/* If root window got new *_NAMES_PROP_ATOM -
it most probably means new keyboard config is loaded by somebody */
@@ -380,7 +407,9 @@ void
xkl_engine_process_create_window_evt(XklEngine * engine,
XCreateWindowEvent * cev)
{
- if (!(engine->priv->listener_type & XKLL_MANAGE_WINDOW_STATES))
+ if (!
+ (xkl_engine_priv(engine, listener_type) &
+ XKLL_MANAGE_WINDOW_STATES))
return;
xkl_debug(200,
@@ -407,8 +436,9 @@ xkl_engine_process_create_window_evt(XklEngine * engine,
xkl_engine_add_toplevel_window(engine, cev->window,
(Window) NULL,
FALSE,
- &engine->priv->
- curr_state);
+ &xkl_engine_priv
+ (engine,
+ curr_state));
}
}
}
@@ -422,8 +452,8 @@ xkl_process_error(Display * dpy, XErrorEvent * evt)
{
XklEngine *engine = xkl_get_the_engine();
- engine->priv->last_error_code = evt->error_code;
- switch (engine->priv->last_error_code) {
+ xkl_engine_priv(engine, last_error_code) = evt->error_code;
+ switch (xkl_engine_priv(engine, last_error_code)) {
case BadWindow:
case BadAccess:
{
@@ -438,7 +468,8 @@ xkl_process_error(Display * dpy, XErrorEvent * evt)
break;
}
default:
- (*engine->priv->default_error_handler) (dpy, evt);
+ (*xkl_engine_priv(engine, default_error_handler)) (dpy,
+ evt);
}
}
@@ -465,23 +496,28 @@ xkl_engine_process_state_modification(XklEngine * engine,
}
/**
- * Only if we manage states - otherwise engine->priv->curr_toplvl_win does not make sense
+ * Only if we manage states - otherwise xkl_engine_priv(engine,curr_toplvl_win) does not make sense
*/
if (!xkl_engine_find_toplevel_window
(engine, focused, &focused_toplevel)
- && engine->priv->listener_type & XKLL_MANAGE_WINDOW_STATES)
- focused_toplevel = engine->priv->curr_toplvl_win; /* what else can I do */
+ && xkl_engine_priv(engine,
+ listener_type) & XKLL_MANAGE_WINDOW_STATES)
+ focused_toplevel = xkl_engine_priv(engine, curr_toplvl_win); /* what else can I do */
xkl_debug(150, "Focused window: " WINID_FORMAT ", '%s'\n",
focused_toplevel,
xkl_get_debug_window_title(engine, focused_toplevel));
- if (engine->priv->listener_type & XKLL_MANAGE_WINDOW_STATES) {
+ if (xkl_engine_priv(engine, listener_type) &
+ XKLL_MANAGE_WINDOW_STATES) {
xkl_debug(150, "CurClient: " WINID_FORMAT ", '%s'\n",
- engine->priv->curr_toplvl_win,
- xkl_get_debug_window_title(engine, engine->priv->
- curr_toplvl_win));
-
- if (focused_toplevel != engine->priv->curr_toplvl_win) {
+ xkl_engine_priv(engine, curr_toplvl_win),
+ xkl_get_debug_window_title(engine,
+ xkl_engine_priv
+ (engine,
+ curr_toplvl_win)));
+
+ if (focused_toplevel !=
+ xkl_engine_priv(engine, curr_toplvl_win)) {
/**
* If not state - we got the new window
*/
@@ -490,13 +526,13 @@ xkl_engine_process_state_modification(XklEngine * engine,
xkl_engine_update_current_state(engine,
grp, inds,
"Updating the state from new focused window");
- if (engine->priv->
- listener_type &
- XKLL_MANAGE_WINDOW_STATES)
+ if (xkl_engine_priv(engine, listener_type)
+ & XKLL_MANAGE_WINDOW_STATES)
xkl_engine_add_toplevel_window
(engine, focused_toplevel,
(Window) NULL, FALSE,
- &engine->priv->curr_state);
+ &xkl_engine_priv(engine,
+ curr_state));
}
/**
* There is state - just get the state from the window
@@ -505,27 +541,30 @@ xkl_engine_process_state_modification(XklEngine * engine,
grp = old_state.group;
inds = old_state.indicators;
}
- engine->priv->curr_toplvl_win = focused_toplevel;
+ xkl_engine_priv(engine, curr_toplvl_win) =
+ focused_toplevel;
xkl_debug(160,
"CurClient:changed to " WINID_FORMAT
- ", '%s'\n",
- engine->priv->curr_toplvl_win,
+ ", '%s'\n", xkl_engine_priv(engine,
+ curr_toplvl_win),
xkl_get_debug_window_title(engine,
- engine->priv->
- curr_toplvl_win));
+ xkl_engine_priv
+ (engine,
+ curr_toplvl_win)));
}
/* If the window already has this this state - we are just restoring it!
(see the second parameter of stateCallback */
have_old_state =
xkl_engine_get_toplevel_window_state(engine,
- engine->priv->
- curr_toplvl_win,
+ xkl_engine_priv
+ (engine,
+ curr_toplvl_win),
&old_state);
} else { /* just tracking the stuff, no smart things */
xkl_debug(160,
"Just updating the current state in the tracking mode\n");
- memcpy(&old_state, &engine->priv->curr_state,
+ memcpy(&old_state, &xkl_engine_priv(engine, curr_state),
sizeof(XklState));
}
@@ -542,10 +581,13 @@ xkl_engine_process_state_modification(XklEngine * engine,
xkl_engine_try_call_state_func(engine, change_type,
&old_state);
- if (engine->priv->listener_type & XKLL_MANAGE_WINDOW_STATES)
+ if (xkl_engine_priv(engine, listener_type) &
+ XKLL_MANAGE_WINDOW_STATES)
xkl_engine_save_toplevel_window_state(engine,
- engine->priv->
- curr_toplvl_win,
- &engine->priv->
- curr_state);
+ xkl_engine_priv
+ (engine,
+ curr_toplvl_win),
+ &xkl_engine_priv
+ (engine,
+ curr_state));
}
diff --git a/libxklavier/xklavier_evt_xkb.c b/libxklavier/xklavier_evt_xkb.c
index 485e7e0..11132b2 100644
--- a/libxklavier/xklavier_evt_xkb.c
+++ b/libxklavier/xklavier_evt_xkb.c
@@ -23,7 +23,7 @@ xkl_xkb_process_x_event(XklEngine * engine, XEvent * xev)
if (xev->type != xkl_xkb_event_type)
return 0;
- if (!(engine->priv->listener_type &
+ if (!(xkl_engine_priv(engine, listener_type) &
(XKLL_MANAGE_WINDOW_STATES | XKLL_TRACK_KEYBOARD_STATE)))
return 0;
@@ -53,11 +53,12 @@ xkl_xkb_process_x_event(XklEngine * engine, XEvent * xev)
xkl_debug(200,
"This type of state notification is not regarding groups\n");
if (kev->state.locked_group !=
- engine->priv->curr_state.group)
+ xkl_engine_priv(engine, curr_state).group)
xkl_debug(0,
"ATTENTION! Currently cached group %d is not equal to the current group from the event: %d\n!",
- engine->priv->curr_state.group,
- kev->state.locked_group);
+ xkl_engine_priv(engine,
+ curr_state).
+ group, kev->state.locked_group);
}
break;
@@ -69,7 +70,7 @@ xkl_xkb_process_x_event(XklEngine * engine, XEvent * xev)
xkl_debug(150, "XkbIndicatorStateNotify\n");
- inds = engine->priv->curr_state.indicators;
+ inds = xkl_engine_priv(engine, curr_state).indicators;
ForPhysIndicators(i,
bit) if (kev->indicators.changed & bit) {
diff --git a/libxklavier/xklavier_evt_xmm.c b/libxklavier/xklavier_evt_xmm.c
index 05b0b02..06dc912 100644
--- a/libxklavier/xklavier_evt_xmm.c
+++ b/libxklavier/xklavier_evt_xmm.c
@@ -12,7 +12,7 @@
static gint
xkl_xmm_process_keypress_event(XklEngine * engine, XKeyPressedEvent * kpe)
{
- if (engine->priv->listener_type & XKLL_MANAGE_LAYOUTS) {
+ if (xkl_engine_priv(engine, listener_type) & XKLL_MANAGE_LAYOUTS) {
xkl_debug(200, "Processing the KeyPress event\n");
gint current_shortcut = 0;
const XmmSwitchOption *sop =
@@ -53,7 +53,8 @@ xkl_xmm_process_property_event(XklEngine * engine, XPropertyEvent * kpe)
XklState state;
xkl_xmm_get_server_state(engine, &state);
- if (engine->priv->listener_type & XKLL_MANAGE_LAYOUTS) {
+ if (xkl_engine_priv(engine, listener_type) &
+ XKLL_MANAGE_LAYOUTS) {
xkl_debug(150,
"Current group from the root window property %d\n",
state.group);
@@ -63,7 +64,7 @@ xkl_xmm_process_property_event(XklEngine * engine, XPropertyEvent * kpe)
return 1;
}
- if (engine->priv->listener_type &
+ if (xkl_engine_priv(engine, listener_type) &
(XKLL_MANAGE_WINDOW_STATES |
XKLL_TRACK_KEYBOARD_STATE)) {
xkl_debug(150,
@@ -79,7 +80,7 @@ xkl_xmm_process_property_event(XklEngine * engine, XPropertyEvent * kpe)
/**
* Configuration is changed!
*/
- if (kpe->atom == engine->priv->base_config_atom) {
+ if (kpe->atom == xkl_engine_priv(engine, base_config_atom)) {
xkl_engine_reset_all_info(engine,
"base config atom changed");
}
diff --git a/libxklavier/xklavier_private.h b/libxklavier/xklavier_private.h
index 39e1c73..2775158 100644
--- a/libxklavier/xklavier_private.h
+++ b/libxklavier/xklavier_private.h
@@ -5,7 +5,7 @@
#include <libxml/xpath.h>
-#include <libxklavier/xklavier_config.h>
+#include <libxklavier/xklavier.h>
enum { WM_NAME,
WM_STATE,
@@ -39,8 +39,6 @@ struct _XklEnginePrivate {
Status last_error_code;
- const gchar *last_error_message;
-
XklState curr_state;
Atom atoms[TOTAL_ATOMS];
@@ -368,10 +366,15 @@ extern void xkl_engine_one_switch_to_secondary_group_performed(XklEngine *
#define WINID_FORMAT "%lx"
-#define xkl_engine_get_display(engine) ((engine)->priv->display)
+#define xkl_engine_priv(engine,member) (engine)->priv->member
+#define xkl_engine_get_display(engine) (xkl_engine_priv(engine,display))
#define xkl_engine_vcall(engine,func) (*(engine)->priv->func)
+
+#define xkl_config_priv(config,member) (config)->priv->member
#define xkl_config_registry_get_engine(config) ((config)->priv->engine)
extern gint xkl_debug_level;
+extern const gchar *xkl_last_error_message;
+
#endif
diff --git a/libxklavier/xklavier_props.c b/libxklavier/xklavier_props.c
index e6e7671..8b06f5d 100644
--- a/libxklavier/xklavier_props.c
+++ b/libxklavier/xklavier_props.c
@@ -9,8 +9,6 @@
#include "config.h"
-#include "xklavier.h"
-#include "xklavier_config.h"
#include "xklavier_private.h"
static GObjectClass *g_object_class = NULL;
@@ -98,10 +96,11 @@ xkl_engine_get_default_names_prop(XklEngine * engine,
{
if (rules_file_out != NULL)
*rules_file_out = g_strdup(XKB_DEFAULT_RULESET);
- data->model = g_strdup(engine->priv->default_model);
+ data->model = g_strdup(xkl_engine_priv(engine, default_model));
/* keeping Nvariants = Nlayouts */
data->layouts = g_new0(char *, 2);
- data->layouts[0] = g_strdup(engine->priv->default_layout);
+ data->layouts[0] =
+ g_strdup(xkl_engine_priv(engine, default_layout));
data->variants = g_new0(char *, 2);
data->variants[0] = g_strdup("");
data->options = NULL;
@@ -114,9 +113,9 @@ xkl_config_rec_get_full_from_server(char **rules_file_out,
XklEngine * engine)
{
gboolean rv = xkl_config_rec_get_from_root_window_property(data,
- engine->
- priv->
- base_config_atom,
+ xkl_engine_priv
+ (engine,
+ base_config_atom),
rules_file_out,
engine);
@@ -179,8 +178,9 @@ gboolean
xkl_config_rec_get_from_backup(XklConfigRec * data, XklEngine * engine)
{
return xkl_config_rec_get_from_root_window_property(data,
- engine->priv->
- backup_config_atom,
+ xkl_engine_priv
+ (engine,
+ backup_config_atom),
NULL, engine);
}
@@ -194,7 +194,8 @@ xkl_backup_names_prop(XklEngine * engine)
xkl_config_rec_init(&data);
if (xkl_config_rec_get_from_root_window_property
- (&data, engine->priv->backup_config_atom, NULL, engine)) {
+ (&data, xkl_engine_priv(engine, backup_config_atom), NULL,
+ engine)) {
xkl_config_rec_destroy(&data);
return TRUE;
}
@@ -204,8 +205,8 @@ xkl_backup_names_prop(XklEngine * engine)
if (cgp) {
if (!xkl_config_rec_set_to_root_window_property
- (&data, engine->priv->backup_config_atom, rf,
- engine)) {
+ (&data, xkl_engine_priv(engine, backup_config_atom),
+ rf, engine)) {
xkl_debug(150,
"Could not backup the configuration");
rv = FALSE;
@@ -230,13 +231,15 @@ xkl_restore_names_prop(XklEngine * engine)
xkl_config_rec_init(&data);
if (!xkl_config_rec_get_from_root_window_property
- (&data, engine->priv->backup_config_atom, NULL, engine)) {
+ (&data, xkl_engine_priv(engine, backup_config_atom), NULL,
+ engine)) {
xkl_config_rec_destroy(&data);
return FALSE;
}
if (!xkl_config_rec_set_to_root_window_property
- (&data, engine->priv->base_config_atom, rf, engine)) {
+ (&data, xkl_engine_priv(engine, base_config_atom), rf,
+ engine)) {
xkl_debug(150, "Could not backup the configuration");
rv = FALSE;
}
@@ -258,22 +261,20 @@ xkl_config_rec_get_from_root_window_property(XklConfigRec * data,
/* no such atom! */
if (rules_atom == None) { /* property cannot exist */
- engine->priv->last_error_message =
- "Could not find the atom";
+ xkl_last_error_message = "Could not find the atom";
return FALSE;
}
rtrn =
XGetWindowProperty(xkl_engine_get_display(engine),
- engine->priv->root_window, rules_atom, 0L,
- XKB_RF_NAMES_PROP_MAXLEN, False, XA_STRING,
- &real_prop_type, &fmt, &nitems,
- &extra_bytes,
+ xkl_engine_priv(engine, root_window),
+ rules_atom, 0L, XKB_RF_NAMES_PROP_MAXLEN,
+ False, XA_STRING, &real_prop_type, &fmt,
+ &nitems, &extra_bytes,
(unsigned char **) (void *) &prop_data);
/* property not found! */
if (rtrn != Success) {
- engine->priv->last_error_message =
- "Could not get the property";
+ xkl_last_error_message = "Could not get the property";
return FALSE;
}
/* set rules file to "" */
@@ -285,13 +286,12 @@ xkl_config_rec_get_from_root_window_property(XklConfigRec * data,
|| (fmt != 8)) {
if (prop_data)
XFree(prop_data);
- engine->priv->last_error_message = "Wrong property format";
+ xkl_last_error_message = "Wrong property format";
return FALSE;
}
if (!prop_data) {
- engine->priv->last_error_message =
- "No properties returned";
+ xkl_last_error_message = "No properties returned";
return FALSE;
}
@@ -402,8 +402,7 @@ xkl_config_rec_set_to_root_window_property(const XklConfigRec * data,
pval = next = g_new(char, len + 1);
if (!pval) {
- engine->priv->last_error_message =
- "Could not allocate buffer";
+ xkl_last_error_message = "Could not allocate buffer";
if (all_layouts != NULL)
g_free(all_layouts);
if (all_variants != NULL)
@@ -447,13 +446,12 @@ xkl_config_rec_set_to_root_window_property(const XklConfigRec * data,
if (all_options != NULL)
g_free(all_options);
g_free(pval);
- engine->priv->last_error_message =
- "Internal property parsing error";
+ xkl_last_error_message = "Internal property parsing error";
return FALSE;
}
Display *display = xkl_engine_get_display(engine);
- rv = XChangeProperty(display, engine->priv->root_window,
+ rv = XChangeProperty(display, xkl_engine_priv(engine, root_window),
rules_atom, XA_STRING, 8, PropModeReplace,
(unsigned char *) pval, len);
XSync(display, False);
diff --git a/libxklavier/xklavier_toplevel.c b/libxklavier/xklavier_toplevel.c
index c4db68e..f343ef4 100644
--- a/libxklavier/xklavier_toplevel.c
+++ b/libxklavier/xklavier_toplevel.c
@@ -25,13 +25,15 @@ xkl_engine_set_toplevel_window_transparent(XklEngine * engine,
CARD32 prop = 1;
XChangeProperty(xkl_engine_get_display(engine),
toplevel_win,
- engine->priv->atoms[XKLAVIER_TRANSPARENT],
- XA_INTEGER, 32, PropModeReplace,
+ xkl_engine_priv(engine, atoms)
+ [XKLAVIER_TRANSPARENT], XA_INTEGER, 32,
+ PropModeReplace,
(const unsigned char *) &prop, 1);
} else if (!transparent && oldval) {
XDeleteProperty(xkl_engine_get_display(engine),
toplevel_win,
- engine->priv->atoms[XKLAVIER_TRANSPARENT]);
+ xkl_engine_priv(engine, atoms)
+ [XKLAVIER_TRANSPARENT]);
}
}
@@ -50,7 +52,7 @@ xkl_engine_add_toplevel_window(XklEngine * engine, Window toplevel_win,
XklState state = *init_state;
gint default_group_to_use = -1;
- if (toplevel_win == engine->priv->root_window)
+ if (toplevel_win == xkl_engine_priv(engine, root_window))
xkl_debug(150, "??? root app win ???\n");
xkl_debug(150,
@@ -82,7 +84,8 @@ xkl_engine_add_toplevel_window(XklEngine * engine, Window toplevel_win,
*/
if (default_group_to_use == -1)
- default_group_to_use = engine->priv->default_group;
+ default_group_to_use =
+ xkl_engine_priv(engine, default_group);
if (default_group_to_use != -1)
state.group = default_group_to_use;
@@ -94,9 +97,10 @@ xkl_engine_add_toplevel_window(XklEngine * engine, Window toplevel_win,
PropertyChangeMask);
if (default_group_to_use != -1) {
- if (engine->priv->curr_toplvl_win == toplevel_win) {
- if ((engine->priv->secondary_groups_mask &
- (1 << default_group_to_use)) != 0)
+ if (xkl_engine_priv(engine, curr_toplvl_win) ==
+ toplevel_win) {
+ if ((xkl_engine_priv(engine, secondary_groups_mask)
+ & (1 << default_group_to_use)) != 0)
xkl_engine_allow_one_switch_to_secondary_group
(engine);
xkl_engine_lock_group(engine,
@@ -123,10 +127,10 @@ xkl_engine_find_toplevel_window_bottom_to_top(XklEngine * engine,
NULL;
guint num = 0;
- if (win == (Window) NULL || win == engine->priv->root_window) {
+ if (win == (Window) NULL
+ || win == xkl_engine_priv(engine, root_window)) {
*toplevel_win_out = win;
- engine->priv->last_error_message =
- "The window is either 0 or root";
+ xkl_last_error_message = "The window is either 0 or root";
return FALSE;
}
@@ -135,11 +139,11 @@ xkl_engine_find_toplevel_window_bottom_to_top(XklEngine * engine,
return TRUE;
}
- engine->priv->last_error_code =
+ xkl_engine_priv(engine, last_error_code) =
xkl_engine_query_tree(engine, win, &rwin, &parent, &children,
&num);
- if (engine->priv->last_error_code != Success) {
+ if (xkl_engine_priv(engine, last_error_code) != Success) {
*toplevel_win_out = (Window) NULL;
return FALSE;
}
@@ -168,10 +172,10 @@ xkl_engine_find_toplevel_window(XklEngine * engine, Window win,
guint num = 0;
gboolean rv;
- if (win == (Window) NULL || win == engine->priv->root_window) {
+ if (win == (Window) NULL
+ || win == xkl_engine_priv(engine, root_window)) {
*toplevel_win_out = (Window) NULL;
- engine->priv->last_error_message =
- "The window is either 0 or root";
+ xkl_last_error_message = "The window is either 0 or root";
xkl_debug(150,
"Window " WINID_FORMAT
" is either 0 or root so could not get the app window for it\n",
@@ -184,11 +188,11 @@ xkl_engine_find_toplevel_window(XklEngine * engine, Window win,
return TRUE;
}
- engine->priv->last_error_code =
+ xkl_engine_priv(engine, last_error_code) =
xkl_engine_query_tree(engine, win, &rwin, &parent, &children,
&num);
- if (engine->priv->last_error_code != Success) {
+ if (xkl_engine_priv(engine, last_error_code) != Success) {
*toplevel_win_out = (Window) NULL;
xkl_debug(150,
"Could not get tree for window " WINID_FORMAT
@@ -247,7 +251,7 @@ xkl_engine_get_toplevel_window_state(XklEngine * engine,
if ((XGetWindowProperty
(xkl_engine_get_display(engine), toplevel_win,
- engine->priv->atoms[XKLAVIER_STATE], 0L,
+ xkl_engine_priv(engine, atoms)[XKLAVIER_STATE], 0L,
XKLAVIER_STATE_PROP_LENGTH, False, XA_INTEGER, &type_ret,
&format_ret, &nitems, &rest,
(unsigned char **) (void *) &prop) == Success)
@@ -293,7 +297,7 @@ xkl_engine_remove_toplevel_window_state(XklEngine * engine,
Window toplevel_win)
{
XDeleteProperty(xkl_engine_get_display(engine), toplevel_win,
- engine->priv->atoms[XKLAVIER_STATE]);
+ xkl_engine_priv(engine, atoms)[XKLAVIER_STATE]);
}
/**
@@ -310,8 +314,9 @@ xkl_engine_save_toplevel_window_state(XklEngine * engine,
prop[1] = state->indicators;
XChangeProperty(xkl_engine_get_display(engine), toplevel_win,
- engine->priv->atoms[XKLAVIER_STATE], XA_INTEGER,
- 32, PropModeReplace, (const unsigned char *) prop,
+ xkl_engine_priv(engine, atoms)[XKLAVIER_STATE],
+ XA_INTEGER, 32, PropModeReplace,
+ (const unsigned char *) prop,
XKLAVIER_STATE_PROP_LENGTH);
xkl_debug(160,
@@ -330,8 +335,8 @@ xkl_engine_is_toplevel_window_transparent(XklEngine * engine,
CARD32 *prop = NULL;
if ((XGetWindowProperty
(xkl_engine_get_display(engine), toplevel_win,
- engine->priv->atoms[XKLAVIER_TRANSPARENT], 0L, 1, False,
- XA_INTEGER, &type_ret, &format_ret, &nitems, &rest,
+ xkl_engine_priv(engine, atoms)[XKLAVIER_TRANSPARENT], 0L, 1,
+ False, XA_INTEGER, &type_ret, &format_ret, &nitems, &rest,
(unsigned char **) (void *) &prop) == Success)
&& (type_ret == XA_INTEGER) && (format_ret == 32)) {
if (prop != NULL)
diff --git a/libxklavier/xklavier_util.c b/libxklavier/xklavier_util.c
index b1704c7..88a1a27 100644
--- a/libxklavier/xklavier_util.c
+++ b/libxklavier/xklavier_util.c
@@ -10,13 +10,13 @@
XklState *
xkl_engine_get_current_state(XklEngine * engine)
{
- return &engine->priv->curr_state;
+ return &xkl_engine_priv(engine, curr_state);
}
const gchar *
-xkl_engine_get_last_error(XklEngine * engine)
+xkl_get_last_error()
{
- return engine->priv->last_error_message;
+ return xkl_last_error_message;
}
gchar *
@@ -29,9 +29,9 @@ xkl_engine_get_window_title(XklEngine * engine, Window w)
if (Success ==
XGetWindowProperty(xkl_engine_get_display(engine), w,
- engine->priv->atoms[WM_NAME], 0L, -1L,
- False, XA_STRING, &type_ret, &format_ret,
- &nitems, &rest, &prop))
+ xkl_engine_priv(engine, atoms)[WM_NAME], 0L,
+ -1L, False, XA_STRING, &type_ret,
+ &format_ret, &nitems, &rest, &prop))
return (gchar *) prop;
else
return NULL;
@@ -76,7 +76,9 @@ xkl_engine_save_state(XklEngine * engine, Window win, XklState * state)
{
Window app_win;
- if (!(engine->priv->listener_type & XKLL_MANAGE_WINDOW_STATES))
+ if (!
+ (xkl_engine_priv(engine, listener_type) &
+ XKLL_MANAGE_WINDOW_STATES))
return;
if (xkl_engine_find_toplevel_window(engine, win, &app_win))
@@ -106,7 +108,7 @@ xkl_get_debug_window_title(XklEngine * engine, Window win)
Window
xkl_engine_get_current_window(XklEngine * engine)
{
- return engine->priv->curr_toplvl_win;
+ return xkl_engine_priv(engine, curr_toplvl_win);
}
/**
@@ -123,11 +125,11 @@ xkl_engine_load_subtree(XklEngine * engine, Window window, gint level,
guint num = 0;
gboolean retval = True;
- engine->priv->last_error_code =
+ xkl_engine_priv(engine, last_error_code) =
xkl_engine_query_tree(engine, window, &rwin, &parent,
&children, &num);
- if (engine->priv->last_error_code != Success) {
+ if (xkl_engine_priv(engine, last_error_code) != Success) {
return FALSE;
}
@@ -192,9 +194,9 @@ xkl_engine_if_window_has_wm_state(XklEngine * engine, Window win)
unsigned char *data = NULL; /* Helps in the case of BadWindow error */
XGetWindowProperty(xkl_engine_get_display(engine), win,
- engine->priv->atoms[WM_STATE], 0, 0, False,
- engine->priv->atoms[WM_STATE], &type, &format,
- &nitems, &after, &data);
+ xkl_engine_priv(engine, atoms)[WM_STATE], 0, 0,
+ False, xkl_engine_priv(engine, atoms)[WM_STATE],
+ &type, &format, &nitems, &after, &data);
if (data != NULL)
XFree(data); /* To avoid an one-byte memory leak because after successfull return
* data array always contains at least one nul byte (NULL-equivalent) */
@@ -211,14 +213,14 @@ xkl_engine_get_registered_parent(XklEngine * engine, Window win)
NULL;
guint nchildren = 0;
- engine->priv->last_error_code =
+ xkl_engine_priv(engine, last_error_code) =
xkl_engine_query_tree(engine, win, &rw, &parent, &children,
&nchildren);
if (children != NULL)
XFree(children);
- return engine->priv->last_error_code ==
+ return xkl_engine_priv(engine, last_error_code) ==
Success ? parent : (Window) NULL;
}
@@ -244,8 +246,7 @@ xkl_engine_query_tree(XklEngine * engine, Window w,
xkl_debug(160,
"Could not get tree info for window "
WINID_FORMAT ": %d\n", w, result);
- engine->priv->last_error_message =
- "Could not get the tree info";
+ xkl_last_error_message = "Could not get the tree info";
}
return result ? Success : FirstExtensionError;
@@ -303,6 +304,6 @@ xkl_engine_update_current_state(XklEngine * engine, int group,
xkl_debug(150,
"Updating the current state with [g:%d/i:%u], reason: %s\n",
group, indicators, reason);
- engine->priv->curr_state.group = group;
- engine->priv->curr_state.indicators = indicators;
+ xkl_engine_priv(engine, curr_state).group = group;
+ xkl_engine_priv(engine, curr_state).indicators = indicators;
}
diff --git a/libxklavier/xklavier_xkb.c b/libxklavier/xklavier_xkb.c
index a312ef3..25be234 100644
--- a/libxklavier/xklavier_xkb.c
+++ b/libxklavier/xklavier_xkb.c
@@ -81,8 +81,9 @@ xkl_xkb_resume_listen(XklEngine * engine)
guint
xkl_xkb_get_max_num_groups(XklEngine * engine)
{
- return engine->priv->features & XKLF_MULTIPLE_LAYOUTS_SUPPORTED ?
- XkbNumKbdGroups : 1;
+ return xkl_engine_priv(engine,
+ features) & XKLF_MULTIPLE_LAYOUTS_SUPPORTED
+ ? XkbNumKbdGroups : 1;
}
guint
@@ -147,11 +148,10 @@ xkl_xkb_load_precached_xkb(XklEngine * engine)
XkbAllIndicatorsMask,
precached_xkb));
if (!rv) {
- engine->priv->last_error_message =
+ xkl_last_error_message =
"Could not load controls/names/indicators";
xkl_debug(0, "%s: %d\n",
- engine->priv->last_error_message,
- status);
+ xkl_last_error_message, status);
XkbFreeKeyboard(precached_xkb,
XkbAllComponentsMask, True);
}
@@ -219,8 +219,7 @@ xkl_xkb_load_all_info(XklEngine * engine)
if (precached_xkb == NULL)
if (!xkl_xkb_load_precached_xkb(engine)) {
- engine->priv->last_error_message =
- "Could not load keyboard";
+ xkl_last_error_message = "Could not load keyboard";
return FALSE;
}
@@ -245,13 +244,12 @@ xkl_xkb_load_all_info(XklEngine * engine)
xkl_debug(200, "Group %d has name [%s]\n", i, *group_name);
}
- engine->priv->last_error_code =
+ xkl_engine_priv(engine, last_error_code) =
XkbGetIndicatorMap(display, XkbAllIndicatorsMask,
xkl_xkb_desc);
- if (engine->priv->last_error_code != Success) {
- engine->priv->last_error_message =
- "Could not load indicator map";
+ if (xkl_engine_priv(engine, last_error_code) != Success) {
+ xkl_last_error_message = "Could not load indicator map";
return FALSE;
}
@@ -481,28 +479,34 @@ xkl_xkb_init(XklEngine * engine)
gint opcode;
gboolean xkl_xkb_ext_present;
- engine->priv->backend_id = "XKB";
- engine->priv->features = XKLF_CAN_TOGGLE_INDICATORS |
+ xkl_engine_priv(engine, backend_id) = "XKB";
+ xkl_engine_priv(engine, features) = XKLF_CAN_TOGGLE_INDICATORS |
XKLF_CAN_OUTPUT_CONFIG_AS_ASCII |
XKLF_CAN_OUTPUT_CONFIG_AS_BINARY;
- engine->priv->activate_config_rec = xkl_xkb_activate_config_rec;
- engine->priv->init_config_registry = xkl_xkb_init_config_registry;
- engine->priv->load_config_registry = xkl_xkb_load_config_registry;
- engine->priv->write_config_rec_to_file =
+ xkl_engine_priv(engine, activate_config_rec) =
+ xkl_xkb_activate_config_rec;
+ xkl_engine_priv(engine, init_config_registry) =
+ xkl_xkb_init_config_registry;
+ xkl_engine_priv(engine, load_config_registry) =
+ xkl_xkb_load_config_registry;
+ xkl_engine_priv(engine, write_config_rec_to_file) =
xkl_xkb_write_config_rec_to_file;
- engine->priv->get_groups_names = xkl_xkb_get_groups_names;
- engine->priv->get_max_num_groups = xkl_xkb_get_max_num_groups;
- engine->priv->get_num_groups = xkl_xkb_get_num_groups;
- engine->priv->lock_group = xkl_xkb_lock_group;
- engine->priv->process_x_event = xkl_xkb_process_x_event;
- engine->priv->free_all_info = xkl_xkb_free_all_info;
- engine->priv->if_cached_info_equals_actual =
+ xkl_engine_priv(engine, get_groups_names) =
+ xkl_xkb_get_groups_names;
+ xkl_engine_priv(engine, get_max_num_groups) =
+ xkl_xkb_get_max_num_groups;
+ xkl_engine_priv(engine, get_num_groups) = xkl_xkb_get_num_groups;
+ xkl_engine_priv(engine, lock_group) = xkl_xkb_lock_group;
+ xkl_engine_priv(engine, process_x_event) = xkl_xkb_process_x_event;
+ xkl_engine_priv(engine, free_all_info) = xkl_xkb_free_all_info;
+ xkl_engine_priv(engine, if_cached_info_equals_actual) =
xkl_xkb_if_cached_info_equals_actual;
- engine->priv->load_all_info = xkl_xkb_load_all_info;
- engine->priv->get_server_state = xkl_xkb_get_server_state;
- engine->priv->pause_listen = xkl_xkb_pause_listen;
- engine->priv->resume_listen = xkl_xkb_resume_listen;
- engine->priv->set_indicators = xkl_xkb_set_indicators;
+ xkl_engine_priv(engine, load_all_info) = xkl_xkb_load_all_info;
+ xkl_engine_priv(engine, get_server_state) =
+ xkl_xkb_get_server_state;
+ xkl_engine_priv(engine, pause_listen) = xkl_xkb_pause_listen;
+ xkl_engine_priv(engine, resume_listen) = xkl_xkb_resume_listen;
+ xkl_engine_priv(engine, set_indicators) = xkl_xkb_set_indicators;
if (getenv("XKL_XKB_DISABLE") != NULL)
return -1;
@@ -514,35 +518,38 @@ xkl_xkb_init(XklEngine * engine)
NULL);
if (!xkl_xkb_ext_present) {
XSetErrorHandler((XErrorHandler)
- engine->priv->default_error_handler);
+ xkl_engine_priv(engine,
+ default_error_handler));
return -1;
}
xkl_debug(160,
"xkbEvenType: %X, xkbError: %X, display: %p, root: "
WINID_FORMAT "\n", xkl_xkb_event_type,
- xkl_xkb_error_code, display, engine->priv->root_window);
+ xkl_xkb_error_code, display, xkl_engine_priv(engine,
+ root_window));
- engine->priv->base_config_atom =
+ xkl_engine_priv(engine, base_config_atom) =
XInternAtom(display, _XKB_RF_NAMES_PROP_ATOM, False);
- engine->priv->backup_config_atom =
+ xkl_engine_priv(engine, backup_config_atom) =
XInternAtom(display, "_XKB_RULES_NAMES_BACKUP", False);
- engine->priv->default_model = "pc101";
- engine->priv->default_layout = "us";
+ xkl_engine_priv(engine, default_model) = "pc101";
+ xkl_engine_priv(engine, default_layout) = "us";
/* First, we have to assign xkl_vtable -
because this function uses it */
if (xkl_xkb_multiple_layouts_supported(engine))
- engine->priv->features |= XKLF_MULTIPLE_LAYOUTS_SUPPORTED;
+ xkl_engine_priv(engine, features) |=
+ XKLF_MULTIPLE_LAYOUTS_SUPPORTED;
return 0;
#else
xkl_debug(160,
"NO XKB LIBS, display: %p, root: " WINID_FORMAT
- "\n", display, engine->priv->root_window);
+ "\n", display, xkl_engine_priv(engine, root_window));
return -1;
#endif
}
diff --git a/libxklavier/xklavier_xmm.c b/libxklavier/xklavier_xmm.c
index 385e742..44ba490 100755
--- a/libxklavier/xklavier_xmm.c
+++ b/libxklavier/xklavier_xmm.c
@@ -127,7 +127,7 @@ xkl_xmm_find_switch_option(XklEngine * engine, gint keycode,
gint
xkl_xmm_resume_listen(XklEngine * engine)
{
- if (engine->priv->listener_type & XKLL_MANAGE_LAYOUTS)
+ if (xkl_engine_priv(engine, listener_type) & XKLL_MANAGE_LAYOUTS)
xkl_xmm_shortcuts_grab(engine);
return 0;
}
@@ -135,7 +135,7 @@ xkl_xmm_resume_listen(XklEngine * engine)
gint
xkl_xmm_pause_listen(XklEngine * engine)
{
- if (engine->priv->listener_type & XKLL_MANAGE_LAYOUTS)
+ if (xkl_engine_priv(engine, listener_type) & XKLL_MANAGE_LAYOUTS)
xkl_xmm_shortcuts_ungrab(engine);
return 0;
}
@@ -195,9 +195,9 @@ xkl_xmm_get_server_state(XklEngine * engine, XklState * state)
result =
XGetWindowProperty(xkl_engine_get_display(engine),
- engine->priv->root_window, xmm_state_atom,
- 0L, 1L, False, XA_INTEGER, &actual_type,
- &actual_format, &actual_items,
+ xkl_engine_priv(engine, root_window),
+ xmm_state_atom, 0L, 1L, False, XA_INTEGER,
+ &actual_type, &actual_format, &actual_items,
&bytes_remaining, &propval);
if (Success == result) {
@@ -250,8 +250,8 @@ xkl_xmm_lock_group(XklEngine * engine, gint group)
/* updating the status property */
propval = group;
Display *display = xkl_engine_get_display(engine);
- XChangeProperty(display, engine->priv->root_window, xmm_state_atom,
- XA_INTEGER, 32, PropModeReplace,
+ XChangeProperty(display, xkl_engine_priv(engine, root_window),
+ xmm_state_atom, XA_INTEGER, 32, PropModeReplace,
(unsigned char *) &propval, 1);
XSync(display, False);
}
@@ -259,42 +259,49 @@ xkl_xmm_lock_group(XklEngine * engine, gint group)
gint
xkl_xmm_init(XklEngine * engine)
{
- engine->priv->backend_id = "xmodmap";
- engine->priv->features = XKLF_MULTIPLE_LAYOUTS_SUPPORTED |
+ xkl_engine_priv(engine, backend_id) = "xmodmap";
+ xkl_engine_priv(engine, features) =
+ XKLF_MULTIPLE_LAYOUTS_SUPPORTED |
XKLF_REQUIRES_MANUAL_LAYOUT_MANAGEMENT;
- engine->priv->activate_config_rec = xkl_xmm_activate_config_rec;
- engine->priv->init_config_registry = xkl_xmm_init_config_registry;
- engine->priv->load_config_registry = xkl_xmm_load_config_registry;
- engine->priv->write_config_rec_to_file = NULL;
-
- engine->priv->get_groups_names = xkl_xmm_get_groups_names;
- engine->priv->get_max_num_groups = xkl_xmm_get_max_num_groups;
- engine->priv->get_num_groups = xkl_xmm_get_num_groups;
- engine->priv->lock_group = xkl_xmm_lock_group;
-
- engine->priv->process_x_event = xkl_xmm_process_x_event;
- engine->priv->free_all_info = xkl_xmm_free_all_info;
- engine->priv->if_cached_info_equals_actual =
+ xkl_engine_priv(engine, activate_config_rec) =
+ xkl_xmm_activate_config_rec;
+ xkl_engine_priv(engine, init_config_registry) =
+ xkl_xmm_init_config_registry;
+ xkl_engine_priv(engine, load_config_registry) =
+ xkl_xmm_load_config_registry;
+ xkl_engine_priv(engine, write_config_rec_to_file) = NULL;
+
+ xkl_engine_priv(engine, get_groups_names) =
+ xkl_xmm_get_groups_names;
+ xkl_engine_priv(engine, get_max_num_groups) =
+ xkl_xmm_get_max_num_groups;
+ xkl_engine_priv(engine, get_num_groups) = xkl_xmm_get_num_groups;
+ xkl_engine_priv(engine, lock_group) = xkl_xmm_lock_group;
+
+ xkl_engine_priv(engine, process_x_event) = xkl_xmm_process_x_event;
+ xkl_engine_priv(engine, free_all_info) = xkl_xmm_free_all_info;
+ xkl_engine_priv(engine, if_cached_info_equals_actual) =
xkl_xmm_if_cached_info_equals_actual;
- engine->priv->load_all_info = xkl_xmm_load_all_info;
- engine->priv->get_server_state = xkl_xmm_get_server_state;
- engine->priv->pause_listen = xkl_xmm_pause_listen;
- engine->priv->resume_listen = xkl_xmm_resume_listen;
- engine->priv->set_indicators = NULL;
+ xkl_engine_priv(engine, load_all_info) = xkl_xmm_load_all_info;
+ xkl_engine_priv(engine, get_server_state) =
+ xkl_xmm_get_server_state;
+ xkl_engine_priv(engine, pause_listen) = xkl_xmm_pause_listen;
+ xkl_engine_priv(engine, resume_listen) = xkl_xmm_resume_listen;
+ xkl_engine_priv(engine, set_indicators) = NULL;
if (getenv("XKL_XMODMAP_DISABLE") != NULL)
return -1;
Display *display = xkl_engine_get_display(engine);
- engine->priv->base_config_atom =
+ xkl_engine_priv(engine, base_config_atom) =
XInternAtom(display, "_XMM_NAMES", False);
- engine->priv->backup_config_atom =
+ xkl_engine_priv(engine, backup_config_atom) =
XInternAtom(display, "_XMM_NAMES_BACKUP", False);
xmm_state_atom = XInternAtom(display, "_XMM_STATE", False);
- engine->priv->default_model = "generic";
- engine->priv->default_layout = "us";
+ xkl_engine_priv(engine, default_model) = "generic";
+ xkl_engine_priv(engine, default_layout) = "us";
return 0;
}
diff --git a/tests/test_config.c b/tests/test_config.c
index 4bfbf37..393b0cd 100644
--- a/tests/test_config.c
+++ b/tests/test_config.c
@@ -6,7 +6,6 @@
#include <string.h>
#include <X11/Xlib.h>
#include <libxklavier/xklavier.h>
-#include <libxklavier/xklavier_config.h>
extern void xkl_config_rec_dump(FILE * file, XklConfigRec * data);
@@ -101,7 +100,8 @@ main(int argc, char *const argv[])
if (debug_level != -1)
xkl_set_debug_level(debug_level);
xkl_debug(0, "Xklavier initialized\n");
- XklConfigRegistry *config = xkl_config_registry_get_instance(engine);
+ XklConfigRegistry *config =
+ xkl_config_registry_get_instance(engine);
xkl_config_registry_load(config);
xkl_debug(0, "Xklavier registry loaded\n");
xkl_debug(0, "Backend: [%s]\n",
@@ -137,14 +137,12 @@ main(int argc, char *const argv[])
} else {
xkl_debug(0,
"The configuration could not be reverted: %s\n",
- xkl_engine_get_last_error
- (engine));
+ xkl_get_last_error());
}
} else {
xkl_debug(0,
"The backup configuration could not be restored: %s\n",
- xkl_engine_get_last_error
- (engine));
+ xkl_get_last_error());
}
g_object_unref(G_OBJECT(r2));
@@ -192,8 +190,7 @@ main(int argc, char *const argv[])
else
xkl_debug(0,
"Could not set the config: %s\n",
- xkl_engine_get_last_error
- (engine));
+ xkl_get_last_error());
break;
case ACTION_WRITE:
xkl_config_rec_write_to_file(engine,
diff --git a/tests/test_monitor.c b/tests/test_monitor.c
index c6e1acb..429dd0a 100644
--- a/tests/test_monitor.c
+++ b/tests/test_monitor.c
@@ -6,7 +6,6 @@
#include <X11/Xutil.h>
#include <X11/XKBlib.h>
#include <libxklavier/xklavier.h>
-#include <libxklavier/xklavier_config.h>
extern void xkl_config_dump(FILE * file, XklConfigRec * data);