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

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


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

The following commit has been merged in the master branch:
commit d14b4411cd0bccf50e4b56962cc2d19b52c6da24
Author: Ahmed Ibrahim Khalil <ahmedibrahimkhali at gmail.com>
Date:   Fri Jun 27 15:41:47 2014 +0200

    Implementation of mousepad plugin
    
    CCMAIL: ahmedibrahimkhali at gmail.com
---
 cmake/FindXTest.cmake                              | 48 ++++++++++++++++
 plugins/CMakeLists.txt                             |  1 +
 plugins/mousepad/CMakeLists.txt                    | 15 +++++
 plugins/mousepad/README                            |  5 ++
 .../kdeconnect_mousepad.desktop}                   | 27 +++++----
 plugins/mousepad/mousepadplugin.cpp                | 65 ++++++++++++++++++++++
 .../pingplugin.h => mousepad/mousepadplugin.h}     | 18 +++---
 7 files changed, 156 insertions(+), 23 deletions(-)

diff --git a/cmake/FindXTest.cmake b/cmake/FindXTest.cmake
new file mode 100644
index 0000000..0c3cd1a
--- /dev/null
+++ b/cmake/FindXTest.cmake
@@ -0,0 +1,48 @@
+# - Find XTEST
+# Find the XTEST libraries
+#
+#  This module defines the following variables:
+#     XTEST_FOUND        - true if XTEST_INCLUDE_DIR & XTEST_LIBRARY are found
+#     XTEST_LIBRARIES    - Set when XTEST_LIBRARY is found
+#     XTEST_INCLUDE_DIRS - Set when XTEST_INCLUDE_DIR is found
+#
+#     XTEST_INCLUDE_DIR  - where to find XTest.h, etc.
+#     XTEST_LIBRARY      - the XTEST library
+#
+
+#=============================================================================
+# Copyright 2011 O.S. Systems Software Ltda.
+# Copyright 2011 Otavio Salvador <otavio at ossystems.com.br>
+# Copyright 2011 Marc-Andre Moreau <marcandre.moreau at gmail.com>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#=============================================================================
+
+find_path(XTEST_INCLUDE_DIR NAMES X11/extensions/XTest.h
+          PATH_SUFFIXES X11/extensions
+          DOC "The XTest include directory"
+)
+
+find_library(XTEST_LIBRARY NAMES Xtst
+          DOC "The XTest library"
+)
+
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(XTest DEFAULT_MSG XTEST_LIBRARY XTEST_INCLUDE_DIR)
+
+if(XTEST_FOUND)
+  set( XTEST_LIBRARIES ${XTEST_LIBRARY} )
+  set( XTEST_INCLUDE_DIRS ${XTEST_INCLUDE_DIR} )
+endif()
+
+mark_as_advanced(XTEST_INCLUDE_DIR XTEST_LIBRARY)
diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt
index e4eeb0e..f50335a 100644
--- a/plugins/CMakeLists.txt
+++ b/plugins/CMakeLists.txt
@@ -7,6 +7,7 @@ add_subdirectory(mpriscontrol)
 add_subdirectory(clipboard)
 add_subdirectory(telephony)
 add_subdirectory(battery)
+add_subdirectory(mousepad)
 add_subdirectory(share)
 add_subdirectory(notifications)
 add_subdirectory(sftp)
diff --git a/plugins/mousepad/CMakeLists.txt b/plugins/mousepad/CMakeLists.txt
new file mode 100644
index 0000000..848b76e
--- /dev/null
+++ b/plugins/mousepad/CMakeLists.txt
@@ -0,0 +1,15 @@
+set(kdeconnect_mousepad_SRCS
+    mousepadplugin.cpp
+)
+
+find_package(XTest REQUIRED)
+find_package(X11 REQUIRED)
+
+kde4_add_plugin(kdeconnect_mousepad ${kdeconnect_mousepad_SRCS})
+
+include_directories(${XTEST_INCLUDE_DIRS} ${X11_INCLUDE_DIR})
+
+target_link_libraries(kdeconnect_mousepad kdeconnectcore ${QT_QTGUI_LIBRARY} ${X11_LIBRARIES} ${XTEST_LIBRARIES})
+
+install(TARGETS kdeconnect_mousepad DESTINATION ${PLUGIN_INSTALL_DIR} )
+install(FILES kdeconnect_mousepad.desktop DESTINATION ${SERVICES_INSTALL_DIR} )
diff --git a/plugins/mousepad/README b/plugins/mousepad/README
new file mode 100644
index 0000000..14a0e56
--- /dev/null
+++ b/plugins/mousepad/README
@@ -0,0 +1,5 @@
+
+When the user moves his on the phone, dx and dy (The difference between the last movement and the current movement of the X and Y Axis respectively)
+is sent inside a NetworkPackage QCursor is used to move mouse cursor according to its relative position.
+
+When the user tap or double taps his phone, a mouse key button is simulated using XTestFakeButtonEvent
diff --git a/plugins/clipboard/kdeconnect_clipboard.desktop b/plugins/mousepad/kdeconnect_mousepad.desktop
similarity index 78%
copy from plugins/clipboard/kdeconnect_clipboard.desktop
copy to plugins/mousepad/kdeconnect_mousepad.desktop
index 4f33306..531a65d 100644
--- a/plugins/clipboard/kdeconnect_clipboard.desktop
+++ b/plugins/mousepad/kdeconnect_mousepad.desktop
@@ -2,18 +2,17 @@
 Encoding=UTF-8
 Type=Service
 ServiceTypes=KdeConnect/Plugin
-X-KDE-Library=kdeconnect_clipboard
-X-KDE-PluginInfo-Author=Albert Vaca
-X-KDE-PluginInfo-Email=albertvaka at gmail.com
-X-KDE-PluginInfo-Name=kdeconnect_clipboard
+X-KDE-Library=kdeconnect_mousepad
+X-KDE-PluginInfo-Author=Ahmed I. Khalil
+X-KDE-PluginInfo-Email=ahmedibrahimkhali at gmail.com
+X-KDE-PluginInfo-Name=kdeconnect_mousepad
 X-KDE-PluginInfo-Version=0.1
-X-KDE-PluginInfo-Website=http://albertvaka.wordpress.com
 X-KDE-PluginInfo-License=GPL
 X-KDE-PluginInfo-EnabledByDefault=true
-Icon=edit-paste
-Name=Clipboard
+Icon=input-mouse
+Name=Mousepad
 Name[bg]=Буфер за обмен
-Name[bs]=Clipboard
+Name[bs]=Mousepad
 Name[ca]=Porta-retalls
 Name[cs]=Schránka
 Name[da]=Udklipsholder
@@ -27,16 +26,16 @@ Name[nl]=Klembord
 Name[pl]=Schowek
 Name[pt]=Área de Transferência
 Name[pt_BR]=Área de transferência
-Name[ro]=Clipboard
+Name[ro]=Mousepad
 Name[ru]=Буфер обмена
 Name[sk]=Schránka
 Name[sv]=Klippbord
 Name[tr]=Pano
 Name[uk]=Буфер обміну
-Name[x-test]=xxClipboardxx
-Comment=Share the clipboard between devices
+Name[x-test]=xxMousepadxx
+Comment=Use your phone as a mousepad
 Comment[bg]=Споделяне на буфера за обмен между устройства
-Comment[bs]=Podijeli Clipboard među uređajima
+Comment[bs]=Podijeli Mousepad među uređajima
 Comment[ca]=Comparteix el porta-retalls entre els dispositius
 Comment[cs]=Sdílejte schránku mezi zařízeními
 Comment[da]=Del indholdet af udklipsholderen mellem enheder
@@ -58,6 +57,6 @@ Comment[tr]=Aygıtlar arasında panoyu paylaştır
 Comment[uk]=Спільне використання буфера обміну даними на пристроях
 Comment[x-test]=xxShare the clipboard between devicesxx
 
-X-KdeConnect-SupportedPackageType=kdeconnect.clipboard
-X-KdeConnect-OutgoingPackageType=kdeconnect.clipboard
+X-KdeConnect-SupportedPackageType=kdeconnect.mousepad
+X-KdeConnect-OutgoingPackageType=kdeconnect.mousepad
 
diff --git a/plugins/mousepad/mousepadplugin.cpp b/plugins/mousepad/mousepadplugin.cpp
new file mode 100644
index 0000000..8786172
--- /dev/null
+++ b/plugins/mousepad/mousepadplugin.cpp
@@ -0,0 +1,65 @@
+/**
+ * Copyright 2014 Ahmed I. Khalil <ahmedibrahimkhali at gmail.com>
+ *
+ * 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) version 3 or any later version
+ * accepted by the membership of KDE e.V. (or its successor approved
+ * by the membership of KDE e.V.), which shall act as a proxy
+ * defined in Section 14 of version 3 of the license.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#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/
+
+MousepadPlugin::MousepadPlugin(QObject* parent, const QVariantList& args)
+       : KdeConnectPlugin(parent, args)
+{
+    
+}
+
+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);
+    }
+    return true;
+}
diff --git a/plugins/ping/pingplugin.h b/plugins/mousepad/mousepadplugin.h
similarity index 77%
copy from plugins/ping/pingplugin.h
copy to plugins/mousepad/mousepadplugin.h
index f31e660..e9ca659 100644
--- a/plugins/ping/pingplugin.h
+++ b/plugins/mousepad/mousepadplugin.h
@@ -1,5 +1,5 @@
 /**
- * Copyright 2013 Albert Vaca <albertvaka at gmail.com>
+ * Copyright 2014 Ahmed I. Khalil <albertvaka at gmail.com>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -18,26 +18,26 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef PINGPLUGIN_H
-#define PINGPLUGIN_H
+#ifndef MOUSEPADPLUGIN_H
+#define MOUSEPADPLUGIN_H
 
 #include <QObject>
 
 #include <core/kdeconnectplugin.h>
 
-class KDE_EXPORT PingPlugin
+#define PACKAGE_TYPE_MOUSEPAD QLatin1String("kdeconnect.mousepad")
+
+class MousepadPlugin
     : public KdeConnectPlugin
 {
     Q_OBJECT
 
 public:
-    explicit PingPlugin(QObject *parent, const QVariantList &args);
-    virtual ~PingPlugin();
-    
+    explicit MousepadPlugin(QObject *parent, const QVariantList &args);
+
 public Q_SLOTS:
     virtual bool receivePackage(const NetworkPackage& np);
-    virtual void connected() { };
-
+    virtual void connected() { }
 };
 
 #endif

-- 
kdeconnect packaging



More information about the pkg-kde-commits mailing list