Initialize group member, avoid segfaulting :)
authorThibaut Girka <thib@sitedethib.com>
Thu, 21 Jul 2011 18:32:24 +0200
changeset 14 fdebd4e61306
parent 13 9a705eabfa7d
child 15 d3d4f1f4c1fd
Initialize group member, avoid segfaulting :)
keyboard.c
--- a/keyboard.c	Thu Jul 21 18:28:16 2011 +0200
+++ b/keyboard.c	Thu Jul 21 18:32:24 2011 +0200
@@ -9,6 +9,7 @@
 VirtualKeyboard *construct_keyboard(VirtualKeyboard *vkb)
 {
     XkbComponentNamesRec names;
+    XkbStateRec state;
     VirtualKey *vkeys = NULL;
     unsigned int width = 0, height = 0;
     unsigned int nb_keys = 0;
@@ -27,10 +28,7 @@
 
     /* Get the xkb instance */
     vkb->xkb = XkbGetKeyboardByName (vkb->display, XkbUseCoreKbd, &names, 0,
-                                     XkbGBN_KeyNamesMask |
-                                     XkbGBN_OtherNamesMask |
-                                     XkbGBN_ClientSymbolsMask |
-                                     XkbGBN_IndicatorMapMask, False);
+                                     XkbGBN_AllComponentsMask, False);
 
     if (vkb->xkb == NULL)
         return NULL;
@@ -67,6 +65,12 @@
     vkb->keys = vkeys;
     vkb->pressed_key = NULL;
     vkb->mods = 0;
+    vkb->group = 0;
+
+    /* Get initial keyboard state */
+    XkbGetState(vkb->display, XkbUseCoreKbd, &state);
+    vkb->mods = state.mods;
+    vkb->group = state.group;
 
     return vkb;
 }