[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498

Maximiliano Curia maxy at moszumanska.debian.org
Fri Oct 14 14:27:45 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=178fcc1

The following commit has been merged in the master branch:
commit 178fcc128d7ba130109682355361ba69d944be30
Author: Ahmed Ibrahim Khalil <ahmedibrahimkhali at gmail.com>
Date:   Sun Jun 29 17:21:54 2014 +0200

    Implemented scrolling, by sending scroll down or scroll up button events,
    according to the difference value.
    
    REVIEW: 119006
---
 plugins/mousepad/mousepadplugin.cpp | 65 ++++++++++++++++++++++++-------------
 plugins/mousepad/mousepadplugin.h   |  5 +++
 2 files changed, 48 insertions(+), 22 deletions(-)

diff --git a/plugins/mousepad/mousepadplugin.cpp b/plugins/mousepad/mousepadplugin.cpp
index 8786172..0191f66 100644
--- a/plugins/mousepad/mousepadplugin.cpp
+++ b/plugins/mousepad/mousepadplugin.cpp
@@ -21,45 +21,66 @@
 #include "mousepadplugin.h"
 
 #include <core/networkpackage.h>
-#include <QApplication>
 #include <X11/extensions/XTest.h>
 
 K_PLUGIN_FACTORY( KdeConnectPluginFactory, registerPlugin< MousepadPlugin >(); )
 K_EXPORT_PLUGIN( KdeConnectPluginFactory("kdeconnect_mousepad", "kdeconnect-plugins") )
 
 #define LEFT_MOUSE_BUTTON 1 // Source: http://bharathisubramanian.wordpress.com/2010/04/01/x11-fake-mouse-events-generation-using-xtest/
+#define MOUSE_WHEEL_UP_BUTTON 4
+#define MOUSE_WHEEL_DOWN_BUTTON 5
 
 MousepadPlugin::MousepadPlugin(QObject* parent, const QVariantList& args)
-       : KdeConnectPlugin(parent, args)
+    : KdeConnectPlugin(parent, args), m_display(0)
 {
-    
+
+}
+
+MousepadPlugin::~MousepadPlugin()
+{
+    if (m_display) {
+        XCloseDisplay(m_display);
+        m_display = 0;
+    }
 }
 
 bool MousepadPlugin::receivePackage(const NetworkPackage& np)
 {
     float dx = np.get<float>("dx", 0);
     float dy = np.get<float>("dy", 0);
-    QPoint point = QCursor::pos();
-    QCursor::setPos(point.x() + (int)dx, point.y() + (int)dy);
-    
+
     bool isSingleClick = np.get<bool>("singleclick", false);
     bool isDoubleClick = np.get<bool>("doubleclick", false);
-    
-    if (isSingleClick || isDoubleClick) {
-	Display *display = XOpenDisplay(NULL);
-	if(display) {
-	    if (isSingleClick) {
-		XTestFakeButtonEvent(display, LEFT_MOUSE_BUTTON, true, CurrentTime);
-		XTestFakeButtonEvent(display, LEFT_MOUSE_BUTTON, false, CurrentTime);
-	    } else if (isDoubleClick) {
-		XTestFakeButtonEvent(display, LEFT_MOUSE_BUTTON, true, CurrentTime);
-		XTestFakeButtonEvent(display, LEFT_MOUSE_BUTTON, false, CurrentTime);
-		XTestFakeButtonEvent(display, LEFT_MOUSE_BUTTON, true, CurrentTime);
-		XTestFakeButtonEvent(display, LEFT_MOUSE_BUTTON, false, CurrentTime);
-	    }
-	    XFlush(display);
-	}
-	XCloseDisplay(display);
+    bool isScroll = np.get<bool>("scroll", false);
+
+    if (isSingleClick || isDoubleClick || isScroll) {
+        if(!m_display) {
+            m_display = XOpenDisplay(NULL);
+        }
+
+        if(m_display) {
+            if (isSingleClick) {
+                XTestFakeButtonEvent(m_display, LEFT_MOUSE_BUTTON, true, CurrentTime);
+                XTestFakeButtonEvent(m_display, LEFT_MOUSE_BUTTON, false, CurrentTime);
+            } else if (isDoubleClick) {
+                XTestFakeButtonEvent(m_display, LEFT_MOUSE_BUTTON, true, CurrentTime);
+                XTestFakeButtonEvent(m_display, LEFT_MOUSE_BUTTON, false, CurrentTime);
+                XTestFakeButtonEvent(m_display, LEFT_MOUSE_BUTTON, true, CurrentTime);
+                XTestFakeButtonEvent(m_display, LEFT_MOUSE_BUTTON, false, CurrentTime);
+            } else if( isScroll ) {
+                if (dy < 0) {
+                    XTestFakeButtonEvent(m_display, MOUSE_WHEEL_DOWN_BUTTON, true, CurrentTime);
+                    XTestFakeButtonEvent(m_display, MOUSE_WHEEL_DOWN_BUTTON, false, CurrentTime);
+                } else {
+                    XTestFakeButtonEvent(m_display, MOUSE_WHEEL_UP_BUTTON, true, CurrentTime);
+                    XTestFakeButtonEvent(m_display, MOUSE_WHEEL_UP_BUTTON, false, CurrentTime);
+                }
+            }
+            XFlush(m_display);
+        }
+    } else {
+        QPoint point = QCursor::pos();
+        QCursor::setPos(point.x() + (int)dx, point.y() + (int)dy);
     }
     return true;
 }
diff --git a/plugins/mousepad/mousepadplugin.h b/plugins/mousepad/mousepadplugin.h
index e9ca659..6a0c047 100644
--- a/plugins/mousepad/mousepadplugin.h
+++ b/plugins/mousepad/mousepadplugin.h
@@ -22,6 +22,7 @@
 #define MOUSEPADPLUGIN_H
 
 #include <QObject>
+#include <QApplication>
 
 #include <core/kdeconnectplugin.h>
 
@@ -34,10 +35,14 @@ class MousepadPlugin
 
 public:
     explicit MousepadPlugin(QObject *parent, const QVariantList &args);
+    virtual ~MousepadPlugin();
 
 public Q_SLOTS:
     virtual bool receivePackage(const NetworkPackage& np);
     virtual void connected() { }
+
+private:
+    Display *m_display;
 };
 
 #endif

-- 
kdeconnect packaging



More information about the pkg-kde-commits mailing list