diff --git a/README.md b/README.md index 2c5d99a9..f0223e2f 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,7 @@ Check the user manual [here](./docs/user-manual/userManual.md) **Not working on Wayland** -If you have a system-wide shortcut assigned to the`Print` key, you should disable it because it may interfere with the global key detection. - -As an alternative you can compile the cli-tool in `./tools/flameshot-cli`. The execution of this tool will launch a new capture via DBus (more functionalities will be implemented). +In order to launch a new capture you need to execute `flameshot-cli`, the sources of the cli tool are in `./tools/flameshot-cli` (the tool is compiled independently). Check the ./docs folder for more information. diff --git a/flameshot.pro b/flameshot.pro index dd5f61f2..1dd1d2d0 100644 --- a/flameshot.pro +++ b/flameshot.pro @@ -36,7 +36,6 @@ include(src/Qt-Color-Widgets//color_widgets.pri) DEFINES += QAPPLICATION_CLASS=QApplication SOURCES += src/main.cpp\ - src/nativeeventfilter.cpp \ src/controller.cpp \ src/capture/button.cpp \ src/capture/buttonhandler.cpp \ @@ -52,7 +51,6 @@ SOURCES += src/main.cpp\ src/flameshotdbusadapter.cpp HEADERS += \ - src/nativeeventfilter.h \ src/controller.h \ src/capture/button.h \ src/capture/buttonhandler.h \ diff --git a/src/controller.cpp b/src/controller.cpp index f6134958..eaeee1a0 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -42,10 +42,6 @@ Controller::Controller(QObject *parent) : QObject(parent), initDefaults(); qApp->setQuitOnLastWindowClosed(false); - m_nativeEventFilter = new NativeEventFilter(this); - qApp->installNativeEventFilter(m_nativeEventFilter); - connect(m_nativeEventFilter, &NativeEventFilter::activated, this, &Controller::createCapture); - QString StyleSheet = Button::getStyle(); qApp->setStyleSheet(StyleSheet); diff --git a/src/controller.h b/src/controller.h index ffa66e9d..b0130d1f 100644 --- a/src/controller.h +++ b/src/controller.h @@ -20,7 +20,6 @@ #include #include -#include "nativeeventfilter.h" class QMenu; class QSystemTrayIcon; @@ -54,8 +53,6 @@ private: QSystemTrayIcon *m_trayIcon; QMenu *m_trayIconMenu; - NativeEventFilter *m_nativeEventFilter; - QPointer m_captureWindow; QPointer m_infoWindow; QPointer m_configWindow; diff --git a/src/nativeeventfilter.cpp b/src/nativeeventfilter.cpp deleted file mode 100644 index 30da3a6d..00000000 --- a/src/nativeeventfilter.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2017 Alejandro Sirgo Rica -// -// This file is part of Flameshot. -// -// Flameshot is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Flameshot is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Flameshot. If not, see . - -#include "nativeeventfilter.h" -#include -#include -#include -#include -#include - -namespace { - Display * display; // Connection to X11 - Window win; // Grab window - int keycode; - QVector maskModifiers; -} - -NativeEventFilter::NativeEventFilter(QObject *parent) : QObject(parent) { - display = QX11Info::display(); - win = DefaultRootWindow(display); - maskModifiers << 0 << Mod2Mask << LockMask << (Mod2Mask | LockMask); - setShortcut(); -} - -bool NativeEventFilter::nativeEventFilter(const QByteArray &eventType, - void *message, long *result) -{ - Q_UNUSED(eventType) - Q_UNUSED(result) - - xcb_key_press_event_t *keyEvent; - - // Check xcb event - if (eventType == "xcb_generic_event_t") { - // cast message xcb event - xcb_generic_event_t *event = static_cast(message); - - // check key press - if ((event->response_type & 127) == XCB_KEY_PRESS){ - - keyEvent = static_cast(message); - - foreach (quint32 maskMods, maskModifiers) { - if((keyEvent->state == maskMods) - && keyEvent->detail == keycode){ - emit activated(); - return true; - } - } - } - } - return false; -} - -void NativeEventFilter::setShortcut() { - keycode = XKeysymToKeycode(display, XK_Print); - foreach (quint32 maskMods, maskModifiers) { - XGrabKey(display, - keycode , - maskMods, - win, - True, - GrabModeAsync, - GrabModeAsync); - } -} diff --git a/src/nativeeventfilter.h b/src/nativeeventfilter.h deleted file mode 100644 index 77bdc193..00000000 --- a/src/nativeeventfilter.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2017 Alejandro Sirgo Rica -// -// This file is part of Flameshot. -// -// Flameshot is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Flameshot is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Flameshot. If not, see . - -#ifndef NATIVEEVENTFILTER_H -#define NATIVEEVENTFILTER_H - -#include -#include - -class NativeEventFilter : public QObject, public QAbstractNativeEventFilter { - Q_OBJECT -public: - explicit NativeEventFilter(QObject *parent = 0); - - bool nativeEventFilter(const QByteArray &eventType, void *message, long *result); - -signals: - void activated(); - -private: - void setShortcut(); -}; - -#endif // NATIVEEVENTFILTER_H