[packages/qt4] allow configure 'grabbing' of linuxinput devices (via ioctl EVIOCGRAB) -
[packages.git] / Xorg / lib / qt4 / patches / 500-allow-device-grabbing.patch
1 --- qt-everywhere-opensource-src-4.7.0/src/gui/embedded/qkbdlinuxinput_qws.cpp  2010-09-10 11:05:24.000000000 +0200
2 +++ qt-everywhere-opensource-src-4.7.0/src/gui/embedded/qkbdlinuxinput_qws.cpp.mod      2011-04-28 21:57:04.208449828 +0200
3 @@ -103,6 +103,7 @@
4      QString dev = QLatin1String("/dev/input/event1");
5      int repeat_delay = -1;
6      int repeat_rate = -1;
7 +    int grab = 0;
8  
9      QStringList args = device.split(QLatin1Char(':'));
10      foreach (const QString &arg, args) {
11 @@ -110,12 +111,16 @@
12              repeat_delay = arg.mid(13).toInt();
13          else if (arg.startsWith(QLatin1String("repeat-rate=")))
14              repeat_rate = arg.mid(12).toInt();
15 +        else if (arg.startsWith(QLatin1String("grab=")))
16 +            grab = arg.mid(5).toInt();
17          else if (arg.startsWith(QLatin1String("/dev/")))
18              dev = arg;
19      }
20  
21      m_fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDWR, 0);
22      if (m_fd >= 0) {
23 +        ::printf("grab kbd: %d\n", grab);
24 +        ::ioctl(m_fd, EVIOCGRAB, grab);
25          if (repeat_delay > 0 && repeat_rate > 0) {
26              int kbdrep[2] = { repeat_delay, repeat_rate };
27              ::ioctl(m_fd, EVIOCSREP, kbdrep);
28 --- qt-everywhere-opensource-src-4.7.0/src/gui/embedded/qmouselinuxinput_qws.cpp        2010-09-10 11:05:24.000000000 +0200
29 +++ qt-everywhere-opensource-src-4.7.0/src/gui/embedded/qmouselinuxinput_qws.cpp.mod    2011-04-28 21:57:13.358562410 +0200
30 @@ -43,6 +43,7 @@
31  
32  #include <QScreen>
33  #include <QSocketNotifier>
34 +#include <QStringList>
35  
36  #include <qplatformdefs.h>
37  #include <private/qcore_unix_p.h> // overrides QT_OPEN
38 @@ -101,11 +102,20 @@
39      setObjectName(QLatin1String("LinuxInputSubsystem Mouse Handler"));
40  
41      QString dev = QLatin1String("/dev/input/event0");
42 -    if (device.startsWith(QLatin1String("/dev/")))
43 -        dev = device;
44 +    int grab = 0;
45 +
46 +    QStringList args = device.split(QLatin1Char(':'));
47 +    foreach (const QString &arg, args) {
48 +        if (arg.startsWith(QLatin1String("grab=")))
49 +            grab = arg.mid(5).toInt();
50 +        else if (arg.startsWith(QLatin1String("/dev/")))
51 +            dev = arg;
52 +    }
53  
54      m_fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0);
55      if (m_fd >= 0) {
56 +        ::printf("grab mouse: %d\n", grab);
57 +        ::ioctl(m_fd, EVIOCGRAB, grab);
58          m_notify = new QSocketNotifier(m_fd, QSocketNotifier::Read, this);
59          connect(m_notify, SIGNAL(activated(int)), this, SLOT(readMouseData()));
60      } else {