4 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
3 changed files with 18 additions and 10 deletions
+11 -7
View File
@@ -106,7 +106,7 @@ bool QHotkeyPrivateX11::registerShortcut(QHotkey::NativeShortcut shortcut)
GrabModeAsync,
GrabModeAsync);
}
XFlush(display);
XSync(display, False);
if(errorHandler.hasError) {
qCWarning(logQHotkey) << "Failed to register hotkey. Error:"
@@ -130,12 +130,11 @@ bool QHotkeyPrivateX11::unregisterShortcut(QHotkey::NativeShortcut shortcut)
shortcut.modifier | specialMod,
DefaultRootWindow(display));
}
XFlush(display);
XSync(display, False);
if(errorHandler.hasError) {
qCWarning(logQHotkey) << "Failed to unregister hotkey. Error:"
<< qPrintable(errorHandler.errorString);
this->unregisterShortcut(shortcut);
return false;
} else
return true;
@@ -157,27 +156,32 @@ QString QHotkeyPrivateX11::HotkeyErrorHandler::errorString;
QHotkeyPrivateX11::HotkeyErrorHandler::HotkeyErrorHandler()
{
this->prevHandler = XSetErrorHandler(&HotkeyErrorHandler::handleError);
prevHandler = XSetErrorHandler(&HotkeyErrorHandler::handleError);
}
QHotkeyPrivateX11::HotkeyErrorHandler::~HotkeyErrorHandler()
{
XSetErrorHandler(this->prevHandler);
XSetErrorHandler(prevHandler);
hasError = false;
errorString.clear();
}
int QHotkeyPrivateX11::HotkeyErrorHandler::handleError(Display *display, XErrorEvent *error)
{
QT_WARNING_PUSH
QT_WARNING_DISABLE_GCC("-Wimplicit-fallthrough")
switch (error->error_code) {
case BadAccess:
case BadValue:
case BadWindow:
if (error->request_code == 33 || //grab key
error->request_code == 34) {// ungrab key
HotkeyErrorHandler::hasError = true;
HotkeyErrorHandler::errorString = QHotkeyPrivateX11::formatX11Error(display, error->error_code);
hasError = true;
errorString = QHotkeyPrivateX11::formatX11Error(display, error->error_code);
return 1;
}
default:
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
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`
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.
**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
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.
+2 -2
View File
@@ -10,7 +10,7 @@
"url": "https://github.com/Skycoder42/QHotkey.git"
},
"version": {
"label": "1.1.3",
"label": "1.1.4",
"revision": "",
"fingerprint": ""
},
@@ -19,4 +19,4 @@
"license": "BSD_3_CLAUSE",
"pri_filename": "qhotkey.pri",
"webpage": "https://github.com/Skycoder42/QHotkey"
}
}