QML keyboard indicator for my personnal needs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

42 lines
1.3 KiB

#include "xcbEventFilter.h"
#include <QApplication>
#include <QDebug>
#include <xcb/xcb.h>
#define explicit dont_use_cxx_explicit
#include <xcb/xkb.h>
#undef explicit
XcbEventFilter::XcbEventFilter(QObject *favicon)
{
m_favicon = favicon;
}
XcbEventFilter::~XcbEventFilter()
{
}
bool XcbEventFilter::nativeEventFilter(const QByteArray &eventType, void *message, long *)
{
if (eventType == "xcb_generic_event_t") {
/* We are only interested in XCB_XKB_STATE_NOTIFY */
xcb_xkb_state_notify_event_t *xkb_event = static_cast<xcb_xkb_state_notify_event_t *>(message);
//qDebug() << "XCB Event: " << xkb_event->any.response_type;
if (xkb_event->xkbType == XCB_XKB_STATE_NOTIFY) {
/* We get the event twice here. Not critical, but to investigate */
//qDebug() << "XCB Mapping Event - group: " << xkb_event->group << " - eventType: " << xkb_event->eventType;
//qDebug() << "current icon: " << m_favicon->property("lang");
switch (xkb_event->group)
{
case 1:
m_favicon->setProperty("lang", "fr");
break;
case 0:
default:
m_favicon->setProperty("lang", "ru");
break;
}
}
}
return false;
}