diff options
author | Thorvald Natvig <slicer@users.sourceforge.net> | 2009-01-19 21:22:36 +0300 |
---|---|---|
committer | Thorvald Natvig <slicer@users.sourceforge.net> | 2009-01-19 21:22:36 +0300 |
commit | 2afcd0ef88e54417e2f84d488741972f0f4425a9 (patch) | |
tree | bf84d56dbb5d80833a22cbb045166ee2c2d8122d /src/mumble | |
parent | c451437fbe39154de8dfbc2212529a0180957c34 (diff) |
Don't use /dev/input devices that are grabbed, and don't use /dev/input at all unless we find a keyboard
git-svn-id: https://mumble.svn.sourceforge.net/svnroot/mumble/trunk@1456 05730e5d-ab1b-0410-a4ac-84af385074fa
Diffstat (limited to 'src/mumble')
-rw-r--r-- | src/mumble/GlobalShortcut_unix.cpp | 27 | ||||
-rw-r--r-- | src/mumble/GlobalShortcut_unix.h | 1 | ||||
-rw-r--r-- | src/mumble/mumble.pro | 2 |
3 files changed, 24 insertions, 6 deletions
diff --git a/src/mumble/GlobalShortcut_unix.cpp b/src/mumble/GlobalShortcut_unix.cpp index 5a97386fa..2d5bcfd08 100644 --- a/src/mumble/GlobalShortcut_unix.cpp +++ b/src/mumble/GlobalShortcut_unix.cpp @@ -59,9 +59,13 @@ GlobalShortcutX::GlobalShortcutX() { connect(fsw, SIGNAL(directoryChanged(const QString &)), this, SLOT(directoryChanged(const QString &))); directoryChanged(dir); - if (qmInputDevices.isEmpty()) { + if (qsKeyboards.isEmpty()) { + foreach(QFile *f, qmInputDevices) + delete f; + qmInputDevices.clear(); + delete fsw; - qWarning("GlobalShortcutX: Unable to open any input devices under /dev/input, falling back to XEVIE"); + qWarning("GlobalShortcutX: Unable to open any keyboard input devices under /dev/input, falling back to XEVIE"); } else { return; } @@ -243,6 +247,7 @@ void GlobalShortcutX::inputReadyRead(int) { if ((ioctl(fd, EVIOCGVERSION, &version) < 0) || (((version >> 16) & 0xFF) < 1)) { qWarning("GlobalShortcutX: Removing dead input device %s", qPrintable(f->fileName())); qmInputDevices.remove(f->fileName()); + qsKeyboards.remove(f->fileName()); delete f; } } @@ -267,9 +272,21 @@ void GlobalShortcutX::directoryChanged(const QString &dir) { if ((ioctl(fd, EVIOCGVERSION, &version) >= 0) && (ioctl(fd, EVIOCGNAME(sizeof(name)), name)>=0) && (ioctl(fd, EVIOCGBIT(0,sizeof(events)), &events) >= 0) && test_bit(EV_KEY, events) && (((version >> 16) & 0xFF) > 0)) { name[255]=0; qWarning("GlobalShortcutX: %s: %s", qPrintable(f->fileName()), name); - fcntl(f->handle(), F_SETFL, O_NONBLOCK); - connect(new QSocketNotifier(f->handle(), QSocketNotifier::Read, f), SIGNAL(activated(int)), this, SLOT(inputReadyRead(int))); - qmInputDevices.insert(f->fileName(), f); + // Is it grabbed by someone else? + if ((ioctl(fd, EVIOCGRAB, 1) < 0)) { + qWarning("GlobalShortcutX: Device exclusively grabbed by someone else (X11 using exclusive-mode evdev?)"); + delete f; + } else { + ioctl(fd, EVIOCGRAB, 0); + uint8_t keys[KEY_CNT/8 + 1]; + if ((ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keys)), &keys) >= 0) && test_bit(KEY_SPACE, keys)) + qsKeyboards.insert(f->fileName()); + + fcntl(f->handle(), F_SETFL, O_NONBLOCK); + connect(new QSocketNotifier(f->handle(), QSocketNotifier::Read, f), SIGNAL(activated(int)), this, SLOT(inputReadyRead(int))); + + qmInputDevices.insert(f->fileName(), f); + } } else { delete f; } diff --git a/src/mumble/GlobalShortcut_unix.h b/src/mumble/GlobalShortcut_unix.h index f03e5138e..69a638f60 100644 --- a/src/mumble/GlobalShortcut_unix.h +++ b/src/mumble/GlobalShortcut_unix.h @@ -41,6 +41,7 @@ class GlobalShortcutX : public GlobalShortcutEngine { Display *display; volatile bool bRunning; bool bXevie; + QSet<QString> qsKeyboards; QMap<QString, QFile *> qmInputDevices; GlobalShortcutX(); diff --git a/src/mumble/mumble.pro b/src/mumble/mumble.pro index 18cd79464..95e6c8d21 100644 --- a/src/mumble/mumble.pro +++ b/src/mumble/mumble.pro @@ -75,7 +75,7 @@ unix { CONFIG *= pulseaudio } - !isEmpty(HAVE_XEVIE):!CONFIG(no-xevie):x11 { + !isEmpty(HAVE_XEVIE):!CONFIG(no-xevie):!macx { CONFIG *= xevie } |