Proper keymap initialization, fix a little bug
authorThibaut Girka <thib@sitedethib.com>
Thu, 21 Jul 2011 19:03:19 +0200
changeset 17 2cb8af0a70ca
parent 16 5dd4f4c17192
child 18 db9a4d812715
Proper keymap initialization, fix a little bug
keyboard.c
ui.c
--- a/keyboard.c	Thu Jul 21 18:47:57 2011 +0200
+++ b/keyboard.c	Thu Jul 21 19:03:19 2011 +0200
@@ -9,7 +9,6 @@
 VirtualKeyboard *construct_keyboard(VirtualKeyboard *vkb)
 {
     XkbComponentNamesRec names;
-    XkbStateRec state;
     VirtualKey *vkeys = NULL;
     unsigned int width = 0, height = 0;
     unsigned int nb_keys = 0;
@@ -67,11 +66,6 @@
     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;
 }
 
--- a/ui.c	Thu Jul 21 18:47:57 2011 +0200
+++ b/ui.c	Thu Jul 21 19:03:19 2011 +0200
@@ -90,6 +90,8 @@
 
 VirtualKeyboardUI *ui_init(VirtualKeyboardUI *ui, VirtualKeyboard *vkb)
 {
+    XkbStateRec state;
+
     ui->vkb = vkb;
     ui->xscreen = DefaultScreen(ui->vkb->display);
     ui->xwin_root = RootWindow(ui->vkb->display, ui->xscreen);
@@ -103,6 +105,12 @@
     ui->backbuffer = 0;
     ui->cairo_surf = NULL;
 
+    /* Get initial keyboard state */
+    XkbGetState(vkb->display, XkbUseCoreKbd, &state);
+    XkbGetUpdatedMap(ui->vkb->display, XkbAllMapComponentsMask, ui->vkb->xkb);
+    vkb->mods = state.mods;
+    vkb->group = state.group;
+
     ui_update_display_size(ui);
 
     return ui;