Merge pull request #4952 from Chocobozzz/qt5

Fix media global shortcuts which don't work
This commit is contained in:
John Maguire 2015-07-14 10:36:39 +01:00
commit 00f8e5b608
1 changed files with 22 additions and 6 deletions

View File

@ -38,6 +38,7 @@
#endif #endif
#include <QVector> #include <QVector>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include "keymapper_x11.h"
namespace { namespace {
@ -214,14 +215,29 @@ quint32 QxtGlobalShortcutPrivate::nativeModifiers(Qt::KeyboardModifiers modifier
quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key) quint32 QxtGlobalShortcutPrivate::nativeKeycode(Qt::Key key)
{ {
// (davidsansome) Try the table from QKeyMapper first - this seems to be
// the only way to get Keysyms for the media keys.
unsigned int keysym = 0;
int i = 0;
while (KeyTbl[i]) {
if (KeyTbl[i+1] == static_cast<uint>(key)) {
keysym = KeyTbl[i];
break;
}
i += 2;
}
// If that didn't work then fall back on XStringToKeysym
if (!keysym) {
keysym = XStringToKeysym(QKeySequence(key).toString().toLatin1().data());
if (keysym == NoSymbol)
keysym = static_cast<ushort>(key);
}
QxtX11Data x11; QxtX11Data x11;
if (!x11.isValid()) if (!x11.isValid())
return 0; return 0;
KeySym keysym = XStringToKeysym(QKeySequence(key).toString().toLatin1().data());
if (keysym == NoSymbol)
keysym = static_cast<ushort>(key);
return XKeysymToKeycode(x11.display(), keysym); return XKeysymToKeycode(x11.display(), keysym);
} }