Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThorvald Natvig <slicer@users.sourceforge.net>2007-10-29 13:12:23 +0300
committerThorvald Natvig <slicer@users.sourceforge.net>2007-10-29 13:12:23 +0300
commit2d1ec937947a6f654dff6bc2af7adcdb42efcf34 (patch)
treeb82d687c94700c4d765d2533eb7e82f2c1f279f2 /src
parent98a1f8fcc26f7ac5b0c0dfc56e3401178d851f25 (diff)
QVariant Shortcut for Linux
git-svn-id: https://mumble.svn.sourceforge.net/svnroot/mumble/trunk@825 05730e5d-ab1b-0410-a4ac-84af385074fa
Diffstat (limited to 'src')
-rw-r--r--src/mumble/GlobalShortcut_unix.cpp127
-rw-r--r--src/mumble/GlobalShortcut_unix.h27
-rw-r--r--src/mumble/GlobalShortcut_win.cpp2
-rw-r--r--src/mumble/GlobalShortcut_win.h1
4 files changed, 6 insertions, 151 deletions
diff --git a/src/mumble/GlobalShortcut_unix.cpp b/src/mumble/GlobalShortcut_unix.cpp
index f618a43cd..ab779847a 100644
--- a/src/mumble/GlobalShortcut_unix.cpp
+++ b/src/mumble/GlobalShortcut_unix.cpp
@@ -40,11 +40,11 @@
#include <fcntl.h>
#endif
+GlobalShortcutEngine *GlobalShortcutEngine::platformInit() {
+ return new GlobalShortcutX();
+}
+
GlobalShortcutX::GlobalShortcutX() {
- engine = this;
- ref = 0;
- bGrabbing = false;
- bNeedRemap = true;
int min, maj;
bRunning=false;
@@ -112,75 +112,11 @@ GlobalShortcutX::GlobalShortcutX() {
start(QThread::TimeCriticalPriority);
}
-void GlobalShortcutX::add(GlobalShortcut *gs) {
- qmShortcuts[gs->idx] = gs;
- bNeedRemap=true;
-}
-
-void GlobalShortcutX::remove(GlobalShortcut *gs) {
- qmShortcuts.remove(gs->idx);
- bNeedRemap=true;
-}
-
-void GlobalShortcutX::grab() {
- bGrabbing = true;
-}
-
-void GlobalShortcutX::release() {
- bGrabbing = false;
-}
-
GlobalShortcutX::~GlobalShortcutX() {
bRunning = false;
wait();
}
-void GlobalShortcutX::remap() {
- bNeedRemap = false;
-
- foreach(Shortcut *s, qhGlobalToX) {
- delete s;
- }
- qhGlobalToX.clear();
- qmhKeyToShortcut.clear();
-
- foreach(GlobalShortcut *gs, qmShortcuts) {
- const QList<QVariant> &ql = g.s.qmShortcuts.value(gs->idx);
- QList<unsigned int> buttons;
- foreach(QVariant v, ql) {
- bool ok;
- int val = v.toInt(&ok);
- if ((val > 0) && ok)
- buttons << val;
- }
- if (buttons.count() > 0) {
- Shortcut *s = new Shortcut();
- s->gs = gs;
- s->bActive = false;
- s->iNumDown = 0;
- for (int i=0;i<buttons.count();i++) {
- s->qlButtons << buttons[i];
- qmhKeyToShortcut.insert(buttons[i], s);
- }
- qhGlobalToX[gs] = s;
- }
- }
-}
-
-void GlobalShortcutX::resetMap() {
- bFirstMouseReleased = false;
- for (int i=0;i<NUM_BUTTONS;i++)
- touchMap[i]=false;
-}
-
-QList<QVariant> GlobalShortcutX::getCurrentButtons() {
- QList<QVariant> keys;
- for (int i=0;i<NUM_BUTTONS;i++)
- if (touchMap[i])
- keys << i;
- return keys;
-}
-
void GlobalShortcutX::run() {
fd_set in_fds;
XEvent evt;
@@ -209,7 +145,7 @@ void GlobalShortcutX::run() {
else
evtcode = 0x118 + evt.xbutton.button;
- handleEvent(evtcode, down);
+ handleButton(evtcode, down);
}
break;
default:
@@ -247,40 +183,11 @@ void GlobalShortcutX::inputReadyRead(int) {
continue;
}
int evtcode = ev.code + 8;
- handleEvent(evtcode, down);
+ handleButton(evtcode, down);
}
#endif
}
-void GlobalShortcutX::handleEvent(int evtcode, bool down) {
- if (down == activeMap[evtcode])
- return;
-
- activeMap[evtcode] = down;
- if (down)
- touchMap[evtcode] = true;
-
- emit buttonPressed(!down);
-
- foreach(Shortcut *s, qmhKeyToShortcut.values(evtcode)) {
- if (down) {
- s->iNumDown++;
- if (s->iNumDown == s->qlButtons.count()) {
- s->bActive = true;
- emit s->gs->triggered(down);
- emit s->gs->down();
- }
- } else {
- s->iNumDown--;
- if (s->bActive) {
- s->bActive = false;
- emit s->gs->triggered(down);
- emit s->gs->up();
- }
- }
- }
-}
-
QString GlobalShortcutX::buttonName(const QVariant &v) {
bool ok;
unsigned int key=v.toUInt(&ok);
@@ -302,25 +209,3 @@ QString GlobalShortcutX::buttonName(const QVariant &v) {
return tr("Mouse %1").arg(key-0x118);
}
}
-
-GlobalShortcut::GlobalShortcut(QObject *p, int index, QString qsName) : QObject(p) {
- if (! GlobalShortcutEngine::engine)
- GlobalShortcutEngine::engine = new GlobalShortcutX();
- GlobalShortcutX *gsx = static_cast<GlobalShortcutX *>(GlobalShortcutEngine::engine);
- gsx->ref++;
- idx = index;
- name=qsName;
- act = false;
- gsx->add(this);
-}
-
-GlobalShortcut::~GlobalShortcut() {
- GlobalShortcutX *gsx = static_cast<GlobalShortcutX *>(GlobalShortcutEngine::engine);
-
- gsx->remove(this);
- gsx->ref--;
- if (gsx->ref == 0) {
- delete gsx;
- gsx = NULL;
- }
-}
diff --git a/src/mumble/GlobalShortcut_unix.h b/src/mumble/GlobalShortcut_unix.h
index 7654aa88f..fd8692f39 100644
--- a/src/mumble/GlobalShortcut_unix.h
+++ b/src/mumble/GlobalShortcut_unix.h
@@ -31,46 +31,19 @@
#include "GlobalShortcut.h"
#include "ConfigDialog.h"
-typedef QPair<int, unsigned int> qpButton;
-
-struct Shortcut {
- GlobalShortcut *gs;
- int iNumDown;
- bool bActive;
- QList<int> qlButtons;
-};
-
#define NUM_BUTTONS 0x2ff
class GlobalShortcutX : public GlobalShortcutEngine {
Q_OBJECT
public:
Display *display;
- int ref;
bool bRunning;
- bool activeMap[NUM_BUTTONS];
- bool touchMap[NUM_BUTTONS];
- bool bFirstMouseReleased;
- QHash<GlobalShortcut *, Shortcut *> qhGlobalToX;
QList<QFile *> qlInputDevices;
- bool globalEvent(XEvent *);
- bool bGrabbing;
- void grab();
- void release();
- QMultiHash<int, Shortcut *> qmhKeyToShortcut;
- void handleEvent(int evtcode, bool down);
GlobalShortcutX();
~GlobalShortcutX();
void run();
- void remap();
- void resetMap();
- void add(GlobalShortcut *);
- void remove(GlobalShortcut *);
- QList<QVariant> getCurrentButtons();
QString buttonName(const QVariant &);
public slots:
void inputReadyRead(int);
- signals:
- void buttonPressed(bool);
};
diff --git a/src/mumble/GlobalShortcut_win.cpp b/src/mumble/GlobalShortcut_win.cpp
index eb7ea15dd..9b9be0999 100644
--- a/src/mumble/GlobalShortcut_win.cpp
+++ b/src/mumble/GlobalShortcut_win.cpp
@@ -49,8 +49,6 @@ GlobalShortcutEngine *GlobalShortcutEngine::platformInit() {
}
GlobalShortcutWin::GlobalShortcutWin() {
- engine = this;
- ref = 0;
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(timeTicked()));
diff --git a/src/mumble/GlobalShortcut_win.h b/src/mumble/GlobalShortcut_win.h
index 813a7e3e9..95ec36fe2 100644
--- a/src/mumble/GlobalShortcut_win.h
+++ b/src/mumble/GlobalShortcut_win.h
@@ -58,7 +58,6 @@ class GlobalShortcutWin : public GlobalShortcutEngine {
Q_OBJECT
public:
QTimer *timer;
- int ref;
LPDIRECTINPUT8 pDI;
QHash<GUID, InputDevice *> qhInputDevices;