[caribou] libcaribou: Fix one XKB group case.



commit b7982227c326a1e944aefea46092c3d8d446642f
Author: Eitan Isaacson <eitan monotonous org>
Date:   Mon May 2 12:46:16 2011 -0700

    libcaribou: Fix one XKB group case.

 libcaribou/keyboard-model.vala |    2 +-
 libcaribou/xadapter.vala       |   23 +++++++++++++++--------
 2 files changed, 16 insertions(+), 9 deletions(-)
---
diff --git a/libcaribou/keyboard-model.vala b/libcaribou/keyboard-model.vala
index b9d96f4..db19dd9 100644
--- a/libcaribou/keyboard-model.vala
+++ b/libcaribou/keyboard-model.vala
@@ -42,7 +42,7 @@ namespace Caribou {
         }
 
         private void on_group_changed (uint grpid, string group, string variant) {
-            active_group = group;
+            active_group = GroupModel.create_group_name (group, variant);
         }
 
     }
diff --git a/libcaribou/xadapter.vala b/libcaribou/xadapter.vala
index d240f08..367e472 100644
--- a/libcaribou/xadapter.vala
+++ b/libcaribou/xadapter.vala
@@ -62,11 +62,11 @@ namespace Caribou {
             if (xev.any.xkb_type == Xkb.StateNotify) {
                 Xkb.StateNotifyEvent *sevent = &xev.state;
                 if ((sevent.changed & Xkb.GroupStateMask) != 0) {
-                    Xkl.ConfigRec config_rec = new Xkl.ConfigRec ();
-                    config_rec.get_from_server (this.xkl_engine);
-                    group_changed (sevent.group, config_rec.layouts[sevent.group],
-                        config_rec.variants[sevent.group]);
+                    string group_name;
+                    string variant_name;
                     this.group = (uchar) sevent.group;
+                    get_current_group (out group_name, out variant_name);
+                    group_changed (this.group, group_name, variant_name);
                 } else if ((sevent.changed & Xkb.ModifierStateMask) != 0) {
                     this.modifiers = (uchar) sevent.mods;
                 }
@@ -183,6 +183,8 @@ namespace Caribou {
             config_rec.get_from_server (this.xkl_engine);
             group_name = config_rec.layouts[this.group];
             variant_name = config_rec.variants[this.group];
+            if (variant_name == null)
+                variant_name = "";
 
             return this.group;
         }
@@ -194,15 +196,20 @@ namespace Caribou {
             config_rec.get_from_server (this.xkl_engine);
 
             for (i=0; i<4; i++)
-                if (config_rec.layouts[i] == null)
+                if (config_rec.layouts[i] == null) {
+                    i--;
                     break;
+                }
 
-            group_names = new string[i];
-            variant_names = new string[i];
+            group_names = new string[i+1];
+            variant_names = new string[i+1];
 
             for (; i>=0; i--) {
                 group_names[i] = config_rec.layouts[i];
-                variant_names[i] = config_rec.variants[i];
+                if (config_rec.variants[i] != null)
+                    variant_names[i] = config_rec.variants[i];
+                else
+                    variant_names[i] = "";
             }
         }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]