diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2013-02-08 20:07:03 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2013-02-08 20:07:03 +0000 |
| commit | b996b5be460041167e5f97fde4b0b5695938360d (patch) | |
| tree | e1c32624accc1bcb975a438c6bd9859700a4f2be | |
| parent | 53cba850b9a66b1a946eedef42e7de82cfff1db0 (diff) | |
| download | qmmp-b996b5be460041167e5f97fde4b0b5695938360d.tar.gz qmmp-b996b5be460041167e5f97fde4b0b5695938360d.tar.bz2 qmmp-b996b5be460041167e5f97fde4b0b5695938360d.zip | |
hotkey plugin: fixed regression
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@3210 90c681e8-e032-0410-971d-27865f9a5e38
| -rw-r--r-- | src/plugins/General/hotkey/CMakeLists.txt | 9 | ||||
| -rw-r--r-- | src/plugins/General/hotkey/hotkey.pro | 1 | ||||
| -rw-r--r-- | src/plugins/General/hotkey/hotkeymanager.cpp | 42 |
3 files changed, 35 insertions, 17 deletions
diff --git a/src/plugins/General/hotkey/CMakeLists.txt b/src/plugins/General/hotkey/CMakeLists.txt index 29a9c06b2..33aa48ffb 100644 --- a/src/plugins/General/hotkey/CMakeLists.txt +++ b/src/plugins/General/hotkey/CMakeLists.txt @@ -30,6 +30,13 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../../) link_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../qmmpui) link_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../qmmp) +# xkb +CHECK_INCLUDE_FILE(X11/XKBlib.h XKBLIB_H_FOUND) +IF(XKBLIB_H_FOUND) +ADD_DEFINITIONS(-DHAVE_XKBLIB_H) +SET(CMAKE_REQUIRED_DEFINITIONS -DHAVE_XKBLIB_H) +ENDIF(XKBLIB_H_FOUND) + SET(libhotkey_SRCS settingsdialog.cpp hotkeyfactory.cpp @@ -44,7 +51,7 @@ SET(libhotkey_MOC_HDRS hotkeydialog.h ) -SET(libhotkey_RCCS +SET(libhotkey_RCCS translations/translations.qrc ) diff --git a/src/plugins/General/hotkey/hotkey.pro b/src/plugins/General/hotkey/hotkey.pro index ff00d1f26..7a3bd3e4d 100644 --- a/src/plugins/General/hotkey/hotkey.pro +++ b/src/plugins/General/hotkey/hotkey.pro @@ -7,6 +7,7 @@ plugin \ link_pkgconfig PKGCONFIG += x11 +DEFINES += HAVE_XKBLIB_H TARGET = $$PLUGINS_PREFIX/General/hotkey QMAKE_CLEAN = $$PLUGINS_PREFIX/General/libhotkey.so diff --git a/src/plugins/General/hotkey/hotkeymanager.cpp b/src/plugins/General/hotkey/hotkeymanager.cpp index 070619b3a..98cb8330d 100644 --- a/src/plugins/General/hotkey/hotkeymanager.cpp +++ b/src/plugins/General/hotkey/hotkeymanager.cpp @@ -34,7 +34,9 @@ extern "C" #include <X11/Xlib.h> #include <X11/keysym.h> #include <X11/XF86keysym.h> +#ifdef HAVE_XKBLIB_H #include <X11/XKBlib.h> +#endif } #undef CursorShape #undef Status @@ -91,7 +93,7 @@ HotkeyManager::HotkeyManager(QObject *parent) : QObject(parent) Hotkey *hotkey = new Hotkey; hotkey->action = i; hotkey->key = key; - hotkey->code = XkbKeycodeToKeysym(QX11Info::display(), hotkey->key, 0, 0); + hotkey->code = XKeysymToKeycode(QX11Info::display(), hotkey->key); if(!hotkey->code) continue; XGrabKey(QX11Info::display(), hotkey->code, mod | mask_mod, rootWindow, False, @@ -103,7 +105,7 @@ HotkeyManager::HotkeyManager(QObject *parent) : QObject(parent) } settings.endGroup(); XSync(QX11Info::display(), False); -// XSetErrorHandler(); + // XSetErrorHandler(); } HotkeyManager::~HotkeyManager() @@ -137,7 +139,7 @@ bool HotkeyManager::eventFilter(QObject* o, QEvent* e) if (e->type() == QEvent::KeyPress && (o == qApp->desktop () || o == qApp->activeWindow ())) { QKeyEvent* k = static_cast<QKeyEvent*>(e); - quint32 key = XkbKeycodeToKeysym(QX11Info::display(), k->nativeScanCode (), 0, 0); + quint32 key = keycodeToKeysym(k->nativeScanCode()); quint32 mod = k->nativeModifiers (); SoundCore *core = SoundCore::instance(); MediaPlayer *player = MediaPlayer::instance(); @@ -176,20 +178,20 @@ bool HotkeyManager::eventFilter(QObject* o, QEvent* e) case Hotkey::VOLUME_UP: case Hotkey::VOLUME_DOWN: { - int volume = qMax(core->leftVolume(), core->rightVolume()); - int balance = 0; - int left = core->leftVolume(); - int right = core->rightVolume(); - if (left || right) - balance = (right - left)*100/volume; - if(hotkey->action == Hotkey::VOLUME_UP) - volume = qMin (100, volume + 5); - else - volume = qMax (0, volume - 5); - core->setVolume(volume-qMax(balance,0)*volume/100, - volume+qMin(balance,0)*volume/100); + int volume = qMax(core->leftVolume(), core->rightVolume()); + int balance = 0; + int left = core->leftVolume(); + int right = core->rightVolume(); + if (left || right) + balance = (right - left)*100/volume; + if(hotkey->action == Hotkey::VOLUME_UP) + volume = qMin (100, volume + 5); + else + volume = qMax (0, volume - 5); + core->setVolume(volume-qMax(balance,0)*volume/100, + volume+qMin(balance,0)*volume/100); } - break; + break; case Hotkey::FORWARD: core->seek(core->elapsed() + 5000); break; @@ -239,7 +241,11 @@ void HotkeyManager::ensureModifiers() int symIndex = 0; do { +#ifdef HAVE_XKBLIB_H sym = XkbKeycodeToKeysym(appDpy, map->modifiermap[mapIndex], symIndex, 0); +#else + sym = XKeycodeToKeysym(appDpy, map->modifiermap[mapIndex], symIndex); +#endif symIndex++; } while ( !sym && symIndex < keysyms_per_keycode); @@ -309,5 +315,9 @@ QList<long> HotkeyManager::ignModifiersList() quint32 HotkeyManager::keycodeToKeysym(quint32 keycode) { +#ifdef HAVE_XKBLIB_H return XkbKeycodeToKeysym(QX11Info::display(), keycode, 0, 0); +#else + return XKeycodeToKeysym(QX11Info::display(), keycode,0); +#endif } |
