summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Udaltsov <svu@gnome.org>2006-02-19 19:11:53 +0000
committerSergey Udaltsov <svu@gnome.org>2006-02-19 19:11:53 +0000
commitbb4af1c3f93a6838af8775c990ffd92fc06e197f (patch)
tree6eeebd9713cff1cca7916695f64bb0dc0cea41fc
parente1a8eca61cabcb1d609900b89e35f5feccecd4a9 (diff)
downloadlibxklavier-bb4af1c3f93a6838af8775c990ffd92fc06e197f.tar.gz
after indent
-rw-r--r--libxklavier/.indent.pro3
-rw-r--r--libxklavier/xklavier.c738
-rw-r--r--libxklavier/xklavier.h159
-rw-r--r--libxklavier/xklavier_config.c835
-rw-r--r--libxklavier/xklavier_config.h162
-rw-r--r--libxklavier/xklavier_config_i18n.c359
-rw-r--r--libxklavier/xklavier_config_xkb.c762
-rw-r--r--libxklavier/xklavier_config_xmm.c46
-rw-r--r--libxklavier/xklavier_dump.c423
-rw-r--r--libxklavier/xklavier_evt.c765
-rw-r--r--libxklavier/xklavier_evt_xkb.c182
-rw-r--r--libxklavier/xklavier_evt_xmm.c255
-rw-r--r--libxklavier/xklavier_private.h247
-rw-r--r--libxklavier/xklavier_private_xkb.h57
-rw-r--r--libxklavier/xklavier_private_xmm.h69
-rw-r--r--libxklavier/xklavier_props.c662
-rw-r--r--libxklavier/xklavier_toplevel.c481
-rw-r--r--libxklavier/xklavier_util.c412
-rw-r--r--libxklavier/xklavier_xkb.c881
-rwxr-xr-xlibxklavier/xklavier_xmm.c444
-rw-r--r--libxklavier/xklavier_xmm_opts.c254
21 files changed, 4267 insertions, 3929 deletions
diff --git a/libxklavier/.indent.pro b/libxklavier/.indent.pro
new file mode 100644
index 0000000..dbec33f
--- /dev/null
+++ b/libxklavier/.indent.pro
@@ -0,0 +1,3 @@
+-kr
+-i8
+-psl
diff --git a/libxklavier/xklavier.c b/libxklavier/xklavier.c
index b9d9e01..372bf7c 100644
--- a/libxklavier/xklavier.c
+++ b/libxklavier/xklavier.c
@@ -51,538 +51,584 @@ static gboolean group_per_toplevel_window = TRUE;
static gboolean handle_indicators = FALSE;
-void xkl_set_indicators_handling( gboolean whether_handle )
+void
+xkl_set_indicators_handling(gboolean whether_handle)
{
- handle_indicators = whether_handle;
+ handle_indicators = whether_handle;
}
-gboolean xkl_get_indicators_handling( void )
+gboolean
+xkl_get_indicators_handling(void)
{
- return handle_indicators;
+ return handle_indicators;
}
-void xkl_set_debug_level( int level )
+void
+xkl_set_debug_level(int level)
{
- xkl_debug_level = level;
+ xkl_debug_level = level;
}
-void xkl_set_group_per_toplevel_window( gboolean is_set )
+void
+xkl_set_group_per_toplevel_window(gboolean is_set)
{
- group_per_toplevel_window = is_set;
+ group_per_toplevel_window = is_set;
}
-gboolean xkl_is_group_per_toplevel_window( void )
+gboolean
+xkl_is_group_per_toplevel_window(void)
{
- return group_per_toplevel_window;
+ return group_per_toplevel_window;
}
-static void xkl_set_switch_to_secondary_group( gboolean val )
+static void
+xkl_set_switch_to_secondary_group(gboolean val)
{
- CARD32 propval = (CARD32)val;
- XChangeProperty( xkl_display,
- xkl_root_window,
- xkl_atoms[XKLAVIER_ALLOW_SECONDARY],
- XA_INTEGER, 32, PropModeReplace,
- (unsigned char*)&propval, 1 );
- XSync( xkl_display, False );
+ CARD32 propval = (CARD32) val;
+ XChangeProperty(xkl_display,
+ xkl_root_window,
+ xkl_atoms[XKLAVIER_ALLOW_SECONDARY],
+ XA_INTEGER, 32, PropModeReplace,
+ (unsigned char *) &propval, 1);
+ XSync(xkl_display, False);
}
-void xkl_group_allow_one_switch_to_secondary( void )
+void
+xkl_group_allow_one_switch_to_secondary(void)
{
- xkl_debug( 150, "Setting allow_one_switch_to_secondary_group flag\n" );
- xkl_set_switch_to_secondary_group( TRUE );
+ xkl_debug(150,
+ "Setting allow_one_switch_to_secondary_group flag\n");
+ xkl_set_switch_to_secondary_group(TRUE);
}
-gboolean xkl_is_one_switch_to_secondary_group_allowed( void )
+gboolean
+xkl_is_one_switch_to_secondary_group_allowed(void)
{
- gboolean rv = FALSE;
- unsigned char *propval = NULL;
- Atom actual_type;
- int actual_format;
- unsigned long bytes_remaining;
- unsigned long actual_items;
- int result;
+ gboolean rv = FALSE;
+ unsigned char *propval = NULL;
+ Atom actual_type;
+ int actual_format;
+ unsigned long bytes_remaining;
+ unsigned long actual_items;
+ int result;
- result = XGetWindowProperty( xkl_display, xkl_root_window,
- xkl_atoms[XKLAVIER_ALLOW_SECONDARY], 0L, 1L,
- False, XA_INTEGER, &actual_type, &actual_format,
- &actual_items, &bytes_remaining,
- &propval );
+ result = XGetWindowProperty(xkl_display, xkl_root_window,
+ xkl_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 )
- {
- rv = (gboolean)*(Bool*)propval;
- }
- XFree( propval );
- }
+ if (Success == result) {
+ if (actual_format == 32 && actual_items == 1) {
+ rv = (gboolean) * (Bool *) propval;
+ }
+ XFree(propval);
+ }
- return rv;
+ return rv;
}
-void xkl_one_switch_to_secondary_group_performed( void )
+void
+xkl_one_switch_to_secondary_group_performed(void)
{
- xkl_debug( 150, "Resetting allow_one_switch_to_secondary_group flag\n" );
- xkl_set_switch_to_secondary_group( FALSE );
+ xkl_debug(150,
+ "Resetting allow_one_switch_to_secondary_group flag\n");
+ xkl_set_switch_to_secondary_group(FALSE);
}
-void xkl_set_default_group( int group )
+void
+xkl_set_default_group(int group)
{
- xkl_default_group = group;
+ xkl_default_group = group;
}
-gint _xkl_get_default_group( void )
+gint
+_xkl_get_default_group(void)
{
- return xkl_default_group;
+ return xkl_default_group;
}
-void xkl_set_secondary_groups_mask( guint mask )
+void
+xkl_set_secondary_groups_mask(guint mask)
{
- xkl_secondary_groups_mask = mask;
+ xkl_secondary_groups_mask = mask;
}
-guint xkl_get_secondary_groups_mask( void )
+guint
+xkl_get_secondary_groups_mask(void)
{
- return xkl_secondary_groups_mask;
+ return xkl_secondary_groups_mask;
}
-gint xkl_register_config_callback( XklConfigNotifyFunc func,
- gpointer data )
+gint
+xkl_register_config_callback(XklConfigNotifyFunc func, gpointer data)
{
- xkl_config_callback = func;
- xkl_config_callback_data = data;
- return 0;
+ xkl_config_callback = func;
+ xkl_config_callback_data = data;
+ return 0;
}
-gint xkl_register_state_callback( XklStateNotifyFunc func,
- gpointer data )
+gint
+xkl_register_state_callback(XklStateNotifyFunc func, gpointer data)
{
- xkl_state_callback = func;
- xkl_state_callback_data = data;
- return 0;
+ xkl_state_callback = func;
+ xkl_state_callback_data = data;
+ return 0;
}
-gint xkl_register_new_window_callback( XklNewWindowNotifyFunc func,
- gpointer data )
+gint
+xkl_register_new_window_callback(XklNewWindowNotifyFunc func,
+ gpointer data)
{
- xkl_new_window_callback = func;
- xkl_new_window_callback_data = data;
- return 0;
+ xkl_new_window_callback = func;
+ xkl_new_window_callback_data = data;
+ return 0;
}
-void xkl_set_log_appender( XklLogAppender func )
+void
+xkl_set_log_appender(XklLogAppender func)
{
- log_appender = func;
+ log_appender = func;
}
-gint xkl_listen_start( guint what )
+gint
+xkl_listen_start(guint what)
{
- xkl_listener_type = what;
-
- if( !( xkl_vtable->features & XKLF_REQUIRES_MANUAL_LAYOUT_MANAGEMENT ) &&
- ( what & XKLL_MANAGE_LAYOUTS ) )
- xkl_debug( 0, "The backend does not require manual layout management - "
- "but it is provided by the application" );
-
- xkl_listen_resume( );
- xkl_load_window_tree( );
- XFlush( xkl_display );
- return 0;
+ xkl_listener_type = what;
+
+ if (!
+ (xkl_vtable->features & XKLF_REQUIRES_MANUAL_LAYOUT_MANAGEMENT)
+ && (what & XKLL_MANAGE_LAYOUTS))
+ xkl_debug(0,
+ "The backend does not require manual layout management - "
+ "but it is provided by the application");
+
+ xkl_listen_resume();
+ xkl_load_window_tree();
+ XFlush(xkl_display);
+ return 0;
}
-gint xkl_listen_stop( void )
+gint
+xkl_listen_stop(void)
{
- xkl_listen_pause( );
- return 0;
+ xkl_listen_pause();
+ return 0;
}
-gint xkl_init( Display * a_dpy )
+gint
+xkl_init(Display * a_dpy)
{
- int scr;
- const gchar *sdl;
- int rv;
+ int scr;
+ const gchar *sdl;
+ int rv;
- sdl = g_getenv( "XKL_DEBUG" );
- if( sdl != NULL )
- {
- xkl_set_debug_level( atoi( sdl ) );
- }
+ sdl = g_getenv("XKL_DEBUG");
+ if (sdl != NULL) {
+ xkl_set_debug_level(atoi(sdl));
+ }
- if( !a_dpy )
- {
- xkl_debug( 10, "xkl_init : display is NULL ?\n");
- return -1;
- }
+ if (!a_dpy) {
+ xkl_debug(10, "xkl_init : display is NULL ?\n");
+ return -1;
+ }
- xkl_default_error_handler =
- XSetErrorHandler( ( XErrorHandler ) xkl_process_error );
+ xkl_default_error_handler =
+ XSetErrorHandler((XErrorHandler) xkl_process_error);
- xkl_display = a_dpy;
- scr = DefaultScreen( xkl_display );
- xkl_root_window = RootWindow( xkl_display, scr );
+ xkl_display = a_dpy;
+ scr = DefaultScreen(xkl_display);
+ xkl_root_window = RootWindow(xkl_display, scr);
- xkl_skip_one_restore = FALSE;
- xkl_default_group = -1;
- xkl_secondary_groups_mask = 0L;
- xkl_toplevel_window_prev = 0;
+ xkl_skip_one_restore = FALSE;
+ xkl_default_group = -1;
+ xkl_secondary_groups_mask = 0L;
+ xkl_toplevel_window_prev = 0;
- xkl_atoms[WM_NAME] = XInternAtom( xkl_display, "WM_NAME", False );
- xkl_atoms[WM_STATE] = XInternAtom( xkl_display, "WM_STATE", False );
- xkl_atoms[XKLAVIER_STATE] = XInternAtom( xkl_display, "XKLAVIER_STATE", False );
- xkl_atoms[XKLAVIER_TRANSPARENT] =
- XInternAtom( xkl_display, "XKLAVIER_TRANSPARENT", False );
- xkl_atoms[XKLAVIER_ALLOW_SECONDARY] =
- XInternAtom( xkl_display, "XKLAVIER_ALLOW_SECONDARY", False );
+ xkl_atoms[WM_NAME] = XInternAtom(xkl_display, "WM_NAME", False);
+ xkl_atoms[WM_STATE] = XInternAtom(xkl_display, "WM_STATE", False);
+ xkl_atoms[XKLAVIER_STATE] =
+ XInternAtom(xkl_display, "XKLAVIER_STATE", False);
+ xkl_atoms[XKLAVIER_TRANSPARENT] =
+ XInternAtom(xkl_display, "XKLAVIER_TRANSPARENT", False);
+ xkl_atoms[XKLAVIER_ALLOW_SECONDARY] =
+ XInternAtom(xkl_display, "XKLAVIER_ALLOW_SECONDARY", False);
- xkl_one_switch_to_secondary_group_performed();
+ xkl_one_switch_to_secondary_group_performed();
- rv = -1;
- xkl_debug( 150, "Trying all backends:\n" );
+ rv = -1;
+ xkl_debug(150, "Trying all backends:\n");
#ifdef ENABLE_XKB_SUPPORT
- xkl_debug( 150, "Trying XKB backend\n" );
- rv = xkl_xkb_init();
+ xkl_debug(150, "Trying XKB backend\n");
+ rv = xkl_xkb_init();
#endif
#ifdef ENABLE_XMM_SUPPORT
- if( rv != 0 )
- {
- xkl_debug( 150, "Trying XMM backend\n" );
- rv = xkl_xmm_init();
- }
+ if (rv != 0) {
+ xkl_debug(150, "Trying XMM backend\n");
+ rv = xkl_xmm_init();
+ }
#endif
- if( rv == 0 )
- {
- xkl_debug( 150, "Actual backend: %s\n",
- xkl_backend_get_name() );
- }
- else
- {
- xkl_debug( 0, "All backends failed, last result: %d\n", rv );
- xkl_display = NULL;
- }
+ if (rv == 0) {
+ xkl_debug(150, "Actual backend: %s\n",
+ xkl_backend_get_name());
+ } else {
+ xkl_debug(0, "All backends failed, last result: %d\n", rv);
+ xkl_display = NULL;
+ }
- return ( rv == 0 ) ?
- ( xkl_load_all_info() ? 0 : xkl_last_error_code ) : -1;
+ return (rv == 0) ?
+ (xkl_load_all_info()? 0 : xkl_last_error_code) : -1;
}
-gint xkl_term( void )
+gint
+xkl_term(void)
{
- XSetErrorHandler( ( XErrorHandler ) xkl_default_error_handler );
- xkl_config_callback = NULL;
- xkl_state_callback = NULL;
- xkl_new_window_callback = NULL;
+ XSetErrorHandler((XErrorHandler) xkl_default_error_handler);
+ xkl_config_callback = NULL;
+ xkl_state_callback = NULL;
+ xkl_new_window_callback = NULL;
- log_appender = xkl_default_log_appender;
- xkl_free_all_info( );
+ log_appender = xkl_default_log_appender;
+ xkl_free_all_info();
- return 0;
+ return 0;
}
-gboolean xkl_key_grab( gint keycode, guint modifiers )
+gboolean
+xkl_key_grab(gint keycode, guint modifiers)
{
- gboolean ret_code;
- gchar *keyname;
+ gboolean ret_code;
+ gchar *keyname;
- if( xkl_debug_level >= 100 )
- {
- keyname = XKeysymToString( XKeycodeToKeysym( xkl_display, keycode, 0 ) );
- xkl_debug( 100, "Listen to the key %d/(%s)/%d\n",
- keycode, keyname, modifiers );
- }
+ if (xkl_debug_level >= 100) {
+ keyname =
+ XKeysymToString(XKeycodeToKeysym
+ (xkl_display, keycode, 0));
+ xkl_debug(100, "Listen to the key %d/(%s)/%d\n", keycode,
+ keyname, modifiers);
+ }
- if( 0 == keycode )
- return FALSE;
+ if (0 == keycode)
+ return FALSE;
- xkl_last_error_code = Success;
+ xkl_last_error_code = Success;
- ret_code = XGrabKey( xkl_display, keycode, modifiers, xkl_root_window,
- TRUE, GrabModeAsync, GrabModeAsync );
- XSync( xkl_display, False );
+ ret_code =
+ XGrabKey(xkl_display, keycode, modifiers, xkl_root_window,
+ TRUE, GrabModeAsync, GrabModeAsync);
+ XSync(xkl_display, False);
- xkl_debug( 100, "XGrabKey recode %d/error %d\n",
- ret_code, xkl_last_error_code );
+ xkl_debug(100, "XGrabKey recode %d/error %d\n",
+ ret_code, xkl_last_error_code);
- ret_code = ( xkl_last_error_code == Success );
+ ret_code = (xkl_last_error_code == Success);
- if( !ret_code )
- xkl_last_error_message = "Could not grab the key";
+ if (!ret_code)
+ xkl_last_error_message = "Could not grab the key";
- return ret_code;
+ return ret_code;
}
-gboolean xkl_key_ungrab( gint keycode, guint modifiers )
+gboolean
+xkl_key_ungrab(gint keycode, guint modifiers)
{
- if( 0 == keycode )
- return FALSE;
+ if (0 == keycode)
+ return FALSE;
- return Success == XUngrabKey( xkl_display, keycode, 0, xkl_root_window );
+ return Success == XUngrabKey(xkl_display, keycode, 0,
+ xkl_root_window);
}
-gint xkl_group_get_next( void )
+gint
+xkl_group_get_next(void)
{
- return ( xkl_current_state.group + 1 ) % xkl_groups_get_num( );
+ return (xkl_current_state.group + 1) % xkl_groups_get_num();
}
-
-gint xkl_get_prev_group( void )
+
+gint
+xkl_get_prev_group(void)
{
- gint n = xkl_groups_get_num( );
- return ( xkl_current_state.group + n - 1 ) % n;
+ gint n = xkl_groups_get_num();
+ return (xkl_current_state.group + n - 1) % n;
}
-gint xkl_get_restore_group( void )
+gint
+xkl_get_restore_group(void)
{
- XklState state;
- if( xkl_current_client == ( Window ) NULL )
- {
- xkl_debug( 150, "cannot restore without current client\n" );
- } else if( xkl_state_get( xkl_current_client, &state ) )
- {
- return state.group;
- } else
- xkl_debug( 150,
- "Unbelievable: current client " WINID_FORMAT
- ", '%s' has no group\n", xkl_current_client,
- xkl_window_get_debug_title( xkl_current_client ) );
- return 0;
+ XklState state;
+ if (xkl_current_client == (Window) NULL) {
+ xkl_debug(150, "cannot restore without current client\n");
+ } else if (xkl_state_get(xkl_current_client, &state)) {
+ return state.group;
+ } else
+ xkl_debug(150,
+ "Unbelievable: current client " WINID_FORMAT
+ ", '%s' has no group\n", xkl_current_client,
+ xkl_window_get_debug_title(xkl_current_client));
+ return 0;
}
-void xkl_set_transparent( Window win, gboolean transparent )
+void
+xkl_set_transparent(Window win, gboolean transparent)
{
- Window toplevel_win;
- xkl_debug( 150, "setting transparent flag %d for " WINID_FORMAT "\n",
- transparent, win );
+ Window toplevel_win;
+ xkl_debug(150,
+ "setting transparent flag %d for " WINID_FORMAT "\n",
+ transparent, win);
- if( !xkl_toplevel_window_find( win, &toplevel_win ) )
- {
- xkl_debug( 150, "No toplevel window!\n" );
- toplevel_win = win;
+ if (!xkl_toplevel_window_find(win, &toplevel_win)) {
+ xkl_debug(150, "No toplevel window!\n");
+ toplevel_win = win;
/* return; */
- }
+ }
- xkl_toplevel_window_set_transparent( toplevel_win, transparent );
+ xkl_toplevel_window_set_transparent(toplevel_win, transparent);
}
-gboolean xkl_window_is_transparent( Window win )
+gboolean
+xkl_window_is_transparent(Window win)
{
- Window toplevel_win;
+ Window toplevel_win;
- if( !xkl_toplevel_window_find( win, &toplevel_win) )
- return FALSE;
- return xkl_toplevel_window_is_transparent( toplevel_win );
+ if (!xkl_toplevel_window_find(win, &toplevel_win))
+ return FALSE;
+ return xkl_toplevel_window_is_transparent(toplevel_win);
}
/**
* Loads the tree recursively.
*/
-gboolean xkl_load_window_tree( void )
+gboolean
+xkl_load_window_tree(void)
{
- Window focused;
- int revert;
- gboolean retval = TRUE, have_toplevel_win;
+ Window focused;
+ int revert;
+ gboolean retval = TRUE, have_toplevel_win;
- if( xkl_listener_type & XKLL_MANAGE_WINDOW_STATES )
- retval = xkl_load_subtree( xkl_root_window, 0, &xkl_current_state );
+ if (xkl_listener_type & XKLL_MANAGE_WINDOW_STATES)
+ retval =
+ xkl_load_subtree(xkl_root_window, 0,
+ &xkl_current_state);
- XGetInputFocus( xkl_display, &focused, &revert );
+ XGetInputFocus(xkl_display, &focused, &revert);
- xkl_debug( 160, "initially focused: " WINID_FORMAT ", '%s'\n",
- focused, xkl_window_get_debug_title( focused ) );
+ xkl_debug(160, "initially focused: " WINID_FORMAT ", '%s'\n",
+ focused, xkl_window_get_debug_title(focused));
- have_toplevel_win = xkl_toplevel_window_find( focused, &xkl_current_client );
+ have_toplevel_win =
+ xkl_toplevel_window_find(focused, &xkl_current_client);
- if( have_toplevel_win )
- {
- gboolean have_state = xkl_toplevel_window_get_state( xkl_current_client,
- &xkl_current_state );
- xkl_debug( 160,
- "initial xkl_cur_client: " WINID_FORMAT
- ", '%s' %s state %d/%X\n", xkl_current_client,
- xkl_window_get_debug_title( xkl_current_client ),
- ( have_state ? "with" : "without" ),
- ( have_state ? xkl_current_state.group : -1 ),
- ( have_state ? xkl_current_state.indicators : -1 ) );
- } else
- {
- xkl_debug( 160,
- "Could not find initial app. "
- "Probably, focus belongs to some WM service window. "
- "Will try to survive:)" );
- }
+ if (have_toplevel_win) {
+ gboolean have_state =
+ xkl_toplevel_window_get_state(xkl_current_client,
+ &xkl_current_state);
+ xkl_debug(160,
+ "initial xkl_cur_client: " WINID_FORMAT
+ ", '%s' %s state %d/%X\n", xkl_current_client,
+ xkl_window_get_debug_title(xkl_current_client),
+ (have_state ? "with" : "without"),
+ (have_state ? xkl_current_state.group : -1),
+ (have_state ? xkl_current_state.
+ indicators : -1));
+ } else {
+ xkl_debug(160,
+ "Could not find initial app. "
+ "Probably, focus belongs to some WM service window. "
+ "Will try to survive:)");
+ }
- return retval;
+ return retval;
}
-void _xkl_debug( const gchar file[], const gchar function[], gint level,
- const gchar format[], ... )
+void
+_xkl_debug(const gchar file[], const gchar function[], gint level,
+ const gchar format[], ...)
{
- va_list lst;
+ va_list lst;
- if( level > xkl_debug_level )
- return;
+ if (level > xkl_debug_level)
+ return;
- va_start( lst, format );
- if( log_appender != NULL )
- ( *log_appender ) ( file, function, level, format, lst );
- va_end( lst );
+ va_start(lst, format);
+ if (log_appender != NULL)
+ (*log_appender) (file, function, level, format, lst);
+ va_end(lst);
}
-void xkl_default_log_appender( const gchar file[], const gchar function[],
- gint level, const gchar format[], va_list args )
+void
+xkl_default_log_appender(const gchar file[], const gchar function[],
+ gint level, const gchar format[], va_list args)
{
- time_t now = time( NULL );
- fprintf( stdout, "[%08ld,%03d,%s:%s/] \t", now, level, file, function );
- vfprintf( stdout, format, args );
+ time_t now = time(NULL);
+ fprintf(stdout, "[%08ld,%03d,%s:%s/] \t", now, level, file,
+ function);
+ vfprintf(stdout, format, args);
}
/**
* Just selects some events from the window.
*/
-void xkl_select_input( Window win, gulong mask )
+void
+xkl_select_input(Window win, gulong mask)
{
- if( xkl_root_window == win )
- xkl_debug( 160,
- "Someone is looking for %lx on root window ***\n",
- mask );
+ if (xkl_root_window == win)
+ xkl_debug(160,
+ "Someone is looking for %lx on root window ***\n",
+ mask);
- XSelectInput( xkl_display, win, mask );
+ XSelectInput(xkl_display, win, mask);
}
-void xkl_select_input_merging( Window win, gulong mask )
+void
+xkl_select_input_merging(Window win, gulong mask)
{
- XWindowAttributes attrs;
- gulong oldmask = 0L, newmask;
- memset( &attrs, 0, sizeof( attrs ) );
- if( XGetWindowAttributes( xkl_display, win, &attrs ) )
- oldmask = attrs.your_event_mask;
+ XWindowAttributes attrs;
+ gulong oldmask = 0L, newmask;
+ memset(&attrs, 0, sizeof(attrs));
+ if (XGetWindowAttributes(xkl_display, win, &attrs))
+ oldmask = attrs.your_event_mask;
- newmask = oldmask | mask;
- if( newmask != oldmask )
- xkl_select_input( win, newmask );
+ newmask = oldmask | mask;
+ if (newmask != oldmask)
+ xkl_select_input(win, newmask);
}
-void xkl_try_call_state_func( XklStateChange change_type,
- XklState * old_state )
+void
+xkl_try_call_state_func(XklStateChange change_type, XklState * old_state)
{
- gint group = xkl_current_state.group;
- gboolean restore = old_state->group == group;
+ gint group = xkl_current_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, xkl_secondary_groups_mask,
- xkl_is_one_switch_to_secondary_group_allowed() );
+ xkl_debug(150,
+ "change_type: %d, group: %d, secondary_group_mask: %X, allowsecondary: %d\n",
+ change_type, group, xkl_secondary_groups_mask,
+ xkl_is_one_switch_to_secondary_group_allowed());
- if( change_type == GROUP_CHANGED )
- {
- if( !restore )
- {
- if( ( xkl_secondary_groups_mask & ( 1 << group ) ) != 0 &&
- !xkl_is_one_switch_to_secondary_group_allowed() )
- {
- xkl_debug( 150, "secondary -> go next\n" );
- group = xkl_group_get_next( );
- xkl_group_lock( group );
- return; /* we do not need to revalidate */
- }
- }
- xkl_one_switch_to_secondary_group_performed();
- }
- if( xkl_state_callback != NULL )
- {
+ if (change_type == GROUP_CHANGED) {
+ if (!restore) {
+ if ((xkl_secondary_groups_mask & (1 << group)) != 0
+ &&
+ !xkl_is_one_switch_to_secondary_group_allowed
+ ()) {
+ xkl_debug(150, "secondary -> go next\n");
+ group = xkl_group_get_next();
+ xkl_group_lock(group);
+ return; /* we do not need to revalidate */
+ }
+ }
+ xkl_one_switch_to_secondary_group_performed();
+ }
+ if (xkl_state_callback != NULL) {
- ( *xkl_state_callback ) ( change_type, xkl_current_state.group,
- restore, xkl_state_callback_data );
- }
+ (*xkl_state_callback) (change_type,
+ xkl_current_state.group, restore,
+ xkl_state_callback_data);
+ }
}
-void xkl_ensure_vtable_inited( void )
+void
+xkl_ensure_vtable_inited(void)
{
- char *p;
- if ( xkl_vtable == NULL )
- {
- xkl_debug( 0, "ERROR: XKL VTable is NOT initialized.\n" );
- /* force the crash! */
- p = NULL; *p = '\0';
- }
+ char *p;
+ if (xkl_vtable == NULL) {
+ xkl_debug(0, "ERROR: XKL VTable is NOT initialized.\n");
+ /* force the crash! */
+ p = NULL;
+ *p = '\0';
+ }
}
-const gchar *xkl_backend_get_name( void )
+const gchar *
+xkl_backend_get_name(void)
{
- return xkl_vtable->id;
+ return xkl_vtable->id;
}
-guint xkl_backend_get_features( void )
+guint
+xkl_backend_get_features(void)
{
- return xkl_vtable->features;
+ return xkl_vtable->features;
}
-void xkl_reset_all_info( const gchar reason[] )
+void
+xkl_reset_all_info(const gchar reason[])
{
- xkl_debug( 150, "Resetting all the cached info, reason: [%s]\n", reason );
- xkl_ensure_vtable_inited();
- if( !(*xkl_vtable->if_cached_info_equals_actual_func)() )
- {
- (*xkl_vtable->free_all_info_func)();
- (*xkl_vtable->load_all_info_func)();
- } else
- xkl_debug( 100, "NOT Resetting the cache: same configuration\n" );
+ xkl_debug(150, "Resetting all the cached info, reason: [%s]\n",
+ reason);
+ xkl_ensure_vtable_inited();
+ if (!(*xkl_vtable->if_cached_info_equals_actual_func) ()) {
+ (*xkl_vtable->free_all_info_func) ();
+ (*xkl_vtable->load_all_info_func) ();
+ } else
+ xkl_debug(100,
+ "NOT Resetting the cache: same configuration\n");
}
/**
* Calling through vtable
*/
-const gchar **xkl_groups_get_names( void )
+const gchar **
+xkl_groups_get_names(void)
{
- xkl_ensure_vtable_inited();
- return (*xkl_vtable->groups_get_names_func)();
+ xkl_ensure_vtable_inited();
+ return (*xkl_vtable->groups_get_names_func) ();
}
-guint xkl_groups_get_num( void )
+guint
+xkl_groups_get_num(void)
{
- xkl_ensure_vtable_inited();
- return (*xkl_vtable->groups_get_num_func)();
+ xkl_ensure_vtable_inited();
+ return (*xkl_vtable->groups_get_num_func) ();
}
-void xkl_group_lock( int group )
+void
+xkl_group_lock(int group)
{
- xkl_ensure_vtable_inited();
- (*xkl_vtable->group_lock_func)( group );
+ xkl_ensure_vtable_inited();
+ (*xkl_vtable->group_lock_func) (group);
}
-gint xkl_listen_pause( void )
+gint
+xkl_listen_pause(void)
{
- xkl_ensure_vtable_inited();
- return (*xkl_vtable->listen_pause_func)();
+ xkl_ensure_vtable_inited();
+ return (*xkl_vtable->listen_pause_func) ();
}
-gint xkl_listen_resume( void )
+gint
+xkl_listen_resume(void)
{
- xkl_ensure_vtable_inited();
- xkl_debug( 150, "listenerType: %x\n", xkl_listener_type );
- if( (*xkl_vtable->listen_resume_func)() )
- return 1;
-
- xkl_select_input_merging( xkl_root_window,
- SubstructureNotifyMask | PropertyChangeMask );
- xkl_ensure_vtable_inited();
- (*xkl_vtable->get_server_state_func)( &xkl_current_state );
- return 0;
+ xkl_ensure_vtable_inited();
+ xkl_debug(150, "listenerType: %x\n", xkl_listener_type);
+ if ((*xkl_vtable->listen_resume_func) ())
+ return 1;
+
+ xkl_select_input_merging(xkl_root_window,
+ SubstructureNotifyMask |
+ PropertyChangeMask);
+ xkl_ensure_vtable_inited();
+ (*xkl_vtable->get_server_state_func) (&xkl_current_state);
+ return 0;
}
-gboolean xkl_load_all_info( void )
+gboolean
+xkl_load_all_info(void)
{
- xkl_ensure_vtable_inited();
- return (*xkl_vtable->load_all_info_func)();
+ xkl_ensure_vtable_inited();
+ return (*xkl_vtable->load_all_info_func) ();
}
-void xkl_free_all_info( void )
+void
+xkl_free_all_info(void)
{
- xkl_ensure_vtable_inited();
- (*xkl_vtable->free_all_info_func)();
+ xkl_ensure_vtable_inited();
+ (*xkl_vtable->free_all_info_func) ();
}
-guint xkl_groups_get_max_num( void )
+guint
+xkl_groups_get_max_num(void)
{
- xkl_ensure_vtable_inited();
- return (*xkl_vtable->groups_get_max_num_func)();
+ xkl_ensure_vtable_inited();
+ return (*xkl_vtable->groups_get_max_num_func) ();
}
-
diff --git a/libxklavier/xklavier.h b/libxklavier/xklavier.h
index 72ac5e7..a9f0459 100644
--- a/libxklavier/xklavier.h
+++ b/libxklavier/xklavier.h
@@ -12,33 +12,30 @@
#include <glib.h>
#ifdef __cplusplus
-extern "C"
-{
+extern "C" {
#endif
- typedef enum
- {
+ typedef enum {
/**
* Group was changed
*/
- GROUP_CHANGED,
+ GROUP_CHANGED,
/**
* Indicators were changed
*/
- INDICATORS_CHANGED
- }
- XklStateChange;
+ 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
*/
@@ -59,14 +56,12 @@ extern "C"
/**
* XKB state. Can be global or per-window
*/
- typedef struct
- {
+ typedef struct {
/** selected group */
- gint32 group;
+ gint32 group;
/** set of active indicators */
- guint32 indicators;
- }
- XklState;
+ guint32 indicators;
+ } XklState;
/**
* @defgroup xklinitterm Library initialization and termination
@@ -81,25 +76,25 @@ extern "C"
* @return 0 if OK, otherwise last X error
* (special case: -1 if XKB extension is not present)
*/
- extern gint xkl_init( Display * dpy );
+ extern gint xkl_init(Display * dpy);
/**
* Terminates everything...
*/
- extern gint xkl_term( void );
+ extern gint xkl_term(void);
/**
* What kind of backend if used
* @return some string id of the backend
*/
- extern const gchar *xkl_backend_get_name( void );
+ extern const gchar *xkl_backend_get_name(void);
/**
* Provides information regarding available backend features
* (combination of XKLF_* constants)
* @return ORed XKLF_* constants
*/
- extern guint xkl_backend_get_features( void );
+ extern guint xkl_backend_get_features(void);
/**
* Provides the information on maximum number of simultaneously supported
@@ -107,7 +102,7 @@ extern "C"
* @return maximum number of the groups in configuration,
* 0 if no restrictions.
*/
- extern unsigned xkl_groups_get_max_num( void );
+ extern unsigned xkl_groups_get_max_num(void);
/** @} */
/**
@@ -137,25 +132,25 @@ extern "C"
* @param what any combination of XKLL_* constants
* @return 0
*/
- extern gint xkl_listen_start( guint what );
+ extern gint xkl_listen_start(guint what);
/**
* Stops listening for XKB-related events
* @return 0
*/
- extern gint xkl_listen_stop( void );
+ extern gint xkl_listen_stop(void);
/**
* Temporary pauses listening for XKB-related events
* @return 0
*/
- extern gint xkl_listen_pause( void );
+ extern gint xkl_listen_pause(void);
/**
* Resumes listening for XKB-related events
* @return 0
*/
- extern gint xkl_listen_resume( void );
+ extern gint xkl_listen_resume(void);
/**
* Grabs some key
@@ -163,7 +158,7 @@ extern "C"
* @param modifiers is a bitmask of modifiers
* @return True on success
*/
- extern gboolean xkl_key_grab( gint keycode, unsigned modifiers );
+ extern gboolean xkl_key_grab(gint keycode, unsigned modifiers);
/**
* Ungrabs some key
@@ -171,7 +166,7 @@ extern "C"
* @param modifiers is a bitmask of modifiers
* @return True on success
*/
- extern gboolean xkl_key_ungrab( gint keycode, unsigned modifiers );
+ extern gboolean xkl_key_ungrab(gint keycode, unsigned modifiers);
/**
* Processes X events. Should be included into the main event cycle of an
@@ -180,12 +175,12 @@ extern "C"
* @return 0 if the event it processed - 1 otherwise
* @see xkl_StartListen
*/
- extern gint xkl_events_filter( XEvent * evt );
+ extern gint xkl_events_filter(XEvent * evt);
/**
* Allows to switch (once) to the secondary group
*/
- extern void xkl_group_allow_one_switch_to_secondary( void );
+ extern void xkl_group_allow_one_switch_to_secondary(void);
/** @} */
@@ -197,13 +192,13 @@ extern "C"
/**
* @return currently focused window
*/
- extern Window xkl_window_get_current( void );
+ extern Window xkl_window_get_current(void);
/**
* @return current state of the keyboard (in XKB terms).
* Returned value is a statically allocated buffer, should not be freed.
*/
- extern XklState *xkl_state_get_current( void );
+ extern XklState *xkl_state_get_current(void);
/** @} */
@@ -216,7 +211,7 @@ extern "C"
* @return the window title of some window or NULL.
* If not NULL, it should be freed with XFree
*/
- extern gchar *xkl_window_get_title( Window w );
+ extern gchar *xkl_window_get_title(Window w);
/**
* Finds the state for a given window (for its "App window").
@@ -225,20 +220,20 @@ extern "C"
* @return True on success, otherwise False
* (the error message can be obtained using xkl_GetLastError).
*/
- extern gboolean xkl_state_get( Window win, XklState * state_out );
+ extern gboolean xkl_state_get(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_state_delete( Window win );
+ extern void xkl_state_delete(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_state_save( Window win, XklState * state );
+ extern void xkl_state_save(Window win, XklState * state);
/**
* Sets the "transparent" flag. It means focus switching onto
@@ -247,14 +242,15 @@ extern "C"
* @param transparent - if true, the windows is transparent.
* @see xkl_IsTranspatent
*/
- extern void xkl_window_set_transparent( Window win, gboolean transparent );
+ extern void xkl_window_set_transparent(Window win,
+ gboolean transparent);
/**
* Returns "transparent" flag.
* @param win is the window to get the transparent flag from.
* @see xkl_SetTranspatent
*/
- extern gboolean xkl_window_is_transparent( Window win );
+ extern gboolean xkl_window_is_transparent(Window win);
/**
* Checks whether 2 windows have the same topmost window
@@ -262,7 +258,8 @@ extern "C"
* @param win2 is second window
* @return True is windows are in the same application
*/
- extern gboolean xkl_windows_is_same_appication( Window win1, Window win2 );
+ extern gboolean xkl_windows_is_same_appication(Window win1,
+ Window win2);
/** @} */
@@ -275,21 +272,21 @@ extern "C"
* @return the total number of groups in the current XKB configuration
* (keyboard)
*/
- extern unsigned xkl_groups_get_num( void );
+ extern unsigned xkl_groups_get_num(void);
/**
* @return the array of group names for the current XKB configuration
* (keyboard).
* This array is static, should not be freed
*/
- extern const gchar **xkl_groups_get_names( void );
+ extern const gchar **xkl_groups_get_names(void);
/**
* @return the array of indicator names for the current XKB configuration
* (keyboard).
* This array is static, should not be freed
*/
- extern const gchar **xkl_indicators_get_names( void );
+ extern const gchar **xkl_indicators_get_names(void);
/** @} */
@@ -302,19 +299,19 @@ extern "C"
* Calculates next group id. Does not change the state of anything.
* @return next group id
*/
- extern gint xkl_group_get_next( void );
+ extern gint xkl_group_get_next(void);
/**
* Calculates prev group id. Does not change the state of anything.
* @return prev group id
*/
- extern gint xkl_group_get_prev( void );
+ extern gint xkl_group_get_prev(void);
/**
* @return saved group id of the current client.
* Does not change the state of anything.
*/
- extern gint xkl_group_get_restore( void );
+ extern gint xkl_group_get_restore(void);
/**
* Locks the group. Can be used after xkl_GetXXXGroup functions
@@ -323,7 +320,7 @@ extern "C"
* @see xkl_GetPrevGroup
* @see xkl_GetRestoreGroup
*/
- extern void xkl_group_lock( gint group );
+ extern void xkl_group_lock(gint group);
/** @} */
@@ -337,7 +334,7 @@ extern "C"
* @param data is anything which can be stored into the pointer
* @see xkl_RegisterConfigCallback
*/
- typedef void ( *XklConfigNotifyFunc ) ( gpointer data );
+ typedef void (*XklConfigNotifyFunc) (gpointer data);
/**
* Registers user callback. Only one callback can be registered at a time
@@ -345,8 +342,8 @@ extern "C"
* @param data is the data to pass
* @see xkl_ConfigCallback
*/
- extern gint xkl_register_config_callback( XklConfigNotifyFunc func,
- gpointer data );
+ extern gint xkl_register_config_callback(XklConfigNotifyFunc func,
+ gpointer data);
/**
* Used for notifying application of new window creation (actually,
@@ -359,8 +356,8 @@ extern "C"
* @see xkl_set_default_group
* @see xkl_get_default_group
*/
- typedef gint ( *XklNewWindowNotifyFunc ) ( Window win, Window parent,
- gpointer data );
+ typedef gint(*XklNewWindowNotifyFunc) (Window win, Window parent,
+ gpointer data);
/**
* Registers user callback. Only one callback can be registered at a time
@@ -368,8 +365,8 @@ extern "C"
* @param data is the data to pass
* @see XklWindowCallback
*/
- extern gint xkl_register_new_window_callback( XklNewWindowNotifyFunc func,
- gpointer data );
+ extern gint xkl_register_new_window_callback(XklNewWindowNotifyFunc
+ func, gpointer data);
/**
* Used for notifying application of the window state change.
@@ -380,8 +377,9 @@ extern "C"
* @param data is anything which can be stored into the pointer
* @see xkl_register_config_callback
*/
- typedef void ( *XklStateNotifyFunc ) ( XklStateChange changeType, gint group,
- gboolean restore, gpointer data );
+ typedef void (*XklStateNotifyFunc) (XklStateChange changeType,
+ gint group, gboolean restore,
+ gpointer data);
/**
* Registers user callback. Only one callback can be registered at a time
@@ -389,8 +387,8 @@ extern "C"
* @param data is the data to pass
* @see XklStateNotifyFunc
*/
- extern gint xkl_register_state_callback( XklStateNotifyFunc func,
- gpointer data );
+ extern gint xkl_register_state_callback(XklStateNotifyFunc func,
+ gpointer data);
/** @} */
@@ -403,23 +401,23 @@ extern "C"
* Sets the configuration parameter: group per application
* @param isGlobal is a new parameter value
*/
- extern void xkl_set_group_per_toplevel_window( gboolean isGlobal );
+ extern void xkl_set_group_per_toplevel_window(gboolean isGlobal);
/**
* @return the value of the parameter: group per application
*/
- extern gboolean xkl_is_group_per_toplevel_window( void );
+ extern gboolean xkl_is_group_per_toplevel_window(void);
/**
* Sets the configuration parameter: perform indicators handling
* @param whetherHandle is a new parameter value
*/
- extern void xkl_set_indicators_handling( gboolean whetherHandle );
+ extern void xkl_set_indicators_handling(gboolean whetherHandle);
/**
* @return the value of the parameter: perform indicator handling
*/
- extern gboolean xkl_get_indicators_handling( void );
+ extern gboolean xkl_get_indicators_handling(void);
/**
* Sets the secondary groups (one bit per group).
@@ -427,26 +425,26 @@ extern "C"
* @param mask is a new group mask
* @see xkl_allow_one_switch_to_secondary_group
*/
- extern void xkl_set_secondary_groups_mask( guint mask );
+ extern void xkl_set_secondary_groups_mask(guint mask);
/**
* @return the secondary group mask
*/
- extern guint xkl_get_secondary_groups_mask( void );
+ extern guint xkl_get_secondary_groups_mask(void);
/**
* Configures the default group set on window creation.
* If -1, no default group is used
* @param group the default group
*/
- extern void xkl_group_set_default( gint group );
+ extern void xkl_group_set_default(gint group);
/**
* Returns the default group set on window creation
* If -1, no default group is used
* @return the default group
*/
- extern gint xkl_group_get_default( void );
+ extern gint xkl_group_get_default(void);
/** @} */
@@ -458,7 +456,7 @@ extern "C"
/**
* @return the text message (statically allocated) of the last error
*/
- extern const gchar *xkl_get_last_error( void );
+ extern const gchar *xkl_get_last_error(void);
/**
* Output (optionally) some debug info
@@ -470,8 +468,8 @@ extern "C"
* @param format is a format (like in printf)
* @see xkl_debug
*/
- extern void _xkl_debug( const gchar file[], const gchar function[],
- gint level, const gchar format[], ... );
+ extern void _xkl_debug(const gchar file[], const gchar function[],
+ gint level, const gchar format[], ...);
/**
* Custom log output method for _xkl_debug. This appender is NOT called if the
@@ -487,11 +485,11 @@ extern "C"
* @see _xkl_debug
* @see xkl_set_debug_level
*/
- typedef void ( *XklLogAppender ) ( const gchar file[],
- const gchar function[],
- gint level,
- const gchar format[],
- va_list args );
+ typedef void (*XklLogAppender) (const gchar file[],
+ const gchar function[],
+ gint level,
+ const gchar format[],
+ va_list args);
/**
* Default log output method. Sends everything to stdout.
@@ -504,24 +502,24 @@ extern "C"
* @param format is a format (like in printf)
* @param args is the list of parameters
*/
- extern void xkl_default_log_appender( const gchar file[],
- const gchar function[],
- gint level,
- const gchar format[],
- va_list args );
+ extern void xkl_default_log_appender(const gchar file[],
+ const gchar function[],
+ gint level,
+ const gchar format[],
+ va_list args);
/**
* Installs the custom log appender.function
* @param fun is the new log appender
*/
- extern void xkl_set_log_appender( XklLogAppender fun );
+ extern void xkl_set_log_appender(XklLogAppender fun);
/**
* Sets maximum debug level.
* Message of the level more than the one set here - will be ignored
* @param level is a new debug level
*/
- extern void xkl_set_debug_level( gint level );
+ extern void xkl_set_debug_level(gint level);
/* Just to make doxygen happy - two block with/without @param format */
#if defined(G_HAVE_GNUC_VARARGS)
@@ -553,6 +551,5 @@ extern "C"
#ifdef __cplusplus
}
-#endif /* __cplusplus */
-
+#endif /* __cplusplus */
#endif
diff --git a/libxklavier/xklavier_config.c b/libxklavier/xklavier_config.c
index e2dc30e..2ee6799 100644
--- a/libxklavier/xklavier_config.c
+++ b/libxklavier/xklavier_config.c
@@ -10,10 +10,9 @@
#include "xklavier_private.h"
-typedef struct _XklConfigRegistry
-{
- xmlDocPtr doc;
- xmlXPathContextPtr xpath_context;
+typedef struct _XklConfigRegistry {
+ xmlDocPtr doc;
+ xmlXPathContextPtr xpath_context;
} XklConfigRegistry;
static XklConfigRegistry the_registry;
@@ -25,506 +24,533 @@ static xmlXPathCompExprPtr option_groups_xpath;
#define xkl_config_registry_is_initialized() \
( the_registry.xpath_context != NULL )
-static xmlChar *xkl_node_get_xml_lang_attr( xmlNodePtr nptr )
-{
- if( nptr->properties != NULL &&
- !g_ascii_strcasecmp( "lang", (char *)nptr->properties[0].name ) &&
- nptr->properties[0].ns != NULL &&
- !g_ascii_strcasecmp( "xml", (char *)nptr->properties[0].ns->prefix ) &&
- nptr->properties[0].children != NULL )
- return nptr->properties[0].children->content;
- else
- return NULL;
-}
-
-static gboolean xkl_read_config_item( xmlNodePtr iptr, XklConfigItem *item )
-{
- xmlNodePtr name_element, nptr, ptr;
- xmlNodePtr desc_element = NULL, short_desc_element = NULL;
- xmlNodePtr nt_desc_element = NULL, nt_short_desc_element = NULL;
-
- gint max_desc_priority = -1;
- gint max_short_desc_priority = -1;
-
- *item->name = 0;
- *item->short_description = 0;
- *item->description = 0;
- if( iptr->type != XML_ELEMENT_NODE )
- return FALSE;
- ptr = iptr->children;
- while( ptr != NULL )
- {
- switch ( ptr->type )
- {
- case XML_ELEMENT_NODE:
- if( !g_ascii_strcasecmp( (char *)ptr->name,
- "configItem" ) )
- break;
- return FALSE;
- case XML_TEXT_NODE:
- ptr = ptr->next;
- continue;
- default:
- return FALSE;
- }
- break;
- }
- if( ptr == NULL )
- return FALSE;
-
- nptr = ptr->children;
-
- if( nptr->type == XML_TEXT_NODE )
- nptr = nptr->next;
- name_element = nptr;
- nptr = nptr->next;
-
- while( nptr != NULL )
- {
- char * node_name = (char *)nptr->name;
- if( nptr->type != XML_TEXT_NODE )
- {
- xmlChar *lang = xkl_node_get_xml_lang_attr( nptr );
-
- if( lang != NULL )
- {
- gint priority = xkl_get_language_priority( (gchar *)lang );
-
- /**
+static xmlChar *
+xkl_node_get_xml_lang_attr(xmlNodePtr nptr)
+{
+ if (nptr->properties != NULL &&
+ !g_ascii_strcasecmp("lang", (char *) nptr->properties[0].name)
+ && nptr->properties[0].ns != NULL
+ && !g_ascii_strcasecmp("xml",
+ (char *) nptr->properties[0].ns->prefix)
+ && nptr->properties[0].children != NULL)
+ return nptr->properties[0].children->content;
+ else
+ return NULL;
+}
+
+static gboolean
+xkl_read_config_item(xmlNodePtr iptr, XklConfigItem * item)
+{
+ xmlNodePtr name_element, nptr, ptr;
+ xmlNodePtr desc_element = NULL, short_desc_element = NULL;
+ xmlNodePtr nt_desc_element = NULL, nt_short_desc_element = NULL;
+
+ gint max_desc_priority = -1;
+ gint max_short_desc_priority = -1;
+
+ *item->name = 0;
+ *item->short_description = 0;
+ *item->description = 0;
+ if (iptr->type != XML_ELEMENT_NODE)
+ return FALSE;
+ ptr = iptr->children;
+ while (ptr != NULL) {
+ switch (ptr->type) {
+ case XML_ELEMENT_NODE:
+ if (!g_ascii_strcasecmp((char *) ptr->name,
+ "configItem"))
+ break;
+ return FALSE;
+ case XML_TEXT_NODE:
+ ptr = ptr->next;
+ continue;
+ default:
+ return FALSE;
+ }
+ break;
+ }
+ if (ptr == NULL)
+ return FALSE;
+
+ nptr = ptr->children;
+
+ if (nptr->type == XML_TEXT_NODE)
+ nptr = nptr->next;
+ name_element = nptr;
+ nptr = nptr->next;
+
+ while (nptr != NULL) {
+ char *node_name = (char *) nptr->name;
+ if (nptr->type != XML_TEXT_NODE) {
+ xmlChar *lang = xkl_node_get_xml_lang_attr(nptr);
+
+ if (lang != NULL) {
+ gint priority =
+ xkl_get_language_priority((gchar *)
+ lang);
+
+ /**
* Find desc/shortdesc with highest priority
*/
- if( !g_ascii_strcasecmp( node_name,
- "description" ) &&
- ( priority > max_desc_priority ) )
- {
- desc_element = nptr;
- max_desc_priority = priority;
- } else if( !g_ascii_strcasecmp( node_name,
- "shortDescription" ) &&
- ( priority > max_short_desc_priority ) )
- {
- short_desc_element = nptr;
- max_short_desc_priority = priority;
- }
- } else // no language specified!
- {
- if( !g_ascii_strcasecmp( node_name,
- "description" ) )
- nt_desc_element = nptr;
- else if( !g_ascii_strcasecmp( node_name,
- "shortDescription" ) )
- nt_short_desc_element = nptr;
- }
- }
- nptr = nptr->next;
- }
-
- /* if no language-specific description found - use the ones without lang */
- if( desc_element == NULL )
- desc_element = nt_desc_element;
-
- if( short_desc_element == NULL )
- short_desc_element = nt_short_desc_element;
+ if (!g_ascii_strcasecmp(node_name,
+ "description") &&
+ (priority > max_desc_priority)) {
+ desc_element = nptr;
+ max_desc_priority = priority;
+ } else if (!g_ascii_strcasecmp(node_name,
+ "shortDescription")
+ && (priority >
+ max_short_desc_priority)) {
+ short_desc_element = nptr;
+ max_short_desc_priority = priority;
+ }
+ } else // no language specified!
+ {
+ if (!g_ascii_strcasecmp(node_name,
+ "description"))
+ nt_desc_element = nptr;
+ else if (!g_ascii_strcasecmp(node_name,
+ "shortDescription"))
+ nt_short_desc_element = nptr;
+ }
+ }
+ nptr = nptr->next;
+ }
+
+ /* if no language-specific description found - use the ones without lang */
+ if (desc_element == NULL)
+ desc_element = nt_desc_element;
+
+ if (short_desc_element == NULL)
+ short_desc_element = nt_short_desc_element;
/**
* Actually, here we should have some code to find
* the correct localized description...
- */
-
- if( name_element != NULL && name_element->children != NULL )
- strncat( item->name, (char *)name_element->children->content,
- XKL_MAX_CI_NAME_LENGTH - 1 );
-
- if( short_desc_element != NULL &&
- short_desc_element->children != NULL )
- {
- gchar * lmsg = xkl_locale_from_utf8( (const gchar *)short_desc_element->children->content );
- strncat( item->short_description,
- lmsg,
- XKL_MAX_CI_SHORT_DESC_LENGTH - 1 );
- g_free( lmsg );
- }
+ */
+
+ if (name_element != NULL && name_element->children != NULL)
+ strncat(item->name,
+ (char *) name_element->children->content,
+ XKL_MAX_CI_NAME_LENGTH - 1);
+
+ if (short_desc_element != NULL &&
+ short_desc_element->children != NULL) {
+ gchar *lmsg =
+ xkl_locale_from_utf8((const gchar *)
+ short_desc_element->children->
+ content);
+ strncat(item->short_description, lmsg,
+ XKL_MAX_CI_SHORT_DESC_LENGTH - 1);
+ g_free(lmsg);
+ }
+
+ if (desc_element != NULL && desc_element->children != NULL) {
+ gchar *lmsg =
+ xkl_locale_from_utf8((const gchar *) desc_element->
+ children->content);
+ strncat(item->description, lmsg,
+ XKL_MAX_CI_DESC_LENGTH - 1);
+ g_free(lmsg);
+ }
+ return TRUE;
+}
+
+static void
+xkl_config_enum_from_node_set(xmlNodeSetPtr nodes,
+ ConfigItemProcessFunc func, gpointer data)
+{
+ gint i;
+ if (nodes != NULL) {
+ xmlNodePtr *pnode = nodes->nodeTab;
+ for (i = nodes->nodeNr; --i >= 0;) {
+ XklConfigItem ci;
+ if (xkl_read_config_item(*pnode, &ci))
+ func(&ci, data);
- if( desc_element != NULL &&
- desc_element->children != NULL )
- {
- gchar * lmsg = xkl_locale_from_utf8( (const gchar *)desc_element->children->content );
- strncat( item->description,
- lmsg,
- XKL_MAX_CI_DESC_LENGTH - 1 );
- g_free( lmsg );
- }
- return TRUE;
+ pnode++;
+ }
+ }
}
-static void xkl_config_enum_from_node_set( xmlNodeSetPtr nodes,
- ConfigItemProcessFunc func,
- gpointer data )
+static void
+xkl_config_enum_simple(xmlXPathCompExprPtr xpath_comp_expr,
+ ConfigItemProcessFunc func, gpointer data)
{
- gint i;
- if( nodes != NULL )
- {
- xmlNodePtr *pnode = nodes->nodeTab;
- for( i = nodes->nodeNr; --i >= 0; )
- {
- XklConfigItem ci;
- if( xkl_read_config_item( *pnode, &ci ) )
- func( &ci, data );
+ xmlXPathObjectPtr xpath_obj;
- pnode++;
- }
- }
+ if (!xkl_config_registry_is_initialized())
+ return;
+ xpath_obj = xmlXPathCompiledEval(xpath_comp_expr,
+ the_registry.xpath_context);
+ if (xpath_obj != NULL) {
+ xkl_config_enum_from_node_set(xpath_obj->nodesetval, func,
+ data);
+ xmlXPathFreeObject(xpath_obj);
+ }
}
-static void xkl_config_enum_simple( xmlXPathCompExprPtr xpath_comp_expr,
- ConfigItemProcessFunc func,
- gpointer data )
+static void
+xkl_config_enum_direct(const gchar * format,
+ const gchar * value,
+ ConfigItemProcessFunc func, gpointer data)
{
- xmlXPathObjectPtr xpath_obj;
+ char xpath_expr[1024];
+ xmlXPathObjectPtr xpath_obj;
- if( !xkl_config_registry_is_initialized( ) )
- return;
- xpath_obj = xmlXPathCompiledEval( xpath_comp_expr,
- the_registry.xpath_context );
- if( xpath_obj != NULL )
- {
- xkl_config_enum_from_node_set( xpath_obj->nodesetval, func, data );
- xmlXPathFreeObject( xpath_obj );
- }
+ if (!xkl_config_registry_is_initialized())
+ return;
+ snprintf(xpath_expr, sizeof xpath_expr, format, value);
+ xpath_obj = xmlXPathEval((unsigned char *) xpath_expr,
+ the_registry.xpath_context);
+ if (xpath_obj != NULL) {
+ xkl_config_enum_from_node_set(xpath_obj->nodesetval, func,
+ data);
+ xmlXPathFreeObject(xpath_obj);
+ }
}
-static void xkl_config_enum_direct( const gchar *format,
- const gchar *value,
- ConfigItemProcessFunc func,
- gpointer data )
+static gboolean
+xkl_config_find_object(const gchar * format,
+ const gchar * arg1,
+ XklConfigItem * pitem /* in/out */ ,
+ xmlNodePtr * pnode /* out */ )
{
- char xpath_expr[1024];
- xmlXPathObjectPtr xpath_obj;
+ xmlXPathObjectPtr xpath_obj;
+ xmlNodeSetPtr nodes;
+ gboolean rv = FALSE;
+ gchar xpath_expr[1024];
- if( !xkl_config_registry_is_initialized( ) )
- return;
- snprintf( xpath_expr, sizeof xpath_expr, format, value );
- xpath_obj = xmlXPathEval( (unsigned char *)xpath_expr,
- the_registry.xpath_context );
- if( xpath_obj != NULL )
- {
- xkl_config_enum_from_node_set( xpath_obj->nodesetval, func, data );
- xmlXPathFreeObject( xpath_obj );
- }
-}
+ if (!xkl_config_registry_is_initialized())
+ return FALSE;
-static gboolean xkl_config_find_object( const gchar *format,
- const gchar *arg1,
- XklConfigItem *pitem /* in/out */ ,
- xmlNodePtr *pnode /* out */ )
-{
- xmlXPathObjectPtr xpath_obj;
- xmlNodeSetPtr nodes;
- gboolean rv = FALSE;
- gchar xpath_expr[1024];
-
- if( !xkl_config_registry_is_initialized( ) )
- return FALSE;
-
- snprintf( xpath_expr, sizeof xpath_expr, format, arg1, pitem->name );
- xpath_obj = xmlXPathEval( (unsigned char *)xpath_expr,
- the_registry.xpath_context );
- if( xpath_obj == NULL )
- return FALSE;
-
- nodes = xpath_obj->nodesetval;
- if( nodes != NULL && nodes->nodeTab != NULL )
- {
- rv = xkl_read_config_item( *nodes->nodeTab, pitem );
- if( pnode != NULL )
- {
- *pnode = *nodes->nodeTab;
- }
- }
+ snprintf(xpath_expr, sizeof xpath_expr, format, arg1, pitem->name);
+ xpath_obj = xmlXPathEval((unsigned char *) xpath_expr,
+ the_registry.xpath_context);
+ if (xpath_obj == NULL)
+ return FALSE;
- xmlXPathFreeObject( xpath_obj );
- return rv;
-}
+ nodes = xpath_obj->nodesetval;
+ if (nodes != NULL && nodes->nodeTab != NULL) {
+ rv = xkl_read_config_item(*nodes->nodeTab, pitem);
+ if (pnode != NULL) {
+ *pnode = *nodes->nodeTab;
+ }
+ }
-gchar *xkl_config_rec_merge_layouts( const XklConfigRec *data )
-{
- return xkl_strings_concat_comma_separated( data->layouts );
+ xmlXPathFreeObject(xpath_obj);
+ return rv;
}
-gchar *xkl_config_rec_merge_variants( const XklConfigRec *data )
+gchar *
+xkl_config_rec_merge_layouts(const XklConfigRec * data)
{
- return xkl_strings_concat_comma_separated( data->variants );
+ return xkl_strings_concat_comma_separated(data->layouts);
}
-gchar *xkl_config_rec_merge_options( const XklConfigRec *data )
+gchar *
+xkl_config_rec_merge_variants(const XklConfigRec * data)
{
- return xkl_strings_concat_comma_separated( data->options );
+ return xkl_strings_concat_comma_separated(data->variants);
}
-gchar *xkl_strings_concat_comma_separated( gchar **array )
+gchar *
+xkl_config_rec_merge_options(const XklConfigRec * data)
{
- return g_strjoinv( ",", array );
+ return xkl_strings_concat_comma_separated(data->options);
}
-void xkl_config_rec_split_layouts( XklConfigRec *data, const gchar *merged )
+gchar *
+xkl_strings_concat_comma_separated(gchar ** array)
{
- xkl_strings_split_comma_separated( &data->layouts, merged );
+ return g_strjoinv(",", array);
}
-void xkl_config_rec_split_variants( XklConfigRec *data, const gchar *merged )
+void
+xkl_config_rec_split_layouts(XklConfigRec * data, const gchar * merged)
{
- xkl_strings_split_comma_separated( &data->variants, merged );
+ xkl_strings_split_comma_separated(&data->layouts, merged);
}
-void xkl_config_rec_split_options( XklConfigRec *data, const gchar *merged )
+void
+xkl_config_rec_split_variants(XklConfigRec * data, const gchar * merged)
{
- xkl_strings_split_comma_separated( &data->options, merged );
+ xkl_strings_split_comma_separated(&data->variants, merged);
}
-void xkl_strings_split_comma_separated( gchar ***array, const gchar *merged )
+void
+xkl_config_rec_split_options(XklConfigRec * data, const gchar * merged)
{
- *array = g_strsplit( merged, ",", 0);
+ xkl_strings_split_comma_separated(&data->options, merged);
}
-gchar* xkl_rules_set_get_name( const gchar default_ruleset[] )
+void
+xkl_strings_split_comma_separated(gchar *** array, const gchar * merged)
{
- static gchar rules_set_name[1024] = "";
- if ( !rules_set_name[0] )
- {
- /* first call */
- gchar* rf = NULL;
- if( !xkl_get_names_prop( xkl_vtable->base_config_atom, &rf, NULL ) ||
- ( rf == NULL ) )
- {
- g_strlcpy( rules_set_name, default_ruleset, sizeof rules_set_name );
- xkl_debug( 100, "Using default rules set: [%s]\n", rules_set_name );
- return rules_set_name;
- }
- g_strlcpy( rules_set_name, rf, sizeof rules_set_name );
- g_free( rf );
- }
- xkl_debug( 100, "Rules set: [%s]\n", rules_set_name );
- return rules_set_name;
+ *array = g_strsplit(merged, ",", 0);
}
-void xkl_config_init( void )
+gchar *
+xkl_rules_set_get_name(const gchar default_ruleset[])
{
- xmlXPathInit( );
- models_xpath = xmlXPathCompile( (unsigned char *)"/xkbConfigRegistry/modelList/model" );
- layouts_xpath = xmlXPathCompile( (unsigned char *)"/xkbConfigRegistry/layoutList/layout" );
- option_groups_xpath =
- xmlXPathCompile( (unsigned char *)"/xkbConfigRegistry/optionList/group" );
- xkl_i18n_init( );
-
- xkl_ensure_vtable_inited();
- (*xkl_vtable->config_init_func)();
+ static gchar rules_set_name[1024] = "";
+ if (!rules_set_name[0]) {
+ /* first call */
+ gchar *rf = NULL;
+ if (!xkl_get_names_prop
+ (xkl_vtable->base_config_atom, &rf, NULL)
+ || (rf == NULL)) {
+ g_strlcpy(rules_set_name, default_ruleset,
+ sizeof rules_set_name);
+ xkl_debug(100, "Using default rules set: [%s]\n",
+ rules_set_name);
+ return rules_set_name;
+ }
+ g_strlcpy(rules_set_name, rf, sizeof rules_set_name);
+ g_free(rf);
+ }
+ xkl_debug(100, "Rules set: [%s]\n", rules_set_name);
+ return rules_set_name;
}
-void xkl_config_term( void )
+void
+xkl_config_init(void)
{
- if( models_xpath != NULL )
- {
- xmlXPathFreeCompExpr( models_xpath );
- models_xpath = NULL;
- }
- if( layouts_xpath != NULL )
- {
- xmlXPathFreeCompExpr( layouts_xpath );
- layouts_xpath = NULL;
- }
- if( option_groups_xpath != NULL )
- {
- xmlXPathFreeCompExpr( option_groups_xpath );
- option_groups_xpath = NULL;
- }
-}
+ xmlXPathInit();
+ models_xpath =
+ xmlXPathCompile((unsigned char *)
+ "/xkbConfigRegistry/modelList/model");
+ layouts_xpath =
+ xmlXPathCompile((unsigned char *)
+ "/xkbConfigRegistry/layoutList/layout");
+ option_groups_xpath =
+ xmlXPathCompile((unsigned char *)
+ "/xkbConfigRegistry/optionList/group");
+ xkl_i18n_init();
-gboolean xkl_config_registry_load_from_file( const gchar * file_name )
-{
- the_registry.doc = xmlParseFile( file_name );
- if( the_registry.doc == NULL )
- {
- the_registry.xpath_context = NULL;
- xkl_last_error_message = "Could not parse XKB configuration registry";
- } else
- the_registry.xpath_context = xmlXPathNewContext( the_registry.doc );
- return xkl_config_registry_is_initialized( );
+ xkl_ensure_vtable_inited();
+ (*xkl_vtable->config_init_func) ();
}
-void xkl_config_registry_free( void )
+void
+xkl_config_term(void)
{
- if( xkl_config_registry_is_initialized( ) )
- {
- xmlXPathFreeContext( the_registry.xpath_context );
- xmlFreeDoc( the_registry.doc );
- the_registry.xpath_context = NULL;
- the_registry.doc = NULL;
- }
+ if (models_xpath != NULL) {
+ xmlXPathFreeCompExpr(models_xpath);
+ models_xpath = NULL;
+ }
+ if (layouts_xpath != NULL) {
+ xmlXPathFreeCompExpr(layouts_xpath);
+ layouts_xpath = NULL;
+ }
+ if (option_groups_xpath != NULL) {
+ xmlXPathFreeCompExpr(option_groups_xpath);
+ option_groups_xpath = NULL;
+ }
}
-void xkl_config_enum_models( ConfigItemProcessFunc func, gpointer data )
+gboolean
+xkl_config_registry_load_from_file(const gchar * file_name)
{
- xkl_config_enum_simple( models_xpath, func, data );
+ the_registry.doc = xmlParseFile(file_name);
+ if (the_registry.doc == NULL) {
+ the_registry.xpath_context = NULL;
+ xkl_last_error_message =
+ "Could not parse XKB configuration registry";
+ } else
+ the_registry.xpath_context =
+ xmlXPathNewContext(the_registry.doc);
+ return xkl_config_registry_is_initialized();
}
-void xkl_config_enum_layouts( ConfigItemProcessFunc func, gpointer data )
+void
+xkl_config_registry_free(void)
{
- xkl_config_enum_simple( layouts_xpath, func, data );
+ if (xkl_config_registry_is_initialized()) {
+ xmlXPathFreeContext(the_registry.xpath_context);
+ xmlFreeDoc(the_registry.doc);
+ the_registry.xpath_context = NULL;
+ the_registry.doc = NULL;
+ }
}
-void xkl_config_enum_layout_variants( const gchar *layout_name,
- ConfigItemProcessFunc func,
- gpointer data )
+void
+xkl_config_enum_models(ConfigItemProcessFunc func, gpointer data)
{
- xkl_config_enum_direct
- ( "/xkbConfigRegistry/layoutList/layout/variantList/variant[../../configItem/name = '%s']",
- layout_name, func, data );
+ xkl_config_enum_simple(models_xpath, func, data);
}
-void xkl_config_enum_option_groups( GroupProcessFunc func, gpointer data )
+void
+xkl_config_enum_layouts(ConfigItemProcessFunc func, gpointer data)
{
- xmlXPathObjectPtr xpath_obj;
- gint i;
-
- if( !xkl_config_registry_is_initialized( ) )
- return;
- xpath_obj =
- xmlXPathCompiledEval( option_groups_xpath, the_registry.xpath_context );
- if( xpath_obj != NULL )
- {
- xmlNodeSetPtr nodes = xpath_obj->nodesetval;
- xmlNodePtr *pnode = nodes->nodeTab;
- for( i = nodes->nodeNr; --i >= 0; )
- {
- XklConfigItem ci;
+ xkl_config_enum_simple(layouts_xpath, func, data);
+}
+
+void
+xkl_config_enum_layout_variants(const gchar * layout_name,
+ ConfigItemProcessFunc func, gpointer data)
+{
+ xkl_config_enum_direct
+ ("/xkbConfigRegistry/layoutList/layout/variantList/variant[../../configItem/name = '%s']",
+ layout_name, func, data);
+}
+
+void
+xkl_config_enum_option_groups(GroupProcessFunc func, gpointer data)
+{
+ xmlXPathObjectPtr xpath_obj;
+ gint i;
+
+ if (!xkl_config_registry_is_initialized())
+ return;
+ xpath_obj =
+ xmlXPathCompiledEval(option_groups_xpath,
+ the_registry.xpath_context);
+ if (xpath_obj != NULL) {
+ xmlNodeSetPtr nodes = xpath_obj->nodesetval;
+ xmlNodePtr *pnode = nodes->nodeTab;
+ for (i = nodes->nodeNr; --i >= 0;) {
+ XklConfigItem ci;
- if( xkl_read_config_item( *pnode, &ci ) )
- {
- gboolean allow_multisel = TRUE;
- xmlChar *sallow_multisel =
- xmlGetProp( *pnode, (unsigned char *)"allowMultipleSelection" );
- if( sallow_multisel != NULL )
- {
- allow_multisel = !g_ascii_strcasecmp( "true",
- (char *)sallow_multisel );
- xmlFree( sallow_multisel );
- }
+ if (xkl_read_config_item(*pnode, &ci)) {
+ gboolean allow_multisel = TRUE;
+ xmlChar *sallow_multisel =
+ xmlGetProp(*pnode,
+ (unsigned char *)
+ "allowMultipleSelection");
+ if (sallow_multisel != NULL) {
+ allow_multisel =
+ !g_ascii_strcasecmp("true",
+ (char *)
+ sallow_multisel);
+ xmlFree(sallow_multisel);
+ }
- func( &ci, allow_multisel, data );
- }
+ func(&ci, allow_multisel, data);
+ }
- pnode++;
- }
- xmlXPathFreeObject( xpath_obj );
- }
+ pnode++;
+ }
+ xmlXPathFreeObject(xpath_obj);
+ }
}
-void xkl_config_enum_options( const gchar *option_group_name,
- ConfigItemProcessFunc func,
- gpointer data )
+void
+xkl_config_enum_options(const gchar * option_group_name,
+ ConfigItemProcessFunc func, gpointer data)
{
- xkl_config_enum_direct
- ( "/xkbConfigRegistry/optionList/group/option[../configItem/name = '%s']",
- option_group_name, func, data );
+ xkl_config_enum_direct
+ ("/xkbConfigRegistry/optionList/group/option[../configItem/name = '%s']",
+ option_group_name, func, data);
}
-gboolean xkl_config_find_model( XklConfigItem * pitem /* in/out */ )
+gboolean
+xkl_config_find_model(XklConfigItem * pitem /* in/out */ )
{
- return
- xkl_config_find_object
- ( "/xkbConfigRegistry/modelList/model[configItem/name = '%s%s']", "",
- pitem, NULL );
+ return
+ xkl_config_find_object
+ ("/xkbConfigRegistry/modelList/model[configItem/name = '%s%s']",
+ "", pitem, NULL);
}
-gboolean xkl_config_find_layout( XklConfigItem * pitem /* in/out */ )
+gboolean
+xkl_config_find_layout(XklConfigItem * pitem /* in/out */ )
{
- return
- xkl_config_find_object
- ( "/xkbConfigRegistry/layoutList/layout[configItem/name = '%s%s']", "",
- pitem, NULL );
+ return
+ xkl_config_find_object
+ ("/xkbConfigRegistry/layoutList/layout[configItem/name = '%s%s']",
+ "", pitem, NULL);
}
-gboolean xkl_config_find_variant( const char *layout_name,
- XklConfigItem * pitem /* in/out */ )
+gboolean
+xkl_config_find_variant(const char *layout_name,
+ XklConfigItem * pitem /* in/out */ )
{
- return
- xkl_config_find_object
- ( "/xkbConfigRegistry/layoutList/layout/variantList/variant"
- "[../../configItem/name = '%s' and configItem/name = '%s']",
- layout_name, pitem, NULL );
+ return
+ xkl_config_find_object
+ ("/xkbConfigRegistry/layoutList/layout/variantList/variant"
+ "[../../configItem/name = '%s' and configItem/name = '%s']",
+ layout_name, pitem, NULL);
}
-gboolean _xkl_config_find_option_group( XklConfigItem * pitem /* in/out */ ,
- gboolean * allow_multiple_selection /* out */ )
+gboolean
+_xkl_config_find_option_group(XklConfigItem * pitem /* in/out */ ,
+ gboolean *
+ allow_multiple_selection /* out */ )
{
- xmlNodePtr node;
- gboolean rv =
- xkl_config_find_object
- ( "/xkbConfigRegistry/optionList/group[configItem/name = '%s%s']", "",
- pitem, &node );
+ xmlNodePtr node;
+ gboolean rv =
+ xkl_config_find_object
+ ("/xkbConfigRegistry/optionList/group[configItem/name = '%s%s']",
+ "",
+ pitem, &node);
- if( rv && allow_multiple_selection != NULL )
- {
- xmlChar *val = xmlGetProp( node,
- (unsigned char *)"allowMultipleSelection" );
- *allow_multiple_selection = FALSE;
- if( val != NULL )
- {
- *allow_multiple_selection = !g_ascii_strcasecmp( "true", (char *)val );
- xmlFree( val );
- }
- }
- return rv;
-}
-
-gboolean xkl_config_find_option( const char *option_group_name,
- XklConfigItem *pitem /* in/out */ )
-{
- return
- xkl_config_find_object
- ( "/xkbConfigRegistry/optionList/group/option"
- "[../configItem/name = '%s' and configItem/name = '%s']",
- option_group_name, pitem, NULL );
+ if (rv && allow_multiple_selection != NULL) {
+ xmlChar *val = xmlGetProp(node,
+ (unsigned char *)
+ "allowMultipleSelection");
+ *allow_multiple_selection = FALSE;
+ if (val != NULL) {
+ *allow_multiple_selection =
+ !g_ascii_strcasecmp("true", (char *) val);
+ xmlFree(val);
+ }
+ }
+ return rv;
+}
+
+gboolean
+xkl_config_find_option(const char *option_group_name,
+ XklConfigItem * pitem /* in/out */ )
+{
+ return
+ xkl_config_find_object
+ ("/xkbConfigRegistry/optionList/group/option"
+ "[../configItem/name = '%s' and configItem/name = '%s']",
+ option_group_name, pitem, NULL);
}
/**
* Calling through vtable
*/
-gboolean xkl_config_activate( const XklConfigRec * data )
+gboolean
+xkl_config_activate(const XklConfigRec * data)
{
- xkl_ensure_vtable_inited();
- return (*xkl_vtable->config_activate_func)( data );
+ xkl_ensure_vtable_inited();
+ return (*xkl_vtable->config_activate_func) (data);
}
-gboolean xkl_config_registry_load( void )
+gboolean
+xkl_config_registry_load(void)
{
- xkl_ensure_vtable_inited();
- return (*xkl_vtable->config_registry_load_func)();
+ xkl_ensure_vtable_inited();
+ return (*xkl_vtable->config_registry_load_func) ();
}
-gboolean xkl_config_write_file( const gchar *file_name,
- const XklConfigRec * data,
- const gboolean binary )
+gboolean
+xkl_config_write_file(const gchar * file_name,
+ const XklConfigRec * data, const gboolean binary)
{
- if( ( !binary &&
- !( xkl_vtable->features & XKLF_CAN_OUTPUT_CONFIG_AS_ASCII ) ) ||
- ( binary &&
- !( xkl_vtable->features & XKLF_CAN_OUTPUT_CONFIG_AS_BINARY ) ) )
- {
- xkl_last_error_message = "Function not supported at backend";
- return FALSE;
- }
- xkl_ensure_vtable_inited();
- return (*xkl_vtable->config_write_file_func)( file_name, data, binary );
+ if ((!binary &&
+ !(xkl_vtable->features & XKLF_CAN_OUTPUT_CONFIG_AS_ASCII)) ||
+ (binary &&
+ !(xkl_vtable->features & XKLF_CAN_OUTPUT_CONFIG_AS_BINARY))) {
+ xkl_last_error_message =
+ "Function not supported at backend";
+ return FALSE;
+ }
+ xkl_ensure_vtable_inited();
+ return (*xkl_vtable->config_write_file_func) (file_name, data,
+ binary);
}
-void xkl_config_dump( FILE* file,
- XklConfigRec * data )
+void
+xkl_config_dump(FILE * file, XklConfigRec * data)
{
- int j;
- fprintf( file, " model: [%s]\n", data->model );
+ int j;
+ fprintf(file, " model: [%s]\n", data->model);
- fprintf( file, " layouts:\n" );
+ fprintf(file, " layouts:\n");
#define OUTPUT_ARRZ(arrz) \
{ \
fprintf( file, " " #arrz ":\n" ); \
@@ -533,9 +559,8 @@ void xkl_config_dump( FILE* file,
for( j = 0; *p != NULL; ) \
fprintf( file, " %d: [%s]\n", j++, *p++ ); \
}
- OUTPUT_ARRZ( layouts );
- OUTPUT_ARRZ( variants );
- OUTPUT_ARRZ( options );
+ OUTPUT_ARRZ(layouts);
+ OUTPUT_ARRZ(variants);
+ OUTPUT_ARRZ(options);
}
-
diff --git a/libxklavier/xklavier_config.h b/libxklavier/xklavier_config.h
index 5070c7d..ee31067 100644
--- a/libxklavier/xklavier_config.h
+++ b/libxklavier/xklavier_config.h
@@ -28,16 +28,15 @@
#define XKL_MAX_CI_DESC_LENGTH 192
#ifdef __cplusplus
-extern "C"
-{
-#endif /* __cplusplus */
+extern "C" {
+#endif /* __cplusplus */
#ifndef DOXYGEN_SHOULD_SKIP_THIS
- typedef struct _XklConfigItem XklConfigItem;
- typedef struct _XklConfigItemClass XklConfigItemClass;
- typedef struct _XklConfigRec XklConfigRec;
- typedef struct _XklConfigRecClass XklConfigRecClass;
+ typedef struct _XklConfigItem XklConfigItem;
+ typedef struct _XklConfigItemClass XklConfigItemClass;
+ typedef struct _XklConfigRec XklConfigRec;
+ typedef struct _XklConfigRecClass XklConfigRecClass;
#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))
@@ -53,77 +52,73 @@ extern "C"
#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
+#endif // DOXYGEN_SHOULD_SKIP_THIS
/**
* The configuration item. Corresponds to XML element "configItem".
*/
- struct _XklConfigItem
- {
+ struct _XklConfigItem {
/**
* The superclass object
*/
- GObject parent;
+ GObject parent;
/**
* The configuration item name. Corresponds to XML element "name".
*/
- gchar name[XKL_MAX_CI_NAME_LENGTH];
+ 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];
+ gchar short_description[XKL_MAX_CI_DESC_LENGTH];
/**
* The configuration item description. Corresponds to XML element "description".
*/
- gchar description[XKL_MAX_CI_DESC_LENGTH];
- };
+ gchar description[XKL_MAX_CI_DESC_LENGTH];
+ };
/**
* The XklConfigItem class, derived from GObject
*/
- struct _XklConfigItemClass
- {
+ struct _XklConfigItemClass {
/**
* The superclass
*/
- GObjectClass parent_class;
- };
+ GObjectClass parent_class;
+ };
/**
* Basic configuration params
*/
- struct _XklConfigRec
- {
+ struct _XklConfigRec {
/**
* The keyboard model
*/
- gchar *model;
+ gchar *model;
/**
* The array of keyboard layouts
*/
- gchar **layouts;
+ gchar **layouts;
/**
* The array of keyboard layout variants (if any)
*/
- gchar **variants;
+ gchar **variants;
/**
* The array of keyboard layout options
*/
- gchar **options;
- };
+ gchar **options;
+ };
/**
* The XklConfigRec class, derived from GObject
*/
- struct _XklConfigRecClass
- {
+ struct _XklConfigRecClass {
/**
* The superclass
*/
- GObjectClass parent_class;
- };
+ GObjectClass parent_class;
+ };
/**
* @defgroup xklconfiginitterm XKB configuration handling initialization and termination
@@ -133,30 +128,31 @@ extern "C"
/**
* Initializes XML configuration-related structures
*/
- extern void xkl_config_init( void );
+ extern void xkl_config_init(void);
/**
* Cleans XML configuration-related structures
*/
- extern void xkl_config_term( void );
+ extern void xkl_config_term(void);
/**
* Loads XML configuration registry
* @param file_name file name to load
* @return true on success
*/
- extern gboolean xkl_config_registry_load_from_file( const gchar* file_name );
+ extern gboolean xkl_config_registry_load_from_file(const gchar *
+ file_name);
/**
* Loads XML configuration registry
* @return true on success
*/
- extern gboolean xkl_config_registry_load( void );
+ extern gboolean xkl_config_registry_load(void);
/**
* Frees XML configuration registry
*/
- extern void xkl_config_registry_free( void );
+ extern void xkl_config_registry_free(void);
/** @} */
/**
@@ -169,8 +165,8 @@ extern "C"
* @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 );
+ typedef void (*ConfigItemProcessFunc) (const XklConfigItem * item,
+ gpointer data);
/**
* Callback type used for enumerating keyboard option groups
@@ -178,24 +174,25 @@ extern "C"
* @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 );
+ 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_enum_models( ConfigItemProcessFunc func,
- gpointer data );
+ extern void xkl_config_enum_models(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_enum_layouts( ConfigItemProcessFunc func,
- gpointer data );
+ extern void xkl_config_enum_layouts(ConfigItemProcessFunc func,
+ gpointer data);
/**
* Enumerates keyboard layout variants from the XML configuration registry
@@ -203,17 +200,18 @@ extern "C"
* @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_enum_layout_variants( const gchar *layout_name,
- ConfigItemProcessFunc func,
- gpointer data );
+ extern void xkl_config_enum_layout_variants(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_enum_option_groups( GroupProcessFunc func,
- gpointer data );
+ extern void xkl_config_enum_option_groups(GroupProcessFunc func,
+ gpointer data);
/**
* Enumerates keyboard options from the XML configuration registry
@@ -222,9 +220,10 @@ extern "C"
* @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_enum_options( const gchar *option_group_name,
- ConfigItemProcessFunc func,
- gpointer data );
+ extern void xkl_config_enum_options(const gchar *
+ option_group_name,
+ ConfigItemProcessFunc func,
+ gpointer data);
/** @} */
@@ -239,7 +238,7 @@ extern "C"
* keyboard model. On successfull return, the descriptions are filled.
* @return TRUE if appropriate element was found and loaded
*/
- extern gboolean xkl_config_find_model( XklConfigItem * item );
+ extern gboolean xkl_config_find_model(XklConfigItem * item);
/**
* Loads a keyboard layout information from the XML configuration registry.
@@ -247,7 +246,7 @@ extern "C"
* keyboard layout. On successfull return, the descriptions are filled.
* @return TRUE if appropriate element was found and loaded
*/
- extern gboolean xkl_config_find_layout( XklConfigItem * item );
+ extern gboolean xkl_config_find_layout(XklConfigItem * item);
/**
* Loads a keyboard layout variant information from the XML configuration
@@ -257,8 +256,8 @@ extern "C"
* keyboard layout variant. On successfull return, the descriptions are filled.
* @return TRUE if appropriate element was found and loaded
*/
- extern gboolean xkl_config_find_variant( const char *layout_name,
- XklConfigItem * item );
+ extern gboolean xkl_config_find_variant(const char *layout_name,
+ XklConfigItem * item);
/**
* Loads a keyboard option group information from the XML configuration
@@ -269,8 +268,9 @@ extern "C"
* the corresponding attribute of XML element "group".
* @return TRUE if appropriate element was found and loaded
*/
- extern gboolean xkl_config_find_option_group( XklConfigItem *item,
- gboolean *allow_multiple_selection );
+ extern gboolean xkl_config_find_option_group(XklConfigItem * item,
+ gboolean *
+ allow_multiple_selection);
/**
* Loads a keyboard option information from the XML configuration
@@ -280,8 +280,9 @@ extern "C"
* keyboard option. On successfull return, the descriptions are filled.
* @return TRUE if appropriate element was found and loaded
*/
- extern gboolean xkl_config_find_option( const gchar *option_group_name,
- XklConfigItem *item );
+ extern gboolean xkl_config_find_option(const gchar *
+ option_group_name,
+ XklConfigItem * item);
/** @} */
/**
@@ -297,14 +298,14 @@ extern "C"
* @see XklSetKeyAsSwitcher
* At the moment, accepts only _ONE_ layout. Later probably I'll improve this..
*/
- extern gboolean xkl_config_activate( const XklConfigRec *data );
+ extern gboolean xkl_config_activate(const XklConfigRec * data);
/**
* Loads the current XKB configuration (from X server)
* @param data is a buffer for XKB configuration
* @return TRUE on success
*/
- extern gboolean xkl_config_get_from_server( XklConfigRec *data );
+ extern gboolean xkl_config_get_from_server(XklConfigRec * data);
/**
* Loads the current XKB configuration (from backup)
@@ -312,7 +313,7 @@ extern "C"
* @return TRUE on success
* @see XklBackupNamesProp
*/
- extern gboolean xkl_config_get_from_backup( XklConfigRec *data );
+ extern gboolean xkl_config_get_from_backup(XklConfigRec * data);
/**
* Writes some XKB configuration into XKM/XKB file
@@ -322,9 +323,9 @@ extern "C"
* @param binary is a flag indicating whether the output file should be binary
* @return TRUE on success
*/
- extern gboolean xkl_config_write_file( const gchar *file_name,
- const XklConfigRec *data,
- const gboolean binary );
+ extern gboolean xkl_config_write_file(const gchar * file_name,
+ const XklConfigRec * data,
+ const gboolean binary);
/** @} */
@@ -342,9 +343,9 @@ extern "C"
* all records are allocated using standard malloc
* @return TRUE on success
*/
- extern gboolean xkl_get_names_prop( Atom rules_atom_name,
- gchar **rules_file_out,
- XklConfigRec *config_out );
+ extern gboolean xkl_get_names_prop(Atom rules_atom_name,
+ gchar ** rules_file_out,
+ XklConfigRec * config_out);
/**
* Saves the XKB configuration into any root window property
@@ -353,23 +354,23 @@ extern "C"
* @param config is a configuration to save
* @return TRUE on success
*/
- extern gboolean xkl_set_names_prop( Atom rules_atom_name,
- gchar *rules_file,
- const XklConfigRec *config );
+ extern gboolean xkl_set_names_prop(Atom rules_atom_name,
+ gchar * rules_file,
+ const XklConfigRec * config);
/**
* Backups current XKB configuration into some property -
* if this property is not defined yet.
* @return TRUE on success
*/
- extern gboolean xkl_backup_names_prop( );
+ extern gboolean xkl_backup_names_prop();
/**
* 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( );
+ extern gboolean xkl_restore_names_prop();
/** @} */
@@ -383,19 +384,19 @@ extern "C"
* Initializes the record (actually, fills it with 0-s)
* @param data is a record to initialize
*/
- extern void xkl_config_rec_init( XklConfigRec *data );
+ extern void xkl_config_rec_init(XklConfigRec * data);
/**
* Resets the record (equal to Destroy and Init)
* @param data is a record to reset
*/
- extern void xkl_config_rec_reset( XklConfigRec *data );
+ extern void xkl_config_rec_reset(XklConfigRec * data);
/**
* Cleans the record (frees all the non-null members)
* @param data is a record to clean
*/
- extern void xkl_config_rec_destroy( XklConfigRec *data );
+ extern void xkl_config_rec_destroy(XklConfigRec * data);
/**
* Compares the records
@@ -403,13 +404,12 @@ extern "C"
* @param data2 is another record
* @return TRUE if records are same
*/
- extern gboolean xkl_config_rec_equals( XklConfigRec *data1,
- XklConfigRec *data2 );
+ extern gboolean xkl_config_rec_equals(XklConfigRec * data1,
+ XklConfigRec * data2);
/** @} */
#ifdef __cplusplus
}
-#endif /* __cplusplus */
-
+#endif /* __cplusplus */
#endif
diff --git a/libxklavier/xklavier_config_i18n.c b/libxklavier/xklavier_config_i18n.c
index 19f4c6b..0ff4ef7 100644
--- a/libxklavier/xklavier_config_i18n.c
+++ b/libxklavier/xklavier_config_i18n.c
@@ -21,214 +21,215 @@ static gchar locale_sub_strings[3][MAX_LOCALE_LEN];
/*
* some bad guys create LC_ALL=LC_CTYPE=ru_RU.UTF-8;LC_NUMERIC=C;LC_TIME=ru_RU.UTF-8;LC_COLLATE=ru_RU.UTF-8;LC_MONETARY=ru_RU.UTF-8;LC_MESSAGES=ru_RU.UTF-8;LC_PAPER=ru_RU.UTF-8;LC_NAME=ru_RU.UTF-8;LC_ADDRESS=ru_RU.UTF-8;LC_TELEPHONE=ru_RU.UTF-8;LC_MEASUREMENT=ru_RU.UTF-8;LC_IDENTIFICATION=ru_RU.UTF-8
*/
-static const gchar *xkl_parse_LC_ALL_to_LC_MESSAGES( const gchar *lc_all )
+static const gchar *
+xkl_parse_LC_ALL_to_LC_MESSAGES(const gchar * lc_all)
{
- const gchar *lc_message_pos = g_strstr_len( lc_all, -1, "LC_MESSAGES=" );
- const gchar *lc_message_end;
- size_t len;
- static gchar buf[128];
- if( lc_message_pos == NULL )
- return lc_all;
- lc_message_pos += 12;
- lc_message_end = g_strstr_len( lc_message_pos, -1, ";" );
- if( lc_message_end == NULL ) /* LC_MESSAGES is the last piece of LC_ALL */
- {
- return lc_message_pos; /* safe to return! */
- }
- len = lc_message_end - lc_message_pos;
- if( len > sizeof( buf ) )
- len = sizeof( buf );
- g_strlcpy( buf, lc_message_pos, len );
- return buf;
+ const gchar *lc_message_pos =
+ g_strstr_len(lc_all, -1, "LC_MESSAGES=");
+ const gchar *lc_message_end;
+ size_t len;
+ static gchar buf[128];
+ if (lc_message_pos == NULL)
+ return lc_all;
+ lc_message_pos += 12;
+ lc_message_end = g_strstr_len(lc_message_pos, -1, ";");
+ if (lc_message_end == NULL) { /* LC_MESSAGES is the last piece of LC_ALL */
+ return lc_message_pos; /* safe to return! */
+ }
+ len = lc_message_end - lc_message_pos;
+ if (len > sizeof(buf))
+ len = sizeof(buf);
+ g_strlcpy(buf, lc_message_pos, len);
+ return buf;
}
/* Taken from gnome-vfs */
-static gboolean xkl_get_charset( const gchar **a )
+static gboolean
+xkl_get_charset(const gchar ** a)
{
- static const gchar *charset = NULL;
+ static const gchar *charset = NULL;
- if( charset == NULL )
- {
- charset = g_getenv( "CHARSET" );
+ if (charset == NULL) {
+ charset = g_getenv("CHARSET");
- if( charset == NULL || charset[0] == '\0' )
- {
+ if (charset == NULL || charset[0] == '\0') {
#ifdef HAVE_LANGINFO_CODESET
- charset = nl_langinfo( CODESET );
- if( charset == NULL || charset[0] == '\0' )
- {
+ charset = nl_langinfo(CODESET);
+ if (charset == NULL || charset[0] == '\0') {
#endif
#ifdef HAVE_SETLOCALE
- charset = setlocale( LC_CTYPE, NULL );
- if( charset == NULL || charset[0] == '\0' )
- {
+ charset = setlocale(LC_CTYPE, NULL);
+ if (charset == NULL || charset[0] == '\0') {
#endif
- charset = getenv( "LC_ALL" );
- if( charset == NULL || charset[0] == '\0' )
- {
- charset = getenv( "LC_CTYPE" );
- if( charset == NULL || charset[0] == '\0' )
- charset = getenv( "LANG" );
- }
+ charset = getenv("LC_ALL");
+ if (charset == NULL
+ || charset[0] == '\0') {
+ charset =
+ getenv("LC_CTYPE");
+ if (charset == NULL
+ || charset[0] == '\0')
+ charset =
+ getenv("LANG");
+ }
#ifdef HAVE_SETLOCALE
- } else
- {
- xkl_debug( 150, "Using charset from setlocale: [%s]\n", charset );
- }
+ } else {
+ xkl_debug(150,
+ "Using charset from setlocale: [%s]\n",
+ charset);
+ }
#endif
#ifdef HAVE_LANGINFO_CODESET
- } else
- {
- xkl_debug( 150, "Using charset from nl_langinfo: [%s]\n", charset );
- }
+ } else {
+ xkl_debug(150,
+ "Using charset from nl_langinfo: [%s]\n",
+ charset);
+ }
#endif
- }
- }
-
- if( charset != NULL && *charset != '\0' )
- {
- *a = charset;
- return ( charset != NULL && g_strstr_len( charset, -1, "UTF-8" ) != NULL );
- }
- /* Assume this for compatibility at present. */
- *a = "US-ASCII";
- xkl_debug( 150, "Using charset fallback: [%s]\n", *a );
-
- return FALSE;
+ }
+ }
+
+ if (charset != NULL && *charset != '\0') {
+ *a = charset;
+ return (charset != NULL
+ && g_strstr_len(charset, -1, "UTF-8") != NULL);
+ }
+ /* Assume this for compatibility at present. */
+ *a = "US-ASCII";
+ xkl_debug(150, "Using charset fallback: [%s]\n", *a);
+
+ return FALSE;
}
-gchar *xkl_locale_from_utf8( const gchar *utf8string )
+gchar *
+xkl_locale_from_utf8(const gchar * utf8string)
{
- size_t len;
-
- iconv_t converter;
- gchar converted[XKL_MAX_CI_DESC_LENGTH];
- gchar *converted_start = converted;
- gchar *utf_start = ( char * ) utf8string;
- size_t clen = XKL_MAX_CI_DESC_LENGTH - 1;
- const gchar *charset;
-
- static gboolean already_warned = FALSE;
-
- if( utf8string == NULL )
- return NULL;
-
- len = strlen( utf8string );
-
- if( xkl_get_charset( &charset ) )
- return g_strdup( utf8string );
-
- converter = iconv_open( charset, "UTF-8" );
- if( converter == ( iconv_t ) - 1 )
- {
- if( !already_warned )
- {
- already_warned = TRUE;
- xkl_debug( 0,
- "Unable to convert MIME info from UTF-8 "
- "to the current locale %s. "
- "MIME info will probably display wrong.",
- charset );
- }
- return g_strdup( utf8string );
- }
-
- if( iconv( converter, &utf_start, &len, &converted_start, &clen ) == -1 )
- {
- xkl_debug( 0,
- "Unable to convert %s from UTF-8 to %s, "
- "this string will probably display wrong.",
- utf8string, charset );
- return g_strdup( utf8string );
- }
- *converted_start = '\0';
-
- iconv_close( converter );
-
- return g_strdup( converted );
+ size_t len;
+
+ iconv_t converter;
+ gchar converted[XKL_MAX_CI_DESC_LENGTH];
+ gchar *converted_start = converted;
+ gchar *utf_start = (char *) utf8string;
+ size_t clen = XKL_MAX_CI_DESC_LENGTH - 1;
+ const gchar *charset;
+
+ static gboolean already_warned = FALSE;
+
+ if (utf8string == NULL)
+ return NULL;
+
+ len = strlen(utf8string);
+
+ if (xkl_get_charset(&charset))
+ return g_strdup(utf8string);
+
+ converter = iconv_open(charset, "UTF-8");
+ if (converter == (iconv_t) - 1) {
+ if (!already_warned) {
+ already_warned = TRUE;
+ xkl_debug(0,
+ "Unable to convert MIME info from UTF-8 "
+ "to the current locale %s. "
+ "MIME info will probably display wrong.",
+ charset);
+ }
+ return g_strdup(utf8string);
+ }
+
+ if (iconv(converter, &utf_start, &len, &converted_start, &clen) ==
+ -1) {
+ xkl_debug(0,
+ "Unable to convert %s from UTF-8 to %s, "
+ "this string will probably display wrong.",
+ utf8string, charset);
+ return g_strdup(utf8string);
+ }
+ *converted_start = '\0';
+
+ iconv_close(converter);
+
+ return g_strdup(converted);
}
/*
* country[_LANG[.ENCODING]] - any other ideas?
*/
-void xkl_i18n_init( void )
+void
+xkl_i18n_init(void)
{
- gchar *dot_pos;
- gchar *underscore_pos;
- const gchar *locale = NULL;
- gchar *cur_substring;
+ gchar *dot_pos;
+ gchar *underscore_pos;
+ const gchar *locale = NULL;
+ gchar *cur_substring;
- locale_sub_strings[0][0] = locale_sub_strings[1][0] =
- locale_sub_strings[2][0] = '\0';
+ locale_sub_strings[0][0] = locale_sub_strings[1][0] =
+ locale_sub_strings[2][0] = '\0';
#ifdef HAVE_SETLOCALE
- locale = setlocale( LC_MESSAGES, NULL );
+ locale = setlocale(LC_MESSAGES, NULL);
#endif
- if( locale == NULL || locale[0] == '\0' )
- {
- locale = getenv( "LC_MESSAGES" );
- if( locale == NULL || locale[0] == '\0' )
- {
- locale = getenv( "LC_ALL" );
- if( locale == NULL || locale[0] == '\0' )
- locale = getenv( "LANG" );
- else
- locale = xkl_parse_LC_ALL_to_LC_MESSAGES( locale );
- }
- }
-
- if( locale == NULL )
- {
- xkl_debug( 0, "Could not find locale - can be problems with i18n" );
- return;
- }
-
- g_strlcpy( locale_sub_strings[0], locale, MAX_LOCALE_LEN );
-
- cur_substring = locale_sub_strings[1];
-
- dot_pos = g_strstr_len( locale, -1, "." );
- if( dot_pos != NULL )
- {
- gint idx = dot_pos - locale;
- if( idx >= MAX_LOCALE_LEN )
- idx = MAX_LOCALE_LEN - 1;
- g_strlcpy( cur_substring, locale, idx );
- cur_substring += MAX_LOCALE_LEN;
- }
-
- underscore_pos = strchr( locale, '_' );
- if( underscore_pos != NULL &&
- ( dot_pos == NULL || dot_pos > underscore_pos ) )
- {
- gint idx = underscore_pos - locale;
- if( idx >= MAX_LOCALE_LEN )
- idx = MAX_LOCALE_LEN - 1;
- g_strlcpy( cur_substring, locale, idx );
- }
-
- xkl_debug( 150, "Locale search order:\n" );
- /* full locale - highest priority */
- xkl_debug( 150, " 0: %s\n", locale_sub_strings[0] );
- xkl_debug( 150, " 1: %s\n", locale_sub_strings[1] );
- xkl_debug( 150, " 2: %s\n", locale_sub_strings[2] );
+ if (locale == NULL || locale[0] == '\0') {
+ locale = getenv("LC_MESSAGES");
+ if (locale == NULL || locale[0] == '\0') {
+ locale = getenv("LC_ALL");
+ if (locale == NULL || locale[0] == '\0')
+ locale = getenv("LANG");
+ else
+ locale =
+ xkl_parse_LC_ALL_to_LC_MESSAGES
+ (locale);
+ }
+ }
+
+ if (locale == NULL) {
+ xkl_debug(0,
+ "Could not find locale - can be problems with i18n");
+ return;
+ }
+
+ g_strlcpy(locale_sub_strings[0], locale, MAX_LOCALE_LEN);
+
+ cur_substring = locale_sub_strings[1];
+
+ dot_pos = g_strstr_len(locale, -1, ".");
+ if (dot_pos != NULL) {
+ gint idx = dot_pos - locale;
+ if (idx >= MAX_LOCALE_LEN)
+ idx = MAX_LOCALE_LEN - 1;
+ g_strlcpy(cur_substring, locale, idx);
+ cur_substring += MAX_LOCALE_LEN;
+ }
+
+ underscore_pos = strchr(locale, '_');
+ if (underscore_pos != NULL &&
+ (dot_pos == NULL || dot_pos > underscore_pos)) {
+ gint idx = underscore_pos - locale;
+ if (idx >= MAX_LOCALE_LEN)
+ idx = MAX_LOCALE_LEN - 1;
+ g_strlcpy(cur_substring, locale, idx);
+ }
+
+ xkl_debug(150, "Locale search order:\n");
+ /* full locale - highest priority */
+ xkl_debug(150, " 0: %s\n", locale_sub_strings[0]);
+ xkl_debug(150, " 1: %s\n", locale_sub_strings[1]);
+ xkl_debug(150, " 2: %s\n", locale_sub_strings[2]);
}
-gint xkl_get_language_priority( const gchar *lang )
+gint
+xkl_get_language_priority(const gchar * lang)
{
- gint i, priority = -1;
-
- for( i = sizeof( locale_sub_strings ) / sizeof( locale_sub_strings[0] );
- --i >= 0; )
- {
- if( locale_sub_strings[0][0] == '\0' )
- continue;
-
- if( !g_ascii_strcasecmp( lang, locale_sub_strings[i] ) )
- {
- priority = i;
- break;
- }
- }
- return priority;
+ gint i, priority = -1;
+
+ for (i =
+ sizeof(locale_sub_strings) / sizeof(locale_sub_strings[0]);
+ --i >= 0;) {
+ if (locale_sub_strings[0][0] == '\0')
+ continue;
+
+ if (!g_ascii_strcasecmp(lang, locale_sub_strings[i])) {
+ priority = i;
+ break;
+ }
+ }
+ return priority;
}
diff --git a/libxklavier/xklavier_config_xkb.c b/libxklavier/xklavier_config_xkb.c
index bc41f67..d221695 100644
--- a/libxklavier/xklavier_config_xkb.c
+++ b/libxklavier/xklavier_config_xkb.c
@@ -32,412 +32,484 @@
#ifdef XKB_HEADERS_PRESENT
static XkbRF_RulesPtr xkl_rules;
-static XkbRF_RulesPtr xkl_rules_set_load( void )
+static XkbRF_RulesPtr
+xkl_rules_set_load(void)
{
- XkbRF_RulesPtr rules_set = NULL;
- char file_name[MAXPATHLEN] = "";
- char *rf = xkl_rules_set_get_name( XKB_DEFAULT_RULESET );
- char *locale = NULL;
-
- if( rf == NULL )
- {
- xkl_last_error_message = "Could not find the XKB rules set";
- return NULL;
- }
-
- locale = setlocale( LC_ALL, NULL );
-
- snprintf( file_name, sizeof file_name, XKB_BASE "/rules/%s", rf );
- xkl_debug( 160, "Loading rules from [%s]\n", file_name );
-
- rules_set = XkbRF_Load( file_name, locale, True, True );
-
- if( rules_set == NULL )
- {
- xkl_last_error_message = "Could not load rules";
- return NULL;
- }
- return rules_set;
+ XkbRF_RulesPtr rules_set = NULL;
+ char file_name[MAXPATHLEN] = "";
+ char *rf = xkl_rules_set_get_name(XKB_DEFAULT_RULESET);
+ char *locale = NULL;
+
+ if (rf == NULL) {
+ xkl_last_error_message =
+ "Could not find the XKB rules set";
+ return NULL;
+ }
+
+ locale = setlocale(LC_ALL, NULL);
+
+ snprintf(file_name, sizeof file_name, XKB_BASE "/rules/%s", rf);
+ xkl_debug(160, "Loading rules from [%s]\n", file_name);
+
+ rules_set = XkbRF_Load(file_name, locale, True, True);
+
+ if (rules_set == NULL) {
+ xkl_last_error_message = "Could not load rules";
+ return NULL;
+ }
+ return rules_set;
}
-static void xkl_rules_set_free( void )
+static void
+xkl_rules_set_free(void)
{
- if ( xkl_rules )
- XkbRF_Free( xkl_rules, True );
- xkl_rules = NULL;
+ if (xkl_rules)
+ XkbRF_Free(xkl_rules, True);
+ xkl_rules = NULL;
}
#endif
-void xkl_xkb_config_init( void )
+void
+xkl_xkb_config_init(void)
{
#ifdef XKB_HEADERS_PRESENT
- XkbInitAtoms( NULL );
+ XkbInitAtoms(NULL);
#endif
}
-gboolean xkl_xkb_config_registry_load( void )
+gboolean
+xkl_xkb_config_registry_load(void)
{
- struct stat stat_buf;
- char file_name[MAXPATHLEN] = "";
- char* rf = xkl_rules_set_get_name( XKB_DEFAULT_RULESET );
+ struct stat stat_buf;
+ char file_name[MAXPATHLEN] = "";
+ char *rf = xkl_rules_set_get_name(XKB_DEFAULT_RULESET);
- if ( rf == NULL )
- return FALSE;
+ if (rf == NULL)
+ return FALSE;
- snprintf( file_name, sizeof file_name, XKB_BASE "/rules/%s.xml", rf );
+ snprintf(file_name, sizeof file_name, XKB_BASE "/rules/%s.xml",
+ rf);
- if( stat( file_name, &stat_buf ) != 0 )
- {
- g_strlcpy( file_name, XML_CFG_FALLBACK_PATH, sizeof file_name );
- }
+ if (stat(file_name, &stat_buf) != 0) {
+ g_strlcpy(file_name, XML_CFG_FALLBACK_PATH,
+ sizeof file_name);
+ }
- return xkl_config_registry_load_from_file( file_name );
+ return xkl_config_registry_load_from_file(file_name);
}
#ifdef XKB_HEADERS_PRESENT
-gboolean xkl_xkb_config_native_prepare( const XklConfigRec * data,
- XkbComponentNamesPtr component_names_ptr )
+gboolean
+xkl_xkb_config_native_prepare(const XklConfigRec * data,
+ XkbComponentNamesPtr component_names_ptr)
{
- XkbRF_VarDefsRec xkl_var_defs;
- gboolean got_components;
-
- memset( &xkl_var_defs, 0, sizeof( xkl_var_defs ) );
-
- xkl_rules = xkl_rules_set_load();
- if( !xkl_rules )
- {
- return FALSE;
- }
-
- xkl_var_defs.model = ( char * ) data->model;
-
- if( data->layouts != NULL )
- xkl_var_defs.layout = xkl_config_rec_merge_layouts( data );
-
- if( data->variants != NULL )
- xkl_var_defs.variant = xkl_config_rec_merge_variants( data );
-
- if( data->options != NULL )
- xkl_var_defs.options = xkl_config_rec_merge_options( data );
-
- got_components = XkbRF_GetComponents( xkl_rules, &xkl_var_defs, component_names_ptr );
-
- g_free( xkl_var_defs.layout );
- g_free( xkl_var_defs.variant );
- g_free( xkl_var_defs.options );
-
- if( !got_components )
- {
- xkl_last_error_message = "Could not translate rules into components";
- /* Just cleanup the stuff in case of failure */
- xkl_xkb_config_native_cleanup( component_names_ptr );
-
- return FALSE;
- }
-
- if ( xkl_debug_level >= 200 )
- {
- xkl_debug( 200, "keymap: %s\n", component_names_ptr->keymap );
- xkl_debug( 200, "keycodes: %s\n", component_names_ptr->keycodes );
- xkl_debug( 200, "compat: %s\n", component_names_ptr->compat );
- xkl_debug( 200, "types: %s\n", component_names_ptr->types );
- xkl_debug( 200, "symbols: %s\n", component_names_ptr->symbols );
- xkl_debug( 200, "geometry: %s\n", component_names_ptr->geometry );
- }
- return TRUE;
+ XkbRF_VarDefsRec xkl_var_defs;
+ gboolean got_components;
+
+ memset(&xkl_var_defs, 0, sizeof(xkl_var_defs));
+
+ xkl_rules = xkl_rules_set_load();
+ if (!xkl_rules) {
+ return FALSE;
+ }
+
+ xkl_var_defs.model = (char *) data->model;
+
+ if (data->layouts != NULL)
+ xkl_var_defs.layout = xkl_config_rec_merge_layouts(data);
+
+ if (data->variants != NULL)
+ xkl_var_defs.variant = xkl_config_rec_merge_variants(data);
+
+ if (data->options != NULL)
+ xkl_var_defs.options = xkl_config_rec_merge_options(data);
+
+ got_components =
+ XkbRF_GetComponents(xkl_rules, &xkl_var_defs,
+ component_names_ptr);
+
+ g_free(xkl_var_defs.layout);
+ g_free(xkl_var_defs.variant);
+ g_free(xkl_var_defs.options);
+
+ if (!got_components) {
+ xkl_last_error_message =
+ "Could not translate rules into components";
+ /* Just cleanup the stuff in case of failure */
+ xkl_xkb_config_native_cleanup(component_names_ptr);
+
+ return FALSE;
+ }
+
+ if (xkl_debug_level >= 200) {
+ xkl_debug(200, "keymap: %s\n",
+ component_names_ptr->keymap);
+ xkl_debug(200, "keycodes: %s\n",
+ component_names_ptr->keycodes);
+ xkl_debug(200, "compat: %s\n",
+ component_names_ptr->compat);
+ xkl_debug(200, "types: %s\n", component_names_ptr->types);
+ xkl_debug(200, "symbols: %s\n",
+ component_names_ptr->symbols);
+ xkl_debug(200, "geometry: %s\n",
+ component_names_ptr->geometry);
+ }
+ return TRUE;
}
-void xkl_xkb_config_native_cleanup( XkbComponentNamesPtr component_names_ptr )
+void
+xkl_xkb_config_native_cleanup(XkbComponentNamesPtr component_names_ptr)
{
- xkl_rules_set_free();
-
- g_free(component_names_ptr->keymap);
- g_free(component_names_ptr->keycodes);
- g_free(component_names_ptr->compat);
- g_free(component_names_ptr->types);
- g_free(component_names_ptr->symbols);
- g_free(component_names_ptr->geometry);
+ xkl_rules_set_free();
+
+ g_free(component_names_ptr->keymap);
+ g_free(component_names_ptr->keycodes);
+ g_free(component_names_ptr->compat);
+ g_free(component_names_ptr->types);
+ g_free(component_names_ptr->symbols);
+ g_free(component_names_ptr->geometry);
}
-static XkbDescPtr xkl_config_get_keyboard( XkbComponentNamesPtr component_names_ptr,
- gboolean activate )
+static XkbDescPtr
+xkl_config_get_keyboard(XkbComponentNamesPtr component_names_ptr,
+ gboolean activate)
{
- XkbDescPtr xkb = NULL;
+ XkbDescPtr xkb = NULL;
#if 0
- xkb = XkbGetKeyboardByName( _xklDpy,
- XkbUseCoreKbd,
- &componentNames,
- XkbGBN_AllComponentsMask &
- ( ~XkbGBN_GeometryMask ),
- XkbGBN_AllComponentsMask &
- ( ~XkbGBN_GeometryMask ),
- activate );
+ xkb = XkbGetKeyboardByName(_xklDpy,
+ XkbUseCoreKbd,
+ &componentNames,
+ XkbGBN_AllComponentsMask &
+ (~XkbGBN_GeometryMask),
+ XkbGBN_AllComponentsMask &
+ (~XkbGBN_GeometryMask), activate);
#else
- char xkm_fn[L_tmpnam];
- char xkb_fn[L_tmpnam];
- FILE* tmpxkm;
- XkbFileInfo result;
- int xkmloadres;
-
- if ( tmpnam( xkm_fn ) != NULL &&
- tmpnam( xkb_fn ) != NULL )
- {
- pid_t cpid, pid;
- int status = 0;
- FILE *tmpxkb;
-
- xkl_debug( 150, "tmp XKB/XKM file names: [%s]/[%s]\n", xkb_fn, xkm_fn );
- if( (tmpxkb = fopen( xkb_fn, "w" )) != NULL )
- {
- fprintf( tmpxkb, "xkb_keymap {\n" );
- fprintf( tmpxkb, " xkb_keycodes { include \"%s\" };\n", component_names_ptr->keycodes );
- fprintf( tmpxkb, " xkb_types { include \"%s\" };\n", component_names_ptr->types );
- fprintf( tmpxkb, " xkb_compat { include \"%s\" };\n", component_names_ptr->compat );
- fprintf( tmpxkb, " xkb_symbols { include \"%s\" };\n", component_names_ptr->symbols );
- fprintf( tmpxkb, " xkb_geometry { include \"%s\" };\n", component_names_ptr->geometry );
- fprintf( tmpxkb, "};\n" );
- fclose( tmpxkb );
-
- xkl_debug( 150, "xkb_keymap {\n"
- " xkb_keycodes { include \"%s\" };\n"
- " xkb_types { include \"%s\" };\n"
- " xkb_compat { include \"%s\" };\n"
- " xkb_symbols { include \"%s\" };\n"
- " xkb_geometry { include \"%s\" };\n};\n",
- component_names_ptr->keycodes,
- component_names_ptr->types,
- component_names_ptr->compat,
- component_names_ptr->symbols,
- component_names_ptr->geometry );
-
- cpid=fork();
- switch( cpid )
- {
- case -1:
- xkl_debug( 0, "Could not fork: %d\n", errno );
- break;
- case 0:
- /* child */
- xkl_debug( 160, "Executing %s\n", XKBCOMP );
- xkl_debug( 160, "%s %s %s %s %s %s %s\n",
- XKBCOMP, XKBCOMP, "-I", "-I" XKB_BASE, "-xkm", xkb_fn, xkm_fn );
- execl( XKBCOMP, XKBCOMP, "-I", "-I" XKB_BASE, "-xkm", xkb_fn, xkm_fn, NULL );
- xkl_debug( 0, "Could not exec %s: %d\n", XKBCOMP, errno );
- exit( 1 );
- default:
- /* parent */
- pid = waitpid( cpid, &status, 0 );
- xkl_debug( 150, "Return status of %d (well, started %d): %d\n", pid, cpid, status );
- memset( (char *)&result, 0, sizeof(result) );
- result.xkb = XkbAllocKeyboard();
-
- if( Success == XkbChangeKbdDisplay( xkl_display, &result ) )
- {
- xkl_debug( 150, "Hacked the kbddesc - set the display...\n" );
- if( (tmpxkm = fopen( xkm_fn, "r" )) != NULL )
- {
- xkmloadres = XkmReadFile( tmpxkm, XkmKeymapLegal, XkmKeymapLegal, &result);
- xkl_debug( 150, "Loaded %s output as XKM file, got %d (comparing to %d)\n",
- XKBCOMP, (int)xkmloadres, (int)XkmKeymapLegal );
- if ( (int)xkmloadres != (int)XkmKeymapLegal )
- {
- xkl_debug( 150, "Loaded legal keymap\n" );
- if( activate )
- {
- xkl_debug( 150, "Activating it...\n" );
- if( XkbWriteToServer(&result) )
- {
- xkl_debug( 150, "Updating the keyboard...\n" );
- xkb = result.xkb;
- } else
- {
- xkl_debug( 0, "Could not write keyboard description to the server\n" );
- }
- } else /* no activate, just load */
- xkb = result.xkb;
- } else /* could not load properly */
- {
- xkl_debug( 0, "Could not load %s output as XKM file, got %d (asked %d)\n",
- XKBCOMP, (int)xkmloadres, (int)XkmKeymapLegal );
- }
- fclose( tmpxkm );
- xkl_debug( 160, "Unlinking the temporary xkm file %s\n", xkm_fn );
- if ( xkl_debug_level < 500 ) /* don't remove on high debug levels! */
- {
- if ( remove( xkm_fn ) == -1 )
- xkl_debug( 0, "Could not unlink the temporary xkm file %s: %d\n",
- xkm_fn, errno );
- } else
- xkl_debug( 500, "Well, not really - the debug level is too high: %d\n", xkl_debug_level );
- } else /* could not open the file */
- {
- xkl_debug( 0, "Could not open the temporary xkm file %s\n", xkm_fn );
- }
- } else /* could not assign to display */
- {
- xkl_debug( 0, "Could not change the keyboard description to display\n" );
- }
- if ( xkb == NULL )
- XkbFreeKeyboard( result.xkb, XkbAllComponentsMask, True );
- break;
- }
- xkl_debug( 160, "Unlinking the temporary xkb file %s\n", xkb_fn );
- if ( xkl_debug_level < 500 ) /* don't remove on high debug levels! */
- {
- if ( remove( xkb_fn ) == -1 )
- xkl_debug( 0, "Could not unlink the temporary xkb file %s: %d\n",
- xkb_fn, errno );
- } else
- xkl_debug( 500, "Well, not really - the debug level is too high: %d\n", xkl_debug_level );
- } else /* could not open input tmp file */
- {
- xkl_debug( 0, "Could not open tmp XKB file [%s]: %d\n", xkb_fn, errno );
- }
- } else
- {
- xkl_debug( 0, "Could not get tmp names\n" );
- }
+ char xkm_fn[L_tmpnam];
+ char xkb_fn[L_tmpnam];
+ FILE *tmpxkm;
+ XkbFileInfo result;
+ int xkmloadres;
+
+ if (tmpnam(xkm_fn) != NULL && tmpnam(xkb_fn) != NULL) {
+ pid_t cpid, pid;
+ int status = 0;
+ FILE *tmpxkb;
+
+ xkl_debug(150, "tmp XKB/XKM file names: [%s]/[%s]\n",
+ xkb_fn, xkm_fn);
+ if ((tmpxkb = fopen(xkb_fn, "w")) != NULL) {
+ fprintf(tmpxkb, "xkb_keymap {\n");
+ fprintf(tmpxkb,
+ " xkb_keycodes { include \"%s\" };\n",
+ component_names_ptr->keycodes);
+ fprintf(tmpxkb,
+ " xkb_types { include \"%s\" };\n",
+ component_names_ptr->types);
+ fprintf(tmpxkb,
+ " xkb_compat { include \"%s\" };\n",
+ component_names_ptr->compat);
+ fprintf(tmpxkb,
+ " xkb_symbols { include \"%s\" };\n",
+ component_names_ptr->symbols);
+ fprintf(tmpxkb,
+ " xkb_geometry { include \"%s\" };\n",
+ component_names_ptr->geometry);
+ fprintf(tmpxkb, "};\n");
+ fclose(tmpxkb);
+
+ xkl_debug(150, "xkb_keymap {\n"
+ " xkb_keycodes { include \"%s\" };\n"
+ " xkb_types { include \"%s\" };\n"
+ " xkb_compat { include \"%s\" };\n"
+ " xkb_symbols { include \"%s\" };\n"
+ " xkb_geometry { include \"%s\" };\n};\n",
+ component_names_ptr->keycodes,
+ component_names_ptr->types,
+ component_names_ptr->compat,
+ component_names_ptr->symbols,
+ component_names_ptr->geometry);
+
+ cpid = fork();
+ switch (cpid) {
+ case -1:
+ xkl_debug(0, "Could not fork: %d\n",
+ errno);
+ break;
+ case 0:
+ /* child */
+ xkl_debug(160, "Executing %s\n", XKBCOMP);
+ xkl_debug(160, "%s %s %s %s %s %s %s\n",
+ XKBCOMP, XKBCOMP, "-I",
+ "-I" XKB_BASE, "-xkm", xkb_fn,
+ xkm_fn);
+ execl(XKBCOMP, XKBCOMP, "-I",
+ "-I" XKB_BASE, "-xkm", xkb_fn,
+ xkm_fn, NULL);
+ xkl_debug(0, "Could not exec %s: %d\n",
+ XKBCOMP, errno);
+ exit(1);
+ default:
+ /* parent */
+ pid = waitpid(cpid, &status, 0);
+ xkl_debug(150,
+ "Return status of %d (well, started %d): %d\n",
+ pid, cpid, status);
+ memset((char *) &result, 0,
+ sizeof(result));
+ result.xkb = XkbAllocKeyboard();
+
+ if (Success ==
+ XkbChangeKbdDisplay(xkl_display,
+ &result)) {
+ xkl_debug(150,
+ "Hacked the kbddesc - set the display...\n");
+ if ((tmpxkm =
+ fopen(xkm_fn, "r")) != NULL) {
+ xkmloadres =
+ XkmReadFile(tmpxkm,
+ XkmKeymapLegal,
+ XkmKeymapLegal,
+ &result);
+ xkl_debug(150,
+ "Loaded %s output as XKM file, got %d (comparing to %d)\n",
+ XKBCOMP,
+ (int) xkmloadres,
+ (int)
+ XkmKeymapLegal);
+ if ((int) xkmloadres !=
+ (int) XkmKeymapLegal) {
+ xkl_debug(150,
+ "Loaded legal keymap\n");
+ if (activate) {
+ xkl_debug
+ (150,
+ "Activating it...\n");
+ if (XkbWriteToServer(&result)) {
+ xkl_debug
+ (150,
+ "Updating the keyboard...\n");
+ xkb = result.xkb;
+ } else {
+ xkl_debug
+ (0,
+ "Could not write keyboard description to the server\n");
+ }
+ } else /* no activate, just load */
+ xkb =
+ result.
+ xkb;
+ } else { /* could not load properly */
+
+ xkl_debug(0,
+ "Could not load %s output as XKM file, got %d (asked %d)\n",
+ XKBCOMP,
+ (int)
+ xkmloadres,
+ (int)
+ XkmKeymapLegal);
+ }
+ fclose(tmpxkm);
+ xkl_debug(160,
+ "Unlinking the temporary xkm file %s\n",
+ xkm_fn);
+ if (xkl_debug_level < 500) { /* don't remove on high debug levels! */
+ if (remove(xkm_fn)
+ == -1)
+ xkl_debug
+ (0,
+ "Could not unlink the temporary xkm file %s: %d\n",
+ xkm_fn,
+ errno);
+ } else
+ xkl_debug(500,
+ "Well, not really - the debug level is too high: %d\n",
+ xkl_debug_level);
+ } else { /* could not open the file */
+
+ xkl_debug(0,
+ "Could not open the temporary xkm file %s\n",
+ xkm_fn);
+ }
+ } else { /* could not assign to display */
+
+ xkl_debug(0,
+ "Could not change the keyboard description to display\n");
+ }
+ if (xkb == NULL)
+ XkbFreeKeyboard(result.xkb,
+ XkbAllComponentsMask,
+ True);
+ break;
+ }
+ xkl_debug(160,
+ "Unlinking the temporary xkb file %s\n",
+ xkb_fn);
+ if (xkl_debug_level < 500) { /* don't remove on high debug levels! */
+ if (remove(xkb_fn) == -1)
+ xkl_debug(0,
+ "Could not unlink the temporary xkb file %s: %d\n",
+ xkb_fn, errno);
+ } else
+ xkl_debug(500,
+ "Well, not really - the debug level is too high: %d\n",
+ xkl_debug_level);
+ } else { /* could not open input tmp file */
+
+ xkl_debug(0,
+ "Could not open tmp XKB file [%s]: %d\n",
+ xkb_fn, errno);
+ }
+ } else {
+ xkl_debug(0, "Could not get tmp names\n");
+ }
#endif
- return xkb;
+ return xkb;
}
-#else /* no XKB headers */
-gboolean xkl_xkb_config_native_prepare( const XklConfigRec * data,
- gpointer componentNamesPtr )
+#else /* no XKB headers */
+gboolean
+xkl_xkb_config_native_prepare(const XklConfigRec * data,
+ gpointer componentNamesPtr)
{
- return FALSE;
+ return FALSE;
}
-void _XklXkbConfigCleanupNative( gpointer componentNamesPtr )
+void
+_XklXkbConfigCleanupNative(gpointer componentNamesPtr)
{
}
#endif
/* check only client side support */
-gboolean xkl_xkb_config_multiple_layouts_supported( void )
+gboolean
+xkl_xkb_config_multiple_layouts_supported(void)
{
- enum { NON_SUPPORTED, SUPPORTED, UNCHECKED };
+ enum { NON_SUPPORTED, SUPPORTED, UNCHECKED };
- static int support_state = UNCHECKED;
+ static int support_state = UNCHECKED;
- if( support_state == UNCHECKED )
- {
- XklConfigRec data;
- char *layouts[] = { "us", "de", NULL };
- char *variants[] = { NULL, NULL, NULL };
+ if (support_state == UNCHECKED) {
+ XklConfigRec data;
+ char *layouts[] = { "us", "de", NULL };
+ char *variants[] = { NULL, NULL, NULL };
#ifdef XKB_HEADERS_PRESENT
- XkbComponentNamesRec component_names;
- memset( &component_names, 0, sizeof( component_names ) );
+ XkbComponentNamesRec component_names;
+ memset(&component_names, 0, sizeof(component_names));
#endif
- data.model = "pc105";
- data.layouts = layouts;
- data.variants = variants;
- data.options = NULL;
+ data.model = "pc105";
+ data.layouts = layouts;
+ data.variants = variants;
+ data.options = NULL;
- xkl_debug( 100, "!!! Checking multiple layouts support\n" );
- support_state = NON_SUPPORTED;
+ xkl_debug(100, "!!! Checking multiple layouts support\n");
+ support_state = NON_SUPPORTED;
#ifdef XKB_HEADERS_PRESENT
- if( xkl_xkb_config_native_prepare( &data, &component_names ) )
- {
- xkl_debug( 100, "!!! Multiple layouts ARE supported\n" );
- support_state = SUPPORTED;
- xkl_xkb_config_native_cleanup( &component_names );
- } else
- {
- xkl_debug( 100, "!!! Multiple layouts ARE NOT supported\n" );
- }
+ if (xkl_xkb_config_native_prepare(&data, &component_names)) {
+ xkl_debug(100,
+ "!!! Multiple layouts ARE supported\n");
+ support_state = SUPPORTED;
+ xkl_xkb_config_native_cleanup(&component_names);
+ } else {
+ xkl_debug(100,
+ "!!! Multiple layouts ARE NOT supported\n");
+ }
#endif
- }
- return support_state == SUPPORTED;
+ }
+ return support_state == SUPPORTED;
}
-gboolean xkl_xkb_config_activate( const XklConfigRec * data )
+gboolean
+xkl_xkb_config_activate(const XklConfigRec * data)
{
- gboolean rv = FALSE;
+ gboolean rv = FALSE;
#if 0
- {
- int i;
- XklDebug( 150, "New model: [%s]\n", data->model );
- XklDebug( 150, "New layouts: %p\n", data->layouts );
- for( i = data->numLayouts; --i >= 0; )
- XklDebug( 150, "New layout[%d]: [%s]\n", i, data->layouts[i] );
- XklDebug( 150, "New variants: %p\n", data->variants );
- for( i = data->numVariants; --i >= 0; )
- XklDebug( 150, "New variant[%d]: [%s]\n", i, data->variants[i] );
- XklDebug( 150, "New options: %p\n", data->options );
- for( i = data->numOptions; --i >= 0; )
- XklDebug( 150, "New option[%d]: [%s]\n", i, data->options[i] );
- }
+ {
+ int i;
+ XklDebug(150, "New model: [%s]\n", data->model);
+ XklDebug(150, "New layouts: %p\n", data->layouts);
+ for (i = data->numLayouts; --i >= 0;)
+ XklDebug(150, "New layout[%d]: [%s]\n", i,
+ data->layouts[i]);
+ XklDebug(150, "New variants: %p\n", data->variants);
+ for (i = data->numVariants; --i >= 0;)
+ XklDebug(150, "New variant[%d]: [%s]\n", i,
+ data->variants[i]);
+ XklDebug(150, "New options: %p\n", data->options);
+ for (i = data->numOptions; --i >= 0;)
+ XklDebug(150, "New option[%d]: [%s]\n", i,
+ data->options[i]);
+ }
#endif
#ifdef XKB_HEADERS_PRESENT
- XkbComponentNamesRec component_names;
- memset( &component_names, 0, sizeof( component_names ) );
-
- if( xkl_xkb_config_native_prepare( data, &component_names ) )
- {
- XkbDescPtr xkb;
- xkb = xkl_config_get_keyboard( &component_names, TRUE );
- if( xkb != NULL )
- {
- if( xkl_set_names_prop
- ( xkl_vtable->base_config_atom, xkl_rules_set_get_name( XKB_DEFAULT_RULESET ), data ) )
- /* We do not need to check the result of _XklGetRulesSetName -
- because PrepareBeforeKbd did it for us */
- rv = TRUE;
- else
- xkl_last_error_message = "Could not set names property";
- XkbFreeKeyboard( xkb, XkbAllComponentsMask, True );
- } else
- {
- xkl_last_error_message = "Could not load keyboard description";
- }
- xkl_xkb_config_native_cleanup( &component_names );
- }
+ XkbComponentNamesRec component_names;
+ memset(&component_names, 0, sizeof(component_names));
+
+ if (xkl_xkb_config_native_prepare(data, &component_names)) {
+ XkbDescPtr xkb;
+ xkb = xkl_config_get_keyboard(&component_names, TRUE);
+ if (xkb != NULL) {
+ if (xkl_set_names_prop
+ (xkl_vtable->base_config_atom,
+ xkl_rules_set_get_name(XKB_DEFAULT_RULESET),
+ data))
+ /* We do not need to check the result of _XklGetRulesSetName -
+ because PrepareBeforeKbd did it for us */
+ rv = TRUE;
+ else
+ xkl_last_error_message =
+ "Could not set names property";
+ XkbFreeKeyboard(xkb, XkbAllComponentsMask, True);
+ } else {
+ xkl_last_error_message =
+ "Could not load keyboard description";
+ }
+ xkl_xkb_config_native_cleanup(&component_names);
+ }
#endif
- return rv;
+ return rv;
}
-gboolean xkl_xkb_config_write_file( const char *file_name,
- const XklConfigRec *data,
- const gboolean binary )
+gboolean
+xkl_xkb_config_write_file(const char *file_name,
+ const XklConfigRec * data, const gboolean binary)
{
- gboolean rv = FALSE;
+ gboolean rv = FALSE;
#ifdef XKB_HEADERS_PRESENT
- XkbComponentNamesRec component_names;
- FILE *output = fopen( file_name, "w" );
- XkbFileInfo dump_info;
-
- if( output == NULL )
- {
- xkl_last_error_message = "Could not open the XKB file";
- return FALSE;
- }
-
- memset( &component_names, 0, sizeof( component_names ) );
-
- if( xkl_xkb_config_native_prepare( data, &component_names ) )
- {
- XkbDescPtr xkb;
- xkb = xkl_config_get_keyboard( &component_names, FALSE );
- if( xkb != NULL )
- {
- dump_info.defined = 0;
- dump_info.xkb = xkb;
- dump_info.type = XkmKeymapFile;
- if( binary )
- rv = XkbWriteXKMFile( output, &dump_info );
- else
- rv = XkbWriteXKBFile( output, &dump_info, True, NULL, NULL );
-
- XkbFreeKeyboard( xkb, XkbGBN_AllComponentsMask, True );
- } else
- xkl_last_error_message = "Could not load keyboard description";
- xkl_xkb_config_native_cleanup( &component_names );
- }
- fclose( output );
+ XkbComponentNamesRec component_names;
+ FILE *output = fopen(file_name, "w");
+ XkbFileInfo dump_info;
+
+ if (output == NULL) {
+ xkl_last_error_message = "Could not open the XKB file";
+ return FALSE;
+ }
+
+ memset(&component_names, 0, sizeof(component_names));
+
+ if (xkl_xkb_config_native_prepare(data, &component_names)) {
+ XkbDescPtr xkb;
+ xkb = xkl_config_get_keyboard(&component_names, FALSE);
+ if (xkb != NULL) {
+ dump_info.defined = 0;
+ dump_info.xkb = xkb;
+ dump_info.type = XkmKeymapFile;
+ if (binary)
+ rv = XkbWriteXKMFile(output, &dump_info);
+ else
+ rv = XkbWriteXKBFile(output, &dump_info,
+ True, NULL, NULL);
+
+ XkbFreeKeyboard(xkb, XkbGBN_AllComponentsMask,
+ True);
+ } else
+ xkl_last_error_message =
+ "Could not load keyboard description";
+ xkl_xkb_config_native_cleanup(&component_names);
+ }
+ fclose(output);
#endif
- return rv;
+ return rv;
}
diff --git a/libxklavier/xklavier_config_xmm.c b/libxklavier/xklavier_config_xmm.c
index 900fd29..1fa618b 100644
--- a/libxklavier/xklavier_config_xmm.c
+++ b/libxklavier/xklavier_config_xmm.c
@@ -19,37 +19,39 @@
#define XK_XKB_KEYS
#include <X11/keysymdef.h>
-void xkl_xmm_config_init( void )
+void
+xkl_xmm_config_init(void)
{
}
-gboolean xkl_xmm_config_registry_load( void )
+gboolean
+xkl_xmm_config_registry_load(void)
{
- struct stat stat_buf;
- gchar file_name[MAXPATHLEN] = "";
- gchar* rf = xkl_rules_set_get_name( "" );
+ struct stat stat_buf;
+ gchar file_name[MAXPATHLEN] = "";
+ gchar *rf = xkl_rules_set_get_name("");
- if ( rf == NULL || rf[0] == '\0' )
- return FALSE;
+ if (rf == NULL || rf[0] == '\0')
+ return FALSE;
- g_snprintf( file_name, sizeof file_name, XMODMAP_BASE "/%s.xml", rf );
+ g_snprintf(file_name, sizeof file_name, XMODMAP_BASE "/%s.xml",
+ rf);
- if( stat( file_name, &stat_buf ) != 0 )
- {
- xkl_last_error_message = "No rules file found";
- return FALSE;
- }
+ if (stat(file_name, &stat_buf) != 0) {
+ xkl_last_error_message = "No rules file found";
+ return FALSE;
+ }
- return xkl_config_registry_load_from_file( file_name );
+ return xkl_config_registry_load_from_file(file_name);
}
-gboolean xkl_xmm_config_activate( const XklConfigRec *data )
+gboolean
+xkl_xmm_config_activate(const XklConfigRec * data)
{
- gboolean rv;
- rv = xkl_set_names_prop( xkl_vtable->base_config_atom,
- current_xmm_rules,
- data );
- if( rv )
- xkl_xmm_group_lock( 0 );
- return rv;
+ gboolean rv;
+ rv = xkl_set_names_prop(xkl_vtable->base_config_atom,
+ current_xmm_rules, data);
+ if (rv)
+ xkl_xmm_group_lock(0);
+ return rv;
}
diff --git a/libxklavier/xklavier_dump.c b/libxklavier/xklavier_dump.c
index 9e97f0c..a62711c 100644
--- a/libxklavier/xklavier_dump.c
+++ b/libxklavier/xklavier_dump.c
@@ -21,261 +21,256 @@
#ifdef XKB_HEADERS_PRESENT
#if 0
-static void _XkbModsRecDump( FILE * fs, XkbModsRec * mods )
+static void
+_XkbModsRecDump(FILE * fs, XkbModsRec * mods)
{
- fprintf( fs, "flags: 0x%X\n", mods->mask );
- fprintf( fs, "real_mods: 0x%X\n", mods->real_mods );
- fprintf( fs, "vmods: 0x%X\n", mods->vmods );
+ fprintf(fs, "flags: 0x%X\n", mods->mask);
+ fprintf(fs, "real_mods: 0x%X\n", mods->real_mods);
+ fprintf(fs, "vmods: 0x%X\n", mods->vmods);
}
-static void _XkbControlsDump( FILE * fs, XkbControlsPtr ctrls )
+static void
+_XkbControlsDump(FILE * fs, XkbControlsPtr ctrls)
{
- gint i;
- gchar buf[1024];
- fprintf( fs, "mk_dflt_btn: %d\n", ctrls->mk_dflt_btn );
- fprintf( fs, "num_groups: %d\n", ctrls->num_groups );
- fprintf( fs, "groups_wrap: %d\n", ctrls->groups_wrap );
- fprintf( fs, "internal: \n" );
- _XkbModsRecDump( fs, &ctrls->internal );
- fprintf( fs, "ignore_lock: \n" );
- _XkbModsRecDump( fs, &ctrls->ignore_lock );
- fprintf( fs, "enabled_ctrls: 0x%X\n", ctrls->enabled_ctrls );
- fprintf( fs, "repeat_delay: %d\n", ctrls->repeat_delay );
- fprintf( fs, "repeat_interval: %d\n", ctrls->repeat_interval );
- fprintf( fs, "slow_keys_delay: %d\n", ctrls->slow_keys_delay );
- fprintf( fs, "debounce_delay: %d\n", ctrls->debounce_delay );
- fprintf( fs, "mk_delay: %d\n", ctrls->mk_delay );
- fprintf( fs, "mk_interval: %d\n", ctrls->mk_interval );
- fprintf( fs, "mk_time_to_max: %d\n", ctrls->mk_time_to_max );
- fprintf( fs, "mk_max_speed: %d\n", ctrls->mk_max_speed );
- fprintf( fs, "mk_curve: %d\n", ctrls->mk_curve );
- fprintf( fs, "ax_options: %d\n", ctrls->ax_options );
- fprintf( fs, "ax_timeout: %d\n", ctrls->ax_timeout );
- fprintf( fs, "axt_opts_mask: 0x%X\n", ctrls->axt_opts_mask );
- fprintf( fs, "axt_opts_values: 0x%X\n", ctrls->axt_opts_values );
- fprintf( fs, "axt_ctrls_mask: 0x%X\n", ctrls->axt_ctrls_mask );
- fprintf( fs, "axt_ctrls_values: 0x%X\n", ctrls->axt_ctrls_values );
- fprintf( fs, "axt_ctrls_values: 0x%X\n", ctrls->axt_ctrls_values );
- fprintf( fs, "per_key_repeat:\n" );
- buf[0] = 0;
- for( i = 0; i < XkbPerKeyBitArraySize; i++ )
- {
- gchar b[5];
- snprintf( b, sizeof( b ), "%d ", ctrls->per_key_repeat[i] );
- strcat( buf, b );
- }
- fprintf( fs, " %s\n", buf );
+ gint i;
+ gchar buf[1024];
+ fprintf(fs, "mk_dflt_btn: %d\n", ctrls->mk_dflt_btn);
+ fprintf(fs, "num_groups: %d\n", ctrls->num_groups);
+ fprintf(fs, "groups_wrap: %d\n", ctrls->groups_wrap);
+ fprintf(fs, "internal: \n");
+ _XkbModsRecDump(fs, &ctrls->internal);
+ fprintf(fs, "ignore_lock: \n");
+ _XkbModsRecDump(fs, &ctrls->ignore_lock);
+ fprintf(fs, "enabled_ctrls: 0x%X\n", ctrls->enabled_ctrls);
+ fprintf(fs, "repeat_delay: %d\n", ctrls->repeat_delay);
+ fprintf(fs, "repeat_interval: %d\n", ctrls->repeat_interval);
+ fprintf(fs, "slow_keys_delay: %d\n", ctrls->slow_keys_delay);
+ fprintf(fs, "debounce_delay: %d\n", ctrls->debounce_delay);
+ fprintf(fs, "mk_delay: %d\n", ctrls->mk_delay);
+ fprintf(fs, "mk_interval: %d\n", ctrls->mk_interval);
+ fprintf(fs, "mk_time_to_max: %d\n", ctrls->mk_time_to_max);
+ fprintf(fs, "mk_max_speed: %d\n", ctrls->mk_max_speed);
+ fprintf(fs, "mk_curve: %d\n", ctrls->mk_curve);
+ fprintf(fs, "ax_options: %d\n", ctrls->ax_options);
+ fprintf(fs, "ax_timeout: %d\n", ctrls->ax_timeout);
+ fprintf(fs, "axt_opts_mask: 0x%X\n", ctrls->axt_opts_mask);
+ fprintf(fs, "axt_opts_values: 0x%X\n", ctrls->axt_opts_values);
+ fprintf(fs, "axt_ctrls_mask: 0x%X\n", ctrls->axt_ctrls_mask);
+ fprintf(fs, "axt_ctrls_values: 0x%X\n", ctrls->axt_ctrls_values);
+ fprintf(fs, "axt_ctrls_values: 0x%X\n", ctrls->axt_ctrls_values);
+ fprintf(fs, "per_key_repeat:\n");
+ buf[0] = 0;
+ for (i = 0; i < XkbPerKeyBitArraySize; i++) {
+ gchar b[5];
+ snprintf(b, sizeof(b), "%d ", ctrls->per_key_repeat[i]);
+ strcat(buf, b);
+ }
+ fprintf(fs, " %s\n", buf);
}
#endif
static const gchar *action_type_names[] = {
- "XkbSA_NoAction",
- "XkbSA_SetMods",
- "XkbSA_LatchMods",
- "XkbSA_LockMods",
- "XkbSA_SetGroup",
- "XkbSA_LatchGroup",
- "XkbSA_LockGroup",
- "XkbSA_MovePtr",
- "XkbSA_PtrBtn",
- "XkbSA_LockPtrBtn",
- "XkbSA_SetPtrDflt",
- "XkbSA_ISOLock",
- "XkbSA_Terminate",
- "XkbSA_SwitchScreen",
- "XkbSA_SetControls",
- "XkbSA_LockControls",
- "XkbSA_ActionMessage",
- "XkbSA_RedirectKey",
- "XkbSA_DeviceBtn",
- "XkbSA_LockDeviceBtn",
- "XkbSA_DeviceValuator"
+ "XkbSA_NoAction",
+ "XkbSA_SetMods",
+ "XkbSA_LatchMods",
+ "XkbSA_LockMods",
+ "XkbSA_SetGroup",
+ "XkbSA_LatchGroup",
+ "XkbSA_LockGroup",
+ "XkbSA_MovePtr",
+ "XkbSA_PtrBtn",
+ "XkbSA_LockPtrBtn",
+ "XkbSA_SetPtrDflt",
+ "XkbSA_ISOLock",
+ "XkbSA_Terminate",
+ "XkbSA_SwitchScreen",
+ "XkbSA_SetControls",
+ "XkbSA_LockControls",
+ "XkbSA_ActionMessage",
+ "XkbSA_RedirectKey",
+ "XkbSA_DeviceBtn",
+ "XkbSA_LockDeviceBtn",
+ "XkbSA_DeviceValuator"
};
-static void xkb_action_dump( FILE * fs, gint level, XkbAction * act )
+static void
+xkb_action_dump(FILE * fs, gint level, XkbAction * act)
{
- XkbGroupAction *ga;
- fprintf( fs, "%*stype: %d(%s)\n", level, "", act->type,
- action_type_names[act->type] );
- switch ( act->type )
- {
- case XkbSA_SetGroup:
- case XkbSA_LatchGroup:
- case XkbSA_LockGroup:
- ga = ( XkbGroupAction * ) act;
- fprintf( fs, "%*sXkbGroupAction: \n", level, "" );
- fprintf( fs, "%*sflags: %d\n", level, "", ga->flags );
- fprintf( fs, "%*sgroup_XXX: %d\n", level, "", ga->group_XXX );
- break;
- }
+ XkbGroupAction *ga;
+ fprintf(fs, "%*stype: %d(%s)\n", level, "", act->type,
+ action_type_names[act->type]);
+ switch (act->type) {
+ case XkbSA_SetGroup:
+ case XkbSA_LatchGroup:
+ case XkbSA_LockGroup:
+ ga = (XkbGroupAction *) act;
+ fprintf(fs, "%*sXkbGroupAction: \n", level, "");
+ fprintf(fs, "%*sflags: %d\n", level, "", ga->flags);
+ fprintf(fs, "%*sgroup_XXX: %d\n", level, "",
+ ga->group_XXX);
+ break;
+ }
}
-static void xkb_behavior_dump( FILE * fs, gint level, XkbBehavior * b )
+static void
+xkb_behavior_dump(FILE * fs, gint level, XkbBehavior * b)
{
- fprintf( fs, "%*stype: %d\n", level, "", b->type );
- fprintf( fs, "%*sdata: %d\n", level, "", b->data );
+ fprintf(fs, "%*stype: %d\n", level, "", b->type);
+ fprintf(fs, "%*sdata: %d\n", level, "", b->data);
}
-static void xkb_server_map_dump( FILE * fs, gint level, XkbServerMapPtr server,
- XkbDescPtr kbd )
+static void
+xkb_server_map_dump(FILE * fs, gint level, XkbServerMapPtr server,
+ XkbDescPtr kbd)
{
- gint i;
- XkbAction *pa = server->acts;
- XkbBehavior *pb = server->behaviors;
- fprintf( fs, "%*snum_acts: %d\n", level, "", server->num_acts );
- fprintf( fs, "%*ssize_acts: %d\n", level, "", server->size_acts );
- if( server->acts != NULL )
- {
- for( i = 0; i < server->num_acts; i++ )
- {
- fprintf( fs, "%*sacts[%d]:\n", level, "", i );
- xkb_action_dump( fs, level + 2, pa++ );
- }
- } else
- fprintf( fs, "%*sNO acts\n", level, "" );
+ gint i;
+ XkbAction *pa = server->acts;
+ XkbBehavior *pb = server->behaviors;
+ fprintf(fs, "%*snum_acts: %d\n", level, "", server->num_acts);
+ fprintf(fs, "%*ssize_acts: %d\n", level, "", server->size_acts);
+ if (server->acts != NULL) {
+ for (i = 0; i < server->num_acts; i++) {
+ fprintf(fs, "%*sacts[%d]:\n", level, "", i);
+ xkb_action_dump(fs, level + 2, pa++);
+ }
+ } else
+ fprintf(fs, "%*sNO acts\n", level, "");
- if( server->key_acts != NULL )
- {
- for( i = 0; i <= kbd->max_key_code; i++ )
- {
- fprintf( fs, "%*skey_acts[%d]: offset %d, total %d\n", level, "", i,
- server->key_acts[i], XkbKeyNumSyms(kbd,i) );
- }
- } else
- fprintf( fs, "%*sNO key_acts\n", level, "" );
+ if (server->key_acts != NULL) {
+ for (i = 0; i <= kbd->max_key_code; i++) {
+ fprintf(fs,
+ "%*skey_acts[%d]: offset %d, total %d\n",
+ level, "", i, server->key_acts[i],
+ XkbKeyNumSyms(kbd, i));
+ }
+ } else
+ fprintf(fs, "%*sNO key_acts\n", level, "");
- for( i = 0; i < XkbNumVirtualMods; i++ )
- {
- fprintf( fs, "%*svmod[%d]: %X\n", level, "", i, server->vmods[i] );
- }
+ for (i = 0; i < XkbNumVirtualMods; i++) {
+ fprintf(fs, "%*svmod[%d]: %X\n", level, "", i,
+ server->vmods[i]);
+ }
- if( server->behaviors != NULL )
- {
- for( i = 0; i <= kbd->max_key_code; i++ )
- {
- fprintf( fs, "%*sbehaviors[%d]:\n", level, "", i );
- xkb_behavior_dump( fs, level + 2, pb++ );
- }
- } else
- fprintf( fs, "%*sNO behaviors\n", level, "" );
+ if (server->behaviors != NULL) {
+ for (i = 0; i <= kbd->max_key_code; i++) {
+ fprintf(fs, "%*sbehaviors[%d]:\n", level, "", i);
+ xkb_behavior_dump(fs, level + 2, pb++);
+ }
+ } else
+ fprintf(fs, "%*sNO behaviors\n", level, "");
- if( server->explicit != NULL )
- {
- for( i = 0; i <= kbd->max_key_code; i++ )
- {
- fprintf( fs, "%*sexplicit[%d]: %d\n", level, "", i,
- server->explicit[i] );
- }
- } else
- fprintf( fs, "%*sNO explicit\n", level, "" );
+ if (server->explicit != NULL) {
+ for (i = 0; i <= kbd->max_key_code; i++) {
+ fprintf(fs, "%*sexplicit[%d]: %d\n", level, "", i,
+ server->explicit[i]);
+ }
+ } else
+ fprintf(fs, "%*sNO explicit\n", level, "");
- if( server->vmodmap != NULL )
- {
- for( i = 0; i <= kbd->max_key_code; i++ )
- {
- fprintf( fs, "%*svmodmap[%d]: %d\n", level, "", i, server->vmodmap[i] );
- }
- } else
- fprintf( fs, "%*sNO vmodmap\n", level, "" );
+ if (server->vmodmap != NULL) {
+ for (i = 0; i <= kbd->max_key_code; i++) {
+ fprintf(fs, "%*svmodmap[%d]: %d\n", level, "", i,
+ server->vmodmap[i]);
+ }
+ } else
+ fprintf(fs, "%*sNO vmodmap\n", level, "");
}
-static void xkb_key_type_dump( FILE * fs, gint level, XkbKeyTypePtr type )
+static void
+xkb_key_type_dump(FILE * fs, gint level, XkbKeyTypePtr type)
{
- gchar *z = type->name == None ? NULL : XGetAtomName( xkl_display, type->name );
- fprintf( fs, "%*sname: 0x%X(%s)\n", level, "", (gint)type->name, z );
- if( z != NULL )
- XFree( z );
+ gchar *z = type->name == None ? NULL : XGetAtomName(xkl_display,
+ type->name);
+ fprintf(fs, "%*sname: 0x%X(%s)\n", level, "", (gint) type->name,
+ z);
+ if (z != NULL)
+ XFree(z);
}
-static void xkb_sym_map_dump( FILE * fs, gint level, XkbSymMapPtr ksm )
+static void
+xkb_sym_map_dump(FILE * fs, gint level, XkbSymMapPtr ksm)
{
- gint i;
- fprintf( fs, "%*skt_index: ", level, "" );
- for( i = 0; i < XkbNumKbdGroups; i++ )
- {
- fprintf( fs, "%d ", ksm->kt_index[i] );
- }
- fprintf( fs, "\n%*sgroup_info: %d\n", level, "", ksm->group_info );
- fprintf( fs, "%*swidth: %d\n", level, "", ksm->width );
- fprintf( fs, "%*soffset: %d\n", level, "", ksm->offset );
+ gint i;
+ fprintf(fs, "%*skt_index: ", level, "");
+ for (i = 0; i < XkbNumKbdGroups; i++) {
+ fprintf(fs, "%d ", ksm->kt_index[i]);
+ }
+ fprintf(fs, "\n%*sgroup_info: %d\n", level, "", ksm->group_info);
+ fprintf(fs, "%*swidth: %d\n", level, "", ksm->width);
+ fprintf(fs, "%*soffset: %d\n", level, "", ksm->offset);
}
-static void xkb_client_map_dump( FILE * fs, gint level, XkbClientMapPtr map,
- XkbDescPtr kbd )
+static void
+xkb_client_map_dump(FILE * fs, gint level, XkbClientMapPtr map,
+ XkbDescPtr kbd)
{
- gint i;
- fprintf( fs, "%*ssize_types: %d\n", level, "", map->size_types );
- fprintf( fs, "%*snum_types: %d\n", level, "", map->num_types );
- if( map->types != NULL )
- {
- XkbKeyTypePtr type = map->types;
- for( i = 0; i < map->num_types; i++ )
- {
- fprintf( fs, "%*stypes[%d]:\n", level, "", i );
- xkb_key_type_dump( fs, level + 2, type++ );
- }
- } else
- fprintf( fs, "%*sNO types\n", level, "" );
+ gint i;
+ fprintf(fs, "%*ssize_types: %d\n", level, "", map->size_types);
+ fprintf(fs, "%*snum_types: %d\n", level, "", map->num_types);
+ if (map->types != NULL) {
+ XkbKeyTypePtr type = map->types;
+ for (i = 0; i < map->num_types; i++) {
+ fprintf(fs, "%*stypes[%d]:\n", level, "", i);
+ xkb_key_type_dump(fs, level + 2, type++);
+ }
+ } else
+ fprintf(fs, "%*sNO types\n", level, "");
- fprintf( fs, "%*ssize_syms: %d\n", level, "", map->size_syms );
- fprintf( fs, "%*snum_syms: %d\n", level, "", map->num_syms );
- if( map->syms != NULL )
- {
- for( i = 0; i < map->num_syms; i++ )
- fprintf( fs, "%*ssyms[%d]:0x%lX(%s)\n", level, "", i, map->syms[i],
- XKeysymToString( map->syms[i] ) );
- } else
- fprintf( fs, "%*sNO syms\n", level, "" );
- if( map->key_sym_map != NULL )
- {
- XkbSymMapPtr ksm = map->key_sym_map;
- for( i = 0; i <= kbd->max_key_code; i++ )
- {
- fprintf( fs, "%*skey_sym_map[%d]:\n", level, "", i );
- xkb_sym_map_dump( fs, level + 2, ksm++ );
- }
- } else
- fprintf( fs, "%*sNO key_sym_map\n", level, "" );
+ fprintf(fs, "%*ssize_syms: %d\n", level, "", map->size_syms);
+ fprintf(fs, "%*snum_syms: %d\n", level, "", map->num_syms);
+ if (map->syms != NULL) {
+ for (i = 0; i < map->num_syms; i++)
+ fprintf(fs, "%*ssyms[%d]:0x%lX(%s)\n", level, "",
+ i, map->syms[i],
+ XKeysymToString(map->syms[i]));
+ } else
+ fprintf(fs, "%*sNO syms\n", level, "");
+ if (map->key_sym_map != NULL) {
+ XkbSymMapPtr ksm = map->key_sym_map;
+ for (i = 0; i <= kbd->max_key_code; i++) {
+ fprintf(fs, "%*skey_sym_map[%d]:\n", level, "", i);
+ xkb_sym_map_dump(fs, level + 2, ksm++);
+ }
+ } else
+ fprintf(fs, "%*sNO key_sym_map\n", level, "");
}
-static void xkb_desc_dump( FILE * fs, gint level, XkbDescPtr kbd )
+static void
+xkb_desc_dump(FILE * fs, gint level, XkbDescPtr kbd)
{
- fprintf( fs, "%*sflags: 0x%X\n", level, "", kbd->flags );
- fprintf( fs, "%*sdevice_spec: %d\n", level, "", kbd->device_spec );
- fprintf( fs, "%*smin_key_code: %d\n", level, "", kbd->min_key_code );
- fprintf( fs, "%*smax_key_code: %d\n", level, "", kbd->max_key_code );
+ fprintf(fs, "%*sflags: 0x%X\n", level, "", kbd->flags);
+ fprintf(fs, "%*sdevice_spec: %d\n", level, "", kbd->device_spec);
+ fprintf(fs, "%*smin_key_code: %d\n", level, "", kbd->min_key_code);
+ fprintf(fs, "%*smax_key_code: %d\n", level, "", kbd->max_key_code);
#if 0
- if( kbd->ctrls != NULL )
- {
- fprintf( fs, "ctrls:\n" );
- _XkbControlsDump( fs, kbd->ctrls );
- } else
- fprintf( fs, "NO server\n" );
+ if (kbd->ctrls != NULL) {
+ fprintf(fs, "ctrls:\n");
+ _XkbControlsDump(fs, kbd->ctrls);
+ } else
+ fprintf(fs, "NO server\n");
#endif
- if( kbd->server != NULL )
- {
- fprintf( fs, "%*sserver:\n", level, "" );
- xkb_server_map_dump( fs, level + 2, kbd->server, kbd );
- } else
- fprintf( fs, "%*sNO server\n", level, "" );
+ if (kbd->server != NULL) {
+ fprintf(fs, "%*sserver:\n", level, "");
+ xkb_server_map_dump(fs, level + 2, kbd->server, kbd);
+ } else
+ fprintf(fs, "%*sNO server\n", level, "");
- if( kbd->map != NULL )
- {
- fprintf( fs, "%*smap:\n", level, "" );
- xkb_client_map_dump( fs, level + 2, kbd->map, kbd );
- } else
- fprintf( fs, "%*sNO map\n", level, "" );
- fprintf( fs, "XKB libraries not present\n" );
+ if (kbd->map != NULL) {
+ fprintf(fs, "%*smap:\n", level, "");
+ xkb_client_map_dump(fs, level + 2, kbd->map, kbd);
+ } else
+ fprintf(fs, "%*sNO map\n", level, "");
+ fprintf(fs, "XKB libraries not present\n");
}
-void xkl_dump_xkb_desc( const gchar *file_name, XkbDescPtr kbd )
+void
+xkl_dump_xkb_desc(const gchar * file_name, XkbDescPtr kbd)
{
- FILE *fs = fopen( file_name, "w+" );
- if( fs != NULL )
- {
- xkb_desc_dump( fs, 0, kbd == NULL ? xkl_xkb_desc : kbd );
- fclose( fs );
- }
+ FILE *fs = fopen(file_name, "w+");
+ if (fs != NULL) {
+ xkb_desc_dump(fs, 0, kbd == NULL ? xkl_xkb_desc : kbd);
+ fclose(fs);
+ }
}
#endif
diff --git a/libxklavier/xklavier_evt.c b/libxklavier/xklavier_evt.c
index f9d8953..8e5540e 100644
--- a/libxklavier/xklavier_evt.c
+++ b/libxklavier/xklavier_evt.c
@@ -7,237 +7,265 @@
#include "xklavier_private.h"
-gint xkl_events_filter( XEvent *xev )
+gint
+xkl_events_filter(XEvent * xev)
{
- XAnyEvent *pe = ( XAnyEvent * ) xev;
- xkl_debug( 400, "**> Filtering event %d of type %d from window %d\n",
- pe->serial, pe->type, pe->window );
- xkl_ensure_vtable_inited();
- if ( !xkl_vtable->process_x_event_func( xev ) )
- switch ( xev->type )
- { /* core events */
- case FocusIn:
- xkl_process_focus_in_evt( &xev->xfocus );
- break;
- case FocusOut:
- xkl_process_focus_out_evt( &xev->xfocus );
- break;
- case PropertyNotify:
- xkl_process_property_evt( &xev->xproperty );
- break;
- case CreateNotify:
- xkl_process_create_window_evt( &xev->xcreatewindow );
- break;
- case DestroyNotify:
- xkl_debug( 150, "Window " WINID_FORMAT " destroyed\n",
- xev->xdestroywindow.window );
- break;
- case UnmapNotify:
- case MapNotify:
- case GravityNotify:
- case ReparentNotify:
- xkl_debug( 200, "%s\n", xkl_event_get_name( xev->type ) );
- break; /* Ignore these events */
- case MappingNotify:
- xkl_debug( 200, "%s\n", xkl_event_get_name( xev->type ) );
- xkl_reset_all_info( "X event: MappingNotify" );
- break;
- default:
- {
- xkl_debug( 200, "Unknown event %d [%s]\n",
- xev->type, xkl_event_get_name( xev->type ) );
- return 1;
- }
- }
- xkl_debug( 400, "Filtered event %d of type %d from window %d **>\n",
- pe->serial, pe->type, pe->window );
- return 1;
+ XAnyEvent *pe = (XAnyEvent *) xev;
+ xkl_debug(400,
+ "**> Filtering event %d of type %d from window %d\n",
+ pe->serial, pe->type, pe->window);
+ xkl_ensure_vtable_inited();
+ if (!xkl_vtable->process_x_event_func(xev))
+ switch (xev->type) { /* core events */
+ case FocusIn:
+ xkl_process_focus_in_evt(&xev->xfocus);
+ break;
+ case FocusOut:
+ xkl_process_focus_out_evt(&xev->xfocus);
+ break;
+ case PropertyNotify:
+ xkl_process_property_evt(&xev->xproperty);
+ break;
+ case CreateNotify:
+ xkl_process_create_window_evt(&xev->xcreatewindow);
+ break;
+ case DestroyNotify:
+ xkl_debug(150,
+ "Window " WINID_FORMAT " destroyed\n",
+ xev->xdestroywindow.window);
+ break;
+ case UnmapNotify:
+ case MapNotify:
+ case GravityNotify:
+ case ReparentNotify:
+ xkl_debug(200, "%s\n",
+ xkl_event_get_name(xev->type));
+ break; /* Ignore these events */
+ case MappingNotify:
+ xkl_debug(200, "%s\n",
+ xkl_event_get_name(xev->type));
+ xkl_reset_all_info("X event: MappingNotify");
+ break;
+ default:
+ {
+ xkl_debug(200, "Unknown event %d [%s]\n",
+ xev->type,
+ xkl_event_get_name(xev->type));
+ return 1;
+ }
+ }
+ xkl_debug(400, "Filtered event %d of type %d from window %d **>\n",
+ pe->serial, pe->type, pe->window);
+ return 1;
}
/**
* FocusIn handler
*/
-void xkl_process_focus_in_evt( XFocusChangeEvent * fev )
+void
+xkl_process_focus_in_evt(XFocusChangeEvent * fev)
{
- Window win;
- Window toplevel_win;
- XklState selected_window_state;
-
- if( !( xkl_listener_type & XKLL_MANAGE_WINDOW_STATES ) )
- return;
-
- win = fev->window;
-
- switch ( fev->mode )
- {
- case NotifyNormal:
- case NotifyWhileGrabbed:
- break;
- default:
- xkl_debug( 160,
- "Window " WINID_FORMAT
- " has got focus during special action %d\n", win, fev->mode );
- return;
- }
-
- xkl_debug( 150, "Window " WINID_FORMAT ", '%s' has got focus\n", win,
- xkl_window_get_debug_title( win ) );
-
- if( !xkl_toplevel_window_find( win, &toplevel_win ) )
- {
- return;
- }
-
- xkl_debug( 150, "Appwin " WINID_FORMAT ", '%s' has got focus\n",
- toplevel_win, xkl_window_get_debug_title( toplevel_win ) );
-
- if( xkl_state_get( toplevel_win, &selected_window_state ) )
- {
- if( xkl_current_client != toplevel_win )
- {
- gboolean old_win_transparent, new_win_transparent;
- XklState tmp_state;
-
- old_win_transparent = xkl_toplevel_window_is_transparent( xkl_current_client );
- if( old_win_transparent )
- xkl_debug( 150, "Leaving transparent window\n" );
+ Window win;
+ Window toplevel_win;
+ XklState selected_window_state;
+
+ if (!(xkl_listener_type & XKLL_MANAGE_WINDOW_STATES))
+ return;
+
+ win = fev->window;
+
+ switch (fev->mode) {
+ case NotifyNormal:
+ case NotifyWhileGrabbed:
+ break;
+ default:
+ xkl_debug(160,
+ "Window " WINID_FORMAT
+ " has got focus during special action %d\n", win,
+ fev->mode);
+ return;
+ }
+
+ xkl_debug(150, "Window " WINID_FORMAT ", '%s' has got focus\n",
+ win, xkl_window_get_debug_title(win));
+
+ if (!xkl_toplevel_window_find(win, &toplevel_win)) {
+ return;
+ }
+
+ xkl_debug(150, "Appwin " WINID_FORMAT ", '%s' has got focus\n",
+ toplevel_win, xkl_window_get_debug_title(toplevel_win));
+
+ if (xkl_state_get(toplevel_win, &selected_window_state)) {
+ if (xkl_current_client != toplevel_win) {
+ gboolean old_win_transparent, new_win_transparent;
+ XklState tmp_state;
+
+ old_win_transparent =
+ xkl_toplevel_window_is_transparent
+ (xkl_current_client);
+ if (old_win_transparent)
+ xkl_debug(150,
+ "Leaving transparent window\n");
/**
* Reload the current state from the current window.
* Do not do it for transparent window - we keep the state from
* the _previous_ window.
*/
- if ( !old_win_transparent &&
- xkl_state_get( xkl_current_client, &tmp_state ) )
- {
- xkl_current_state_update( tmp_state.group,
- tmp_state.indicators,
- "Loading current (previous) state from the current (previous) window" );
- }
-
- xkl_current_client = toplevel_win;
- xkl_debug( 150, "CurClient:changed to " WINID_FORMAT ", '%s'\n",
- xkl_current_client,
- xkl_window_get_debug_title( xkl_current_client ) );
-
- new_win_transparent = xkl_toplevel_window_is_transparent( toplevel_win );
- if( new_win_transparent )
- xkl_debug( 150, "Entering transparent window\n" );
-
- if( xkl_is_group_per_toplevel_window() == !new_win_transparent )
- {
- /* We skip restoration only if we return to the same app window */
- gboolean do_skip = FALSE;
- if( xkl_skip_one_restore )
- {
- xkl_skip_one_restore = FALSE;
- if( toplevel_win == xkl_toplevel_window_prev )
- do_skip = TRUE;
- }
-
- if( do_skip )
- {
- xkl_debug( 150,
- "Skipping one restore as requested - instead, "
- "saving the current group into the window state\n" );
- xkl_toplevel_window_save_state( toplevel_win, &xkl_current_state );
- } else
- {
- if( xkl_current_state.group != selected_window_state.group )
- {
- xkl_debug( 150,
- "Restoring the group from %d to %d after gaining focus\n",
- xkl_current_state.group, selected_window_state.group );
- /**
+ if (!old_win_transparent &&
+ xkl_state_get(xkl_current_client, &tmp_state))
+ {
+ xkl_current_state_update(tmp_state.group,
+ tmp_state.
+ indicators,
+ "Loading current (previous) state from the current (previous) window");
+ }
+
+ xkl_current_client = toplevel_win;
+ xkl_debug(150,
+ "CurClient:changed to " WINID_FORMAT
+ ", '%s'\n", xkl_current_client,
+ xkl_window_get_debug_title
+ (xkl_current_client));
+
+ new_win_transparent =
+ xkl_toplevel_window_is_transparent
+ (toplevel_win);
+ if (new_win_transparent)
+ xkl_debug(150,
+ "Entering transparent window\n");
+
+ if (xkl_is_group_per_toplevel_window() ==
+ !new_win_transparent) {
+ /* We skip restoration only if we return to the same app window */
+ gboolean do_skip = FALSE;
+ if (xkl_skip_one_restore) {
+ xkl_skip_one_restore = FALSE;
+ if (toplevel_win ==
+ xkl_toplevel_window_prev)
+ do_skip = TRUE;
+ }
+
+ if (do_skip) {
+ xkl_debug(150,
+ "Skipping one restore as requested - instead, "
+ "saving the current group into the window state\n");
+ xkl_toplevel_window_save_state
+ (toplevel_win,
+ &xkl_current_state);
+ } else {
+ if (xkl_current_state.group !=
+ selected_window_state.group) {
+ xkl_debug(150,
+ "Restoring the group from %d to %d after gaining focus\n",
+ xkl_current_state.
+ group,
+ selected_window_state.
+ group);
+ /**
* For fast mouse movements - the state is probably not updated yet
* (because of the group change notification being late).
* so we'll enforce the update. But this should only happen in GPA mode
*/
- xkl_current_state_update( selected_window_state.group,
- selected_window_state.indicators,
- "Enforcing fast update of the current state" );
- xkl_group_lock( selected_window_state.group );
- } else
- {
- xkl_debug( 150,
- "Both old and new focused window "
- "have group %d so no point restoring it\n",
- selected_window_state.group );
- xkl_one_switch_to_secondary_group_performed();
- }
- }
-
- if( ( xkl_vtable->features & XKLF_CAN_TOGGLE_INDICATORS ) &&
- xkl_get_indicators_handling( ) )
- {
- xkl_debug( 150,
- "Restoring the indicators from %X to %X after gaining focus\n",
- xkl_current_state.indicators,
- selected_window_state.indicators );
- xkl_ensure_vtable_inited();
- (*xkl_vtable->indicators_set_func)( &selected_window_state );
- } else
- xkl_debug( 150,
- "Not restoring the indicators %X after gaining focus: indicator handling is not enabled\n",
- xkl_current_state.indicators );
- } else
- xkl_debug( 150,
- "Not restoring the group %d after gaining focus: global layout (xor transparent window)\n",
- xkl_current_state.group );
- } else
- xkl_debug( 150, "Same app window - just do nothing\n" );
- } else
- {
- xkl_debug( 150, "But it does not have xklavier_state\n" );
- if( xkl_window_has_wm_state( win ) )
- {
- xkl_debug( 150, "But it does have wm_state so we'll add it\n" );
- xkl_current_client = toplevel_win;
- xkl_debug( 150, "CurClient:changed to " WINID_FORMAT ", '%s'\n",
- xkl_current_client,
- xkl_window_get_debug_title( xkl_current_client ) );
- xkl_toplevel_window_add( xkl_current_client, ( Window ) NULL, FALSE,
- &xkl_current_state );
- } else
- xkl_debug( 150, "And it does have wm_state either\n" );
- }
+ xkl_current_state_update
+ (selected_window_state.
+ group,
+ selected_window_state.
+ indicators,
+ "Enforcing fast update of the current state");
+ xkl_group_lock
+ (selected_window_state.
+ group);
+ } else {
+ xkl_debug(150,
+ "Both old and new focused window "
+ "have group %d so no point restoring it\n",
+ selected_window_state.
+ group);
+ xkl_one_switch_to_secondary_group_performed
+ ();
+ }
+ }
+
+ if ((xkl_vtable->
+ features & XKLF_CAN_TOGGLE_INDICATORS)
+ && xkl_get_indicators_handling()) {
+ xkl_debug(150,
+ "Restoring the indicators from %X to %X after gaining focus\n",
+ xkl_current_state.
+ indicators,
+ selected_window_state.
+ indicators);
+ xkl_ensure_vtable_inited();
+ (*xkl_vtable->
+ indicators_set_func)
+ (&selected_window_state);
+ } else
+ xkl_debug(150,
+ "Not restoring the indicators %X after gaining focus: indicator handling is not enabled\n",
+ xkl_current_state.
+ indicators);
+ } else
+ xkl_debug(150,
+ "Not restoring the group %d after gaining focus: global layout (xor transparent window)\n",
+ xkl_current_state.group);
+ } else
+ xkl_debug(150,
+ "Same app window - just do nothing\n");
+ } else {
+ xkl_debug(150, "But it does not have xklavier_state\n");
+ if (xkl_window_has_wm_state(win)) {
+ xkl_debug(150,
+ "But it does have wm_state so we'll add it\n");
+ xkl_current_client = toplevel_win;
+ xkl_debug(150,
+ "CurClient:changed to " WINID_FORMAT
+ ", '%s'\n", xkl_current_client,
+ xkl_window_get_debug_title
+ (xkl_current_client));
+ xkl_toplevel_window_add(xkl_current_client,
+ (Window) NULL, FALSE,
+ &xkl_current_state);
+ } else
+ xkl_debug(150,
+ "And it does have wm_state either\n");
+ }
}
/**
* FocusOut handler
*/
-void xkl_process_focus_out_evt( XFocusChangeEvent * fev )
+void
+xkl_process_focus_out_evt(XFocusChangeEvent * fev)
{
- if( !( xkl_listener_type & XKLL_MANAGE_WINDOW_STATES ) )
- return;
-
- if( fev->mode != NotifyNormal )
- {
- xkl_debug( 200,
- "Window " WINID_FORMAT
- " has lost focus during special action %d\n", fev->window,
- fev->mode );
- return;
- }
-
- xkl_debug( 160, "Window " WINID_FORMAT ", '%s' has lost focus\n",
- fev->window, xkl_window_get_debug_title( fev->window ) );
-
- if( xkl_window_is_transparent( fev->window ) )
- {
- xkl_debug( 150, "Leaving transparent window!\n" );
+ if (!(xkl_listener_type & XKLL_MANAGE_WINDOW_STATES))
+ return;
+
+ if (fev->mode != NotifyNormal) {
+ xkl_debug(200,
+ "Window " WINID_FORMAT
+ " has lost focus during special action %d\n",
+ fev->window, fev->mode);
+ return;
+ }
+
+ xkl_debug(160, "Window " WINID_FORMAT ", '%s' has lost focus\n",
+ fev->window, xkl_window_get_debug_title(fev->window));
+
+ if (xkl_window_is_transparent(fev->window)) {
+ xkl_debug(150, "Leaving transparent window!\n");
/**
* If we are leaving the transparent window - we skip the restore operation.
* This is useful for secondary groups switching from the transparent control
* window.
*/
- xkl_skip_one_restore = TRUE;
- } else
- {
- Window p;
- if( xkl_toplevel_window_find( fev->window, &p ) )
- xkl_toplevel_window_prev = p;
- }
+ xkl_skip_one_restore = TRUE;
+ } else {
+ Window p;
+ if (xkl_toplevel_window_find(fev->window, &p))
+ xkl_toplevel_window_prev = p;
+ }
}
/**
@@ -247,78 +275,80 @@ void xkl_process_focus_out_evt( XFocusChangeEvent * fev )
* - WM_STATE property for all windows
* - Configuration property of the root window
*/
-void xkl_process_property_evt( XPropertyEvent * pev )
+void
+xkl_process_property_evt(XPropertyEvent * pev)
{
- if( 400 <= xkl_debug_level )
- {
- char *atom_name = XGetAtomName( xkl_display, pev->atom );
- if( atom_name != NULL )
- {
- xkl_debug( 400, "The property '%s' changed for " WINID_FORMAT "\n",
- atom_name, pev->window );
- XFree( atom_name );
- } else
- {
- xkl_debug( 200, "Some magic property changed for " WINID_FORMAT "\n",
- pev->window );
- }
- }
-
- if( xkl_listener_type & XKLL_MANAGE_WINDOW_STATES )
- {
- if( pev->atom == xkl_atoms[WM_STATE] )
- {
- gboolean has_xkl_state = xkl_state_get( pev->window, NULL );
-
- if( pev->state == PropertyNewValue )
- {
- xkl_debug( 160, "New value of WM_STATE on window " WINID_FORMAT "\n",
- pev->window );
- if( !has_xkl_state ) /* Is this event the first or not? */
- {
- xkl_toplevel_window_add( pev->window, ( Window ) NULL, FALSE,
- &xkl_current_state );
- }
- } else
- { /* ev->xproperty.state == PropertyDelete, either client or WM can remove it, ICCCM 4.1.3.1 */
- xkl_debug( 160, "Something (%d) happened to WM_STATE of window 0x%x\n",
- pev->state, pev->window );
- xkl_select_input_merging( pev->window, PropertyChangeMask );
- if( has_xkl_state )
- {
- xkl_state_delete( pev->window );
- }
- }
- } else
- if( pev->atom == xkl_vtable->base_config_atom
- && pev->window == xkl_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 */
- xkl_reset_all_info( "New value of *_NAMES_PROP_ATOM on root window" );
- }
- }
- } /* XKLL_MANAGE_WINDOW_STATES */
+ if (400 <= xkl_debug_level) {
+ char *atom_name = XGetAtomName(xkl_display, pev->atom);
+ if (atom_name != NULL) {
+ xkl_debug(400,
+ "The property '%s' changed for "
+ WINID_FORMAT "\n", atom_name,
+ pev->window);
+ XFree(atom_name);
+ } else {
+ xkl_debug(200,
+ "Some magic property changed for "
+ WINID_FORMAT "\n", pev->window);
+ }
+ }
+
+ if (xkl_listener_type & XKLL_MANAGE_WINDOW_STATES) {
+ if (pev->atom == xkl_atoms[WM_STATE]) {
+ gboolean has_xkl_state =
+ xkl_state_get(pev->window, NULL);
+
+ if (pev->state == PropertyNewValue) {
+ xkl_debug(160,
+ "New value of WM_STATE on window "
+ WINID_FORMAT "\n", pev->window);
+ if (!has_xkl_state) { /* Is this event the first or not? */
+ xkl_toplevel_window_add(pev->
+ window,
+ (Window)
+ NULL,
+ FALSE,
+ &xkl_current_state);
+ }
+ } else { /* ev->xproperty.state == PropertyDelete, either client or WM can remove it, ICCCM 4.1.3.1 */
+ xkl_debug(160,
+ "Something (%d) happened to WM_STATE of window 0x%x\n",
+ pev->state, pev->window);
+ xkl_select_input_merging(pev->window,
+ PropertyChangeMask);
+ if (has_xkl_state) {
+ xkl_state_delete(pev->window);
+ }
+ }
+ } else
+ if (pev->atom == xkl_vtable->base_config_atom
+ && pev->window == xkl_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 */
+ xkl_reset_all_info
+ ("New value of *_NAMES_PROP_ATOM on root window");
+ }
+ }
+ } /* XKLL_MANAGE_WINDOW_STATES */
}
/**
* CreateNotify handler. Just interested in properties and focus events...
*/
-void xkl_process_create_window_evt( XCreateWindowEvent * cev )
+void
+xkl_process_create_window_evt(XCreateWindowEvent * cev)
{
- if( !( xkl_listener_type & XKLL_MANAGE_WINDOW_STATES ) )
- return;
+ if (!(xkl_listener_type & XKLL_MANAGE_WINDOW_STATES))
+ return;
- xkl_debug( 200,
- "Under-root window " WINID_FORMAT
- "/%s (%d,%d,%d x %d) is created\n", cev->window,
- xkl_window_get_debug_title( cev->window ), cev->x, cev->y,
- cev->width, cev->height );
+ xkl_debug(200,
+ "Under-root window " WINID_FORMAT
+ "/%s (%d,%d,%d x %d) is created\n", cev->window,
+ xkl_window_get_debug_title(cev->window), cev->x, cev->y,
+ cev->width, cev->height);
- if( !cev->override_redirect )
- {
+ if (!cev->override_redirect) {
/* ICCCM 4.1.6: override-redirect is NOT private to
* client (and must not be changed - am I right?)
* We really need only PropertyChangeMask on this window but even in the case of
@@ -326,127 +356,134 @@ void xkl_process_create_window_evt( XCreateWindowEvent * cev )
* event + SelectInput request is not zero) and we definitely will (my system DO)
* lose FocusIn/Out events after the following call of PropertyNotifyHandler.
* So I just decided to purify this extra FocusChangeMask in the FocusIn/OutHandler. */
- xkl_select_input_merging( cev->window,
- PropertyChangeMask | FocusChangeMask );
-
- if( xkl_window_has_wm_state( cev->window ) )
- {
- xkl_debug( 200,
- "Just created window already has WM_STATE - so I'll add it" );
- xkl_toplevel_window_add( cev->window, ( Window ) NULL,
- FALSE, &xkl_current_state );
- }
- }
+ xkl_select_input_merging(cev->window,
+ PropertyChangeMask |
+ FocusChangeMask);
+
+ if (xkl_window_has_wm_state(cev->window)) {
+ xkl_debug(200,
+ "Just created window already has WM_STATE - so I'll add it");
+ xkl_toplevel_window_add(cev->window, (Window) NULL,
+ FALSE, &xkl_current_state);
+ }
+ }
}
/**
* Just error handler - sometimes we get BadWindow error for already gone
* windows, so we'll just ignore
*/
-void xkl_process_error( Display * dpy, XErrorEvent * evt )
+void
+xkl_process_error(Display * dpy, XErrorEvent * evt)
{
- xkl_last_error_code = evt->error_code;
- switch ( xkl_last_error_code )
- {
- case BadWindow:
- case BadAccess:
- {
- /* in most cases this means we are late:) */
- xkl_debug( 200, "ERROR: %p, " WINID_FORMAT ", %d, %d, %d\n",
- dpy,
- ( unsigned long ) evt->resourceid,
- ( int ) evt->error_code,
- ( int ) evt->request_code, ( int ) evt->minor_code );
- break;
- }
- default:
- ( *xkl_default_error_handler ) ( dpy, evt );
- }
+ xkl_last_error_code = evt->error_code;
+ switch (xkl_last_error_code) {
+ case BadWindow:
+ case BadAccess:
+ {
+ /* in most cases this means we are late:) */
+ xkl_debug(200,
+ "ERROR: %p, " WINID_FORMAT
+ ", %d, %d, %d\n", dpy,
+ (unsigned long) evt->resourceid,
+ (int) evt->error_code,
+ (int) evt->request_code,
+ (int) evt->minor_code);
+ break;
+ }
+ default:
+ (*xkl_default_error_handler) (dpy, evt);
+ }
}
/**
* Some common functionality for Xkb handler
*/
-void xkl_process_state_modification( XklStateChange change_type,
- gint grp,
- guint inds,
- gboolean set_inds )
+void
+xkl_process_state_modification(XklStateChange change_type,
+ gint grp, guint inds, gboolean set_inds)
{
- Window focused, focused_toplevel;
- XklState old_state;
- gint revert;
- gboolean have_old_state = TRUE;
- gboolean set_group = change_type == GROUP_CHANGED;
+ Window focused, focused_toplevel;
+ XklState old_state;
+ gint revert;
+ gboolean have_old_state = TRUE;
+ gboolean set_group = change_type == GROUP_CHANGED;
- XGetInputFocus( xkl_display, &focused, &revert );
+ XGetInputFocus(xkl_display, &focused, &revert);
- if( ( focused == None ) || ( focused == PointerRoot ) )
- {
- xkl_debug( 160, "Something with focus: " WINID_FORMAT "\n", focused );
- return;
- }
+ if ((focused == None) || (focused == PointerRoot)) {
+ xkl_debug(160, "Something with focus: " WINID_FORMAT "\n",
+ focused);
+ return;
+ }
/**
* Only if we manage states - otherwise xkl_current_client does not make sense
*/
- if( !xkl_toplevel_window_find( focused, &focused_toplevel ) &&
- xkl_listener_type & XKLL_MANAGE_WINDOW_STATES )
- focused_toplevel = xkl_current_client; /* what else can I do */
-
- xkl_debug( 150, "Focused window: " WINID_FORMAT ", '%s'\n",
- focused_toplevel, xkl_window_get_debug_title( focused_toplevel ) );
- if( xkl_listener_type & XKLL_MANAGE_WINDOW_STATES )
- {
- xkl_debug( 150, "CurClient: " WINID_FORMAT ", '%s'\n",
- xkl_current_client,
- xkl_window_get_debug_title( xkl_current_client ) );
-
- if( focused_toplevel != xkl_current_client )
- {
+ if (!xkl_toplevel_window_find(focused, &focused_toplevel) &&
+ xkl_listener_type & XKLL_MANAGE_WINDOW_STATES)
+ focused_toplevel = xkl_current_client; /* what else can I do */
+
+ xkl_debug(150, "Focused window: " WINID_FORMAT ", '%s'\n",
+ focused_toplevel,
+ xkl_window_get_debug_title(focused_toplevel));
+ if (xkl_listener_type & XKLL_MANAGE_WINDOW_STATES) {
+ xkl_debug(150, "CurClient: " WINID_FORMAT ", '%s'\n",
+ xkl_current_client,
+ xkl_window_get_debug_title(xkl_current_client));
+
+ if (focused_toplevel != xkl_current_client) {
/**
* If not state - we got the new window
*/
- if ( !xkl_toplevel_window_get_state( focused_toplevel, &old_state ) )
- {
- xkl_current_state_update( grp, inds,
- "Updating the state from new focused window" );
- if( xkl_listener_type & XKLL_MANAGE_WINDOW_STATES )
- xkl_toplevel_window_add( focused_toplevel, ( Window ) NULL,
- FALSE, &xkl_current_state );
- }
+ if (!xkl_toplevel_window_get_state
+ (focused_toplevel, &old_state)) {
+ xkl_current_state_update(grp, inds,
+ "Updating the state from new focused window");
+ if (xkl_listener_type &
+ XKLL_MANAGE_WINDOW_STATES)
+ xkl_toplevel_window_add
+ (focused_toplevel,
+ (Window) NULL, FALSE,
+ &xkl_current_state);
+ }
/**
* There is state - just get the state from the window
*/
- else
- {
- grp = old_state.group;
- inds = old_state.indicators;
- }
- xkl_current_client = focused_toplevel;
- xkl_debug( 160, "CurClient:changed to " WINID_FORMAT ", '%s'\n",
- xkl_current_client,
- xkl_window_get_debug_title( xkl_current_client ) );
- }
- /* If the window already has this this state - we are just restoring it!
- (see the second parameter of stateCallback */
- have_old_state = xkl_toplevel_window_get_state( xkl_current_client,
- &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, &xkl_current_state, sizeof( XklState ) );
- }
-
- if( set_group || have_old_state )
- {
- xkl_current_state_update( set_group ? grp : old_state.group,
- set_inds ? inds : old_state.indicators,
- "Restoring the state from the window" );
- }
-
- if( have_old_state )
- xkl_try_call_state_func( change_type, &old_state );
-
- if( xkl_listener_type & XKLL_MANAGE_WINDOW_STATES )
- xkl_toplevel_window_save_state( xkl_current_client, &xkl_current_state );
+ else {
+ grp = old_state.group;
+ inds = old_state.indicators;
+ }
+ xkl_current_client = focused_toplevel;
+ xkl_debug(160,
+ "CurClient:changed to " WINID_FORMAT
+ ", '%s'\n", xkl_current_client,
+ xkl_window_get_debug_title
+ (xkl_current_client));
+ }
+ /* If the window already has this this state - we are just restoring it!
+ (see the second parameter of stateCallback */
+ have_old_state =
+ xkl_toplevel_window_get_state(xkl_current_client,
+ &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, &xkl_current_state, sizeof(XklState));
+ }
+
+ if (set_group || have_old_state) {
+ xkl_current_state_update(set_group ? grp : old_state.group,
+ set_inds ? inds : old_state.
+ indicators,
+ "Restoring the state from the window");
+ }
+
+ if (have_old_state)
+ xkl_try_call_state_func(change_type, &old_state);
+
+ if (xkl_listener_type & XKLL_MANAGE_WINDOW_STATES)
+ xkl_toplevel_window_save_state(xkl_current_client,
+ &xkl_current_state);
}
diff --git a/libxklavier/xklavier_evt_xkb.c b/libxklavier/xklavier_evt_xkb.c
index ec92e5c..eb23aa1 100644
--- a/libxklavier/xklavier_evt_xkb.c
+++ b/libxklavier/xklavier_evt_xkb.c
@@ -11,127 +11,129 @@
/**
* XKB event handler
*/
-gint xkl_xkb_process_x_event( XEvent *xev )
+gint
+xkl_xkb_process_x_event(XEvent * xev)
{
#ifdef XKB_HEADERS_PRESENT
- gint i;
- guint bit;
- guint inds;
- XkbEvent *kev = (XkbEvent*)xev;
-
- if( xev->type != xkl_xkb_event_type )
- return 0;
-
- if( !( xkl_listener_type &
- ( XKLL_MANAGE_WINDOW_STATES | XKLL_TRACK_KEYBOARD_STATE ) ) )
- return 0;
-
- xkl_debug( 150, "Xkb event detected\n" );
-
- switch ( kev->any.xkb_type )
- {
+ gint i;
+ guint bit;
+ guint inds;
+ XkbEvent *kev = (XkbEvent *) xev;
+
+ if (xev->type != xkl_xkb_event_type)
+ return 0;
+
+ if (!(xkl_listener_type &
+ (XKLL_MANAGE_WINDOW_STATES | XKLL_TRACK_KEYBOARD_STATE)))
+ return 0;
+
+ xkl_debug(150, "Xkb event detected\n");
+
+ switch (kev->any.xkb_type) {
/**
* Group is changed!
*/
- case XkbStateNotify:
+ case XkbStateNotify:
#define GROUP_CHANGE_MASK \
( XkbGroupStateMask | XkbGroupBaseMask | XkbGroupLatchMask | XkbGroupLockMask )
- xkl_debug( 150,
- "XkbStateNotify detected, changes: %X/(mask %X), new group %d\n",
- kev->state.changed, GROUP_CHANGE_MASK,
- kev->state.locked_group );
-
- if( kev->state.changed & GROUP_CHANGE_MASK )
- xkl_process_state_modification( GROUP_CHANGED,
- kev->state.locked_group,
- 0,
- FALSE );
- else /* ...not interested... */
- {
- xkl_debug( 200,
- "This type of state notification is not regarding groups\n" );
- if ( kev->state.locked_group != xkl_current_state.group )
- xkl_debug( 0,
- "ATTENTION! Currently cached group %d is not equal to the current group from the event: %d\n!",
- xkl_current_state.group,
- kev->state.locked_group );
- }
-
- break;
+ xkl_debug(150,
+ "XkbStateNotify detected, changes: %X/(mask %X), new group %d\n",
+ kev->state.changed, GROUP_CHANGE_MASK,
+ kev->state.locked_group);
+
+ if (kev->state.changed & GROUP_CHANGE_MASK)
+ xkl_process_state_modification(GROUP_CHANGED,
+ kev->state.
+ locked_group, 0,
+ FALSE);
+ else { /* ...not interested... */
+
+ xkl_debug(200,
+ "This type of state notification is not regarding groups\n");
+ if (kev->state.locked_group !=
+ xkl_current_state.group)
+ xkl_debug(0,
+ "ATTENTION! Currently cached group %d is not equal to the current group from the event: %d\n!",
+ xkl_current_state.group,
+ kev->state.locked_group);
+ }
+
+ break;
/**
* Indicators are changed!
*/
- case XkbIndicatorStateNotify:
+ case XkbIndicatorStateNotify:
- xkl_debug( 150, "XkbIndicatorStateNotify\n" );
+ xkl_debug(150, "XkbIndicatorStateNotify\n");
- inds = xkl_current_state.indicators;
+ inds = xkl_current_state.indicators;
- ForPhysIndicators( i, bit ) if( kev->indicators.changed & bit )
- {
- if( kev->indicators.state & bit )
- inds |= bit;
- else
- inds &= ~bit;
- }
+ ForPhysIndicators(i,
+ bit) if (kev->indicators.changed & bit) {
+ if (kev->indicators.state & bit)
+ inds |= bit;
+ else
+ inds &= ~bit;
+ }
- xkl_process_state_modification( INDICATORS_CHANGED,
- 0,
- inds,
- TRUE );
- break;
+ xkl_process_state_modification(INDICATORS_CHANGED,
+ 0, inds, TRUE);
+ break;
/**
* The configuration is changed!
*/
- case XkbIndicatorMapNotify:
- case XkbControlsNotify:
- case XkbNamesNotify:
+ case XkbIndicatorMapNotify:
+ case XkbControlsNotify:
+ case XkbNamesNotify:
#if 0
- /* not really fair - but still better than flooding... */
- XklDebug( 200, "warning: configuration event %s is not actually processed\n",
- _XklXkbGetXkbEventName( kev->any.xkb_type ) );
- break;
+ /* not really fair - but still better than flooding... */
+ XklDebug(200,
+ "warning: configuration event %s is not actually processed\n",
+ _XklXkbGetXkbEventName(kev->any.xkb_type));
+ break;
#endif
- case XkbNewKeyboardNotify:
- xkl_debug( 150, "%s\n",
- xkl_xkb_event_get_name( kev->any.xkb_type ) );
- xkl_reset_all_info( "XKB event: XkbNewKeyboardNotify" );
- break;
+ case XkbNewKeyboardNotify:
+ xkl_debug(150, "%s\n",
+ xkl_xkb_event_get_name(kev->any.xkb_type));
+ xkl_reset_all_info("XKB event: XkbNewKeyboardNotify");
+ break;
/**
* ...Not interested...
*/
- default:
- xkl_debug( 150, "Unknown XKB event %d [%s]\n",
- kev->any.xkb_type, xkl_xkb_event_get_name( kev->any.xkb_type ) );
- return 0;
- }
- return 1;
+ default:
+ xkl_debug(150, "Unknown XKB event %d [%s]\n",
+ kev->any.xkb_type,
+ xkl_xkb_event_get_name(kev->any.xkb_type));
+ return 0;
+ }
+ return 1;
#else
- return 0;
+ return 0;
#endif
}
-void xkl_xkb_indicators_set( const XklState *window_state )
+void
+xkl_xkb_indicators_set(const XklState * window_state)
{
#ifdef XKB_HEADERS_PRESENT
- int i;
- unsigned bit;
-
- ForPhysIndicators( i,
- bit ) if( xkl_xkb_desc->names->indicators[i] != None )
- {
- gboolean status;
- status = xkl_indicator_set( i,
- ( window_state->indicators & bit ) != 0 );
- xkl_debug( 150, "Set indicator \"%s\"/%d to %d: %d\n",
- xkl_indicator_names[i],
- xkl_xkb_desc->names->indicators[i],
- window_state->indicators & bit,
- status );
- }
+ int i;
+ unsigned bit;
+
+ ForPhysIndicators(i,
+ bit) if (xkl_xkb_desc->names->indicators[i] !=
+ None) {
+ gboolean status;
+ status = xkl_indicator_set(i,
+ (window_state->
+ indicators & bit) != 0);
+ xkl_debug(150, "Set indicator \"%s\"/%d to %d: %d\n",
+ xkl_indicator_names[i],
+ xkl_xkb_desc->names->indicators[i],
+ window_state->indicators & bit, status);
+ }
#endif
}
diff --git a/libxklavier/xklavier_evt_xmm.c b/libxklavier/xklavier_evt_xmm.c
index 0a94de1..2eae35f 100644
--- a/libxklavier/xklavier_evt_xmm.c
+++ b/libxklavier/xklavier_evt_xmm.c
@@ -9,164 +9,173 @@
#include "xklavier_private.h"
#include "xklavier_private_xmm.h"
-static gint xkl_xmm_process_keypress_event( XKeyPressedEvent* kpe )
+static gint
+xkl_xmm_process_keypress_event(XKeyPressedEvent * kpe)
{
- if( xkl_listener_type & XKLL_MANAGE_LAYOUTS )
- {
- xkl_debug( 200, "Processing the KeyPress event\n" );
- gint current_shortcut = 0;
- const XmmSwitchOption *sop = xkl_xmm_switch_option_find( kpe->keycode,
- kpe->state,
- &current_shortcut );
- if( sop != NULL )
- {
- xkl_debug( 150, "It is THE shortcut\n" );
- XklState state;
- xkl_xmm_state_get_server( &state );
- if( state.group != -1 )
- {
- gint new_group = ( state.group + sop->shortcut_steps[current_shortcut] ) %
- g_strv_length (current_xmm_config.layouts);
- xkl_debug( 150, "Setting new xmm group %d\n", new_group );
- xkl_xmm_group_lock( new_group );
- return 1;
- }
- }
- }
- return 0;
+ if (xkl_listener_type & XKLL_MANAGE_LAYOUTS) {
+ xkl_debug(200, "Processing the KeyPress event\n");
+ gint current_shortcut = 0;
+ const XmmSwitchOption *sop =
+ xkl_xmm_switch_option_find(kpe->keycode,
+ kpe->state,
+ &current_shortcut);
+ if (sop != NULL) {
+ xkl_debug(150, "It is THE shortcut\n");
+ XklState state;
+ xkl_xmm_state_get_server(&state);
+ if (state.group != -1) {
+ gint new_group =
+ (state.group +
+ sop->
+ shortcut_steps[current_shortcut]) %
+ g_strv_length(current_xmm_config.
+ layouts);
+ xkl_debug(150,
+ "Setting new xmm group %d\n",
+ new_group);
+ xkl_xmm_group_lock(new_group);
+ return 1;
+ }
+ }
+ }
+ return 0;
}
-static gint xkl_xmm_process_property_event( XPropertyEvent* kpe )
+static gint
+xkl_xmm_process_property_event(XPropertyEvent * kpe)
{
- xkl_debug( 200, "Processing the PropertyNotify event: %d/%d\n",
- kpe->atom, xmm_state_atom );
+ xkl_debug(200, "Processing the PropertyNotify event: %d/%d\n",
+ kpe->atom, xmm_state_atom);
/**
* Group is changed!
*/
- if( kpe->atom == xmm_state_atom )
- {
- XklState state;
- xkl_xmm_state_get_server( &state );
-
- if( xkl_listener_type & XKLL_MANAGE_LAYOUTS )
- {
- xkl_debug( 150, "Current group from the root window property %d\n", state.group );
- xkl_xmm_shortcuts_ungrab();
- xkl_xmm_group_actualize( state.group );
- xkl_xmm_shortcuts_grab();
- return 1;
- }
-
- if( xkl_listener_type &
- ( XKLL_MANAGE_WINDOW_STATES | XKLL_TRACK_KEYBOARD_STATE ) )
- {
- xkl_debug( 150,
- "XMM state changed, new 'group' %d\n",
- state.group );
-
- xkl_process_state_modification( GROUP_CHANGED,
- state.group,
- 0,
- False );
- }
- } else
+ if (kpe->atom == xmm_state_atom) {
+ XklState state;
+ xkl_xmm_state_get_server(&state);
+
+ if (xkl_listener_type & XKLL_MANAGE_LAYOUTS) {
+ xkl_debug(150,
+ "Current group from the root window property %d\n",
+ state.group);
+ xkl_xmm_shortcuts_ungrab();
+ xkl_xmm_group_actualize(state.group);
+ xkl_xmm_shortcuts_grab();
+ return 1;
+ }
+
+ if (xkl_listener_type &
+ (XKLL_MANAGE_WINDOW_STATES |
+ XKLL_TRACK_KEYBOARD_STATE)) {
+ xkl_debug(150,
+ "XMM state changed, new 'group' %d\n",
+ state.group);
+
+ xkl_process_state_modification(GROUP_CHANGED,
+ state.group,
+ 0, False);
+ }
+ } else
/**
* Configuration is changed!
*/
- if( kpe->atom == xkl_vtable->base_config_atom )
- {
- xkl_reset_all_info( "base config atom changed" );
- }
-
- return 0;
+ if (kpe->atom == xkl_vtable->base_config_atom) {
+ xkl_reset_all_info("base config atom changed");
+ }
+
+ return 0;
}
/**
* XMM event handler
*/
-gint xkl_xmm_process_x_event( XEvent *xev )
+gint
+xkl_xmm_process_x_event(XEvent * xev)
{
- switch( xev->type )
- {
- case KeyPress:
- return xkl_xmm_process_keypress_event( (XKeyPressedEvent*)xev );
- case PropertyNotify:
- return xkl_xmm_process_property_event( (XPropertyEvent*)xev );
- }
- return 0;
+ switch (xev->type) {
+ case KeyPress:
+ return xkl_xmm_process_keypress_event((XKeyPressedEvent *)
+ xev);
+ case PropertyNotify:
+ return xkl_xmm_process_property_event((XPropertyEvent *)
+ xev);
+ }
+ return 0;
}
/**
* We have to find which of Shift/Lock/Control/ModX masks
* belong to Caps/Num/Scroll lock
*/
-static void xkl_xmm_init_xmm_indicators_map( guint* p_caps_lock_mask,
- guint* p_num_lock_mask,
- guint* p_scroll_lock_mask )
+static void
+xkl_xmm_init_xmm_indicators_map(guint * p_caps_lock_mask,
+ guint * p_num_lock_mask,
+ guint * p_scroll_lock_mask)
{
- XModifierKeymap *xmkm = NULL;
- KeyCode *kcmap, nlkc, clkc, slkc;
- int m, k, mask;
-
- xmkm = XGetModifierMapping( xkl_display );
- if( xmkm )
- {
- clkc = XKeysymToKeycode( xkl_display, XK_Num_Lock );
- nlkc = XKeysymToKeycode( xkl_display, XK_Caps_Lock );
- slkc = XKeysymToKeycode( xkl_display, XK_Scroll_Lock );
-
- kcmap = xmkm->modifiermap;
- mask = 1;
- for( m = 8; --m >= 0; mask <<= 1 )
- for( k = xmkm->max_keypermod; --k >= 0; kcmap++ )
- {
- if( *kcmap == clkc )
- *p_caps_lock_mask = mask;
- if( *kcmap == slkc )
- *p_scroll_lock_mask = mask;
- if( *kcmap == nlkc )
- *p_num_lock_mask = mask;
- }
- XFreeModifiermap( xmkm );
- }
+ XModifierKeymap *xmkm = NULL;
+ KeyCode *kcmap, nlkc, clkc, slkc;
+ int m, k, mask;
+
+ xmkm = XGetModifierMapping(xkl_display);
+ if (xmkm) {
+ clkc = XKeysymToKeycode(xkl_display, XK_Num_Lock);
+ nlkc = XKeysymToKeycode(xkl_display, XK_Caps_Lock);
+ slkc = XKeysymToKeycode(xkl_display, XK_Scroll_Lock);
+
+ kcmap = xmkm->modifiermap;
+ mask = 1;
+ for (m = 8; --m >= 0; mask <<= 1)
+ for (k = xmkm->max_keypermod; --k >= 0; kcmap++) {
+ if (*kcmap == clkc)
+ *p_caps_lock_mask = mask;
+ if (*kcmap == slkc)
+ *p_scroll_lock_mask = mask;
+ if (*kcmap == nlkc)
+ *p_num_lock_mask = mask;
+ }
+ XFreeModifiermap(xmkm);
+ }
}
-void xkl_xmm_grab_ignoring_indicators( gint keycode, guint modifiers )
+void
+xkl_xmm_grab_ignoring_indicators(gint keycode, guint modifiers)
{
- guint caps_lock_mask = 0, num_lock_mask = 0, scroll_lock_mask = 0;
-
- xkl_xmm_init_xmm_indicators_map( &caps_lock_mask, &num_lock_mask, &scroll_lock_mask );
+ guint caps_lock_mask = 0, num_lock_mask = 0, scroll_lock_mask = 0;
+
+ xkl_xmm_init_xmm_indicators_map(&caps_lock_mask, &num_lock_mask,
+ &scroll_lock_mask);
#define GRAB(mods) \
xkl_key_grab( keycode, modifiers|(mods) )
-
- GRAB( 0 );
- GRAB( caps_lock_mask );
- GRAB( num_lock_mask );
- GRAB( scroll_lock_mask );
- GRAB( caps_lock_mask | num_lock_mask );
- GRAB( caps_lock_mask | scroll_lock_mask );
- GRAB( num_lock_mask | scroll_lock_mask );
- GRAB( caps_lock_mask | num_lock_mask | scroll_lock_mask );
+
+ GRAB(0);
+ GRAB(caps_lock_mask);
+ GRAB(num_lock_mask);
+ GRAB(scroll_lock_mask);
+ GRAB(caps_lock_mask | num_lock_mask);
+ GRAB(caps_lock_mask | scroll_lock_mask);
+ GRAB(num_lock_mask | scroll_lock_mask);
+ GRAB(caps_lock_mask | num_lock_mask | scroll_lock_mask);
#undef GRAB
}
-void xkl_xmm_ungrab_ignoring_indicators( gint keycode, guint modifiers )
+void
+xkl_xmm_ungrab_ignoring_indicators(gint keycode, guint modifiers)
{
- guint caps_lock_mask = 0, num_lock_mask = 0, scroll_lock_mask = 0;
+ guint caps_lock_mask = 0, num_lock_mask = 0, scroll_lock_mask = 0;
+
+ xkl_xmm_init_xmm_indicators_map(&caps_lock_mask, &num_lock_mask,
+ &scroll_lock_mask);
- xkl_xmm_init_xmm_indicators_map( &caps_lock_mask, &num_lock_mask, &scroll_lock_mask );
-
#define UNGRAB(mods) \
xkl_key_ungrab( keycode, modifiers|(mods) )
-
- UNGRAB( 0 );
- UNGRAB( caps_lock_mask );
- UNGRAB( num_lock_mask );
- UNGRAB( scroll_lock_mask );
- UNGRAB( caps_lock_mask | num_lock_mask );
- UNGRAB( caps_lock_mask | scroll_lock_mask );
- UNGRAB( num_lock_mask | scroll_lock_mask );
- UNGRAB( caps_lock_mask | num_lock_mask | scroll_lock_mask );
+
+ UNGRAB(0);
+ UNGRAB(caps_lock_mask);
+ UNGRAB(num_lock_mask);
+ UNGRAB(scroll_lock_mask);
+ UNGRAB(caps_lock_mask | num_lock_mask);
+ UNGRAB(caps_lock_mask | scroll_lock_mask);
+ UNGRAB(num_lock_mask | scroll_lock_mask);
+ UNGRAB(caps_lock_mask | num_lock_mask | scroll_lock_mask);
#undef UNGRAB
}
diff --git a/libxklavier/xklavier_private.h b/libxklavier/xklavier_private.h
index ce0393e..d3a560c 100644
--- a/libxklavier/xklavier_private.h
+++ b/libxklavier/xklavier_private.h
@@ -6,65 +6,64 @@
#include <libxklavier/xklavier_config.h>
/* XklConfigRec */
-typedef gboolean ( *XklVTConfigActivateFunc )( const XklConfigRec * data );
+typedef gboolean(*XklVTConfigActivateFunc) (const XklConfigRec * data);
-typedef void ( *XklVTConfigInitFunc )( void );
+typedef void (*XklVTConfigInitFunc) (void);
-typedef gboolean ( *XklVTConfigRegistryLoadFunc )( void );
+typedef gboolean(*XklVTConfigRegistryLoadFunc) (void);
-typedef gboolean ( *XklVTConfigWriteFileFunc )( const gchar *file_name,
- const XklConfigRec * data,
- const gboolean binary );
+typedef gboolean(*XklVTConfigWriteFileFunc) (const gchar * file_name,
+ const XklConfigRec * data,
+ const gboolean binary);
/* Groups */
-typedef const gchar **( *XklVTGroupsGetNamesFunc )( void );
+typedef const gchar **(*XklVTGroupsGetNamesFunc) (void);
-typedef guint ( *XklVTGroupsGetMaxNumFunc )( void );
+typedef guint(*XklVTGroupsGetMaxNumFunc) (void);
-typedef guint ( *XklVTGroupsGetNumFunc )( void );
+typedef guint(*XklVTGroupsGetNumFunc) (void);
-typedef void ( *XklVTGroupLockFunc )( gint group );
+typedef void (*XklVTGroupLockFunc) (gint group);
-typedef gint ( *XklVTProcessXEventFunc )( XEvent *xev );
+typedef gint(*XklVTProcessXEventFunc) (XEvent * xev);
-typedef void ( *XklVTFreeAllInfoFunc )( void );
+typedef void (*XklVTFreeAllInfoFunc) (void);
-typedef gboolean ( *XklVTIfCachedInfoEqualsActualFunc) ( void );
+typedef gboolean(*XklVTIfCachedInfoEqualsActualFunc) (void);
-typedef gboolean ( *XklVTLoadAllInfoFunc )( void );
+typedef gboolean(*XklVTLoadAllInfoFunc) (void);
-typedef void ( *XklVTGetServerStateFunc)( XklState * current_state_out );
+typedef void (*XklVTGetServerStateFunc) (XklState * current_state_out);
-typedef gint ( *XklVTPauseResumeListenFunc )( void );
+typedef gint(*XklVTPauseResumeListenFunc) (void);
-typedef void ( *XklVTIndicatorsSetFunc )( const XklState *window_state );
+typedef void (*XklVTIndicatorsSetFunc) (const XklState * window_state);
-typedef struct
-{
+typedef struct {
/**
* Backend name
*/
- const gchar *id;
+ const gchar *id;
/**
* Functions supported by the backend, combination of XKLF_* constants
*/
- guint8 features;
+ guint8 features;
/**
* Activates the configuration.
* xkb: create proper the XkbDescRec and send it to the server
* xmodmap: save the property, init layout #1
*/
- XklVTConfigActivateFunc config_activate_func;
+ XklVTConfigActivateFunc config_activate_func;
/**
* Background-specific initialization.
* xkb: XkbInitAtoms - init internal xkb atoms table
* xmodmap: void.
*/
- XklVTConfigInitFunc config_init_func; /* private */
+ XklVTConfigInitFunc config_init_func; /* private */
/**
* Loads the registry tree into DOM (using whatever path(s))
@@ -72,7 +71,7 @@ typedef struct
* xkb: loads xml from XKB_BASE+"/rules/"+ruleset+".xml"
* xmodmap: loads xml from XMODMAP_BASE+"/"+ruleset+".xml"
*/
- XklVTConfigRegistryLoadFunc config_registry_load_func;
+ XklVTConfigRegistryLoadFunc config_registry_load_func;
/**
* Write the configuration into the file (binary/textual)
@@ -80,7 +79,7 @@ typedef struct
* xmodmap: if text requested, just dump XklConfigRec to the
* file - not really useful. If binary - fail (not supported)
*/
- XklVTConfigWriteFileFunc config_write_file_func;
+ XklVTConfigWriteFileFunc config_write_file_func;
/**
@@ -88,21 +87,21 @@ typedef struct
* xkb: return cached list of the group names
* xmodmap: return the list of layouts from the internal XklConfigRec
*/
- XklVTGroupsGetNamesFunc groups_get_names_func;
+ XklVTGroupsGetNamesFunc groups_get_names_func;
/**
* Get the maximum number of loaded groups
* xkb: returns 1 or XkbNumKbdGroups
* xmodmap: return 0
*/
- XklVTGroupsGetMaxNumFunc groups_get_max_num_func;
+ XklVTGroupsGetMaxNumFunc groups_get_max_num_func;
/**
* Get the number of loaded groups
* xkb: return from the cached XkbDesc
* xmodmap: return number of layouts from internal XklConfigRec
*/
- XklVTGroupsGetNumFunc groups_get_num_func;
+ XklVTGroupsGetNumFunc groups_get_num_func;
/**
* Switches the keyboard to the group N
@@ -110,7 +109,7 @@ typedef struct
* xmodmap: changes the root window property
* (listener invokes xmodmap with appropriate config file).
*/
- XklVTGroupLockFunc group_lock_func;
+ XklVTGroupLockFunc group_lock_func;
/**
@@ -118,201 +117,202 @@ typedef struct
* xkb: XkbEvent handling
* xmodmap: keep track on the root window properties. What else can we do?
*/
- XklVTProcessXEventFunc process_x_event_func;
+ XklVTProcessXEventFunc process_x_event_func;
/**
* Flushes the cached server config info.
* xkb: frees XkbDesc
* xmodmap: frees internal XklConfigRec
*/
- XklVTFreeAllInfoFunc free_all_info_func; /* private */
+ XklVTFreeAllInfoFunc free_all_info_func; /* private */
/**
* Compares the cached info with the actual one, from the server
* xkb: Compares some parts of XkbDescPtr
* xmodmap: returns False
*/
- XklVTIfCachedInfoEqualsActualFunc if_cached_info_equals_actual_func;
+ XklVTIfCachedInfoEqualsActualFunc
+ if_cached_info_equals_actual_func;
/**
* Loads the configuration info from the server
* xkb: loads XkbDesc, names, indicators
* xmodmap: loads internal XklConfigRec from server
*/
- XklVTLoadAllInfoFunc load_all_info_func; /* private */
+ XklVTLoadAllInfoFunc load_all_info_func; /* private */
/**
* Gets the current stateCallback
* xkb: XkbGetState and XkbGetIndicatorState
* xmodmap: check the root window property (regarding the group)
*/
- XklVTGetServerStateFunc get_server_state_func;
+ XklVTGetServerStateFunc get_server_state_func;
/**
* Stop tracking the keyboard-related events
* xkb: XkbSelectEvents(..., 0)
* xmodmap: Ungrab the switching shortcut.
*/
- XklVTPauseResumeListenFunc listen_pause_func;
+ XklVTPauseResumeListenFunc listen_pause_func;
/**
* Start tracking the keyboard-related events
* xkb: XkbSelectEvents + XkbSelectEventDetails
* xmodmap: Grab the switching shortcut.
*/
- XklVTPauseResumeListenFunc listen_resume_func;
+ XklVTPauseResumeListenFunc listen_resume_func;
/**
* Set the indicators state from the XklState
* xkb: XklSetIndicator for all indicators
* xmodmap: NULL. Not supported
*/
- XklVTIndicatorsSetFunc indicators_set_func; /* private */
-
- /* all data is private - no direct access */
+ XklVTIndicatorsSetFunc indicators_set_func; /* private */
+
+ /* all data is private - no direct access */
/**
* The base configuration atom.
* xkb: _XKB_RF_NAMES_PROP_ATOM
* xmodmap: "_XMM_NAMES"
*/
- Atom base_config_atom;
-
+ Atom base_config_atom;
+
/**
* The configuration backup atom
* xkb: "_XKB_RULES_NAMES_BACKUP"
* xmodmap: "_XMM_NAMES_BACKUP"
*/
- Atom backup_config_atom;
-
+ Atom backup_config_atom;
+
/**
* Fallback for missing model
*/
- const gchar* default_model;
+ const gchar *default_model;
/**
* Fallback for missing layout
*/
- const gchar* default_layout;
-
+ const gchar *default_layout;
+
} XklVTable;
-extern void xkl_ensure_vtable_inited( void );
+extern void xkl_ensure_vtable_inited(void);
-extern void xkl_process_focus_in_evt( XFocusChangeEvent *fev );
-extern void xkl_process_focus_out_evt( XFocusChangeEvent *fev );
-extern void xkl_process_property_evt( XPropertyEvent *rev );
-extern void xkl_process_create_window_evt( XCreateWindowEvent *cev );
+extern void xkl_process_focus_in_evt(XFocusChangeEvent * fev);
+extern void xkl_process_focus_out_evt(XFocusChangeEvent * fev);
+extern void xkl_process_property_evt(XPropertyEvent * rev);
+extern void xkl_process_create_window_evt(XCreateWindowEvent * cev);
-extern void xkl_process_error( Display *dpy, XErrorEvent *evt );
+extern void xkl_process_error(Display * dpy, XErrorEvent * evt);
-extern void xkl_process_state_modification( XklStateChange change_type,
- gint group,
- unsigned inds,
- gboolean set_indicators );
+extern void xkl_process_state_modification(XklStateChange change_type,
+ gint group,
+ unsigned inds,
+ gboolean set_indicators);
-extern Window xkl_get_registered_parent( Window win );
-extern gboolean xkl_load_all_info( void );
-extern void xkl_free_all_info( void );
-extern void xkl_reset_all_info( const gchar reason[] );
-extern gboolean xkl_load_window_tree( void );
-extern gboolean xkl_load_subtree( Window window,
- gint level,
- XklState *init_state );
+extern Window xkl_get_registered_parent(Window win);
+extern gboolean xkl_load_all_info(void);
+extern void xkl_free_all_info(void);
+extern void xkl_reset_all_info(const gchar reason[]);
+extern gboolean xkl_load_window_tree(void);
+extern gboolean xkl_load_subtree(Window window,
+ gint level, XklState * init_state);
-extern gboolean xkl_window_has_wm_state( Window win );
+extern gboolean xkl_window_has_wm_state(Window win);
/**
* Toplevel window stuff
*/
-extern void xkl_toplevel_window_add( Window win,
- Window parent, gboolean force,
- XklState *init_state );
+extern void xkl_toplevel_window_add(Window win,
+ Window parent, gboolean force,
+ XklState * init_state);
-extern gboolean xkl_toplevel_window_find_bottom_to_top( Window win,
- Window *toplevel_win_out );
+extern gboolean xkl_toplevel_window_find_bottom_to_top(Window win,
+ Window *
+ toplevel_win_out);
-extern gboolean xkl_toplevel_window_find( Window win,
- Window *toplevel_win_out );
+extern gboolean xkl_toplevel_window_find(Window win,
+ Window * toplevel_win_out);
-extern gboolean xkl_toplevel_window_is_transparent( Window toplevel_win );
+extern gboolean xkl_toplevel_window_is_transparent(Window toplevel_win);
-extern void xkl_toplevel_window_set_transparent( Window toplevel_win,
- gboolean transparent );
+extern void xkl_toplevel_window_set_transparent(Window toplevel_win,
+ gboolean transparent);
-extern gboolean xkl_toplevel_window_get_state( Window toplevel_win,
- XklState *state_out );
+extern gboolean xkl_toplevel_window_get_state(Window toplevel_win,
+ XklState * state_out);
-extern void xkl_toplevel_window_remove_state( Window toplevel_win );
-extern void xkl_toplevel_window_save_state( Window toplevel_win, XklState *state );
+extern void xkl_toplevel_window_remove_state(Window toplevel_win);
+extern void xkl_toplevel_window_save_state(Window toplevel_win,
+ XklState * state);
/***/
-extern void xkl_select_input_merging( Window win, gulong mask );
+extern void xkl_select_input_merging(Window win, gulong mask);
-extern gchar *xkl_window_get_debug_title( Window win );
+extern gchar *xkl_window_get_debug_title(Window win);
-extern Status xkl_status_query_tree( Window w,
- Window * root_out,
- Window * parent_out,
- Window ** children_out,
- guint *nchildren_out );
+extern Status xkl_status_query_tree(Window w,
+ Window * root_out,
+ Window * parent_out,
+ Window ** children_out,
+ guint * nchildren_out);
-extern gboolean xkl_indicator_set( gint indicator_num, gboolean set );
+extern gboolean xkl_indicator_set(gint indicator_num, gboolean set);
-extern void xkl_try_call_state_func( XklStateChange change_type,
- XklState * old_state );
+extern void xkl_try_call_state_func(XklStateChange change_type,
+ XklState * old_state);
-extern void xkl_i18n_init( void );
+extern void xkl_i18n_init(void);
-extern gchar *xkl_locale_from_utf8( const gchar *utf8string );
+extern gchar *xkl_locale_from_utf8(const gchar * utf8string);
-extern gint xkl_get_language_priority( const gchar *language );
+extern gint xkl_get_language_priority(const gchar * language);
-extern gchar* xkl_rules_set_get_name( const gchar default_ruleset[] );
+extern gchar *xkl_rules_set_get_name(const gchar default_ruleset[]);
-extern gboolean xkl_config_get_full_from_server( gchar **rules_file_out,
- XklConfigRec * data );
+extern gboolean xkl_config_get_full_from_server(gchar ** rules_file_out,
+ XklConfigRec * data);
-extern gchar *xkl_strings_concat_comma_separated( gchar **array );
+extern gchar *xkl_strings_concat_comma_separated(gchar ** array);
-extern void xkl_strings_split_comma_separated( gchar ***array,
- const gchar *merged );
+extern void xkl_strings_split_comma_separated(gchar *** array,
+ const gchar * merged);
/**
* XConfigRec
*/
-extern gchar *xkl_config_rec_merge_layouts( const XklConfigRec * data );
+extern gchar *xkl_config_rec_merge_layouts(const XklConfigRec * data);
-extern gchar *xkl_config_rec_merge_variants( const XklConfigRec * data );
+extern gchar *xkl_config_rec_merge_variants(const XklConfigRec * data);
-extern gchar *xkl_config_rec_merge_options( const XklConfigRec * data );
+extern gchar *xkl_config_rec_merge_options(const XklConfigRec * data);
-extern void xkl_config_rec_split_layouts( XklConfigRec * data,
- const gchar *merged );
+extern void xkl_config_rec_split_layouts(XklConfigRec * data,
+ const gchar * merged);
-extern void xkl_config_rec_split_variants( XklConfigRec * data,
- const gchar *merged );
+extern void xkl_config_rec_split_variants(XklConfigRec * data,
+ const gchar * merged);
-extern void xkl_config_rec_split_options( XklConfigRec * data,
- const gchar *merged );
+extern void xkl_config_rec_split_options(XklConfigRec * data,
+ const gchar * merged);
/***/
-extern void xkl_config_dump( FILE* file,
- XklConfigRec * data );
-
-extern const gchar *xkl_event_get_name( gint type );
+extern void xkl_config_dump(FILE * file, XklConfigRec * data);
+
+extern const gchar *xkl_event_get_name(gint type);
-extern void xkl_current_state_update( gint group,
- unsigned indicators,
- const gchar reason[] );
+extern void xkl_current_state_update(gint group,
+ unsigned indicators,
+ const gchar reason[]);
-extern gint xkl_xkb_init( void );
+extern gint xkl_xkb_init(void);
-extern gint xkl_xmm_init( void );
+extern gint xkl_xmm_init(void);
-extern gboolean xkl_is_one_switch_to_secondary_group_allowed( void );
+extern gboolean xkl_is_one_switch_to_secondary_group_allowed(void);
-extern void xkl_one_switch_to_secondary_group_performed( void );
+extern void xkl_one_switch_to_secondary_group_performed(void);
extern Display *xkl_display;
@@ -331,11 +331,12 @@ extern XErrorHandler xkl_default_error_handler;
extern gchar *xkl_indicator_names[];
enum { WM_NAME,
- WM_STATE,
- XKLAVIER_STATE,
- XKLAVIER_TRANSPARENT,
- XKLAVIER_ALLOW_SECONDARY,
- TOTAL_ATOMS };
+ WM_STATE,
+ XKLAVIER_STATE,
+ XKLAVIER_TRANSPARENT,
+ XKLAVIER_ALLOW_SECONDARY,
+ TOTAL_ATOMS
+};
#define XKLAVIER_STATE_PROP_LENGTH 2
diff --git a/libxklavier/xklavier_private_xkb.h b/libxklavier/xklavier_private_xkb.h
index 64bd179..0701e20 100644
--- a/libxklavier/xklavier_private_xkb.h
+++ b/libxklavier/xklavier_private_xkb.h
@@ -16,53 +16,54 @@ extern XkbRF_VarDefsRec xkl_var_defs;
extern XkbDescPtr xkl_xkb_desc;
-extern void xkl_dump_xkb_desc( const char *file_name,
- XkbDescPtr kbd );
+extern void xkl_dump_xkb_desc(const char *file_name, XkbDescPtr kbd);
-extern gboolean xkl_xkb_config_multiple_layouts_supported( void );
+extern gboolean xkl_xkb_config_multiple_layouts_supported(void);
-extern const gchar *xkl_xkb_event_get_name( gint xkb_type );
+extern const gchar *xkl_xkb_event_get_name(gint xkb_type);
-extern gboolean xkl_xkb_config_native_prepare( const XklConfigRec *data,
- XkbComponentNamesPtr component_names );
+extern gboolean xkl_xkb_config_native_prepare(const XklConfigRec * data,
+ XkbComponentNamesPtr
+ component_names);
-extern void xkl_xkb_config_native_cleanup( XkbComponentNamesPtr component_names );
+extern void xkl_xkb_config_native_cleanup(XkbComponentNamesPtr
+ component_names);
/* Start VTable methods */
-extern gboolean xkl_xkb_config_activate( const XklConfigRec * data );
+extern gboolean xkl_xkb_config_activate(const XklConfigRec * data);
-extern void xkl_xkb_config_init( void );
+extern void xkl_xkb_config_init(void);
-extern gboolean xkl_xkb_config_registry_load( void );
+extern gboolean xkl_xkb_config_registry_load(void);
-extern gboolean xkl_xkb_config_write_file( const char *file_name,
- const XklConfigRec * data,
- const gboolean binary );
+extern gboolean xkl_xkb_config_write_file(const char *file_name,
+ const XklConfigRec * data,
+ const gboolean binary);
-extern gint xkl_xkb_process_x_event( XEvent * kev );
+extern gint xkl_xkb_process_x_event(XEvent * kev);
-extern void xkl_xkb_free_all_info( void );
+extern void xkl_xkb_free_all_info(void);
-extern const gchar **xkl_xkb_groups_get_names( void );
+extern const gchar **xkl_xkb_groups_get_names(void);
-extern guint xkl_xkb_groups_get_max_num( void );
+extern guint xkl_xkb_groups_get_max_num(void);
-extern guint xkl_xkb_groups_get_num( void );
+extern guint xkl_xkb_groups_get_num(void);
-extern void xkl_xkb_state_get_server( XklState * current_state_out );
+extern void xkl_xkb_state_get_server(XklState * current_state_out);
-extern gboolean xkl_xkb_if_cached_info_equals_actual( void );
+extern gboolean xkl_xkb_if_cached_info_equals_actual(void);
-extern gboolean xkl_xkb_load_all_info( void );
+extern gboolean xkl_xkb_load_all_info(void);
-extern void xkl_xkb_group_lock( gint group );
+extern void xkl_xkb_group_lock(gint group);
-extern gint xkl_xkb_listen_pause( void );
+extern gint xkl_xkb_listen_pause(void);
-extern gint xkl_xkb_listen_resume( void );
+extern gint xkl_xkb_listen_resume(void);
-extern void xkl_xkb_indicators_set( const XklState *window_state );
+extern void xkl_xkb_indicators_set(const XklState * window_state);
/* End of VTable methods */
@@ -72,10 +73,10 @@ extern void xkl_xkb_indicators_set( const XklState *window_state );
* VERY VERY BAD STYLE, some kind of 'protected' methods -
* but some programs may want to hook into them.
*/
-extern gboolean xkl_xkb_config_prepare_native( const XklConfigRec * data,
- gpointer component_names );
+extern gboolean xkl_xkb_config_prepare_native(const XklConfigRec * data,
+ gpointer component_names);
-extern void xkl_xkb_config_cleanup_native( gpointer component_names );
+extern void xkl_xkb_config_cleanup_native(gpointer component_names);
#endif
diff --git a/libxklavier/xklavier_private_xmm.h b/libxklavier/xklavier_private_xmm.h
index e3408cf..c63f45b 100644
--- a/libxklavier/xklavier_private_xmm.h
+++ b/libxklavier/xklavier_private_xmm.h
@@ -1,21 +1,19 @@
#ifndef __XKLAVIER_PRIVATE_XMM_H__
#define __XKLAVIER_PRIVATE_XMM_H__
-typedef struct _XmmShortcut
-{
- guint keysym;
- guint modifiers;
+typedef struct _XmmShortcut {
+ guint keysym;
+ guint modifiers;
} XmmShortcut;
#define MAX_SHORTCUTS_PER_OPTION 4
-typedef struct _XmmSwitchOption
-{
- const gchar* option_name;
- XmmShortcut shortcuts[MAX_SHORTCUTS_PER_OPTION + 1];
- gint shortcut_steps[MAX_SHORTCUTS_PER_OPTION + 1];
+typedef struct _XmmSwitchOption {
+ const gchar *option_name;
+ XmmShortcut shortcuts[MAX_SHORTCUTS_PER_OPTION + 1];
+ gint shortcut_steps[MAX_SHORTCUTS_PER_OPTION + 1];
} XmmSwitchOption;
-extern gchar* current_xmm_rules;
+extern gchar *current_xmm_rules;
extern XklConfigRec current_xmm_config;
@@ -24,53 +22,56 @@ extern Atom xmm_state_atom;
/* in the ideal world this should be a hashmap */
extern XmmSwitchOption all_switch_options[];
-extern void xkl_xmm_grab_ignoring_indicators( gint keycode, guint modifiers );
+extern void xkl_xmm_grab_ignoring_indicators(gint keycode,
+ guint modifiers);
-extern void xkl_xmm_ungrab_ignoring_indicators( gint keycode, guint modifiers );
+extern void xkl_xmm_ungrab_ignoring_indicators(gint keycode,
+ guint modifiers);
-extern void xkl_xmm_shortcuts_grab( void );
+extern void xkl_xmm_shortcuts_grab(void);
-extern void xkl_xmm_shortcuts_ungrab( void );
+extern void xkl_xmm_shortcuts_ungrab(void);
-extern const gchar* xkl_xmm_shortcut_get_current_option_name( void );
+extern const gchar *xkl_xmm_shortcut_get_current_option_name(void);
-XmmSwitchOption *xkl_xmm_shortcut_get_current( void );
+XmmSwitchOption *xkl_xmm_shortcut_get_current(void);
-extern void xkl_xmm_group_actualize( gint group );
+extern void xkl_xmm_group_actualize(gint group);
-const XmmSwitchOption *xkl_xmm_switch_option_find( gint keycode,
- guint state,
- gint * current_shortcut_out );
+const XmmSwitchOption *xkl_xmm_switch_option_find(gint keycode,
+ guint state,
+ gint *
+ current_shortcut_out);
/* Start VTable methods */
-extern gboolean xkl_xmm_config_activate( const XklConfigRec * data );
+extern gboolean xkl_xmm_config_activate(const XklConfigRec * data);
-extern void xkl_xmm_config_init( void );
+extern void xkl_xmm_config_init(void);
-extern gboolean xkl_xmm_config_registry_load( void );
+extern gboolean xkl_xmm_config_registry_load(void);
-extern gint xkl_xmm_process_x_event( XEvent * kev );
+extern gint xkl_xmm_process_x_event(XEvent * kev);
-extern void xkl_xmm_free_all_info( void );
+extern void xkl_xmm_free_all_info(void);
-extern const gchar **xkl_xmm_groups_get_names( void );
+extern const gchar **xkl_xmm_groups_get_names(void);
-extern guint xkl_xmm_groups_get_max_num( void );
+extern guint xkl_xmm_groups_get_max_num(void);
-extern guint xkl_xmm_groups_get_num( void );
+extern guint xkl_xmm_groups_get_num(void);
-extern void xkl_xmm_group_lock( gint group );
+extern void xkl_xmm_group_lock(gint group);
-extern void xkl_xmm_state_get_server( XklState * current_state_out );
+extern void xkl_xmm_state_get_server(XklState * current_state_out);
-extern gboolean xkl_xmm_if_cached_info_equals_actual( void );
+extern gboolean xkl_xmm_if_cached_info_equals_actual(void);
-extern gboolean xkl_xmm_load_all_info( void );
+extern gboolean xkl_xmm_load_all_info(void);
-extern gint xkl_xmm_listen_pause( void );
+extern gint xkl_xmm_listen_pause(void);
-extern gint xkl_xmm_listen_resume( void );
+extern gint xkl_xmm_listen_resume(void);
/* End of VTable methods */
diff --git a/libxklavier/xklavier_props.c b/libxklavier/xklavier_props.c
index 652542c..1a45744 100644
--- a/libxklavier/xklavier_props.c
+++ b/libxklavier/xklavier_props.c
@@ -13,381 +13,387 @@
#include "xklavier_config.h"
#include "xklavier_private.h"
-void xkl_config_rec_init( XklConfigRec * data )
+void
+xkl_config_rec_init(XklConfigRec * data)
{
- /* clear the structure VarDefsPtr... */
- memset( ( void * ) data, 0, sizeof( XklConfigRec ) );
+ /* clear the structure VarDefsPtr... */
+ memset((void *) data, 0, sizeof(XklConfigRec));
}
-static gboolean xkl_strings_equal( gchar* p1, gchar* p2 )
+static gboolean
+xkl_strings_equal(gchar * p1, gchar * p2)
{
- if ( p1 == p2 )
- return TRUE;
- if ( ( p1 == NULL && p2 != NULL ) ||
- ( p1 != NULL && p2 == NULL ) )
- return FALSE;
- return !g_ascii_strcasecmp( p1, p2 );
+ if (p1 == p2)
+ return TRUE;
+ if ((p1 == NULL && p2 != NULL) || (p1 != NULL && p2 == NULL))
+ return FALSE;
+ return !g_ascii_strcasecmp(p1, p2);
}
-static gboolean xkl_lists_equal( gchar **items1, gchar **items2 )
+static gboolean
+xkl_lists_equal(gchar ** items1, gchar ** items2)
{
- if ( items1 == items2 )
- return TRUE;
+ if (items1 == items2)
+ return TRUE;
- if ( ( items1 == NULL && items2 != NULL ) ||
- ( items1 != NULL && items2 == NULL ) )
- return FALSE;
+ if ((items1 == NULL && items2 != NULL) ||
+ (items1 != NULL && items2 == NULL))
+ return FALSE;
- while ( *items1 != NULL && *items2 != NULL )
- if ( !xkl_strings_equal( *items1++ , *items2++ ) )
- return FALSE;
+ while (*items1 != NULL && *items2 != NULL)
+ if (!xkl_strings_equal(*items1++, *items2++))
+ return FALSE;
- return ( *items1 == NULL && *items2 == NULL );
+ return (*items1 == NULL && *items2 == NULL);
}
-static gboolean xkl_get_default_names_prop( char **rules_file_out,
- XklConfigRec *data )
+static gboolean
+xkl_get_default_names_prop(char **rules_file_out, XklConfigRec * data)
{
- if ( rules_file_out != NULL )
- *rules_file_out = strdup( XKB_DEFAULT_RULESET );
- data->model = g_strdup( xkl_vtable->default_model );
+ if (rules_file_out != NULL)
+ *rules_file_out = strdup(XKB_DEFAULT_RULESET);
+ data->model = g_strdup(xkl_vtable->default_model);
/* keeping Nvariants = Nlayouts */
- data->layouts = g_new0 ( char *, 2 );
- data->layouts[0] = g_strdup( xkl_vtable->default_layout );
- data->variants = g_new0 ( char *, 2 );
- data->variants[0] = g_strdup( "" );
- data->options = NULL;
- return TRUE;
+ data->layouts = g_new0(char *, 2);
+ data->layouts[0] = g_strdup(xkl_vtable->default_layout);
+ data->variants = g_new0(char *, 2);
+ data->variants[0] = g_strdup("");
+ data->options = NULL;
+ return TRUE;
}
-gboolean xkl_config_get_full_from_server( char **rules_file_out,
- XklConfigRec *data )
+gboolean
+xkl_config_get_full_from_server(char **rules_file_out, XklConfigRec * data)
{
- gboolean rv =
- xkl_get_names_prop( xkl_vtable->base_config_atom, rules_file_out, data );
+ gboolean rv =
+ xkl_get_names_prop(xkl_vtable->base_config_atom,
+ rules_file_out, data);
- if( !rv )
- rv = xkl_get_default_names_prop( rules_file_out, data );
+ if (!rv)
+ rv = xkl_get_default_names_prop(rules_file_out, data);
- return rv;
+ return rv;
}
-gboolean xkl_config_rec_equals( XklConfigRec *data1, XklConfigRec *data2 )
+gboolean
+xkl_config_rec_equals(XklConfigRec * data1, XklConfigRec * data2)
{
- if ( data1 == data2 )
- return TRUE;
- if ( !xkl_strings_equal( data1->model, data2->model ) )
- return FALSE;
- if ( !xkl_lists_equal( data1->layouts,
- data2->layouts ) )
- return FALSE;
- if ( !xkl_lists_equal( data1->variants,
- data2->variants ) )
- return FALSE;
- return xkl_lists_equal( data1->options,
- data2->options );
+ if (data1 == data2)
+ return TRUE;
+ if (!xkl_strings_equal(data1->model, data2->model))
+ return FALSE;
+ if (!xkl_lists_equal(data1->layouts, data2->layouts))
+ return FALSE;
+ if (!xkl_lists_equal(data1->variants, data2->variants))
+ return FALSE;
+ return xkl_lists_equal(data1->options, data2->options);
}
-void xkl_config_rec_destroy( XklConfigRec * data )
+void
+xkl_config_rec_destroy(XklConfigRec * data)
{
- if( data->model != NULL )
- g_free( data->model );
-
- g_strfreev ( data->layouts );
- g_strfreev ( data->variants );
- g_strfreev ( data->options );
- data->layouts =
- data->variants =
- data->options = NULL;
+ if (data->model != NULL)
+ g_free(data->model);
+
+ g_strfreev(data->layouts);
+ g_strfreev(data->variants);
+ g_strfreev(data->options);
+ data->layouts = data->variants = data->options = NULL;
}
-void xkl_config_rec_reset( XklConfigRec * data )
+void
+xkl_config_rec_reset(XklConfigRec * data)
{
- xkl_config_rec_destroy( data );
- xkl_config_rec_init( data );
+ xkl_config_rec_destroy(data);
+ xkl_config_rec_init(data);
}
-gboolean xkl_config_get_from_server( XklConfigRec * data )
+gboolean
+xkl_config_get_from_server(XklConfigRec * data)
{
- return xkl_config_get_full_from_server( NULL, data );
+ return xkl_config_get_full_from_server(NULL, data);
}
-gboolean xkl_config_get_from_backup( XklConfigRec * data )
+gboolean
+xkl_config_get_from_backup(XklConfigRec * data)
{
- return xkl_get_names_prop( xkl_vtable->backup_config_atom, NULL, data );
+ return xkl_get_names_prop(xkl_vtable->backup_config_atom, NULL,
+ data);
}
-gboolean xkl_backup_names_prop( void )
+gboolean
+xkl_backup_names_prop(void)
{
- gboolean rv = TRUE;
- gchar *rf = NULL;
- XklConfigRec data;
- gboolean cgp = FALSE;
-
- xkl_config_rec_init( &data );
- if( xkl_get_names_prop
- ( xkl_vtable->backup_config_atom, NULL, &data ) )
- {
- xkl_config_rec_destroy( &data );
- return TRUE;
- }
- /* "backup" property is not defined */
- xkl_config_rec_reset( &data );
- cgp = xkl_config_get_full_from_server( &rf, &data );
-
- if ( cgp )
- {
- if( !xkl_set_names_prop( xkl_vtable->backup_config_atom, rf, &data ) )
- {
- xkl_debug( 150, "Could not backup the configuration" );
- rv = FALSE;
- }
- if( rf != NULL )
- g_free( rf );
- } else
- {
- xkl_debug( 150, "Could not get the configuration for backup" );
- rv = FALSE;
- }
- xkl_config_rec_destroy( &data );
- return rv;
+ gboolean rv = TRUE;
+ gchar *rf = NULL;
+ XklConfigRec data;
+ gboolean cgp = FALSE;
+
+ xkl_config_rec_init(&data);
+ if (xkl_get_names_prop
+ (xkl_vtable->backup_config_atom, NULL, &data)) {
+ xkl_config_rec_destroy(&data);
+ return TRUE;
+ }
+ /* "backup" property is not defined */
+ xkl_config_rec_reset(&data);
+ cgp = xkl_config_get_full_from_server(&rf, &data);
+
+ if (cgp) {
+ if (!xkl_set_names_prop
+ (xkl_vtable->backup_config_atom, rf, &data)) {
+ xkl_debug(150,
+ "Could not backup the configuration");
+ rv = FALSE;
+ }
+ if (rf != NULL)
+ g_free(rf);
+ } else {
+ xkl_debug(150,
+ "Could not get the configuration for backup");
+ rv = FALSE;
+ }
+ xkl_config_rec_destroy(&data);
+ return rv;
}
-gboolean xkl_restore_names_prop( void )
+gboolean
+xkl_restore_names_prop(void)
{
- gboolean rv = TRUE;
- gchar *rf = NULL;
- XklConfigRec data;
-
- xkl_config_rec_init( &data );
- if( !xkl_get_names_prop( xkl_vtable->backup_config_atom, NULL, &data ) )
- {
- xkl_config_rec_destroy( &data );
- return FALSE;
- }
-
- if( !xkl_set_names_prop( xkl_vtable->base_config_atom, rf, &data ) )
- {
- xkl_debug( 150, "Could not backup the configuration" );
- rv = FALSE;
- }
- xkl_config_rec_destroy( &data );
- return rv;
+ gboolean rv = TRUE;
+ gchar *rf = NULL;
+ XklConfigRec data;
+
+ xkl_config_rec_init(&data);
+ if (!xkl_get_names_prop
+ (xkl_vtable->backup_config_atom, NULL, &data)) {
+ xkl_config_rec_destroy(&data);
+ return FALSE;
+ }
+
+ if (!xkl_set_names_prop(xkl_vtable->base_config_atom, rf, &data)) {
+ xkl_debug(150, "Could not backup the configuration");
+ rv = FALSE;
+ }
+ xkl_config_rec_destroy(&data);
+ return rv;
}
-gboolean xkl_get_names_prop( Atom rules_atom,
- gchar **rules_file_out,
- XklConfigRec *data )
+gboolean
+xkl_get_names_prop(Atom rules_atom,
+ gchar ** rules_file_out, XklConfigRec * data)
{
- Atom real_prop_type;
- int fmt;
- unsigned long nitems, extra_bytes;
- char *prop_data = NULL, *out;
- Status rtrn;
-
- /* no such atom! */
- if( rules_atom == None ) /* property cannot exist */
- {
- xkl_last_error_message = "Could not find the atom";
- return FALSE;
- }
-
- rtrn =
- XGetWindowProperty( xkl_display, xkl_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 )
- {
- xkl_last_error_message = "Could not get the property";
- return FALSE;
- }
- /* set rules file to "" */
- if( rules_file_out )
- *rules_file_out = NULL;
-
- /* has to be array of strings */
- if( ( extra_bytes > 0 ) || ( real_prop_type != XA_STRING ) || ( fmt != 8 ) )
- {
- if( prop_data )
- XFree( prop_data );
- xkl_last_error_message = "Wrong property format";
- return FALSE;
- }
-
- if( !prop_data )
- {
- xkl_last_error_message = "No properties returned";
- return FALSE;
- }
-
- /* rules file */
- out = prop_data;
- if( out && ( *out ) && rules_file_out )
- *rules_file_out = g_strdup( out );
- out += strlen( out ) + 1;
-
- /* if user is interested in rules only - don't waste the time */
- if( !data )
- {
- XFree( prop_data );
- return TRUE;
- }
-
- if( ( out - prop_data ) < nitems )
- {
- if( *out )
- data->model = g_strdup( out );
- out += strlen( out ) + 1;
- }
-
- if( ( out - prop_data ) < nitems )
- {
- xkl_config_rec_split_layouts( data, out );
- out += strlen( out ) + 1;
- }
-
- if( ( out - prop_data ) < nitems )
- {
- gint nv, nl;
- gchar **layout, **variant;
- xkl_config_rec_split_variants( data, out );
- /*
- Now have to ensure that number of variants matches the number of layouts
- The 'remainder' is filled with NULLs (not ""s!)
- */
-
- nv = g_strv_length( data->variants );
- nl = g_strv_length( data->layouts );
- if( nv < nl )
- {
- data->variants = g_realloc( data->variants,
- ( nl + 1 ) * sizeof( char * ) );
- memset( data->variants + nv + 1, 0,
- ( nl - nv ) * sizeof( char * ) );
- }
- /* take variants from layouts like ru(winkeys) */
- layout = data->layouts;
- variant = data->variants;
- while( *layout != NULL && *variant != NULL )
- {
- gchar *varstart = g_strstr_len( *layout, -1, "(" );
- if( varstart != NULL )
- {
- gchar *varend = g_strstr_len( varstart, -1, ")" );
- if( varend != NULL )
- {
- gint varlen = varend - varstart;
- gint laylen = varstart - *layout;
- /* I am not sure - but I assume variants in layout have priority */
- gchar *var = *variant = ( *variant != NULL ) ?
- g_realloc( *variant, varlen ) : g_new( gchar, varlen );
- memcpy( var, varstart + 1, --varlen );
- var[varlen] = '\0';
- /* Resize the original layout */
- ( (char*)g_realloc( *layout, laylen + 1 ) )[laylen] = '\0';
- }
- }
- layout++;
- variant++;
- }
- out += strlen( out ) + 1;
- }
-
- if( ( out - prop_data ) < nitems )
- {
- xkl_config_rec_split_options( data, out );
- }
- XFree( prop_data );
- return TRUE;
+ Atom real_prop_type;
+ int fmt;
+ unsigned long nitems, extra_bytes;
+ char *prop_data = NULL, *out;
+ Status rtrn;
+
+ /* no such atom! */
+ if (rules_atom == None) { /* property cannot exist */
+ xkl_last_error_message = "Could not find the atom";
+ return FALSE;
+ }
+
+ rtrn =
+ XGetWindowProperty(xkl_display, xkl_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) {
+ xkl_last_error_message = "Could not get the property";
+ return FALSE;
+ }
+ /* set rules file to "" */
+ if (rules_file_out)
+ *rules_file_out = NULL;
+
+ /* has to be array of strings */
+ if ((extra_bytes > 0) || (real_prop_type != XA_STRING)
+ || (fmt != 8)) {
+ if (prop_data)
+ XFree(prop_data);
+ xkl_last_error_message = "Wrong property format";
+ return FALSE;
+ }
+
+ if (!prop_data) {
+ xkl_last_error_message = "No properties returned";
+ return FALSE;
+ }
+
+ /* rules file */
+ out = prop_data;
+ if (out && (*out) && rules_file_out)
+ *rules_file_out = g_strdup(out);
+ out += strlen(out) + 1;
+
+ /* if user is interested in rules only - don't waste the time */
+ if (!data) {
+ XFree(prop_data);
+ return TRUE;
+ }
+
+ if ((out - prop_data) < nitems) {
+ if (*out)
+ data->model = g_strdup(out);
+ out += strlen(out) + 1;
+ }
+
+ if ((out - prop_data) < nitems) {
+ xkl_config_rec_split_layouts(data, out);
+ out += strlen(out) + 1;
+ }
+
+ if ((out - prop_data) < nitems) {
+ gint nv, nl;
+ gchar **layout, **variant;
+ xkl_config_rec_split_variants(data, out);
+ /*
+ Now have to ensure that number of variants matches the number of layouts
+ The 'remainder' is filled with NULLs (not ""s!)
+ */
+
+ nv = g_strv_length(data->variants);
+ nl = g_strv_length(data->layouts);
+ if (nv < nl) {
+ data->variants = g_realloc(data->variants,
+ (nl +
+ 1) * sizeof(char *));
+ memset(data->variants + nv + 1, 0,
+ (nl - nv) * sizeof(char *));
+ }
+ /* take variants from layouts like ru(winkeys) */
+ layout = data->layouts;
+ variant = data->variants;
+ while (*layout != NULL && *variant != NULL) {
+ gchar *varstart = g_strstr_len(*layout, -1, "(");
+ if (varstart != NULL) {
+ gchar *varend =
+ g_strstr_len(varstart, -1, ")");
+ if (varend != NULL) {
+ gint varlen = varend - varstart;
+ gint laylen = varstart - *layout;
+ /* I am not sure - but I assume variants in layout have priority */
+ gchar *var = *variant =
+ (*variant !=
+ NULL) ? g_realloc(*variant,
+ varlen) :
+ g_new(gchar, varlen);
+ memcpy(var, varstart + 1,
+ --varlen);
+ var[varlen] = '\0';
+ /* Resize the original layout */
+ ((char *)
+ g_realloc(*layout,
+ laylen + 1))[laylen] =
+ '\0';
+ }
+ }
+ layout++;
+ variant++;
+ }
+ out += strlen(out) + 1;
+ }
+
+ if ((out - prop_data) < nitems) {
+ xkl_config_rec_split_options(data, out);
+ }
+ XFree(prop_data);
+ return TRUE;
}
/* taken from XFree86 maprules.c */
-gboolean xkl_set_names_prop( Atom rules_atom,
- gchar *rules_file,
- const XklConfigRec * data )
+gboolean
+xkl_set_names_prop(Atom rules_atom,
+ gchar * rules_file, const XklConfigRec * data)
{
- gint len, rv;
- gchar *pval;
- gchar *next;
- gchar *all_layouts = xkl_config_rec_merge_layouts( data );
- gchar *all_variants = xkl_config_rec_merge_variants( data );
- gchar *all_options = xkl_config_rec_merge_options( data );
-
- len = ( rules_file ? strlen( rules_file ) : 0 );
- len += ( data->model ? strlen( data->model ) : 0 );
- len += ( all_layouts ? strlen( all_layouts ) : 0 );
- len += ( all_variants ? strlen( all_variants ) : 0 );
- len += ( all_options ? strlen( all_options ) : 0 );
- if( len < 1 )
- return TRUE;
-
- len += 5; /* trailing NULs */
-
- pval = next = g_new( char, len + 1 );
- if( !pval )
- {
- xkl_last_error_message = "Could not allocate buffer";
- if ( all_layouts != NULL ) g_free( all_layouts );
- if ( all_variants != NULL ) g_free( all_variants );
- if ( all_options != NULL ) g_free( all_options );
- return FALSE;
- }
- if( rules_file )
- {
- strcpy( next, rules_file );
- next += strlen( rules_file );
- }
- *next++ = '\0';
- if( data->model )
- {
- strcpy( next, data->model );
- next += strlen( data->model );
- }
- *next++ = '\0';
- if( data->layouts )
- {
- strcpy( next, all_layouts );
- next += strlen( all_layouts );
- }
- *next++ = '\0';
- if( data->variants )
- {
- strcpy( next, all_variants );
- next += strlen( all_variants );
- }
- *next++ = '\0';
- if( data->options )
- {
- strcpy( next, all_options );
- next += strlen( all_options );
- }
- *next++ = '\0';
- if( ( next - pval ) != len )
- {
- xkl_debug( 150, "Illegal final position: %d/%d\n", ( next - pval ), len );
- if ( all_layouts != NULL ) g_free( all_layouts );
- if ( all_variants != NULL ) g_free( all_variants );
- if ( all_options != NULL ) g_free( all_options );
- g_free( pval );
- xkl_last_error_message = "Internal property parsing error";
- return FALSE;
- }
-
- rv = XChangeProperty( xkl_display, xkl_root_window, rules_atom, XA_STRING, 8,
- PropModeReplace, ( unsigned char * ) pval, len );
- XSync( xkl_display, False );
+ gint len, rv;
+ gchar *pval;
+ gchar *next;
+ gchar *all_layouts = xkl_config_rec_merge_layouts(data);
+ gchar *all_variants = xkl_config_rec_merge_variants(data);
+ gchar *all_options = xkl_config_rec_merge_options(data);
+
+ len = (rules_file ? strlen(rules_file) : 0);
+ len += (data->model ? strlen(data->model) : 0);
+ len += (all_layouts ? strlen(all_layouts) : 0);
+ len += (all_variants ? strlen(all_variants) : 0);
+ len += (all_options ? strlen(all_options) : 0);
+ if (len < 1)
+ return TRUE;
+
+ len += 5; /* trailing NULs */
+
+ pval = next = g_new(char, len + 1);
+ if (!pval) {
+ xkl_last_error_message = "Could not allocate buffer";
+ if (all_layouts != NULL)
+ g_free(all_layouts);
+ if (all_variants != NULL)
+ g_free(all_variants);
+ if (all_options != NULL)
+ g_free(all_options);
+ return FALSE;
+ }
+ if (rules_file) {
+ strcpy(next, rules_file);
+ next += strlen(rules_file);
+ }
+ *next++ = '\0';
+ if (data->model) {
+ strcpy(next, data->model);
+ next += strlen(data->model);
+ }
+ *next++ = '\0';
+ if (data->layouts) {
+ strcpy(next, all_layouts);
+ next += strlen(all_layouts);
+ }
+ *next++ = '\0';
+ if (data->variants) {
+ strcpy(next, all_variants);
+ next += strlen(all_variants);
+ }
+ *next++ = '\0';
+ if (data->options) {
+ strcpy(next, all_options);
+ next += strlen(all_options);
+ }
+ *next++ = '\0';
+ if ((next - pval) != len) {
+ xkl_debug(150, "Illegal final position: %d/%d\n",
+ (next - pval), len);
+ if (all_layouts != NULL)
+ g_free(all_layouts);
+ if (all_variants != NULL)
+ g_free(all_variants);
+ if (all_options != NULL)
+ g_free(all_options);
+ g_free(pval);
+ xkl_last_error_message = "Internal property parsing error";
+ return FALSE;
+ }
+
+ rv = XChangeProperty(xkl_display, xkl_root_window, rules_atom,
+ XA_STRING, 8, PropModeReplace,
+ (unsigned char *) pval, len);
+ XSync(xkl_display, False);
#if 0
- for( i = len - 1; --i >= 0; )
- if( pval[i] == '\0' )
- pval[i] = '?';
- XklDebug( 150, "Stored [%s] of length %d to [%s] of %X: %d\n", pval, len,
- propName, _xklRootWindow, rv );
+ for (i = len - 1; --i >= 0;)
+ if (pval[i] == '\0')
+ pval[i] = '?';
+ XklDebug(150, "Stored [%s] of length %d to [%s] of %X: %d\n", pval,
+ len, propName, _xklRootWindow, rv);
#endif
- if ( all_layouts != NULL ) g_free( all_layouts );
- if ( all_variants != NULL ) g_free( all_variants );
- if ( all_options != NULL ) g_free( all_options );
- g_free( pval );
- return TRUE;
+ if (all_layouts != NULL)
+ g_free(all_layouts);
+ if (all_variants != NULL)
+ g_free(all_variants);
+ if (all_options != NULL)
+ g_free(all_options);
+ g_free(pval);
+ return TRUE;
}
diff --git a/libxklavier/xklavier_toplevel.c b/libxklavier/xklavier_toplevel.c
index d8ab632..f9f31ea 100644
--- a/libxklavier/xklavier_toplevel.c
+++ b/libxklavier/xklavier_toplevel.c
@@ -9,26 +9,25 @@
Window xkl_toplevel_window_prev;
-void xkl_toplevel_window_set_transparent( Window toplevel_win,
- gboolean transparent )
+void
+xkl_toplevel_window_set_transparent(Window toplevel_win,
+ gboolean transparent)
{
- gboolean oldval;
-
- oldval = xkl_window_is_transparent( toplevel_win );
- xkl_debug( 150, "toplevel_win " WINID_FORMAT " was %stransparent\n",
- toplevel_win, oldval ? "" : "not " );
- if( transparent && !oldval )
- {
- CARD32 prop = 1;
- XChangeProperty( xkl_display, toplevel_win,
- xkl_atoms[XKLAVIER_TRANSPARENT],
- XA_INTEGER, 32, PropModeReplace,
- ( const unsigned char * ) &prop, 1 );
- } else if( !transparent && oldval )
- {
- XDeleteProperty( xkl_display, toplevel_win,
- xkl_atoms[XKLAVIER_TRANSPARENT] );
- }
+ gboolean oldval;
+
+ oldval = xkl_window_is_transparent(toplevel_win);
+ xkl_debug(150, "toplevel_win " WINID_FORMAT " was %stransparent\n",
+ toplevel_win, oldval ? "" : "not ");
+ if (transparent && !oldval) {
+ CARD32 prop = 1;
+ XChangeProperty(xkl_display, toplevel_win,
+ xkl_atoms[XKLAVIER_TRANSPARENT],
+ XA_INTEGER, 32, PropModeReplace,
+ (const unsigned char *) &prop, 1);
+ } else if (!transparent && oldval) {
+ XDeleteProperty(xkl_display, toplevel_win,
+ xkl_atoms[XKLAVIER_TRANSPARENT]);
+ }
}
/**
@@ -37,99 +36,101 @@ void xkl_toplevel_window_set_transparent( Window toplevel_win,
* and register ourselves us listeners.
* Note: User's callback is called
*/
-void xkl_toplevel_window_add( Window toplevel_win, Window parent,
- gboolean ignore_existing_state,
- XklState * init_state )
+void
+xkl_toplevel_window_add(Window toplevel_win, Window parent,
+ gboolean ignore_existing_state,
+ XklState * init_state)
{
- XklState state = *init_state;
- gint default_group_to_use = -1;
-
- if( toplevel_win == xkl_root_window )
- xkl_debug( 150, "??? root app win ???\n" );
-
- xkl_debug( 150, "Trying to add window " WINID_FORMAT "/%s with group %d\n",
- toplevel_win, xkl_window_get_debug_title( toplevel_win),
- init_state->group );
-
- if( !ignore_existing_state )
- {
- gboolean have_state = xkl_toplevel_window_get_state( toplevel_win, &state );
-
- if( have_state )
- {
- xkl_debug( 150,
- "The window " WINID_FORMAT
- " does not require to be added, it already has the xklavier state \n",
- toplevel_win );
- return;
- }
- }
-
- if( xkl_new_window_callback != NULL )
- default_group_to_use = ( *xkl_new_window_callback ) ( toplevel_win,
- parent,
- xkl_new_window_callback_data );
-
- if( default_group_to_use == -1 )
- default_group_to_use = xkl_default_group;
-
- if( default_group_to_use != -1 )
- state.group = default_group_to_use;
-
- xkl_toplevel_window_save_state( toplevel_win, &state );
- xkl_select_input_merging( toplevel_win, FocusChangeMask | PropertyChangeMask );
-
- if( default_group_to_use != -1 )
- {
- if( xkl_current_client == toplevel_win )
- {
- if( ( xkl_secondary_groups_mask & ( 1 << default_group_to_use ) ) != 0 )
- xkl_group_allow_one_switch_to_secondary();
- xkl_group_lock( default_group_to_use );
- }
- }
-
- if( parent == ( Window ) NULL )
- parent = xkl_get_registered_parent( toplevel_win );
-
- xkl_debug( 150, "done\n" );
+ XklState state = *init_state;
+ gint default_group_to_use = -1;
+
+ if (toplevel_win == xkl_root_window)
+ xkl_debug(150, "??? root app win ???\n");
+
+ xkl_debug(150,
+ "Trying to add window " WINID_FORMAT
+ "/%s with group %d\n", toplevel_win,
+ xkl_window_get_debug_title(toplevel_win),
+ init_state->group);
+
+ if (!ignore_existing_state) {
+ gboolean have_state =
+ xkl_toplevel_window_get_state(toplevel_win, &state);
+
+ if (have_state) {
+ xkl_debug(150,
+ "The window " WINID_FORMAT
+ " does not require to be added, it already has the xklavier state \n",
+ toplevel_win);
+ return;
+ }
+ }
+
+ if (xkl_new_window_callback != NULL)
+ default_group_to_use =
+ (*xkl_new_window_callback) (toplevel_win, parent,
+ xkl_new_window_callback_data);
+
+ if (default_group_to_use == -1)
+ default_group_to_use = xkl_default_group;
+
+ if (default_group_to_use != -1)
+ state.group = default_group_to_use;
+
+ xkl_toplevel_window_save_state(toplevel_win, &state);
+ xkl_select_input_merging(toplevel_win,
+ FocusChangeMask | PropertyChangeMask);
+
+ if (default_group_to_use != -1) {
+ if (xkl_current_client == toplevel_win) {
+ if ((xkl_secondary_groups_mask &
+ (1 << default_group_to_use)) != 0)
+ xkl_group_allow_one_switch_to_secondary();
+ xkl_group_lock(default_group_to_use);
+ }
+ }
+
+ if (parent == (Window) NULL)
+ parent = xkl_get_registered_parent(toplevel_win);
+
+ xkl_debug(150, "done\n");
}
/**
* Checks the window and goes up
*/
-gboolean xkl_toplevel_window_find_bottom_to_top( Window win,
- Window *toplevel_win_out )
+gboolean
+xkl_toplevel_window_find_bottom_to_top(Window win,
+ Window * toplevel_win_out)
{
- Window parent = ( Window ) NULL, rwin = ( Window ) NULL, *children = NULL;
- guint num = 0;
-
- if( win == ( Window ) NULL || win == xkl_root_window )
- {
- *toplevel_win_out = win;
- xkl_last_error_message = "The window is either 0 or root";
- return FALSE;
- }
-
- if( xkl_window_has_wm_state( win ) )
- {
- *toplevel_win_out = win;
- return TRUE;
- }
-
- xkl_last_error_code =
- xkl_status_query_tree( win, &rwin, &parent, &children, &num );
-
- if( xkl_last_error_code != Success )
- {
- *toplevel_win_out = ( Window ) NULL;
- return FALSE;
- }
-
- if( children != NULL )
- XFree( children );
-
- return xkl_toplevel_window_find_bottom_to_top( parent, toplevel_win_out );
+ Window parent = (Window) NULL, rwin = (Window) NULL, *children =
+ NULL;
+ guint num = 0;
+
+ if (win == (Window) NULL || win == xkl_root_window) {
+ *toplevel_win_out = win;
+ xkl_last_error_message = "The window is either 0 or root";
+ return FALSE;
+ }
+
+ if (xkl_window_has_wm_state(win)) {
+ *toplevel_win_out = win;
+ return TRUE;
+ }
+
+ xkl_last_error_code =
+ xkl_status_query_tree(win, &rwin, &parent, &children, &num);
+
+ if (xkl_last_error_code != Success) {
+ *toplevel_win_out = (Window) NULL;
+ return FALSE;
+ }
+
+ if (children != NULL)
+ XFree(children);
+
+ return xkl_toplevel_window_find_bottom_to_top(parent,
+ toplevel_win_out);
}
/**
@@ -139,165 +140,171 @@ gboolean xkl_toplevel_window_find_bottom_to_top( Window win,
* Then, goes to parent.
* NOTE: root window cannot be "App window" under normal circumstances
*/
-gboolean xkl_toplevel_window_find( Window win, Window * toplevel_win_out )
+gboolean
+xkl_toplevel_window_find(Window win, Window * toplevel_win_out)
{
- Window parent = ( Window ) NULL,
- rwin = ( Window ) NULL, *children = NULL, *child;
- guint num = 0;
- gboolean rv;
-
- if( win == ( Window ) NULL || win == xkl_root_window )
- {
- *toplevel_win_out = ( Window ) NULL;
- 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",
- win );
- return FALSE;
- }
-
- if( xkl_window_has_wm_state( win ) )
- {
- *toplevel_win_out = win;
- return TRUE;
- }
-
- xkl_last_error_code =
- xkl_status_query_tree( win, &rwin, &parent, &children, &num );
-
- if( xkl_last_error_code != Success )
- {
- *toplevel_win_out = ( Window ) NULL;
- xkl_debug( 150,
- "Could not get tree for window " WINID_FORMAT
- " so could not get the app window for it\n", win );
- return FALSE;
- }
+ Window parent = (Window) NULL,
+ rwin = (Window) NULL, *children = NULL, *child;
+ guint num = 0;
+ gboolean rv;
+
+ if (win == (Window) NULL || win == xkl_root_window) {
+ *toplevel_win_out = (Window) NULL;
+ 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",
+ win);
+ return FALSE;
+ }
+
+ if (xkl_window_has_wm_state(win)) {
+ *toplevel_win_out = win;
+ return TRUE;
+ }
+
+ xkl_last_error_code =
+ xkl_status_query_tree(win, &rwin, &parent, &children, &num);
+
+ if (xkl_last_error_code != Success) {
+ *toplevel_win_out = (Window) NULL;
+ xkl_debug(150,
+ "Could not get tree for window " WINID_FORMAT
+ " so could not get the app window for it\n",
+ win);
+ return FALSE;
+ }
/**
* Here we first check the children (in case win is just above some "App Window")
* and then go upstairs
*/
- child = children;
- while( num )
- {
- if( xkl_window_has_wm_state( *child ) )
- {
- *toplevel_win_out = *child;
- if( children != NULL )
- XFree( children );
- return TRUE;
- }
- child++;
- num--;
- }
-
- if( children != NULL )
- XFree( children );
-
- rv = xkl_toplevel_window_find_bottom_to_top( parent, toplevel_win_out );
-
- if( !rv )
- xkl_debug( 200, "Could not get the app window for " WINID_FORMAT "/%s\n",
- win, xkl_window_get_debug_title( win ) );
-
- return rv;
+ child = children;
+ while (num) {
+ if (xkl_window_has_wm_state(*child)) {
+ *toplevel_win_out = *child;
+ if (children != NULL)
+ XFree(children);
+ return TRUE;
+ }
+ child++;
+ num--;
+ }
+
+ if (children != NULL)
+ XFree(children);
+
+ rv = xkl_toplevel_window_find_bottom_to_top(parent,
+ toplevel_win_out);
+
+ if (!rv)
+ xkl_debug(200,
+ "Could not get the app window for " WINID_FORMAT
+ "/%s\n", win, xkl_window_get_debug_title(win));
+
+ return rv;
}
/**
* Gets the state from the window property
*/
-gboolean xkl_toplevel_window_get_state( Window toplevel_win, XklState * state_out )
+gboolean
+xkl_toplevel_window_get_state(Window toplevel_win, XklState * state_out)
{
- Atom type_ret;
- int format_ret;
- unsigned long nitems, rest;
- CARD32 *prop = NULL;
- gboolean ret = FALSE;
-
- gint grp = -1;
- guint inds = 0;
-
- if( ( XGetWindowProperty
- ( xkl_display, toplevel_win, xkl_atoms[XKLAVIER_STATE], 0L,
- XKLAVIER_STATE_PROP_LENGTH, False,
- XA_INTEGER, &type_ret, &format_ret, &nitems, &rest,
- ( unsigned char ** ) ( void * ) &prop ) == Success )
- && ( type_ret == XA_INTEGER ) && ( format_ret == 32 ) )
- {
- grp = prop[0];
- if( grp >= xkl_groups_get_num( ) || grp < 0 )
- grp = 0;
-
- inds = prop[1];
-
- if( state_out != NULL )
- {
- state_out->group = grp;
- state_out->indicators = inds;
- }
- if( prop != NULL )
- XFree( prop );
-
- ret = TRUE;
- }
-
- if( ret )
- xkl_debug( 150,
- "Appwin " WINID_FORMAT
- ", '%s' has the group %d, indicators %X\n", toplevel_win,
- xkl_window_get_debug_title( toplevel_win ), grp, inds );
- else
- xkl_debug( 150, "Appwin " WINID_FORMAT ", '%s' does not have state\n",
- toplevel_win, xkl_window_get_debug_title( toplevel_win ) );
-
- return ret;
+ Atom type_ret;
+ int format_ret;
+ unsigned long nitems, rest;
+ CARD32 *prop = NULL;
+ gboolean ret = FALSE;
+
+ gint grp = -1;
+ guint inds = 0;
+
+ if ((XGetWindowProperty
+ (xkl_display, toplevel_win, xkl_atoms[XKLAVIER_STATE], 0L,
+ XKLAVIER_STATE_PROP_LENGTH, False,
+ XA_INTEGER, &type_ret, &format_ret, &nitems, &rest,
+ (unsigned char **) (void *) &prop) == Success)
+ && (type_ret == XA_INTEGER) && (format_ret == 32)) {
+ grp = prop[0];
+ if (grp >= xkl_groups_get_num() || grp < 0)
+ grp = 0;
+
+ inds = prop[1];
+
+ if (state_out != NULL) {
+ state_out->group = grp;
+ state_out->indicators = inds;
+ }
+ if (prop != NULL)
+ XFree(prop);
+
+ ret = TRUE;
+ }
+
+ if (ret)
+ xkl_debug(150,
+ "Appwin " WINID_FORMAT
+ ", '%s' has the group %d, indicators %X\n",
+ toplevel_win,
+ xkl_window_get_debug_title(toplevel_win), grp,
+ inds);
+ else
+ xkl_debug(150,
+ "Appwin " WINID_FORMAT
+ ", '%s' does not have state\n", toplevel_win,
+ xkl_window_get_debug_title(toplevel_win));
+
+ return ret;
}
-
+
/**
* Deletes the state from the window properties
*/
-void xkl_toplevel_window_remove_state( Window toplevel_win )
+void
+xkl_toplevel_window_remove_state(Window toplevel_win)
{
- XDeleteProperty( xkl_display, toplevel_win, xkl_atoms[XKLAVIER_STATE] );
+ XDeleteProperty(xkl_display, toplevel_win,
+ xkl_atoms[XKLAVIER_STATE]);
}
/**
* Saves the state into the window properties
*/
-void xkl_toplevel_window_save_state( Window toplevel_win, XklState * state )
+void
+xkl_toplevel_window_save_state(Window toplevel_win, XklState * state)
{
- CARD32 prop[XKLAVIER_STATE_PROP_LENGTH];
+ CARD32 prop[XKLAVIER_STATE_PROP_LENGTH];
- prop[0] = state->group;
- prop[1] = state->indicators;
+ prop[0] = state->group;
+ prop[1] = state->indicators;
- XChangeProperty( xkl_display, toplevel_win, xkl_atoms[XKLAVIER_STATE],
- XA_INTEGER, 32, PropModeReplace,
- ( const unsigned char * ) prop,
- XKLAVIER_STATE_PROP_LENGTH );
+ XChangeProperty(xkl_display, toplevel_win,
+ xkl_atoms[XKLAVIER_STATE], XA_INTEGER, 32,
+ PropModeReplace, (const unsigned char *) prop,
+ XKLAVIER_STATE_PROP_LENGTH);
- xkl_debug( 160,
- "Saved the group %d, indicators %X for appwin " WINID_FORMAT "\n",
- state->group, state->indicators, toplevel_win );
+ xkl_debug(160,
+ "Saved the group %d, indicators %X for appwin "
+ WINID_FORMAT "\n", state->group, state->indicators,
+ toplevel_win);
}
-gboolean xkl_toplevel_window_is_transparent( Window toplevel_win )
+gboolean
+xkl_toplevel_window_is_transparent(Window toplevel_win)
{
- Atom type_ret;
- int format_ret;
- unsigned long nitems, rest;
- CARD32 *prop = NULL;
- if( ( XGetWindowProperty
- ( xkl_display, toplevel_win, xkl_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 )
- XFree( prop );
- return TRUE;
- }
- return FALSE;
+ Atom type_ret;
+ int format_ret;
+ unsigned long nitems, rest;
+ CARD32 *prop = NULL;
+ if ((XGetWindowProperty
+ (xkl_display, toplevel_win, xkl_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)
+ XFree(prop);
+ return TRUE;
+ }
+ return FALSE;
}
diff --git a/libxklavier/xklavier_util.c b/libxklavier/xklavier_util.c
index 8b77949..ed19658 100644
--- a/libxklavier/xklavier_util.c
+++ b/libxklavier/xklavier_util.c
@@ -7,94 +7,101 @@
#include "xklavier_private.h"
-XklState *xkl_state_get_current( )
+XklState *
+xkl_state_get_current()
{
- return &xkl_current_state;
+ return &xkl_current_state;
}
-const gchar *xkl_get_last_error( )
+const gchar *
+xkl_get_last_error()
{
- return xkl_last_error_message;
+ return xkl_last_error_message;
}
-gchar *xkl_window_get_title( Window w )
+gchar *
+xkl_window_get_title(Window w)
{
- Atom type_ret;
- int format_ret;
- unsigned long nitems, rest;
- unsigned char *prop;
-
- if( Success == XGetWindowProperty( xkl_display, w, xkl_atoms[WM_NAME], 0L,
- -1L, False, XA_STRING, &type_ret,
- &format_ret, &nitems, &rest, &prop ) )
- return (gchar *)prop;
- else
- return NULL;
+ Atom type_ret;
+ int format_ret;
+ unsigned long nitems, rest;
+ unsigned char *prop;
+
+ if (Success ==
+ XGetWindowProperty(xkl_display, w, xkl_atoms[WM_NAME], 0L, -1L,
+ False, XA_STRING, &type_ret, &format_ret,
+ &nitems, &rest, &prop))
+ return (gchar *) prop;
+ else
+ return NULL;
}
-gboolean xkl_windows_is_same_application( Window win1, Window win2 )
+gboolean
+xkl_windows_is_same_application(Window win1, Window win2)
{
- Window app1, app2;
- return xkl_toplevel_window_find( win1, &app1 ) &&
- xkl_toplevel_window_find( win2, &app2 ) && app1 == app2;
+ Window app1, app2;
+ return xkl_toplevel_window_find(win1, &app1) &&
+ xkl_toplevel_window_find(win2, &app2) && app1 == app2;
}
-gboolean xkl_state_get( Window win, XklState * state_out )
+gboolean
+xkl_state_get(Window win, XklState * state_out)
{
- Window app_win;
+ Window app_win;
- if( !xkl_toplevel_window_find( win, &app_win ) )
- {
- if( state_out != NULL )
- state_out->group = -1;
- return FALSE;
- }
+ if (!xkl_toplevel_window_find(win, &app_win)) {
+ if (state_out != NULL)
+ state_out->group = -1;
+ return FALSE;
+ }
- return xkl_toplevel_window_get_state( app_win, state_out );
+ return xkl_toplevel_window_get_state(app_win, state_out);
}
-void xkl_state_delete( Window win )
+void
+xkl_state_delete(Window win)
{
- Window app_win;
+ Window app_win;
- if( xkl_toplevel_window_find( win, &app_win ) )
- xkl_toplevel_window_remove_state( app_win );
+ if (xkl_toplevel_window_find(win, &app_win))
+ xkl_toplevel_window_remove_state(app_win);
}
-void xkl_state_save( Window win, XklState * state )
+void
+xkl_state_save(Window win, XklState * state)
{
- Window app_win;
+ Window app_win;
- if( !( xkl_listener_type & XKLL_MANAGE_WINDOW_STATES ) )
- return;
+ if (!(xkl_listener_type & XKLL_MANAGE_WINDOW_STATES))
+ return;
- if( xkl_toplevel_window_find( win, &app_win ) )
- xkl_toplevel_window_save_state( app_win, state );
+ if (xkl_toplevel_window_find(win, &app_win))
+ xkl_toplevel_window_save_state(app_win, state);
}
/**
* Prepares the name of window suitable for debugging (32characters long).
*/
-gchar *xkl_window_get_debug_title( Window win )
+gchar *
+xkl_window_get_debug_title(Window win)
{
- static gchar sname[33];
- gchar *name;
- strcpy( sname, "NULL" );
- if( win != ( Window ) NULL )
- {
- name = xkl_window_get_title( win );
- if( name != NULL )
- {
- snprintf( sname, sizeof( sname ), "%.32s", name );
- g_free( name );
- }
- }
- return sname;
+ static gchar sname[33];
+ gchar *name;
+ strcpy(sname, "NULL");
+ if (win != (Window) NULL) {
+ name = xkl_window_get_title(win);
+ if (name != NULL) {
+ snprintf(sname, sizeof(sname), "%.32s", name);
+ g_free(name);
+ }
+ }
+ return sname;
}
-Window xkl_window_get_current( )
+Window
+xkl_window_get_current()
{
- return xkl_current_client;
+ return xkl_current_client;
}
/**
@@ -102,172 +109,185 @@ Window xkl_window_get_current( )
* All the windows with WM_STATE are added.
* All the windows within level 0 are listened for focus and property
*/
-gboolean xkl_load_subtree( Window window, gint level, XklState * init_state )
+gboolean
+xkl_load_subtree(Window window, gint level, XklState * init_state)
{
- Window rwin = ( Window ) NULL,
- parent = ( Window ) NULL, *children = NULL, *child;
- guint num = 0;
- gboolean retval = True;
-
- xkl_last_error_code =
- xkl_status_query_tree( window, &rwin, &parent, &children, &num );
-
- if( xkl_last_error_code != Success )
- {
- return FALSE;
- }
-
- child = children;
- while( num )
- {
- if( xkl_window_has_wm_state( *child ) )
- {
- xkl_debug( 160, "Window " WINID_FORMAT " '%s' has WM_STATE so we'll add it\n",
- *child, xkl_window_get_debug_title( *child ) );
- xkl_toplevel_window_add( *child, window, TRUE, init_state );
- } else
- {
- xkl_debug( 200, "Window " WINID_FORMAT " '%s' does not have have WM_STATE so we'll not add it\n",
- *child, xkl_window_get_debug_title( *child ) );
-
- if( level == 0 )
- {
- xkl_debug( 200, "But we are at level 0 so we'll spy on it\n" );
- xkl_select_input_merging( *child,
- FocusChangeMask | PropertyChangeMask );
- } else
- xkl_debug( 200, "And we are at level %d so we'll not spy on it\n",
- level );
-
- retval = xkl_load_subtree( *child, level + 1, init_state );
- }
-
- child++;
- num--;
- }
-
- if( children != NULL )
- XFree( children );
-
- return retval;
+ Window rwin = (Window) NULL,
+ parent = (Window) NULL, *children = NULL, *child;
+ guint num = 0;
+ gboolean retval = True;
+
+ xkl_last_error_code =
+ xkl_status_query_tree(window, &rwin, &parent, &children, &num);
+
+ if (xkl_last_error_code != Success) {
+ return FALSE;
+ }
+
+ child = children;
+ while (num) {
+ if (xkl_window_has_wm_state(*child)) {
+ xkl_debug(160,
+ "Window " WINID_FORMAT
+ " '%s' has WM_STATE so we'll add it\n",
+ *child,
+ xkl_window_get_debug_title(*child));
+ xkl_toplevel_window_add(*child, window, TRUE,
+ init_state);
+ } else {
+ xkl_debug(200,
+ "Window " WINID_FORMAT
+ " '%s' does not have have WM_STATE so we'll not add it\n",
+ *child,
+ xkl_window_get_debug_title(*child));
+
+ if (level == 0) {
+ xkl_debug(200,
+ "But we are at level 0 so we'll spy on it\n");
+ xkl_select_input_merging(*child,
+ FocusChangeMask |
+ PropertyChangeMask);
+ } else
+ xkl_debug(200,
+ "And we are at level %d so we'll not spy on it\n",
+ level);
+
+ retval =
+ xkl_load_subtree(*child, level + 1,
+ init_state);
+ }
+
+ child++;
+ num--;
+ }
+
+ if (children != NULL)
+ XFree(children);
+
+ return retval;
}
/**
* Checks whether given window has WM_STATE property (i.e. "App window").
*/
-gboolean xkl_window_has_wm_state( Window win )
-{ /* ICCCM 4.1.3.1 */
- Atom type = None;
- int format;
- unsigned long nitems;
- unsigned long after;
- unsigned char *data = NULL; /* Helps in the case of BadWindow error */
-
- XGetWindowProperty( xkl_display, win, xkl_atoms[WM_STATE], 0, 0, False,
- xkl_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) */
- return type != None;
+gboolean
+xkl_window_has_wm_state(Window win)
+{ /* ICCCM 4.1.3.1 */
+ Atom type = None;
+ int format;
+ unsigned long nitems;
+ unsigned long after;
+ unsigned char *data = NULL; /* Helps in the case of BadWindow error */
+
+ XGetWindowProperty(xkl_display, win, xkl_atoms[WM_STATE], 0, 0,
+ False, xkl_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) */
+ return type != None;
}
/**
* Finds out the official parent window (accortind to XQueryTree)
*/
-Window xkl_get_registered_parent( Window win )
+Window
+xkl_get_registered_parent(Window win)
{
- Window parent = ( Window ) NULL, rw = ( Window ) NULL, *children = NULL;
- guint nchildren = 0;
+ Window parent = (Window) NULL, rw = (Window) NULL, *children =
+ NULL;
+ guint nchildren = 0;
- xkl_last_error_code =
- xkl_status_query_tree( win, &rw, &parent, &children, &nchildren );
+ xkl_last_error_code =
+ xkl_status_query_tree(win, &rw, &parent, &children,
+ &nchildren);
- if( children != NULL )
- XFree( children );
+ if (children != NULL)
+ XFree(children);
- return xkl_last_error_code == Success ? parent : ( Window ) NULL;
+ return xkl_last_error_code == Success ? parent : (Window) NULL;
}
/**
* Make sure about the result. Origial XQueryTree is pretty stupid beast:)
*/
-Status xkl_status_query_tree( Window w,
- Window * root_out,
- Window * parent_out,
- Window ** children_out,
- guint *nchildren_out )
+Status
+xkl_status_query_tree(Window w,
+ Window * root_out,
+ Window * parent_out,
+ Window ** children_out, guint * nchildren_out)
{
- gboolean result;
- unsigned int nc;
-
- result = ( gboolean ) XQueryTree( xkl_display,
- w,
- root_out,
- parent_out,
- children_out, &nc );
- *nchildren_out = nc;
-
- if( !result )
- {
- xkl_debug( 160,
- "Could not get tree info for window " WINID_FORMAT ": %d\n", w,
- result );
- xkl_last_error_message = "Could not get the tree info";
- }
-
- return result ? Success : FirstExtensionError;
+ gboolean result;
+ unsigned int nc;
+
+ result = (gboolean) XQueryTree(xkl_display,
+ w,
+ root_out,
+ parent_out, children_out, &nc);
+ *nchildren_out = nc;
+
+ if (!result) {
+ xkl_debug(160,
+ "Could not get tree info for window "
+ WINID_FORMAT ": %d\n", w, result);
+ xkl_last_error_message = "Could not get the tree info";
+ }
+
+ return result ? Success : FirstExtensionError;
}
-const gchar *xkl_event_get_name( gint type )
+const gchar *
+xkl_event_get_name(gint type)
{
- /* Not really good to use the fact of consecutivity
- but X protocol is already standartized so... */
- static const gchar *evt_names[] = {
- "KeyPress",
- "KeyRelease",
- "ButtonPress",
- "ButtonRelease",
- "MotionNotify",
- "EnterNotify",
- "LeaveNotify",
- "FocusIn",
- "FocusOut",
- "KeymapNotify",
- "Expose",
- "GraphicsExpose",
- "NoExpose",
- "VisibilityNotify",
- "CreateNotify",
- "DestroyNotify",
- "UnmapNotify",
- "MapNotify",
- "MapRequest",
- "ReparentNotify",
- "ConfigureNotify",
- "ConfigureRequest",
- "GravityNotify",
- "ResizeRequest",
- "CirculateNotify",
- "CirculateRequest",
- "PropertyNotify",
- "SelectionClear",
- "SelectionRequest",
- "SelectionNotify",
- "ColormapNotify", "ClientMessage", "MappingNotify", "LASTEvent"
- };
- type -= KeyPress;
- if( type < 0 ||
- type >= ( sizeof( evt_names ) / sizeof( evt_names[0] ) ) )
- return "UNKNOWN";
- return evt_names[type];
+ /* Not really good to use the fact of consecutivity
+ but X protocol is already standartized so... */
+ static const gchar *evt_names[] = {
+ "KeyPress",
+ "KeyRelease",
+ "ButtonPress",
+ "ButtonRelease",
+ "MotionNotify",
+ "EnterNotify",
+ "LeaveNotify",
+ "FocusIn",
+ "FocusOut",
+ "KeymapNotify",
+ "Expose",
+ "GraphicsExpose",
+ "NoExpose",
+ "VisibilityNotify",
+ "CreateNotify",
+ "DestroyNotify",
+ "UnmapNotify",
+ "MapNotify",
+ "MapRequest",
+ "ReparentNotify",
+ "ConfigureNotify",
+ "ConfigureRequest",
+ "GravityNotify",
+ "ResizeRequest",
+ "CirculateNotify",
+ "CirculateRequest",
+ "PropertyNotify",
+ "SelectionClear",
+ "SelectionRequest",
+ "SelectionNotify",
+ "ColormapNotify", "ClientMessage", "MappingNotify",
+ "LASTEvent"
+ };
+ type -= KeyPress;
+ if (type < 0 || type >= (sizeof(evt_names) / sizeof(evt_names[0])))
+ return "UNKNOWN";
+ return evt_names[type];
}
-void xkl_current_state_update( int group, unsigned indicators, const char reason[] )
+void
+xkl_current_state_update(int group, unsigned indicators,
+ const char reason[])
{
- xkl_debug( 150,
- "Updating the current state with [g:%d/i:%u], reason: %s\n",
- group, indicators, reason );
- xkl_current_state.group = group;
- xkl_current_state.indicators = indicators;
+ xkl_debug(150,
+ "Updating the current state with [g:%d/i:%u], reason: %s\n",
+ group, indicators, reason);
+ xkl_current_state.group = group;
+ xkl_current_state.indicators = indicators;
}
diff --git a/libxklavier/xklavier_xkb.c b/libxklavier/xklavier_xkb.c
index 4ca88de..fb439e2 100644
--- a/libxklavier/xklavier_xkb.c
+++ b/libxklavier/xklavier_xkb.c
@@ -20,14 +20,16 @@ gint xkl_xkb_event_type, xkl_xkb_error_code;
static gchar *group_names[XkbNumKbdGroups];
-const gchar **xkl_xkb_groups_get_names( void )
+const gchar **
+xkl_xkb_groups_get_names(void)
{
- return ( const gchar ** ) group_names;
+ return (const gchar **) group_names;
}
-gint xkl_xkb_listen_pause( void )
+gint
+xkl_xkb_listen_pause(void)
{
- XkbSelectEvents( xkl_display, XkbUseCoreKbd, XkbAllEventsMask, 0 );
+ XkbSelectEvents(xkl_display, XkbUseCoreKbd, XkbAllEventsMask, 0);
/* XkbSelectEventDetails( xkl_display,
XkbUseCoreKbd,
XkbStateNotify,
@@ -36,12 +38,13 @@ gint xkl_xkb_listen_pause( void )
!!_XklSelectInput( _xklRootWindow, 0 );
*/
- return 0;
+ return 0;
}
-gint xkl_xkb_listen_resume( void )
+gint
+xkl_xkb_listen_resume(void)
{
- /* What events we want */
+ /* What events we want */
#define XKB_EVT_MASK \
(XkbStateNotifyMask| \
XkbNamesNotifyMask| \
@@ -50,35 +53,40 @@ gint xkl_xkb_listen_resume( void )
XkbIndicatorMapNotifyMask| \
XkbNewKeyboardNotifyMask)
- XkbSelectEvents( xkl_display, XkbUseCoreKbd, XKB_EVT_MASK, XKB_EVT_MASK );
+ XkbSelectEvents(xkl_display, XkbUseCoreKbd, XKB_EVT_MASK,
+ XKB_EVT_MASK);
#define XKB_STATE_EVT_DTL_MASK \
(XkbGroupStateMask)
- XkbSelectEventDetails( xkl_display,
- XkbUseCoreKbd,
- XkbStateNotify,
- XKB_STATE_EVT_DTL_MASK, XKB_STATE_EVT_DTL_MASK );
+ XkbSelectEventDetails(xkl_display,
+ XkbUseCoreKbd,
+ XkbStateNotify,
+ XKB_STATE_EVT_DTL_MASK,
+ XKB_STATE_EVT_DTL_MASK);
#define XKB_NAMES_EVT_DTL_MASK \
(XkbGroupNamesMask|XkbIndicatorNamesMask)
- XkbSelectEventDetails( xkl_display,
- XkbUseCoreKbd,
- XkbNamesNotify,
- XKB_NAMES_EVT_DTL_MASK, XKB_NAMES_EVT_DTL_MASK );
- return 0;
+ XkbSelectEventDetails(xkl_display,
+ XkbUseCoreKbd,
+ XkbNamesNotify,
+ XKB_NAMES_EVT_DTL_MASK,
+ XKB_NAMES_EVT_DTL_MASK);
+ return 0;
}
-guint xkl_xkb_groups_get_max_num( void )
+guint
+xkl_xkb_groups_get_max_num(void)
{
- return xkl_vtable->features & XKLF_MULTIPLE_LAYOUTS_SUPPORTED ?
- XkbNumKbdGroups : 1;
+ return xkl_vtable->features & XKLF_MULTIPLE_LAYOUTS_SUPPORTED ?
+ XkbNumKbdGroups : 1;
}
-guint xkl_xkb_groups_get_num( void )
+guint
+xkl_xkb_groups_get_num(void)
{
- return xkl_xkb_desc->ctrls->num_groups;
+ return xkl_xkb_desc->ctrls->num_groups;
}
#define KBD_MASK \
@@ -88,456 +96,471 @@ guint xkl_xkb_groups_get_num( void )
#define NAMES_MASK \
( XkbGroupNamesMask | XkbIndicatorNamesMask )
-void xkl_xkb_free_all_info( void )
+void
+xkl_xkb_free_all_info(void)
{
- gint i;
- gchar **pi = xkl_indicator_names;
- for( i = 0; i < XkbNumIndicators; i++, pi++ )
- {
- /* only free non-empty ones */
- if( *pi && **pi )
- XFree( *pi );
- }
- if( xkl_xkb_desc != NULL )
- {
- int i;
- char **group_name = group_names;
- for( i = xkl_xkb_desc->ctrls->num_groups; --i >= 0; group_name++ )
- if( *group_name )
- {
- XFree( *group_name );
- *group_name = NULL;
- }
- XkbFreeKeyboard( xkl_xkb_desc, XkbAllComponentsMask, True );
- xkl_xkb_desc = NULL;
- }
-
- /* just in case - never actually happens...*/
- if( precached_xkb != NULL )
- {
- XkbFreeKeyboard( precached_xkb, XkbAllComponentsMask, True );
- precached_xkb = NULL;
- }
+ gint i;
+ gchar **pi = xkl_indicator_names;
+ for (i = 0; i < XkbNumIndicators; i++, pi++) {
+ /* only free non-empty ones */
+ if (*pi && **pi)
+ XFree(*pi);
+ }
+ if (xkl_xkb_desc != NULL) {
+ int i;
+ char **group_name = group_names;
+ for (i = xkl_xkb_desc->ctrls->num_groups; --i >= 0;
+ group_name++)
+ if (*group_name) {
+ XFree(*group_name);
+ *group_name = NULL;
+ }
+ XkbFreeKeyboard(xkl_xkb_desc, XkbAllComponentsMask, True);
+ xkl_xkb_desc = NULL;
+ }
+
+ /* just in case - never actually happens... */
+ if (precached_xkb != NULL) {
+ XkbFreeKeyboard(precached_xkb, XkbAllComponentsMask, True);
+ precached_xkb = NULL;
+ }
}
-static gboolean xkl_xkb_load_precached_xkb( void )
+static gboolean
+xkl_xkb_load_precached_xkb(void)
{
- gboolean rv = FALSE;
- Status status;
-
- precached_xkb = XkbGetMap( xkl_display, KBD_MASK, XkbUseCoreKbd );
- if( precached_xkb != NULL )
- {
- rv = Success == ( status = XkbGetControls( xkl_display,
- CTRLS_MASK,
- precached_xkb ) ) &&
- Success == ( status = XkbGetNames( xkl_display,
- NAMES_MASK,
- precached_xkb ) ) &&
- Success == ( status = XkbGetIndicatorMap( xkl_display,
- XkbAllIndicatorsMask,
- precached_xkb ) );
- if( !rv )
- {
- xkl_last_error_message = "Could not load controls/names/indicators";
- xkl_debug( 0, "%s: %d\n", xkl_last_error_message, status );
- XkbFreeKeyboard( precached_xkb, XkbAllComponentsMask, True );
- }
- }
- return rv;
+ gboolean rv = FALSE;
+ Status status;
+
+ precached_xkb = XkbGetMap(xkl_display, KBD_MASK, XkbUseCoreKbd);
+ if (precached_xkb != NULL) {
+ rv = Success == (status = XkbGetControls(xkl_display,
+ CTRLS_MASK,
+ precached_xkb)) &&
+ Success == (status = XkbGetNames(xkl_display,
+ NAMES_MASK,
+ precached_xkb)) &&
+ Success == (status = XkbGetIndicatorMap(xkl_display,
+ XkbAllIndicatorsMask,
+ precached_xkb));
+ if (!rv) {
+ xkl_last_error_message =
+ "Could not load controls/names/indicators";
+ xkl_debug(0, "%s: %d\n", xkl_last_error_message,
+ status);
+ XkbFreeKeyboard(precached_xkb,
+ XkbAllComponentsMask, True);
+ }
+ }
+ return rv;
}
-gboolean xkl_xkb_if_cached_info_equals_actual( void )
+gboolean
+xkl_xkb_if_cached_info_equals_actual(void)
{
- gint i;
- Atom *pa1, *pa2;
- gboolean rv = FALSE;
-
- if( xkl_xkb_load_precached_xkb() )
- {
- /* First, compare the number of groups */
- if( xkl_xkb_desc->ctrls->num_groups == precached_xkb->ctrls->num_groups )
- {
- /* Then, compare group names, just atoms */
- pa1 = xkl_xkb_desc->names->groups;
- pa2 = precached_xkb->names->groups;
- for( i = xkl_xkb_desc->ctrls->num_groups; --i >= 0; pa1++, pa2++ )
- if( *pa1 != *pa2 )
- break;
-
- /* Then, compare indicator names, just atoms */
- if( i < 0 )
- {
- pa1 = xkl_xkb_desc->names->indicators;
- pa2 = precached_xkb->names->indicators;
- for( i = XkbNumIndicators; --i >= 0; pa1++, pa2++ )
- if( *pa1 != *pa2 )
- break;
- rv = i < 0;
- }
- }
+ gint i;
+ Atom *pa1, *pa2;
+ gboolean rv = FALSE;
+
+ if (xkl_xkb_load_precached_xkb()) {
+ /* First, compare the number of groups */
+ if (xkl_xkb_desc->ctrls->num_groups ==
+ precached_xkb->ctrls->num_groups) {
+ /* Then, compare group names, just atoms */
+ pa1 = xkl_xkb_desc->names->groups;
+ pa2 = precached_xkb->names->groups;
+ for (i = xkl_xkb_desc->ctrls->num_groups; --i >= 0;
+ pa1++, pa2++)
+ if (*pa1 != *pa2)
+ break;
+
+ /* Then, compare indicator names, just atoms */
+ if (i < 0) {
+ pa1 = xkl_xkb_desc->names->indicators;
+ pa2 = precached_xkb->names->indicators;
+ for (i = XkbNumIndicators; --i >= 0;
+ pa1++, pa2++)
+ if (*pa1 != *pa2)
+ break;
+ rv = i < 0;
+ }
+ }
/**
* in case of failure, reuse in _XklXkbLoadAllInfo
* in case of success - free it
*/
- if( rv )
- {
- XkbFreeKeyboard( precached_xkb, XkbAllComponentsMask, True );
- precached_xkb = NULL;
- }
- } else
- {
- xkl_debug( 0, "Could not load the XkbDescPtr for comparison\n" );
- }
- return rv;
+ if (rv) {
+ XkbFreeKeyboard(precached_xkb,
+ XkbAllComponentsMask, True);
+ precached_xkb = NULL;
+ }
+ } else {
+ xkl_debug(0,
+ "Could not load the XkbDescPtr for comparison\n");
+ }
+ return rv;
}
/**
* Load some XKB parameters
*/
-gboolean xkl_xkb_load_all_info( void )
+gboolean
+xkl_xkb_load_all_info(void)
{
- gint i;
- Atom *pa;
- gchar **group_name;
- gchar **pi = xkl_indicator_names;
-
- if ( precached_xkb == NULL )
- if ( !xkl_xkb_load_precached_xkb() )
- {
- xkl_last_error_message = "Could not load keyboard";
- return FALSE;
- }
-
- /* take it from the cache (in most cases LoadAll is called from ResetAll which in turn ...)*/
- xkl_xkb_desc = precached_xkb;
- precached_xkb = NULL;
-
- /* First, output the number of the groups */
- xkl_debug( 200, "found %d groups\n", xkl_xkb_desc->ctrls->num_groups );
-
- /* Then, cache (and output) the names of the groups */
- pa = xkl_xkb_desc->names->groups;
- group_name = group_names;
- for( i = xkl_xkb_desc->ctrls->num_groups; --i >= 0; pa++, group_name++ )
- {
- *group_name = XGetAtomName( xkl_display,
- *pa == None ?
- XInternAtom( xkl_display, "-", False ) : *pa );
- xkl_debug( 200, "Group %d has name [%s]\n", i, *group_name );
- }
-
- xkl_last_error_code =
- XkbGetIndicatorMap( xkl_display, XkbAllIndicatorsMask, xkl_xkb_desc );
-
- if( xkl_last_error_code != Success )
- {
- xkl_last_error_message = "Could not load indicator map";
- return FALSE;
- }
-
- /* Then, cache (and output) the names of the indicators */
- pa = xkl_xkb_desc->names->indicators;
- for( i = XkbNumIndicators; --i >= 0; pi++, pa++ )
- {
- Atom a = *pa;
- if( a != None )
- *pi = XGetAtomName( xkl_display, a );
- else
- *pi = "";
-
- xkl_debug( 200, "Indicator[%d] is %s\n", i, *pi );
- }
-
- xkl_debug( 200, "Real indicators are %X\n",
- xkl_xkb_desc->indicators->phys_indicators );
-
- if( xkl_config_callback != NULL )
- ( *xkl_config_callback ) ( xkl_config_callback_data );
- return TRUE;
+ gint i;
+ Atom *pa;
+ gchar **group_name;
+ gchar **pi = xkl_indicator_names;
+
+ if (precached_xkb == NULL)
+ if (!xkl_xkb_load_precached_xkb()) {
+ xkl_last_error_message = "Could not load keyboard";
+ return FALSE;
+ }
+
+ /* take it from the cache (in most cases LoadAll is called from ResetAll which in turn ...) */
+ xkl_xkb_desc = precached_xkb;
+ precached_xkb = NULL;
+
+ /* First, output the number of the groups */
+ xkl_debug(200, "found %d groups\n",
+ xkl_xkb_desc->ctrls->num_groups);
+
+ /* Then, cache (and output) the names of the groups */
+ pa = xkl_xkb_desc->names->groups;
+ group_name = group_names;
+ for (i = xkl_xkb_desc->ctrls->num_groups; --i >= 0;
+ pa++, group_name++) {
+ *group_name =
+ XGetAtomName(xkl_display,
+ *pa == None ? XInternAtom(xkl_display,
+ "-",
+ False) : *pa);
+ xkl_debug(200, "Group %d has name [%s]\n", i, *group_name);
+ }
+
+ xkl_last_error_code =
+ XkbGetIndicatorMap(xkl_display, XkbAllIndicatorsMask,
+ xkl_xkb_desc);
+
+ if (xkl_last_error_code != Success) {
+ xkl_last_error_message = "Could not load indicator map";
+ return FALSE;
+ }
+
+ /* Then, cache (and output) the names of the indicators */
+ pa = xkl_xkb_desc->names->indicators;
+ for (i = XkbNumIndicators; --i >= 0; pi++, pa++) {
+ Atom a = *pa;
+ if (a != None)
+ *pi = XGetAtomName(xkl_display, a);
+ else
+ *pi = "";
+
+ xkl_debug(200, "Indicator[%d] is %s\n", i, *pi);
+ }
+
+ xkl_debug(200, "Real indicators are %X\n",
+ xkl_xkb_desc->indicators->phys_indicators);
+
+ if (xkl_config_callback != NULL)
+ (*xkl_config_callback) (xkl_config_callback_data);
+ return TRUE;
}
-void xkl_xkb_group_lock( int group )
+void
+xkl_xkb_group_lock(int group)
{
- xkl_debug( 100, "Posted request for change the group to %d ##\n", group );
- XkbLockGroup( xkl_display, XkbUseCoreKbd, group );
- XSync( xkl_display, False );
+ xkl_debug(100, "Posted request for change the group to %d ##\n",
+ group);
+ XkbLockGroup(xkl_display, XkbUseCoreKbd, group);
+ XSync(xkl_display, False);
}
/**
* Updates current internal state from X state
*/
-void xkl_xkb_get_server_state( XklState * current_state_out )
+void
+xkl_xkb_get_server_state(XklState * current_state_out)
{
- XkbStateRec state;
-
- current_state_out->group = 0;
- if( Success == XkbGetState( xkl_display, XkbUseCoreKbd, &state ) )
- current_state_out->group = state.locked_group;
-
- if( Success ==
- XkbGetIndicatorState( xkl_display, XkbUseCoreKbd,
- &current_state_out->indicators ) )
- current_state_out->indicators &= xkl_xkb_desc->indicators->phys_indicators;
- else
- current_state_out->indicators = 0;
+ XkbStateRec state;
+
+ current_state_out->group = 0;
+ if (Success == XkbGetState(xkl_display, XkbUseCoreKbd, &state))
+ current_state_out->group = state.locked_group;
+
+ if (Success ==
+ XkbGetIndicatorState(xkl_display, XkbUseCoreKbd,
+ &current_state_out->indicators))
+ current_state_out->indicators &=
+ xkl_xkb_desc->indicators->phys_indicators;
+ else
+ current_state_out->indicators = 0;
}
/*
* Actually taken from mxkbledpanel, valueChangedProc
*/
-gboolean xkl_indicator_set( gint indicator_num, gboolean set )
+gboolean
+xkl_indicator_set(gint indicator_num, gboolean set)
{
- XkbIndicatorMapPtr map;
-
- map = xkl_xkb_desc->indicators->maps + indicator_num;
-
- /* The 'flags' field tells whether this indicator is automatic
- * (XkbIM_NoExplicit - 0x80), explicit (XkbIM_NoAutomatic - 0x40),
- * or neither (both - 0xC0).
- *
- * If NoAutomatic is set, the server ignores the rest of the
- * fields in the indicator map (i.e. it disables automatic control
- * of the LED). If NoExplicit is set, the server prevents clients
- * from explicitly changing the value of the LED (using the core
- * protocol *or* XKB). If NoAutomatic *and* NoExplicit are set,
- * the LED cannot be changed (unless you change the map first).
- * If neither NoAutomatic nor NoExplicit are set, the server will
- * change the LED according to the indicator map, but clients can
- * override that (until the next automatic change) using the core
- * protocol or XKB.
- */
- switch ( map->flags & ( XkbIM_NoExplicit | XkbIM_NoAutomatic ) )
- {
- case XkbIM_NoExplicit | XkbIM_NoAutomatic:
- {
- /* Can do nothing. Just ignore the indicator */
- return TRUE;
- }
-
- case XkbIM_NoAutomatic:
- {
- if( xkl_xkb_desc->names->indicators[indicator_num] != None )
- XkbSetNamedIndicator( xkl_display, XkbUseCoreKbd,
- xkl_xkb_desc->names->indicators[indicator_num],
- set, False, NULL );
- else
- {
- XKeyboardControl xkc;
- xkc.led = indicator_num;
- xkc.led_mode = set ? LedModeOn : LedModeOff;
- XChangeKeyboardControl( xkl_display, KBLed | KBLedMode, &xkc );
- XSync( xkl_display, False );
- }
-
- return TRUE;
- }
-
- case XkbIM_NoExplicit:
- break;
- }
-
- /* The 'ctrls' field tells what controls tell this indicator to
- * to turn on: RepeatKeys (0x1), SlowKeys (0x2), BounceKeys (0x4),
- * StickyKeys (0x8), MouseKeys (0x10), AccessXKeys (0x20),
- * TimeOut (0x40), Feedback (0x80), ToggleKeys (0x100),
- * Overlay1 (0x200), Overlay2 (0x400), GroupsWrap (0x800),
- * InternalMods (0x1000), IgnoreLockMods (0x2000),
- * PerKeyRepeat (0x3000), or ControlsEnabled (0x4000)
- */
- if( map->ctrls )
- {
- gulong which = map->ctrls;
-
- XkbGetControls( xkl_display, XkbAllControlsMask, xkl_xkb_desc );
- if( set )
- xkl_xkb_desc->ctrls->enabled_ctrls |= which;
- else
- xkl_xkb_desc->ctrls->enabled_ctrls &= ~which;
- XkbSetControls( xkl_display, which | XkbControlsEnabledMask, xkl_xkb_desc );
- }
-
- /* The 'which_groups' field tells when this indicator turns on
- * for the 'groups' field: base (0x1), latched (0x2), locked (0x4),
- * or effective (0x8).
- */
- if( map->groups )
- {
- gint i;
- guint group = 1;
-
- /* Turning on a group indicator is kind of tricky. For
- * now, we will just Latch or Lock the first group we find
- * if that is what this indicator does. Otherwise, we're
- * just going to punt and get out of here.
- */
- if( set )
- {
- for( i = XkbNumKbdGroups; --i >= 0; )
- if( ( 1 << i ) & map->groups )
- {
- group = i;
- break;
- }
- if( map->which_groups & ( XkbIM_UseLocked | XkbIM_UseEffective ) )
- {
- /* Important: Groups should be ignored here - because they are handled separately! */
- /* XklLockGroup( group ); */
- } else if( map->which_groups & XkbIM_UseLatched )
- XkbLatchGroup( xkl_display, XkbUseCoreKbd, group );
- else
- {
- /* Can do nothing. Just ignore the indicator */
- return TRUE;
- }
- } else
- /* Turning off a group indicator will mean that we just
- * Lock the first group that this indicator doesn't watch.
- */
- {
- for( i = XkbNumKbdGroups; --i >= 0; )
- if( !( ( 1 << i ) & map->groups ) )
- {
- group = i;
- break;
- }
- xkl_group_lock( group );
- }
- }
-
- /* The 'which_mods' field tells when this indicator turns on
- * for the modifiers: base (0x1), latched (0x2), locked (0x4),
- * or effective (0x8).
- *
- * The 'real_mods' field tells whether this turns on when one of
- * the real X modifiers is set: Shift (0x1), Lock (0x2), Control (0x4),
- * Mod1 (0x8), Mod2 (0x10), Mod3 (0x20), Mod4 (0x40), or Mod5 (0x80).
- *
- * The 'virtual_mods' field tells whether this turns on when one of
- * the virtual modifiers is set.
- *
- * The 'mask' field tells what real X modifiers the virtual_modifiers
- * map to?
- */
- if( map->mods.real_mods || map->mods.mask )
- {
- guint affect, mods;
-
- affect = ( map->mods.real_mods | map->mods.mask );
-
- mods = set ? affect : 0;
-
- if( map->which_mods & ( XkbIM_UseLocked | XkbIM_UseEffective ) )
- XkbLockModifiers( xkl_display, XkbUseCoreKbd, affect, mods );
- else if( map->which_mods & XkbIM_UseLatched )
- XkbLatchModifiers( xkl_display, XkbUseCoreKbd, affect, mods );
- else
- {
- return TRUE;
- }
- }
- return TRUE;
+ XkbIndicatorMapPtr map;
+
+ map = xkl_xkb_desc->indicators->maps + indicator_num;
+
+ /* The 'flags' field tells whether this indicator is automatic
+ * (XkbIM_NoExplicit - 0x80), explicit (XkbIM_NoAutomatic - 0x40),
+ * or neither (both - 0xC0).
+ *
+ * If NoAutomatic is set, the server ignores the rest of the
+ * fields in the indicator map (i.e. it disables automatic control
+ * of the LED). If NoExplicit is set, the server prevents clients
+ * from explicitly changing the value of the LED (using the core
+ * protocol *or* XKB). If NoAutomatic *and* NoExplicit are set,
+ * the LED cannot be changed (unless you change the map first).
+ * If neither NoAutomatic nor NoExplicit are set, the server will
+ * change the LED according to the indicator map, but clients can
+ * override that (until the next automatic change) using the core
+ * protocol or XKB.
+ */
+ switch (map->flags & (XkbIM_NoExplicit | XkbIM_NoAutomatic)) {
+ case XkbIM_NoExplicit | XkbIM_NoAutomatic:
+ {
+ /* Can do nothing. Just ignore the indicator */
+ return TRUE;
+ }
+
+ case XkbIM_NoAutomatic:
+ {
+ if (xkl_xkb_desc->names->
+ indicators[indicator_num] != None)
+ XkbSetNamedIndicator(xkl_display,
+ XkbUseCoreKbd,
+ xkl_xkb_desc->names->
+ indicators
+ [indicator_num], set,
+ False, NULL);
+ else {
+ XKeyboardControl xkc;
+ xkc.led = indicator_num;
+ xkc.led_mode =
+ set ? LedModeOn : LedModeOff;
+ XChangeKeyboardControl(xkl_display,
+ KBLed | KBLedMode,
+ &xkc);
+ XSync(xkl_display, False);
+ }
+
+ return TRUE;
+ }
+
+ case XkbIM_NoExplicit:
+ break;
+ }
+
+ /* The 'ctrls' field tells what controls tell this indicator to
+ * to turn on: RepeatKeys (0x1), SlowKeys (0x2), BounceKeys (0x4),
+ * StickyKeys (0x8), MouseKeys (0x10), AccessXKeys (0x20),
+ * TimeOut (0x40), Feedback (0x80), ToggleKeys (0x100),
+ * Overlay1 (0x200), Overlay2 (0x400), GroupsWrap (0x800),
+ * InternalMods (0x1000), IgnoreLockMods (0x2000),
+ * PerKeyRepeat (0x3000), or ControlsEnabled (0x4000)
+ */
+ if (map->ctrls) {
+ gulong which = map->ctrls;
+
+ XkbGetControls(xkl_display, XkbAllControlsMask,
+ xkl_xkb_desc);
+ if (set)
+ xkl_xkb_desc->ctrls->enabled_ctrls |= which;
+ else
+ xkl_xkb_desc->ctrls->enabled_ctrls &= ~which;
+ XkbSetControls(xkl_display, which | XkbControlsEnabledMask,
+ xkl_xkb_desc);
+ }
+
+ /* The 'which_groups' field tells when this indicator turns on
+ * for the 'groups' field: base (0x1), latched (0x2), locked (0x4),
+ * or effective (0x8).
+ */
+ if (map->groups) {
+ gint i;
+ guint group = 1;
+
+ /* Turning on a group indicator is kind of tricky. For
+ * now, we will just Latch or Lock the first group we find
+ * if that is what this indicator does. Otherwise, we're
+ * just going to punt and get out of here.
+ */
+ if (set) {
+ for (i = XkbNumKbdGroups; --i >= 0;)
+ if ((1 << i) & map->groups) {
+ group = i;
+ break;
+ }
+ if (map->
+ which_groups & (XkbIM_UseLocked |
+ XkbIM_UseEffective)) {
+ /* Important: Groups should be ignored here - because they are handled separately! */
+ /* XklLockGroup( group ); */
+ } else if (map->which_groups & XkbIM_UseLatched)
+ XkbLatchGroup(xkl_display, XkbUseCoreKbd,
+ group);
+ else {
+ /* Can do nothing. Just ignore the indicator */
+ return TRUE;
+ }
+ } else
+ /* Turning off a group indicator will mean that we just
+ * Lock the first group that this indicator doesn't watch.
+ */
+ {
+ for (i = XkbNumKbdGroups; --i >= 0;)
+ if (!((1 << i) & map->groups)) {
+ group = i;
+ break;
+ }
+ xkl_group_lock(group);
+ }
+ }
+
+ /* The 'which_mods' field tells when this indicator turns on
+ * for the modifiers: base (0x1), latched (0x2), locked (0x4),
+ * or effective (0x8).
+ *
+ * The 'real_mods' field tells whether this turns on when one of
+ * the real X modifiers is set: Shift (0x1), Lock (0x2), Control (0x4),
+ * Mod1 (0x8), Mod2 (0x10), Mod3 (0x20), Mod4 (0x40), or Mod5 (0x80).
+ *
+ * The 'virtual_mods' field tells whether this turns on when one of
+ * the virtual modifiers is set.
+ *
+ * The 'mask' field tells what real X modifiers the virtual_modifiers
+ * map to?
+ */
+ if (map->mods.real_mods || map->mods.mask) {
+ guint affect, mods;
+
+ affect = (map->mods.real_mods | map->mods.mask);
+
+ mods = set ? affect : 0;
+
+ if (map->
+ which_mods & (XkbIM_UseLocked | XkbIM_UseEffective))
+ XkbLockModifiers(xkl_display, XkbUseCoreKbd,
+ affect, mods);
+ else if (map->which_mods & XkbIM_UseLatched)
+ XkbLatchModifiers(xkl_display, XkbUseCoreKbd,
+ affect, mods);
+ else {
+ return TRUE;
+ }
+ }
+ return TRUE;
}
#endif
-gint xkl_xkb_init( void )
+gint
+xkl_xkb_init(void)
{
#ifdef XKB_HEADERS_PRESENT
- gint opcode;
- gboolean xkl_xkb_ext_present;
- static XklVTable xkl_xkb_vtable =
-{
- "XKB",
- XKLF_CAN_TOGGLE_INDICATORS |
- XKLF_CAN_OUTPUT_CONFIG_AS_ASCII |
- XKLF_CAN_OUTPUT_CONFIG_AS_BINARY,
- xkl_xkb_config_activate,
- xkl_xkb_config_init,
- xkl_xkb_config_registry_load,
- xkl_xkb_config_write_file,
-
- xkl_xkb_groups_get_names,
- xkl_xkb_groups_get_max_num,
- xkl_xkb_groups_get_num,
- xkl_xkb_group_lock,
-
- xkl_xkb_process_x_event,
- xkl_xkb_free_all_info,
- xkl_xkb_if_cached_info_equals_actual,
- xkl_xkb_load_all_info,
- xkl_xkb_get_server_state,
- xkl_xkb_listen_pause,
- xkl_xkb_listen_resume,
- xkl_xkb_indicators_set,
- };
-
- if( getenv( "XKL_XKB_DISABLE" ) != NULL )
- return -1;
-
- xkl_xkb_ext_present = XkbQueryExtension( xkl_display,
- &opcode, &xkl_xkb_event_type,
- &xkl_xkb_error_code, NULL, NULL );
- if( !xkl_xkb_ext_present )
- {
- XSetErrorHandler( ( XErrorHandler ) xkl_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,
- xkl_display, xkl_root_window );
-
- xkl_xkb_vtable.base_config_atom =
- XInternAtom( xkl_display, _XKB_RF_NAMES_PROP_ATOM, False );
- xkl_xkb_vtable.backup_config_atom =
- XInternAtom( xkl_display, "_XKB_RULES_NAMES_BACKUP", False );
-
- xkl_xkb_vtable.default_model = "pc101";
- xkl_xkb_vtable.default_layout = "us";
-
- xkl_vtable = &xkl_xkb_vtable;
-
- /* First, we have to assign xkl_vtable -
- because this function uses it */
-
- if( xkl_xkb_config_multiple_layouts_supported() )
- xkl_xkb_vtable.features |= XKLF_MULTIPLE_LAYOUTS_SUPPORTED;
-
- return 0;
+ gint opcode;
+ gboolean xkl_xkb_ext_present;
+ static XklVTable xkl_xkb_vtable = {
+ "XKB",
+ XKLF_CAN_TOGGLE_INDICATORS |
+ XKLF_CAN_OUTPUT_CONFIG_AS_ASCII |
+ XKLF_CAN_OUTPUT_CONFIG_AS_BINARY,
+ xkl_xkb_config_activate,
+ xkl_xkb_config_init,
+ xkl_xkb_config_registry_load,
+ xkl_xkb_config_write_file,
+
+ xkl_xkb_groups_get_names,
+ xkl_xkb_groups_get_max_num,
+ xkl_xkb_groups_get_num,
+ xkl_xkb_group_lock,
+
+ xkl_xkb_process_x_event,
+ xkl_xkb_free_all_info,
+ xkl_xkb_if_cached_info_equals_actual,
+ xkl_xkb_load_all_info,
+ xkl_xkb_get_server_state,
+ xkl_xkb_listen_pause,
+ xkl_xkb_listen_resume,
+ xkl_xkb_indicators_set,
+ };
+
+ if (getenv("XKL_XKB_DISABLE") != NULL)
+ return -1;
+
+ xkl_xkb_ext_present = XkbQueryExtension(xkl_display,
+ &opcode,
+ &xkl_xkb_event_type,
+ &xkl_xkb_error_code, NULL,
+ NULL);
+ if (!xkl_xkb_ext_present) {
+ XSetErrorHandler((XErrorHandler)
+ xkl_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, xkl_display, xkl_root_window);
+
+ xkl_xkb_vtable.base_config_atom =
+ XInternAtom(xkl_display, _XKB_RF_NAMES_PROP_ATOM, False);
+ xkl_xkb_vtable.backup_config_atom =
+ XInternAtom(xkl_display, "_XKB_RULES_NAMES_BACKUP", False);
+
+ xkl_xkb_vtable.default_model = "pc101";
+ xkl_xkb_vtable.default_layout = "us";
+
+ xkl_vtable = &xkl_xkb_vtable;
+
+ /* First, we have to assign xkl_vtable -
+ because this function uses it */
+
+ if (xkl_xkb_config_multiple_layouts_supported())
+ xkl_xkb_vtable.features |= XKLF_MULTIPLE_LAYOUTS_SUPPORTED;
+
+ return 0;
#else
- xkl_debug( 160,
- "NO XKB LIBS, display: %p, root: " WINID_FORMAT
- "\n", xkl_display, xkl_root_window );
- return -1;
+ xkl_debug(160,
+ "NO XKB LIBS, display: %p, root: " WINID_FORMAT
+ "\n", xkl_display, xkl_root_window);
+ return -1;
#endif
}
#ifdef XKB_HEADERS_PRESENT
-const gchar *xkl_xkb_event_get_name( int xkb_type )
+const gchar *
+xkl_xkb_event_get_name(int xkb_type)
{
- /* Not really good to use the fact of consecutivity
- but XKB protocol extension is already standartized so... */
- static const char *evt_names[] = {
- "XkbNewKeyboardNotify",
- "XkbMapNotify",
- "XkbStateNotify",
- "XkbControlsNotify",
- "XkbIndicatorStateNotify",
- "XkbIndicatorMapNotify",
- "XkbNamesNotify",
- "XkbCompatMapNotify",
- "XkbBellNotify",
- "XkbActionMessage",
- "XkbAccessXNotify",
- "XkbExtensionDeviceNotify",
- "LASTEvent"
- };
- xkb_type -= XkbNewKeyboardNotify;
- if( xkb_type < 0 ||
- xkb_type >= ( sizeof( evt_names ) / sizeof( evt_names[0] ) ) )
- return "UNKNOWN/OOR";
- return evt_names[xkb_type];
+ /* Not really good to use the fact of consecutivity
+ but XKB protocol extension is already standartized so... */
+ static const char *evt_names[] = {
+ "XkbNewKeyboardNotify",
+ "XkbMapNotify",
+ "XkbStateNotify",
+ "XkbControlsNotify",
+ "XkbIndicatorStateNotify",
+ "XkbIndicatorMapNotify",
+ "XkbNamesNotify",
+ "XkbCompatMapNotify",
+ "XkbBellNotify",
+ "XkbActionMessage",
+ "XkbAccessXNotify",
+ "XkbExtensionDeviceNotify",
+ "LASTEvent"
+ };
+ xkb_type -= XkbNewKeyboardNotify;
+ if (xkb_type < 0 ||
+ xkb_type >= (sizeof(evt_names) / sizeof(evt_names[0])))
+ return "UNKNOWN/OOR";
+ return evt_names[xkb_type];
}
#endif
diff --git a/libxklavier/xklavier_xmm.c b/libxklavier/xklavier_xmm.c
index afef5f7..22d6131 100755
--- a/libxklavier/xklavier_xmm.c
+++ b/libxklavier/xklavier_xmm.c
@@ -15,275 +15,283 @@
#define SHORTCUT_OPTION_PREFIX "grp:"
-gchar* current_xmm_rules = NULL;
+gchar *current_xmm_rules = NULL;
XklConfigRec current_xmm_config;
Atom xmm_state_atom;
-const gchar **xkl_xmm_groups_get_names( void )
+const gchar **
+xkl_xmm_groups_get_names(void)
{
- return (const gchar **)current_xmm_config.layouts;
+ return (const gchar **) current_xmm_config.layouts;
}
-void xkl_xmm_shortcuts_grab( void )
+void
+xkl_xmm_shortcuts_grab(void)
{
- const XmmShortcut *shortcut;
- const XmmSwitchOption *option = xkl_xmm_shortcut_get_current();
-
- xkl_debug( 150, "Found shortcut option: %p\n", option );
- if( option == NULL )
- return;
-
- shortcut = option->shortcuts;
- while (shortcut->keysym != XK_VoidSymbol)
- {
- int keycode = XKeysymToKeycode( xkl_display, shortcut->keysym );
- xkl_xmm_grab_ignoring_indicators( keycode,
- shortcut->modifiers );
- shortcut++;
- }
+ const XmmShortcut *shortcut;
+ const XmmSwitchOption *option = xkl_xmm_shortcut_get_current();
+
+ xkl_debug(150, "Found shortcut option: %p\n", option);
+ if (option == NULL)
+ return;
+
+ shortcut = option->shortcuts;
+ while (shortcut->keysym != XK_VoidSymbol) {
+ int keycode =
+ XKeysymToKeycode(xkl_display, shortcut->keysym);
+ xkl_xmm_grab_ignoring_indicators(keycode,
+ shortcut->modifiers);
+ shortcut++;
+ }
}
-void xkl_xmm_shortcuts_ungrab( void )
+void
+xkl_xmm_shortcuts_ungrab(void)
{
- const XmmShortcut *shortcut;
- const XmmSwitchOption *option = xkl_xmm_shortcut_get_current();
-
- if( option == NULL )
- return;
-
- shortcut = option->shortcuts;
- while (shortcut->keysym != XK_VoidSymbol)
- {
- int keycode = XKeysymToKeycode( xkl_display, shortcut->keysym );
- xkl_xmm_ungrab_ignoring_indicators( keycode,
- shortcut->modifiers );
- shortcut++;
- }
+ const XmmShortcut *shortcut;
+ const XmmSwitchOption *option = xkl_xmm_shortcut_get_current();
+
+ if (option == NULL)
+ return;
+
+ shortcut = option->shortcuts;
+ while (shortcut->keysym != XK_VoidSymbol) {
+ int keycode =
+ XKeysymToKeycode(xkl_display, shortcut->keysym);
+ xkl_xmm_ungrab_ignoring_indicators(keycode,
+ shortcut->modifiers);
+ shortcut++;
+ }
}
-XmmSwitchOption *xkl_xmm_shortcut_get_current( void )
+XmmSwitchOption *
+xkl_xmm_shortcut_get_current(void)
{
- const gchar* option_name = xkl_xmm_shortcut_get_current_option_name();
- XmmSwitchOption *switch_option = all_switch_options;
- xkl_debug( 150, "Configured switch option: [%s]\n", option_name );
- if( option_name == NULL )
- return NULL;
- while( switch_option->option_name != NULL )
- {
- if( !g_ascii_strcasecmp( switch_option->option_name, option_name ) )
- return switch_option;
- switch_option++;
- }
- return NULL;
+ const gchar *option_name =
+ xkl_xmm_shortcut_get_current_option_name();
+ XmmSwitchOption *switch_option = all_switch_options;
+ xkl_debug(150, "Configured switch option: [%s]\n", option_name);
+ if (option_name == NULL)
+ return NULL;
+ while (switch_option->option_name != NULL) {
+ if (!g_ascii_strcasecmp
+ (switch_option->option_name, option_name))
+ return switch_option;
+ switch_option++;
+ }
+ return NULL;
}
-const gchar* xkl_xmm_shortcut_get_current_option_name( void )
+const gchar *
+xkl_xmm_shortcut_get_current_option_name(void)
{
- gchar** option = current_xmm_config.options;
- if( option == NULL )
- return NULL;
-
- while( *option != NULL )
- {
- /* starts with "grp:" */
- if( strstr( *option, SHORTCUT_OPTION_PREFIX ) != NULL )
- {
- return *option + sizeof SHORTCUT_OPTION_PREFIX - 1;
- }
- option++;
- }
- return NULL;
+ gchar **option = current_xmm_config.options;
+ if (option == NULL)
+ return NULL;
+
+ while (*option != NULL) {
+ /* starts with "grp:" */
+ if (strstr(*option, SHORTCUT_OPTION_PREFIX) != NULL) {
+ return *option + sizeof SHORTCUT_OPTION_PREFIX - 1;
+ }
+ option++;
+ }
+ return NULL;
}
-const XmmSwitchOption *xkl_xmm_switch_option_find( gint keycode,
- guint state,
- gint* current_shortcut_rv )
+const XmmSwitchOption *
+xkl_xmm_switch_option_find(gint keycode,
+ guint state, gint * current_shortcut_rv)
{
- const XmmSwitchOption *rv = xkl_xmm_shortcut_get_current();
-
- if( rv != NULL )
- {
- XmmShortcut *sc = rv->shortcuts;
- while (sc->keysym != XK_VoidSymbol)
- {
- if( ( XKeysymToKeycode( xkl_display, sc->keysym ) == keycode ) &&
- ( ( state & sc->modifiers ) == sc->modifiers ) )
- {
- return rv;
- }
- sc++;
- }
- }
- return NULL;
+ const XmmSwitchOption *rv = xkl_xmm_shortcut_get_current();
+
+ if (rv != NULL) {
+ XmmShortcut *sc = rv->shortcuts;
+ while (sc->keysym != XK_VoidSymbol) {
+ if ((XKeysymToKeycode(xkl_display, sc->keysym) ==
+ keycode)
+ && ((state & sc->modifiers) ==
+ sc->modifiers)) {
+ return rv;
+ }
+ sc++;
+ }
+ }
+ return NULL;
}
-gint xkl_xmm_listen_resume( void )
+gint
+xkl_xmm_listen_resume(void)
{
- if( xkl_listener_type & XKLL_MANAGE_LAYOUTS )
- xkl_xmm_shortcuts_grab();
- return 0;
+ if (xkl_listener_type & XKLL_MANAGE_LAYOUTS)
+ xkl_xmm_shortcuts_grab();
+ return 0;
}
-gint xkl_xmm_listen_pause( void )
+gint
+xkl_xmm_listen_pause(void)
{
- if( xkl_listener_type & XKLL_MANAGE_LAYOUTS )
- xkl_xmm_shortcuts_ungrab();
- return 0;
+ if (xkl_listener_type & XKLL_MANAGE_LAYOUTS)
+ xkl_xmm_shortcuts_ungrab();
+ return 0;
}
-guint xkl_xmm_groups_get_max_num( void )
+guint
+xkl_xmm_groups_get_max_num(void)
{
- return 0;
+ return 0;
}
-guint xkl_xmm_groups_get_num( void )
+guint
+xkl_xmm_groups_get_num(void)
{
- gint rv = 0;
- gchar ** p = current_xmm_config.layouts;
- if( p != NULL )
- while( *p++ != NULL ) rv++;
- return rv;
+ gint rv = 0;
+ gchar **p = current_xmm_config.layouts;
+ if (p != NULL)
+ while (*p++ != NULL)
+ rv++;
+ return rv;
}
-
-void xkl_xmm_free_all_info( void )
+
+void
+xkl_xmm_free_all_info(void)
{
- if( current_xmm_rules != NULL )
- {
- g_free( current_xmm_rules );
- current_xmm_rules = NULL;
- }
- xkl_config_rec_reset( &current_xmm_config );
+ if (current_xmm_rules != NULL) {
+ g_free(current_xmm_rules);
+ current_xmm_rules = NULL;
+ }
+ xkl_config_rec_reset(&current_xmm_config);
}
-gboolean xkl_xmm_if_cached_info_equals_actual( void )
+gboolean
+xkl_xmm_if_cached_info_equals_actual(void)
{
- return FALSE;
+ return FALSE;
}
-gboolean xkl_xmm_load_all_info( )
+gboolean
+xkl_xmm_load_all_info()
{
- return xkl_config_get_full_from_server( &current_xmm_rules,
- &current_xmm_config );
+ return xkl_config_get_full_from_server(&current_xmm_rules,
+ &current_xmm_config);
}
-void xkl_xmm_state_get_server( XklState * state )
+void
+xkl_xmm_state_get_server(XklState * state)
{
- unsigned char *propval = NULL;
- Atom actual_type;
- int actual_format;
- unsigned long bytes_remaining;
- unsigned long actual_items;
- int result;
-
- memset( state, 0, sizeof( *state ) );
-
- result = XGetWindowProperty( xkl_display, xkl_root_window,
- xmm_state_atom, 0L, 1L,
- False, XA_INTEGER, &actual_type,
- &actual_format, &actual_items,
- &bytes_remaining, &propval );
-
- if( Success == result )
- {
- if( actual_format == 32 || actual_items == 1 )
- {
- state->group = *(CARD32*)propval;
- } else
- {
- xkl_debug( 160, "Could not get the xmodmap current group\n" );
- }
- XFree( propval );
- } else
- {
- xkl_debug( 160, "Could not get the xmodmap current group: %d\n", result );
- }
+ unsigned char *propval = NULL;
+ Atom actual_type;
+ int actual_format;
+ unsigned long bytes_remaining;
+ unsigned long actual_items;
+ int result;
+
+ memset(state, 0, sizeof(*state));
+
+ result = XGetWindowProperty(xkl_display, xkl_root_window,
+ xmm_state_atom, 0L, 1L,
+ False, XA_INTEGER, &actual_type,
+ &actual_format, &actual_items,
+ &bytes_remaining, &propval);
+
+ if (Success == result) {
+ if (actual_format == 32 || actual_items == 1) {
+ state->group = *(CARD32 *) propval;
+ } else {
+ xkl_debug(160,
+ "Could not get the xmodmap current group\n");
+ }
+ XFree(propval);
+ } else {
+ xkl_debug(160,
+ "Could not get the xmodmap current group: %d\n",
+ result);
+ }
}
-void xkl_xmm_group_actualize( gint group )
+void
+xkl_xmm_group_actualize(gint group)
{
- char cmd[1024];
- int res;
- const gchar* layout_name = NULL;
-
- if( xkl_xmm_groups_get_num() < group )
- return;
-
- layout_name = current_xmm_config.layouts[group];
-
- snprintf( cmd, sizeof cmd,
- "xmodmap %s/xmodmap.%s",
- XMODMAP_BASE, layout_name );
-
- res = system( cmd );
- if( res > 0 )
- {
- xkl_debug( 0, "xmodmap error %d\n", res );
- } else if( res < 0 )
- {
- xkl_debug( 0, "Could not execute xmodmap: %d\n", res );
- }
- XSync( xkl_display, False );
+ char cmd[1024];
+ int res;
+ const gchar *layout_name = NULL;
+
+ if (xkl_xmm_groups_get_num() < group)
+ return;
+
+ layout_name = current_xmm_config.layouts[group];
+
+ snprintf(cmd, sizeof cmd,
+ "xmodmap %s/xmodmap.%s", XMODMAP_BASE, layout_name);
+
+ res = system(cmd);
+ if (res > 0) {
+ xkl_debug(0, "xmodmap error %d\n", res);
+ } else if (res < 0) {
+ xkl_debug(0, "Could not execute xmodmap: %d\n", res);
+ }
+ XSync(xkl_display, False);
}
-void xkl_xmm_group_lock( gint group )
+void
+xkl_xmm_group_lock(gint group)
{
- CARD32 propval;
-
- if( xkl_xmm_groups_get_num() < group )
- return;
-
- /* updating the status property */
- propval = group;
- XChangeProperty( xkl_display, xkl_root_window, xmm_state_atom,
- XA_INTEGER, 32, PropModeReplace,
- (unsigned char*)&propval, 1 );
- XSync( xkl_display, False );
+ CARD32 propval;
+
+ if (xkl_xmm_groups_get_num() < group)
+ return;
+
+ /* updating the status property */
+ propval = group;
+ XChangeProperty(xkl_display, xkl_root_window, xmm_state_atom,
+ XA_INTEGER, 32, PropModeReplace,
+ (unsigned char *) &propval, 1);
+ XSync(xkl_display, False);
}
-gint xkl_xmm_init( void )
+gint
+xkl_xmm_init(void)
{
- static XklVTable xkl_xmm_vtable =
- {
- "xmodmap",
- XKLF_MULTIPLE_LAYOUTS_SUPPORTED |
- XKLF_REQUIRES_MANUAL_LAYOUT_MANAGEMENT,
- xkl_xmm_config_activate,
- xkl_xmm_config_init,
- xkl_xmm_config_registry_load,
- NULL, /* no write_file */
-
- xkl_xmm_groups_get_names,
- xkl_xmm_groups_get_max_num,
- xkl_xmm_groups_get_num,
- xkl_xmm_group_lock,
-
- xkl_xmm_process_x_event,
- xkl_xmm_free_all_info,
- xkl_xmm_if_cached_info_equals_actual,
- xkl_xmm_load_all_info,
- xkl_xmm_state_get_server,
- xkl_xmm_listen_pause,
- xkl_xmm_listen_resume,
- NULL, /* no indicators_set */
- };
-
- if( getenv( "XKL_XMODMAP_DISABLE" ) != NULL )
- return -1;
-
- xkl_xmm_vtable.base_config_atom =
- XInternAtom( xkl_display, "_XMM_NAMES", False );
- xkl_xmm_vtable.backup_config_atom =
- XInternAtom( xkl_display, "_XMM_NAMES_BACKUP", False );
-
- xmm_state_atom =
- XInternAtom( xkl_display, "_XMM_STATE", False );
-
- xkl_xmm_vtable.default_model = "generic";
- xkl_xmm_vtable.default_layout = "us";
-
- xkl_vtable = &xkl_xmm_vtable;
-
- return 0;
+ static XklVTable xkl_xmm_vtable = {
+ "xmodmap",
+ XKLF_MULTIPLE_LAYOUTS_SUPPORTED |
+ XKLF_REQUIRES_MANUAL_LAYOUT_MANAGEMENT,
+ xkl_xmm_config_activate,
+ xkl_xmm_config_init,
+ xkl_xmm_config_registry_load,
+ NULL, /* no write_file */
+
+ xkl_xmm_groups_get_names,
+ xkl_xmm_groups_get_max_num,
+ xkl_xmm_groups_get_num,
+ xkl_xmm_group_lock,
+
+ xkl_xmm_process_x_event,
+ xkl_xmm_free_all_info,
+ xkl_xmm_if_cached_info_equals_actual,
+ xkl_xmm_load_all_info,
+ xkl_xmm_state_get_server,
+ xkl_xmm_listen_pause,
+ xkl_xmm_listen_resume,
+ NULL, /* no indicators_set */
+ };
+
+ if (getenv("XKL_XMODMAP_DISABLE") != NULL)
+ return -1;
+
+ xkl_xmm_vtable.base_config_atom =
+ XInternAtom(xkl_display, "_XMM_NAMES", False);
+ xkl_xmm_vtable.backup_config_atom =
+ XInternAtom(xkl_display, "_XMM_NAMES_BACKUP", False);
+
+ xmm_state_atom = XInternAtom(xkl_display, "_XMM_STATE", False);
+
+ xkl_xmm_vtable.default_model = "generic";
+ xkl_xmm_vtable.default_layout = "us";
+
+ xkl_vtable = &xkl_xmm_vtable;
+
+ return 0;
}
diff --git a/libxklavier/xklavier_xmm_opts.c b/libxklavier/xklavier_xmm_opts.c
index e96a757..ea3bbd3 100644
--- a/libxklavier/xklavier_xmm_opts.c
+++ b/libxklavier/xklavier_xmm_opts.c
@@ -15,90 +15,172 @@
#define SHORTCUT_OPTION_PREFIX "grp:"
-XmmSwitchOption all_switch_options[] =
-{
- {
- "ralt_toggle",
- { { XK_Alt_R, 0 }, { XK_VoidSymbol } }, { 1 }
- },
- {
- "lalt_toggle",
- { { XK_Alt_L, 0 }, { XK_VoidSymbol } }, { 1 }
- },
- {
- "caps_toggle",
- { { XK_Caps_Lock, 0 }, { XK_VoidSymbol } }, { 1 }
- },
- {
- "shift_caps_toggle",
- { { XK_Caps_Lock, ShiftMask }, { XK_VoidSymbol } }, { 1 }
- },
- {
- "shifts_toggle",
- { { XK_Shift_R, ShiftMask },
- { XK_Shift_L, ShiftMask }, { XK_VoidSymbol } }, { 1, -1 }
- },
- {
- "alts_toggle",
- { { XK_Alt_R, Mod1Mask },
- { XK_Alt_L, Mod1Mask }, { XK_VoidSymbol } }, { 1, -1 }
- },
- {
- "ctrls_toggle",
- { { XK_Control_R, ControlMask },
- { XK_Control_L, ControlMask }, { XK_VoidSymbol } }, { 1, -1 }
- },
- {
- "ctrl_shift_toggle",
- { { XK_Control_R, ShiftMask },
- { XK_Control_L, ShiftMask },
- { XK_Shift_R, ControlMask },
- { XK_Shift_L, ControlMask }, { XK_VoidSymbol } }, { 1, -1, 1, -1 }
- },
- {
- "ctrl_alt_toggle",
- { { XK_Control_R, Mod1Mask },
- { XK_Control_L, Mod1Mask },
- { XK_Alt_R, ControlMask },
- { XK_Alt_L, ControlMask }, { XK_VoidSymbol } }, { 1, -1, 1, -1 }
- },
- {
- "alt_shift_toggle",
- { { XK_Shift_R, Mod1Mask },
- { XK_Shift_L, Mod1Mask },
- { XK_Alt_R, ShiftMask },
- { XK_Alt_L, ShiftMask }, { XK_VoidSymbol } }, { 1, -1, 1, -1 }
- },
- {
- "menu_toggle",
- { { XK_Menu, 0 }, { XK_VoidSymbol } }, { 1 }
- },
- {
- "lwin_toggle",
- { { XK_Super_L, 0 }, { XK_VoidSymbol } }, { 1 }
- },
- {
- "rwin_toggle",
- { { XK_Super_R, 0 }, { XK_VoidSymbol } }, { 1 }
- },
- {
- "lshift_toggle",
- { { XK_Shift_L, 0 }, { XK_VoidSymbol } }, { 1 }
- },
- {
- "rshift_toggle",
- { { XK_Shift_R, 0 }, { XK_VoidSymbol } }, { 1 }
- },
- {
- "lctrl_toggle",
- { { XK_Control_L, 0 }, { XK_VoidSymbol } }, { 1 }
- },
- {
- "rctrl_toggle",
- { { XK_Control_R, 0 }, { XK_VoidSymbol } }, { 1 }
- },
- {
- NULL,
- { { 0, 0 }, { XK_VoidSymbol } }, { 1 }
- }
+XmmSwitchOption all_switch_options[] = {
+ {
+ "ralt_toggle",
+ {{XK_Alt_R, 0}
+ , {XK_VoidSymbol}
+ }
+ , {1}
+ }
+ ,
+ {
+ "lalt_toggle",
+ {{XK_Alt_L, 0}
+ , {XK_VoidSymbol}
+ }
+ , {1}
+ }
+ ,
+ {
+ "caps_toggle",
+ {{XK_Caps_Lock, 0}
+ , {XK_VoidSymbol}
+ }
+ , {1}
+ }
+ ,
+ {
+ "shift_caps_toggle",
+ {{XK_Caps_Lock, ShiftMask}
+ , {XK_VoidSymbol}
+ }
+ , {1}
+ }
+ ,
+ {
+ "shifts_toggle",
+ {{XK_Shift_R, ShiftMask}
+ ,
+ {XK_Shift_L, ShiftMask}
+ , {XK_VoidSymbol}
+ }
+ , {1, -1}
+ }
+ ,
+ {
+ "alts_toggle",
+ {{XK_Alt_R, Mod1Mask}
+ ,
+ {XK_Alt_L, Mod1Mask}
+ , {XK_VoidSymbol}
+ }
+ , {1, -1}
+ }
+ ,
+ {
+ "ctrls_toggle",
+ {{XK_Control_R, ControlMask}
+ ,
+ {XK_Control_L, ControlMask}
+ , {XK_VoidSymbol}
+ }
+ , {1, -1}
+ }
+ ,
+ {
+ "ctrl_shift_toggle",
+ {{XK_Control_R, ShiftMask}
+ ,
+ {XK_Control_L, ShiftMask}
+ ,
+ {XK_Shift_R, ControlMask}
+ ,
+ {XK_Shift_L, ControlMask}
+ , {XK_VoidSymbol}
+ }
+ , {1, -1, 1, -1}
+ }
+ ,
+ {
+ "ctrl_alt_toggle",
+ {{XK_Control_R, Mod1Mask}
+ ,
+ {XK_Control_L, Mod1Mask}
+ ,
+ {XK_Alt_R, ControlMask}
+ ,
+ {XK_Alt_L, ControlMask}
+ , {XK_VoidSymbol}
+ }
+ , {1, -1, 1, -1}
+ }
+ ,
+ {
+ "alt_shift_toggle",
+ {{XK_Shift_R, Mod1Mask}
+ ,
+ {XK_Shift_L, Mod1Mask}
+ ,
+ {XK_Alt_R, ShiftMask}
+ ,
+ {XK_Alt_L, ShiftMask}
+ , {XK_VoidSymbol}
+ }
+ , {1, -1, 1, -1}
+ }
+ ,
+ {
+ "menu_toggle",
+ {{XK_Menu, 0}
+ , {XK_VoidSymbol}
+ }
+ , {1}
+ }
+ ,
+ {
+ "lwin_toggle",
+ {{XK_Super_L, 0}
+ , {XK_VoidSymbol}
+ }
+ , {1}
+ }
+ ,
+ {
+ "rwin_toggle",
+ {{XK_Super_R, 0}
+ , {XK_VoidSymbol}
+ }
+ , {1}
+ }
+ ,
+ {
+ "lshift_toggle",
+ {{XK_Shift_L, 0}
+ , {XK_VoidSymbol}
+ }
+ , {1}
+ }
+ ,
+ {
+ "rshift_toggle",
+ {{XK_Shift_R, 0}
+ , {XK_VoidSymbol}
+ }
+ , {1}
+ }
+ ,
+ {
+ "lctrl_toggle",
+ {{XK_Control_L, 0}
+ , {XK_VoidSymbol}
+ }
+ , {1}
+ }
+ ,
+ {
+ "rctrl_toggle",
+ {{XK_Control_R, 0}
+ , {XK_VoidSymbol}
+ }
+ , {1}
+ }
+ ,
+ {
+ NULL,
+ {{0, 0}
+ , {XK_VoidSymbol}
+ }
+ , {1}
+ }
};