[Xfce4-commits] <xfce4-xkb-plugin:4.10_panel_support> Simplify handling of NULL xkb variants.

Igor Slepchin noreply at xfce.org
Fri Apr 12 19:50:01 CEST 2013


Updating branch refs/heads/4.10_panel_support
         to cec24f9a34f88b6caba61b0fb2a59c6b7ec370bc (commit)
       from 0aab3c44d1f19583fe5d9affa9034c199b772cdc (commit)

commit cec24f9a34f88b6caba61b0fb2a59c6b7ec370bc
Author: Igor Slepchin <igor.slepchin at gmail.com>
Date:   Fri Apr 12 13:46:10 2013 -0400

    Simplify handling of NULL xkb variants.
    
    This also ensures that variants are preserved when X-new-device
    is issued on xkb-plugin running with no config of its own.

 panel-plugin/xkb-config.c |   35 +++++++++++++++--------------------
 1 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/panel-plugin/xkb-config.c b/panel-plugin/xkb-config.c
index e34c036..54c8032 100644
--- a/panel-plugin/xkb-config.c
+++ b/panel-plugin/xkb-config.c
@@ -303,7 +303,6 @@ xkb_config_update_settings (t_xkb_settings *settings)
 
     gchar **opt;
     gchar **prefix;
-    gchar *tmp1, *tmp2;
     int i;
 
     g_assert (config != NULL);
@@ -322,6 +321,20 @@ xkb_config_update_settings (t_xkb_settings *settings)
         {
             DBG ("ERROR: can't get xkl config: [%s]", xkl_get_last_error());
         }
+
+        /* XklConfigRec uses for NULL for empty variant instead of "".
+           So if has skipped variants we can't get proper settings->kbd_config->variants.
+           xkl will also get confused if we try to activate() any config_rec
+           that has NULLs for empty variants.
+           Hence, we'll replace NULL variants with ""
+        */
+        for (i = 0; config->config_rec->layouts[i]; i++)
+        {
+            if (!config->config_rec->variants[i])
+                config->config_rec->variants[i] = g_strdup ("");
+        }
+
+        XKB_DEBUG_CONFIG_REC (config->config_rec, "retrieved");
         if (settings->kbd_config == NULL)
             settings->kbd_config = g_new0 (t_xkb_kbd_config, 1);
 
@@ -329,26 +342,8 @@ xkb_config_update_settings (t_xkb_settings *settings)
         settings->kbd_config->model = g_strdup (config->config_rec->model);
         g_free (settings->kbd_config->layouts);
         settings->kbd_config->layouts = g_strjoinv (",", config->config_rec->layouts);
-
-        /* XklConfigRec uses for NULL for empty variant instead of "".
-         * So if has skipped variants we can't get proper settings->kbd_config->variants.
-         * So I use this hack to get proper kbd_config->variants */
-        tmp1 = g_strdup("");
-        tmp2 = NULL;
-        for (i = 0; config->config_rec->layouts[i]; i++)
-        {
-            tmp2 = g_strconcat (tmp1, config->config_rec->variants[i] ? config->config_rec->variants[i] : "", NULL);
-            g_free(tmp1);
-            tmp1 = tmp2;
-            if (config->config_rec->layouts[i + 1])
-            {
-                tmp2 = g_strconcat (tmp1, ",", NULL);
-                g_free(tmp1);
-                tmp1 = tmp2;
-            }
-        }
         g_free (settings->kbd_config->variants);
-        settings->kbd_config->variants = tmp2;
+        settings->kbd_config->variants = g_strjoinv (",", config->config_rec->variants);
     }
     else
     {


More information about the Xfce4-commits mailing list