Hello community,

here is the log from the commit of package ksnip for openSUSE:Factory checked 
in at 2020-06-06 23:39:40
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/ksnip (Old)
 and      /work/SRC/openSUSE:Factory/.ksnip.new.3606 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ksnip"

Sat Jun  6 23:39:40 2020 rev:4 rq:811917 version:1.6.2

Changes:
--------
--- /work/SRC/openSUSE:Factory/ksnip/ksnip.changes      2020-02-28 
15:21:31.049914647 +0100
+++ /work/SRC/openSUSE:Factory/.ksnip.new.3606/ksnip.changes    2020-06-06 
23:40:03.881040184 +0200
@@ -1,0 +2,14 @@
+Fri Jun  5 18:29:58 UTC 2020 - Christophe Giboudeaux <[email protected]>
+
+- Update to 1.6.2
+  * Changed: Add missing plugs to silence snap socket warnings.
+  * Fixed: Window decoration and alt+tab menu show Wayland generic icon on KDE 
Plasma.
+  * Fixed: Logout canceled by 'ksnip' under KDE.
+  * Fixed: Ksnip not displayed on the monitor (off screen).
+  * Fixed: CTRL+Q to quit Ksnip not working.
+  * Fixed: Global Hotkeys not working with activated Num and Caps Lock under 
X11.
+  * Fixed: Meta Global Hotkey under X11 not working.
+- Add upstream patch:
+  * 0001-Fix-compilation-error-with-Qt-5.15-279.patch
+
+-------------------------------------------------------------------

Old:
----
  ksnip-1.6.1.tar.gz

New:
----
  0001-Fix-compilation-error-with-Qt-5.15-279.patch
  ksnip-1.6.2.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ ksnip.spec ++++++
--- /var/tmp/diff_new_pack.8YF5Yq/_old  2020-06-06 23:40:05.121044075 +0200
+++ /var/tmp/diff_new_pack.8YF5Yq/_new  2020-06-06 23:40:05.125044089 +0200
@@ -17,13 +17,15 @@
 
 
 Name:           ksnip
-Version:        1.6.1
+Version:        1.6.2
 Release:        0
 Summary:        Screenshot tool
 License:        GPL-2.0-or-later
 Group:          Productivity/Graphics/Other
 URL:            https://github.com/DamirPorobic/ksnip
 Source:         
https://github.com/DamirPorobic/ksnip/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
+# PATCH-FIX-UPSTREAM
+Patch0:         0001-Fix-compilation-error-with-Qt-5.15-279.patch
 BuildRequires:  cmake
 BuildRequires:  extra-cmake-modules
 BuildRequires:  gcc-c++
@@ -49,11 +51,11 @@
 %lang_package
 
 %prep
-%setup -q
+%autosetup -p1
 
 %build
 %cmake
-%make_jobs
+%cmake_build
 
 %install
 %cmake_install

++++++ 0001-Fix-compilation-error-with-Qt-5.15-279.patch ++++++
>From 35f93bb2a25f6c8948f2664c15eaad2d0860003a Mon Sep 17 00:00:00 2001
From: Dmitry Atamanov <[email protected]>
Date: Sat, 28 Mar 2020 03:00:28 +0500
Subject: [PATCH] Fix compilation error with Qt 5.15 (#279)

* Fix compilation error with Qt 5.15

* Remove include guard

Co-authored-by: Damir Porobic <[email protected]>
---
 src/gui/snippingArea/AdornerSizeInfo.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/gui/snippingArea/AdornerSizeInfo.h 
b/src/gui/snippingArea/AdornerSizeInfo.h
index 5167145..d6264c5 100644
--- a/src/gui/snippingArea/AdornerSizeInfo.h
+++ b/src/gui/snippingArea/AdornerSizeInfo.h
@@ -21,6 +21,7 @@
 #define KSNIP_ADORNERSIZEINFO_H
 
 #include <QPainter>
+#include <QPainterPath>
 
 class AdornerSizeInfo
 {
-- 
2.26.2

++++++ ksnip-1.6.1.tar.gz -> ksnip-1.6.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ksnip-1.6.1/CHANGELOG.md new/ksnip-1.6.2/CHANGELOG.md
--- old/ksnip-1.6.1/CHANGELOG.md        2020-02-23 19:55:46.000000000 +0100
+++ new/ksnip-1.6.2/CHANGELOG.md        2020-05-05 18:14:45.000000000 +0200
@@ -1,5 +1,14 @@
 # Change log
 
+## Release 1.6.2
+* Changed: Add missing plugs to silence snap socket warnings. 
([#313](https://github.com/ksnip/ksnip/issues/313))
+* Fixed: Window decoration and alt+tab menu show Wayland generic icon on KDE 
Plasma. ([#269](https://github.com/ksnip/kImageAnnotator/issues/269))
+* Fixed: Logout canceled by 'ksnip' under KDE. 
([#281](https://github.com/ksnip/kImageAnnotator/issues/281))
+* Fixed: Ksnip not displayed on the monitor (off screen). 
([#307](https://github.com/ksnip/kImageAnnotator/issues/307))
+* Fixed: CTRL+Q to quit Ksnip not working. 
([#308](https://github.com/ksnip/kImageAnnotator/issues/308))
+* Fixed: Global Hotkeys not working with activated Num and Caps Lock under 
X11. ([#310](https://github.com/ksnip/kImageAnnotator/issues/310))
+* Fixed: Meta Global Hotkey under X11 not working. 
([#311](https://github.com/ksnip/kImageAnnotator/issues/311))
+
 ## Release 1.6.1
 * Change: Allow opening link directly to image without opening in browser. 
([#248](https://github.com/ksnip/kImageAnnotator/issues/248))
 * Change: Always use transparent snipping area background for Wayland. 
([#176](https://github.com/ksnip/kImageAnnotator/issues/176))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ksnip-1.6.1/CMakeLists.txt 
new/ksnip-1.6.2/CMakeLists.txt
--- old/ksnip-1.6.1/CMakeLists.txt      2020-02-23 19:55:46.000000000 +0100
+++ new/ksnip-1.6.2/CMakeLists.txt      2020-05-05 18:14:45.000000000 +0200
@@ -1,5 +1,5 @@
 cmake_minimum_required(VERSION 3.5)
-project(ksnip LANGUAGES CXX VERSION 1.6.1)
+project(ksnip LANGUAGES CXX VERSION 1.6.2)
 
 if (DEFINED VERSION_SUFIX AND NOT "${VERSION_SUFIX}" STREQUAL "")
     set(KSNIP_VERSION_SUFIX "-${VERSION_SUFIX}")
@@ -27,7 +27,7 @@
 set(CMAKE_CXX_STANDARD_REQUIRED ON)
 set(CMAKE_CXX_EXTENSIONS OFF)
 
-set(QT_MIN_VERSION "5.6.1")
+set(QT_MIN_VERSION "5.7.1")
 
 find_package(Qt5 ${QT_MIN_VERSION} REQUIRED Widgets Network Xml PrintSupport 
DBus)
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ksnip-1.6.1/README.md new/ksnip-1.6.2/README.md
--- old/ksnip-1.6.1/README.md   2020-02-23 19:55:46.000000000 +0100
+++ new/ksnip-1.6.2/README.md   2020-05-05 18:14:45.000000000 +0200
@@ -1,7 +1,7 @@
 # [ksnip](http://ksnip.org/) &middot; [![Build 
Status][travis-badge]][travis-url] [![GitHub commits (since latest 
release)][gh-comm-since-badge]][gh-comm-since-url] [![Translation 
status][weblate-badge]][weblate-url] [![GitHub total 
downloads][gh-dl-badge]][gh-dl-url] [![SourceForge total 
downloads][sf-dt-badge]][sf-dt-badge-url] 
 
 
-Version v1.6.1
+Version v1.6.2
 
 Ksnip is a Qt based cross-platform screenshot tool that provides many 
annotation features 
 for your screenshots.
@@ -67,6 +67,24 @@
 `$ sudo dpkg -i ksnip*.deb`  
 `$ ksnip`  
 
+### Snap (Linux)
+The usual installation for snaps, will install latest version:  
+`$ sudo snap install ksnip`  
+
+The continuous build version is also available as edge, in order to install it 
you need to provide the edge flag:  
+`$ sudo snap install ksnip --edge`  
+
+Snap startup time can be speed up and console output cleaned up by running 
following commands:
+```
+snap connect ksnip:network-observe 
+snap connect ksnip:network-manager-observe 
+snap connect ksnip:system-observe 
+snap connect ksnip:removable-media 
+```
+ This needs to be done only once and connects some snap plugs which are 
currently not auto-connected.  
+ 
+[![Get it from the Snap 
Store](https://snapcraft.io/static/images/badges/en/snap-store-black.svg)](https://snapcraft.io/ksnip)
+
 ### EXE (Windows)
 The exe file with all required dependencies comes in a zipped package, which 
just need to be unzipped 
 with your favorite zip tool. Ksnip can then be started by just double clicking 
ksnip.exe.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ksnip-1.6.1/ci/scripts/bootstrap.sh 
new/ksnip-1.6.2/ci/scripts/bootstrap.sh
--- old/ksnip-1.6.1/ci/scripts/bootstrap.sh     2020-02-23 19:55:46.000000000 
+0100
+++ new/ksnip-1.6.2/ci/scripts/bootstrap.sh     2020-05-05 18:14:45.000000000 
+0200
@@ -1,7 +1,7 @@
 #!/bin/bash
 
 if [[ "${BINARY_TYPE}" == "AppImage" ]]; then
-    sudo add-apt-repository ppa:beineri/opt-qt562-trusty -y
+    sudo add-apt-repository ppa:beineri/opt-qt571-trusty -y
     sudo apt-get update -qq
 
     echo "--> Download linuxdeployqt tool"
@@ -18,20 +18,20 @@
 
     echo "--> Download Dependencies"
 
-    
QT_BASE_URL="https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/qt5_563/qt.563.win32_msvc2015/5.6.3-0-201709190903";
+    
QT_BASE_URL="https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/qt5_57/qt.57.win32_msvc2015/5.7.1-0";
     wget --quiet -O qtbase.7z 
"${QT_BASE_URL}qtbase-Windows-Windows_10-MSVC2015-Windows-Windows_10-X86.7z"
     wget --quiet -O qtwinextras.7z 
"${QT_BASE_URL}qtwinextras-Windows-Windows_10-MSVC2015-Windows-Windows_10-X86.7z"
     wget --quiet -O qttools.7z 
"${QT_BASE_URL}qttools-Windows-Windows_10-MSVC2015-Windows-Windows_10-X86.7z"
     wget --quiet -O qttranslations.7z 
"${QT_BASE_URL}qttranslations-Windows-Windows_10-MSVC2015-Windows-Windows_10-X86.7z"
     wget --quiet -O qtsvg.7z 
"${QT_BASE_URL}qtsvg-Windows-Windows_10-MSVC2015-Windows-Windows_10-X86.7z"
-         wget --quiet -O openssl.zip 
"https://indy.fulgan.com/SSL/openssl-1.0.2q-i386-win32.zip";
+       wget --quiet -O openssl.zip 
"https://indy.fulgan.com/SSL/openssl-1.0.2q-i386-win32.zip";
 
     7z x qtbase.7z -o/c/qt
     7z x qtwinextras.7z -o/c/qt
     7z x qttools.7z -o/c/qt
     7z x qttranslations.7z -o/c/qt
     7z x qtsvg.7z -o/c/qt
-       
+
     7z x openssl.zip -o/c/openssl
 
     # windeployqt fails to find the binaries so we link the binaries where its 
looking for it
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ksnip-1.6.1/ci/scripts/exe/bootstrap_envvars.sh 
new/ksnip-1.6.2/ci/scripts/exe/bootstrap_envvars.sh
--- old/ksnip-1.6.1/ci/scripts/exe/bootstrap_envvars.sh 2020-02-23 
19:55:46.000000000 +0100
+++ new/ksnip-1.6.2/ci/scripts/exe/bootstrap_envvars.sh 2020-05-05 
18:14:45.000000000 +0200
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-QT_DIR="/c/qt/5.6.3/msvc2015"
+QT_DIR="/c/qt/5.7/msvc2015"
 PROGRAMFILES="/c/Program Files (x86)"
 WINDOWS_KITS="$PROGRAMFILES/Windows Kits"
 WINDOWS_KITS_BIN="$WINDOWS_KITS/10/bin/10.0.17134.0"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ksnip-1.6.1/ci/scripts/setup.sh 
new/ksnip-1.6.2/ci/scripts/setup.sh
--- old/ksnip-1.6.1/ci/scripts/setup.sh 2020-02-23 19:55:46.000000000 +0100
+++ new/ksnip-1.6.2/ci/scripts/setup.sh 2020-05-05 18:14:45.000000000 +0200
@@ -20,7 +20,7 @@
 git clone git://github.com/DamirPorobic/kImageAnnotator
 
 if [[ "${BINARY_TYPE}" == "AppImage" ]]; then
-    sudo apt-get -y install qt56base qt56x11extras qt56tools qt56svg
+    sudo apt-get -y install qt57base qt57x11extras qt57tools qt57svg
     source /opt/qt*/bin/qt*-env.sh
 
     echo "--> Install Extra CMake Modules"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ksnip-1.6.1/snap/snapcraft.yaml 
new/ksnip-1.6.2/snap/snapcraft.yaml
--- old/ksnip-1.6.1/snap/snapcraft.yaml 1970-01-01 01:00:00.000000000 +0100
+++ new/ksnip-1.6.2/snap/snapcraft.yaml 2020-05-05 18:14:45.000000000 +0200
@@ -0,0 +1,72 @@
+name: ksnip
+base: core18
+adopt-info: ksnip
+icon: desktop/ksnip.svg
+grade: stable
+confinement: strict
+summary: Screenshot and Annotation Tool
+description: |
+  Qt based cross-platform screenshot tool that provides many annotation 
features for your screenshots.
+
+
+apps:
+  ksnip:
+    command: ksnip
+    common-id: ksnip
+    environment:
+      # Coerce XDG_CURRENT_DESKTOP to Unity so that App Indicators
+      # are used and do not fall back to Notification Area applets
+      # or disappear completely.
+      XDG_CURRENT_DESKTOP: Unity:Unity7
+      # Set theme fix on gnome/gtk
+      QT_QPA_PLATFORMTHEME: gtk3
+    desktop: share/applications/ksnip.desktop
+    extensions: [kde-neon]
+    plugs:
+      - home
+      - removable-media
+      - unity7
+      - network
+      - network-manager-observe
+      - network-observe
+      - opengl
+      - system-observe
+
+parts:
+  ksnip:
+    source: .
+    plugin: cmake
+    parse-info: [share/metainfo/ksnip.appdata.xml]
+    after:
+      - kimageannotator
+    build-snaps:
+      - kde-frameworks-5-core18-sdk
+    build-packages:
+      - libglvnd-dev
+      - libx11-dev
+    configflags:
+      - 
-DCMAKE_FIND_ROOT_PATH=/snap/kde-frameworks-5-core18-sdk/current;/snap/kimageannotator/current
+    override-pull: |
+      snapcraftctl pull
+      sed -i 's|Icon=.*|Icon=share/pixmaps/ksnip.svg|g' desktop/ksnip.desktop
+      snapcraftctl set-version $(cat CMakeLists.txt | grep project\(ksnip | 
cut -d" " -f5 | cut -d")" -f1)
+  kimageannotator:
+    source: https://github.com/ksnip/kImageAnnotator.git
+    plugin: cmake
+    after:
+      - kcolorpicker
+    configflags:
+      - 
-DCMAKE_FIND_ROOT_PATH=/snap/kde-frameworks-5-core18-sdk/current;/snap/kcolorpicker/current
+  kcolorpicker:
+    source: https://github.com/ksnip/kColorPicker.git
+    plugin: cmake
+    configflags:
+      - -DCMAKE_FIND_ROOT_PATH=/snap/kde-frameworks-5-core18-sdk/current
+  cleanup:
+    after: [kcolorpicker, kimageannotator, ksnip]
+    plugin: nil
+    build-snaps: [ kde-frameworks-5-core18 ]
+    override-prime: |
+        set -eux
+        cd /snap/kde-frameworks-5-core18/current
+        find . -type f,l -exec rm -f $SNAPCRAFT_PRIME/{} \;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ksnip-1.6.1/src/CMakeLists.txt 
new/ksnip-1.6.2/src/CMakeLists.txt
--- old/ksnip-1.6.1/src/CMakeLists.txt  2020-02-23 19:55:46.000000000 +0100
+++ new/ksnip-1.6.2/src/CMakeLists.txt  2020-05-05 18:14:45.000000000 +0200
@@ -92,6 +92,7 @@
                ${CMAKE_SOURCE_DIR}/src/gui/snippingArea/LinuxSnippingArea.cpp
                ${CMAKE_SOURCE_DIR}/src/gui/globalHotKeys/X11KeyHandler.cpp
                
${CMAKE_SOURCE_DIR}/src/gui/globalHotKeys/KeySequenceToX11KeyCodeTranslator.cpp
+               ${CMAKE_SOURCE_DIR}/src/gui/globalHotKeys/X11ErrorLogger.cpp
                )
 elseif (WIN32)
        set(KSNIP_SRCS
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ksnip-1.6.1/src/gui/MainWindow.cpp 
new/ksnip-1.6.2/src/gui/MainWindow.cpp
--- old/ksnip-1.6.1/src/gui/MainWindow.cpp      2020-02-23 19:55:46.000000000 
+0100
+++ new/ksnip-1.6.2/src/gui/MainWindow.cpp      2020-05-05 18:14:45.000000000 
+0200
@@ -41,7 +41,8 @@
                mGlobalHotKeyHandler(new 
GlobalHotKeyHandler(mImageGrabber->supportedCaptureModes())),
                mTrayIcon(new TrayIcon(this)),
                mSelectedWindowState(Qt::WindowActive),
-               mWindowStateChangeLock(false)
+               mWindowStateChangeLock(false),
+               mSessionManagerRequestedQuit(false)
 {
        // When we run in CLI only mode we don't need to setup gui, but only 
need
        // to connect imagegrabber signals to mainwindow slots to handle the
@@ -54,16 +55,17 @@
 
        initGui();
 
+       connect(qApp, &QGuiApplication::commitDataRequest, this, 
&MainWindow::sessionFinished);
+
        setWindowIcon(QIcon(QStringLiteral(":/icons/ksnip.svg")));
-       setPosition(mConfig->windowPosition());
+       setPosition();
 
        connect(mConfig, &KsnipConfig::toolConfigChanged, this, 
&MainWindow::setupImageAnnotator);
 
        connect(mKImageAnnotator, &KImageAnnotator::imageChanged, this, 
&MainWindow::screenshotChanged);
 
        connect(mImageGrabber, &AbstractImageGrabber::finished, this, 
&MainWindow::showCapture);
-       connect(mImageGrabber, &AbstractImageGrabber::canceled, [this]()
-       { setHidden(false); });
+       connect(mImageGrabber, &AbstractImageGrabber::canceled, this, 
&MainWindow::captureCanceled);
 
        connect(mCaptureUploader, &CaptureUploader::finished, this, 
&MainWindow::uploadFinished);
 
@@ -88,13 +90,14 @@
        }
 }
 
-void MainWindow::setPosition(const QPoint &lastPosition)
+void MainWindow::setPosition()
 {
-       auto position = lastPosition;
+       auto position = mConfig->windowPosition();
        auto screenGeometry = QApplication::desktop()->screenGeometry();
-       if(!screenGeometry.contains(lastPosition)) {
+       if(!screenGeometry.contains(position)) {
                auto screenCenter = screenGeometry.center();
-               position = QPoint(screenCenter.x() - size().width(), 
screenCenter.y() - size().height());
+               auto ksnipSize = size();
+               position = QPoint(screenCenter.x() - ksnipSize.width() / 2, 
screenCenter.y() - ksnipSize.height() / 2);
        }
        move(position);
 }
@@ -229,7 +232,9 @@
 
 void MainWindow::closeEvent(QCloseEvent* event)
 {
-       event->ignore();
+       if(!mSessionManagerRequestedQuit) {
+               event->ignore();
+       }
        mTrayIcon->isVisible() && mConfig->closeToTray() ? hide() : quit();
 }
 
@@ -333,7 +338,7 @@
 
     mPrintAction->setText(tr("Print"));
     mPrintAction->setToolTip(tr("Opens printer dialog and provide option to 
print image"));
-    mPrintAction->setShortcut(QKeySequence::Print);
+    mPrintAction->setShortcut(Qt::CTRL + Qt::Key_P);
     mPrintAction->setIcon(QIcon::fromTheme(QStringLiteral("document-print")));
     connect(mPrintAction, &QAction::triggered, this, 
&MainWindow::printClicked);
 
@@ -354,7 +359,7 @@
        connect(mAddWatermarkAction, &QAction::triggered, this, 
&MainWindow::addWatermark);
 
     mQuitAction->setText(tr("Quit"));
-    mQuitAction->setShortcut(QKeySequence::Quit);
+    mQuitAction->setShortcut(Qt::CTRL + Qt::Key_Q);
     mQuitAction->setIcon(QIcon::fromTheme(QStringLiteral("application-exit")));
     connect(mQuitAction, &QAction::triggered, this, &MainWindow::quit);
 
@@ -535,3 +540,13 @@
                mKImageAnnotator->showScaler();
        });
 }
+
+void MainWindow::sessionFinished()
+{
+       mSessionManagerRequestedQuit = true;
+}
+
+void MainWindow::captureCanceled()
+{
+       setHidden(false);
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ksnip-1.6.1/src/gui/MainWindow.h 
new/ksnip-1.6.2/src/gui/MainWindow.h
--- old/ksnip-1.6.1/src/gui/MainWindow.h        2020-02-23 19:55:46.000000000 
+0100
+++ new/ksnip-1.6.2/src/gui/MainWindow.h        2020-05-05 18:14:45.000000000 
+0200
@@ -74,6 +74,7 @@
     RunMode mMode;
     bool mIsUnsaved;
     bool mHidden;
+    bool mSessionManagerRequestedQuit;
     Qt::WindowState mSelectedWindowState;
     bool mWindowStateChangeLock;
     QAction *mUploadToImgurAction;
@@ -123,8 +124,10 @@
     void showSettingsDialog();
     void showAboutDialog();
     void showScaleDialog();
-       void setPosition(const QPoint &lastPosition);
+       void setPosition();
        void handleGuiStartup();
+       void sessionFinished();
+       void captureCanceled();
 };
 
 #endif // KSNIP_MAINWINDOW_H
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/ksnip-1.6.1/src/gui/globalHotKeys/KeySequenceToX11KeyCodeTranslator.cpp 
new/ksnip-1.6.2/src/gui/globalHotKeys/KeySequenceToX11KeyCodeTranslator.cpp
--- old/ksnip-1.6.1/src/gui/globalHotKeys/KeySequenceToX11KeyCodeTranslator.cpp 
2020-02-23 19:55:46.000000000 +0100
+++ new/ksnip-1.6.2/src/gui/globalHotKeys/KeySequenceToX11KeyCodeTranslator.cpp 
2020-05-05 18:14:45.000000000 +0200
@@ -50,6 +50,9 @@
        if (modifierString.contains(QStringLiteral("CTRL"))) {
                modifier |= ControlMask;
        }
+       if (modifierString.contains(QStringLiteral("META"))) {
+               modifier |= Mod4Mask;
+       }
 
        return modifier;
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ksnip-1.6.1/src/gui/globalHotKeys/X11ErrorLogger.cpp 
new/ksnip-1.6.2/src/gui/globalHotKeys/X11ErrorLogger.cpp
--- old/ksnip-1.6.1/src/gui/globalHotKeys/X11ErrorLogger.cpp    1970-01-01 
01:00:00.000000000 +0100
+++ new/ksnip-1.6.2/src/gui/globalHotKeys/X11ErrorLogger.cpp    2020-05-05 
18:14:45.000000000 +0200
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2020 Damir Porobic <[email protected]>
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "X11ErrorLogger.h"
+
+X11ErrorLogger::X11ErrorLogger()
+{
+       XSetErrorHandler(errorHandler);
+}
+
+int X11ErrorLogger::errorHandler(Display *d, XErrorEvent *e)
+{
+       Q_UNUSED(d);
+       switch (e->error_code) {
+               case BadAccess:
+                       qCritical("Unable to assign Global Hotkey, key sequence 
already in use by other Application");
+                       break;
+               default:
+                       qCritical("Unknown Global Hotkey Error Code: %s", 
qPrintable(QString::number(e->error_code)));
+                       break;
+       }
+       return 1;
+}
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ksnip-1.6.1/src/gui/globalHotKeys/X11ErrorLogger.h 
new/ksnip-1.6.2/src/gui/globalHotKeys/X11ErrorLogger.h
--- old/ksnip-1.6.1/src/gui/globalHotKeys/X11ErrorLogger.h      1970-01-01 
01:00:00.000000000 +0100
+++ new/ksnip-1.6.2/src/gui/globalHotKeys/X11ErrorLogger.h      2020-05-05 
18:14:45.000000000 +0200
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2020 Damir Porobic <[email protected]>
+ *
+ * This program 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef KSNIP_X11ERRORLOGGER_H
+#define KSNIP_X11ERRORLOGGER_H
+
+#include <QString>
+
+#include <X11/Xlib.h>
+
+class X11ErrorLogger
+{
+public:
+       X11ErrorLogger();
+       ~X11ErrorLogger() = default;
+
+private:
+
+       static int errorHandler(Display *d, XErrorEvent *e);
+};
+
+#endif //KSNIP_X11ERRORLOGGER_H
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ksnip-1.6.1/src/gui/globalHotKeys/X11KeyHandler.cpp 
new/ksnip-1.6.2/src/gui/globalHotKeys/X11KeyHandler.cpp
--- old/ksnip-1.6.1/src/gui/globalHotKeys/X11KeyHandler.cpp     2020-02-23 
19:55:46.000000000 +0100
+++ new/ksnip-1.6.2/src/gui/globalHotKeys/X11KeyHandler.cpp     2020-05-05 
18:14:45.000000000 +0200
@@ -17,10 +17,18 @@
  * Boston, MA 02110-1301, USA.
  */
 
+/*
+ * Inspired by Skycoder42`s QHotKey implementation 
https://github.com/Skycoder42/QHotkey/blob/master/QHotkey/qhotkey_x11.cpp
+ */
+
 #include "X11KeyHandler.h"
 
-#include <xcb/xcb.h>
-#include <X11/Xlib.h>
+#include "X11ErrorLogger.h"
+
+X11KeyHandler::X11KeyHandler() :
+       mFixedModifiers({ 0, Mod2Mask, LockMask, (Mod2Mask | LockMask)})
+{
+}
 
 X11KeyHandler::~X11KeyHandler()
 {
@@ -34,8 +42,11 @@
                return false;
        }
 
+       X11ErrorLogger x11ErrorLogger;
        mKeyCodeCombo = mKeyCodeMapper.map(keySequence);
-       XGrabKey(display, mKeyCodeCombo.key, mKeyCodeCombo.modifier, 
DefaultRootWindow(display), true, GrabModeAsync, GrabModeAsync);
+       for(auto fixedModifier : mFixedModifiers) {
+               GrabKey(display, fixedModifier);
+       }
 
        XSync(display, False);
        return true;
@@ -46,11 +57,19 @@
        auto genericEvent = static_cast<xcb_generic_event_t *>(message);
        if (genericEvent->response_type == XCB_KEY_PRESS) {
                auto keyEvent = static_cast<xcb_key_press_event_t *>(message);
-               return keyEvent->detail == mKeyCodeCombo.key && keyEvent->state 
== mKeyCodeCombo.modifier;
+
+               for(auto fixedModifier : mFixedModifiers) {
+                       if(isMatching(keyEvent, fixedModifier)) {
+                               return true;
+                       }
+               }
        }
        return false;
 }
 
+bool X11KeyHandler::isMatching(const xcb_key_press_event_t *keyEvent, unsigned 
int fixedModifier) const
+{ return keyEvent->detail == mKeyCodeCombo.key && keyEvent->state == 
(mKeyCodeCombo.modifier | fixedModifier); }
+
 void X11KeyHandler::unregisterKey() const
 {
        auto display = QX11Info::display();
@@ -58,6 +77,20 @@
                return;
        }
 
-       XUngrabKey(display, mKeyCodeCombo.key, mKeyCodeCombo.modifier, 
DefaultRootWindow(display));
+       X11ErrorLogger x11ErrorLogger;
+       for(auto fixedModifier : mFixedModifiers) {
+               UngrabKey(display, fixedModifier);
+       }
+
        XSync(display, False);
 }
+
+void X11KeyHandler::GrabKey(Display *display, unsigned int fixedModifier) const
+{
+       XGrabKey(display, mKeyCodeCombo.key, mKeyCodeCombo.modifier | 
fixedModifier, DefaultRootWindow(display), true, GrabModeAsync, GrabModeAsync);
+}
+
+void X11KeyHandler::UngrabKey(Display *display, unsigned int fixedModifier) 
const
+{
+       XUngrabKey(display, mKeyCodeCombo.key, mKeyCodeCombo.modifier | 
fixedModifier, DefaultRootWindow(display));
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ksnip-1.6.1/src/gui/globalHotKeys/X11KeyHandler.h 
new/ksnip-1.6.2/src/gui/globalHotKeys/X11KeyHandler.h
--- old/ksnip-1.6.1/src/gui/globalHotKeys/X11KeyHandler.h       2020-02-23 
19:55:46.000000000 +0100
+++ new/ksnip-1.6.2/src/gui/globalHotKeys/X11KeyHandler.h       2020-05-05 
18:14:45.000000000 +0200
@@ -23,13 +23,15 @@
 #include <QX11Info>
 #include <QVector>
 
+#include <xcb/xcb.h>
+
 #include "AbstractKeyHandler.h"
 #include "KeySequenceToX11KeyCodeTranslator.h"
 
 class X11KeyHandler : public AbstractKeyHandler
 {
 public:
-       X11KeyHandler() = default;
+       X11KeyHandler();
        ~X11KeyHandler() override;
 
        bool registerKey(const QKeySequence &keySequence) override;
@@ -38,8 +40,13 @@
 private:
        KeyCodeCombo mKeyCodeCombo;
        KeySequenceToX11KeyCodeTranslator mKeyCodeMapper;
+       QVector<unsigned int> mFixedModifiers;
 
        void unregisterKey() const;
+
+       void GrabKey(Display *display, unsigned int fixedModifier) const;
+       void UngrabKey(Display *display, unsigned int fixedModifier) const;
+       bool isMatching(const xcb_key_press_event_t *keyEvent, unsigned int 
fixedModifier) const;
 };
 
 #endif //KSNIP_X11KEYHANDLER_H
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ksnip-1.6.1/src/main.cpp new/ksnip-1.6.2/src/main.cpp
--- old/ksnip-1.6.1/src/main.cpp        2020-02-23 19:55:46.000000000 +0100
+++ new/ksnip-1.6.2/src/main.cpp        2020-05-05 18:14:45.000000000 +0200
@@ -40,6 +40,7 @@
     app.setOrganizationDomain(QStringLiteral("ksnip.org"));
     app.setApplicationName(QStringLiteral("ksnip"));
     app.setApplicationVersion(QStringLiteral(KSNIP_VERSION));
+    app.setDesktopFileName(QStringLiteral("ksnip.desktop"));
 
     app.setStyle(KsnipConfigProvider::instance()->applicationStyle());
 


Reply via email to