+ dpy = XkbOpenDisplay(NULL,
+ &event_rtrn,
+ &error_rtrn, NULL, NULL, &reason_rtrn);
+ if (dpy == NULL) {
+ qDebug() << "Cannot open display";
+ qApp->quit();
+ }
+
+ /* We would like receive the only Xkb event: XkbStateNotify. And only
+ * when XkbLockGroup happens. */
+ if (False == XkbSelectEvents(dpy,
+ XkbUseCoreKbd,
+ XkbAllEventsMask,
+ 0)) {
+ qDebug() << "Cannot XkbSelectEvents.";
+ qApp->quit();
+ }
+
+ if (False == XkbSelectEventDetails(dpy,
+ XkbUseCoreKbd,
+ XkbStateNotify,
+ XkbAllEventsMask,
+ XkbGroupLockMask)) {
+ qDebug() << "Cannot XkbSelectEventDetails.";
+ qApp->quit();
+ }
+
+ while (1) {
+ XNextEvent(dpy, &labuda.core);
+ state = labuda.state.group;
+ /* Should not be necessary, here works only with 2 keyboard dispositions */
+ if ((state < 0) || (state > 1))
+ state = 1;
+ qDebug() << "XNextEvent";
+ /* TODO: update flag depending on state */
+ }