1 === modified file 'libunity-2d-private/src/keymonitor.cpp'
2 --- libunity-2d-private/src/keymonitor.cpp 2011-09-23 12:45:33 +0000
3 +++ libunity-2d-private/src/keymonitor.cpp 2011-10-28 22:18:46 +0000
5 #include "keymonitor.h"
8 -#include <QtConcurrentRun>
9 +#include <QSocketNotifier>
16 KeyMonitor::KeyMonitor(QObject* parent)
17 -: QObject(parent), m_stop(false)
20 if (this->registerEvents()) {
22 - m_future = QtConcurrent::run(this, &KeyMonitor::run);
26 KeyMonitor::~KeyMonitor()
28 - /* let the running thread know that it should stop */
31 + XCloseDisplay(m_display);
34 KeyMonitor* KeyMonitor::instance()
36 m_modList.append(xmodmap->modifiermap[i]);
40 + XFreeModifiermap(xmodmap);
43 bool KeyMonitor::registerEvents()
48 + int x11FileDescriptor;
56 + XCloseDevice(m_display, device);
59 + XFreeDeviceList(devices);
61 if (m_eventList.size() == 0) {
62 UQ_WARNING << "No input devices found.";
68 + /* Dispatch XEvents when there is activity on the X11 file descriptor */
69 + x11FileDescriptor = ConnectionNumber(m_display);
70 + QSocketNotifier* socketNotifier = new QSocketNotifier(x11FileDescriptor, QSocketNotifier::Read, this);
71 + connect(socketNotifier, SIGNAL(activated(int)), this, SLOT(x11EventDispatch()));
77 -void KeyMonitor::run()
78 +void KeyMonitor::x11EventDispatch()
82 - while(!m_stop && !XNextEvent(m_display, &event)) {
83 + while (XPending(m_display) > 0) {
84 + XNextEvent(m_display, &event);
85 if (event.type == key_press_type) {
86 XDeviceKeyEvent *keyEvent = (XDeviceKeyEvent *) &event;
87 if (!m_modList.contains((KeyCode) keyEvent->keycode)) {
89 === modified file 'libunity-2d-private/src/keymonitor.h'
90 --- libunity-2d-private/src/keymonitor.h 2011-09-19 19:06:54 +0000
91 +++ libunity-2d-private/src/keymonitor.h 2011-10-28 22:14:18 +0000
95 bool registerEvents();
100 + void x11EventDispatch();
104 - QFuture<void> m_future;
106 QVector<XEventClass> m_eventList;
107 QVector<KeyCode> m_modList;