1 #include "xlib_wrapper.h"
2 #include <QApplication>
9 #include <X11/XKBlib.h>
11 XlibWrapper::XlibWrapper()
13 timer = new QTimer(this);
14 timer->setSingleShot(true);
15 connect(timer, SIGNAL(timeout()),
16 this, SLOT(XlibWrapperSlot()));
19 /* Instead of this, should subscribe to the correct QEvent */
21 void XlibWrapper::XlibWrapperSlot()
31 qDebug() << "Timer...";
32 dpy = XkbOpenDisplay(NULL,
34 &error_rtrn, NULL, NULL, &reason_rtrn);
36 qDebug() << "Cannot open display";
40 /* We would like receive the only Xkb event: XkbStateNotify. And only
41 * when XkbLockGroup happens. */
42 if (False == XkbSelectEvents(dpy,
46 qDebug() << "Cannot XkbSelectEvents.";
50 if (False == XkbSelectEventDetails(dpy,
55 qDebug() << "Cannot XkbSelectEventDetails.";
60 XNextEvent(dpy, &labuda.core);
61 state = labuda.state.group;
62 /* Should not be necessary, here works only with 2 keyboard dispositions */
63 if ((state < 0) || (state > 1))
65 qDebug() << "XNextEvent";
66 /* TODO: update flag depending on state */