13 Commits
Author SHA1 Message Date
Skycoder42 91f3542b5d qm update 2017-06-25 14:41:23 +02:00
Skycoder42 1833a053f6 fixed xerrorhandler
fixes #4
2017-06-25 14:40:03 +02:00
Felix Barz f288e85ef1 Create README.md 2017-06-15 11:41:09 +02:00
Skycoder42 2578b69dc5 remove recursive call
detected by #4
2017-06-02 21:24:14 +02:00
Skycoder42 a0678c4cfc qpm update 2017-05-14 22:28:10 +02:00
Skycoder42 cdb4d37453 replaced XSync by XFlush 2017-05-14 22:27:26 +02:00
Skycoder42 9eace8fbbd do not discard events on XSync 2017-05-14 13:39:54 +02:00
Skycoder42 6baf644b40 fixed misread parameter
#3
2017-05-14 13:35:13 +02:00
Skycoder42 3fa176a380 Added XSync call for hotkey without window
For #3
2017-05-14 13:32:06 +02:00
Skycoder42 7c4ef6a03a qpm update 2017-05-01 12:17:18 +02:00
Skycoder42 15e34a7dbf fixed initial tab 2017-05-01 12:15:01 +02:00
Felix Barz b8f32c3381 Merge pull request #2 from ArsenArsen/patch-1
Fix a compile error on MXE
2017-05-01 12:13:48 +02:00
ArsenArsen 10d1e44b21 Fix a compile error on MXE 2017-05-01 11:48:53 +02:00
6 changed files with 29 additions and 10 deletions
+1 -1
View File
@@ -17,7 +17,7 @@
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>3</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="playTab"> <widget class="QWidget" name="playTab">
<attribute name="title"> <attribute name="title">
+9
View File
@@ -1,11 +1,20 @@
#include "hottestwidget.h" #include "hottestwidget.h"
#include <QApplication> #include <QApplication>
//#define START_BACKGROUND
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QApplication a(argc, argv); QApplication a(argc, argv);
HotTestWidget w; HotTestWidget w;
#ifdef START_BACKGROUND
auto startKey = new QHotkey(QKeySequence(Qt::MetaModifier | Qt::ControlModifier | Qt::Key_S), true, &w);
QObject::connect(startKey, &QHotkey::activated,
&w, &QWidget::show);
#else
w.show(); w.show();
#endif
return a.exec(); return a.exec();
} }
+11 -5
View File
@@ -106,6 +106,7 @@ bool QHotkeyPrivateX11::registerShortcut(QHotkey::NativeShortcut shortcut)
GrabModeAsync, GrabModeAsync,
GrabModeAsync); GrabModeAsync);
} }
XSync(display, False);
if(errorHandler.hasError) { if(errorHandler.hasError) {
qCWarning(logQHotkey) << "Failed to register hotkey. Error:" qCWarning(logQHotkey) << "Failed to register hotkey. Error:"
@@ -129,11 +130,11 @@ bool QHotkeyPrivateX11::unregisterShortcut(QHotkey::NativeShortcut shortcut)
shortcut.modifier | specialMod, shortcut.modifier | specialMod,
DefaultRootWindow(display)); DefaultRootWindow(display));
} }
XSync(display, False);
if(errorHandler.hasError) { if(errorHandler.hasError) {
qCWarning(logQHotkey) << "Failed to unregister hotkey. Error:" qCWarning(logQHotkey) << "Failed to unregister hotkey. Error:"
<< qPrintable(errorHandler.errorString); << qPrintable(errorHandler.errorString);
this->unregisterShortcut(shortcut);
return false; return false;
} else } else
return true; return true;
@@ -155,27 +156,32 @@ QString QHotkeyPrivateX11::HotkeyErrorHandler::errorString;
QHotkeyPrivateX11::HotkeyErrorHandler::HotkeyErrorHandler() QHotkeyPrivateX11::HotkeyErrorHandler::HotkeyErrorHandler()
{ {
this->prevHandler = XSetErrorHandler(&HotkeyErrorHandler::handleError); prevHandler = XSetErrorHandler(&HotkeyErrorHandler::handleError);
} }
QHotkeyPrivateX11::HotkeyErrorHandler::~HotkeyErrorHandler() QHotkeyPrivateX11::HotkeyErrorHandler::~HotkeyErrorHandler()
{ {
XSetErrorHandler(this->prevHandler); XSetErrorHandler(prevHandler);
hasError = false;
errorString.clear();
} }
int QHotkeyPrivateX11::HotkeyErrorHandler::handleError(Display *display, XErrorEvent *error) int QHotkeyPrivateX11::HotkeyErrorHandler::handleError(Display *display, XErrorEvent *error)
{ {
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wimplicit-fallthrough")
switch (error->error_code) { switch (error->error_code) {
case BadAccess: case BadAccess:
case BadValue: case BadValue:
case BadWindow: case BadWindow:
if (error->request_code == 33 || //grab key if (error->request_code == 33 || //grab key
error->request_code == 34) {// ungrab key error->request_code == 34) {// ungrab key
HotkeyErrorHandler::hasError = true; hasError = true;
HotkeyErrorHandler::errorString = QHotkeyPrivateX11::formatX11Error(display, error->error_code); errorString = QHotkeyPrivateX11::formatX11Error(display, error->error_code);
return 1; return 1;
} }
default: default:
return 0; return 0;
} }
QT_WARNING_POP
} }
+5 -1
View File
@@ -15,12 +15,16 @@ The QHotkey is a class that can be used to create hotkeys/global shortcuts, aka
## Installation ## Installation
The package is providet as qpm package, [`de.skycoder42.qhotkey`](https://www.qpm.io/packages/de.skycoder42.qhotkey/index.html). To install: The package is providet as qpm package, [`de.skycoder42.qhotkey`](https://www.qpm.io/packages/de.skycoder42.qhotkey/index.html). To install:
1. Install qpm (See [GitHub - Installing](https://github.com/Cutehacks/qpm/blob/master/README.md#installing)) 1. Install qpm (See [GitHub - Installing](https://github.com/Cutehacks/qpm/blob/master/README.md#installing), for **windows** see below)
2. In your projects root directory, run `qpm install de.skycoder42.qhotkey` 2. In your projects root directory, run `qpm install de.skycoder42.qhotkey`
3. Include qpm to your project by adding `include(vendor/vendor.pri)` to your `.pro` file 3. Include qpm to your project by adding `include(vendor/vendor.pri)` to your `.pro` file
Check their [GitHub - Usage for App Developers](https://github.com/Cutehacks/qpm/blob/master/README.md#usage-for-app-developers) to learn more about qpm. Check their [GitHub - Usage for App Developers](https://github.com/Cutehacks/qpm/blob/master/README.md#usage-for-app-developers) to learn more about qpm.
**Important for Windows users:** QPM Version *0.10.0* (the one you can download on the website) is currently broken on windows! It's already fixed in master, but not released yet. Until a newer versions gets released, you can download the latest dev build from here:
- https://storage.googleapis.com/www.qpm.io/download/latest/windows_amd64/qpm.exe
- https://storage.googleapis.com/www.qpm.io/download/latest/windows_386/qpm.exe
## Usage ## Usage
The general usage is to create QHotkey instances for specific hotkeys, register them and then simply connect to the signal emitted once the hotkey is pressed. The general usage is to create QHotkey instances for specific hotkeys, register them and then simply connect to the signal emitted once the hotkey is pressed.
+1 -1
View File
@@ -10,7 +10,7 @@ mac {
LIBS += -framework Carbon LIBS += -framework Carbon
} else:win32 { } else:win32 {
SOURCES += $$PWD/QHotkey/qhotkey_win.cpp SOURCES += $$PWD/QHotkey/qhotkey_win.cpp
LIBS += -lUser32 LIBS += -luser32
} else:unix { } else:unix {
SOURCES += $$PWD/QHotkey/qhotkey_x11.cpp SOURCES += $$PWD/QHotkey/qhotkey_x11.cpp
QT += x11extras QT += x11extras
+1 -1
View File
@@ -10,7 +10,7 @@
"url": "https://github.com/Skycoder42/QHotkey.git" "url": "https://github.com/Skycoder42/QHotkey.git"
}, },
"version": { "version": {
"label": "1.1.1", "label": "1.1.4",
"revision": "", "revision": "",
"fingerprint": "" "fingerprint": ""
}, },