updated on Sun Jan 15 16:02:00 UTC 2012
[aur-mirror.git] / unity-2d / keymonitor-shutdown-fixes.patch
blob7f11ae7ddc502225aba5fcf409358c2d8134c0af
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
4 @@ -21,7 +21,7 @@
5 #include "keymonitor.h"
7 // Qt
8 -#include <QtConcurrentRun>
9 +#include <QSocketNotifier>
10 #include <QDebug>
12 // X11
13 @@ -38,19 +38,17 @@
16 KeyMonitor::KeyMonitor(QObject* parent)
17 -: QObject(parent), m_stop(false)
18 +: QObject(parent)
20 if (this->registerEvents()) {
21 getModifiers();
22 - m_future = QtConcurrent::run(this, &KeyMonitor::run);
26 KeyMonitor::~KeyMonitor()
28 - /* let the running thread know that it should stop */
29 - m_stop = true;
30 m_eventList.clear();
31 + XCloseDisplay(m_display);
34 KeyMonitor* KeyMonitor::instance()
35 @@ -74,6 +72,8 @@
36 m_modList.append(xmodmap->modifiermap[i]);
40 + XFreeModifiermap(xmodmap);
43 bool KeyMonitor::registerEvents()
44 @@ -82,6 +82,7 @@
45 Window window;
47 XDeviceInfo *devices;
48 + int x11FileDescriptor;
49 int num_devices;
50 int i, j;
52 @@ -116,8 +117,11 @@
56 + XCloseDevice(m_display, device);
59 + XFreeDeviceList(devices);
61 if (m_eventList.size() == 0) {
62 UQ_WARNING << "No input devices found.";
63 return false;
64 @@ -128,15 +132,21 @@
65 return false;
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()));
73 return true;
77 -void KeyMonitor::run()
78 +void KeyMonitor::x11EventDispatch()
80 XEvent event;
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
92 @@ -51,11 +51,12 @@
94 void getModifiers();
95 bool registerEvents();
96 - void run();
99 +private Q_SLOTS:
100 + void x11EventDispatch();
102 +private:
103 Display *m_display;
104 - QFuture<void> m_future;
105 - bool m_stop;
106 QVector<XEventClass> m_eventList;
107 QVector<KeyCode> m_modList;