[SCM] kdeconnect packaging branch, master, updated. debian/0.9g-1-1183-g9d69498
Maximiliano Curia
maxy at moszumanska.debian.org
Fri Oct 14 14:28:43 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/kdeconnect.git;a=commitdiff;h=ab5438d
The following commit has been merged in the master branch:
commit ab5438d338974ae7508b4e9d7d987063004342c0
Author: Martin Gräßlin <mgraesslin at kde.org>
Date: Thu Jul 2 14:49:38 2015 +0200
[mousepad] Use QX11Info to get the Display
Don't open a second Display, we can use the one used by Qt.
Advantages are: we are on the correct Display, we don't open a Display
connection on e.g. Wayland (it would succeed but not work as a connection
to Xwayland would be opened) and we can drop the copy of fixx11h.
It's also a prerequisite to properly split the implementation to support
Wayland in a later change.
REVIEW: 124230
---
plugins/mousepad/CMakeLists.txt | 3 +-
plugins/mousepad/fixx11h.h | 301 ------------------------------------
plugins/mousepad/mousepadplugin.cpp | 73 +++++----
plugins/mousepad/mousepadplugin.h | 4 +-
4 files changed, 38 insertions(+), 343 deletions(-)
diff --git a/plugins/mousepad/CMakeLists.txt b/plugins/mousepad/CMakeLists.txt
index 823b54b..88716c7 100644
--- a/plugins/mousepad/CMakeLists.txt
+++ b/plugins/mousepad/CMakeLists.txt
@@ -5,9 +5,10 @@ set(kdeconnect_mousepad_SRCS
find_package(XTest REQUIRED)
find_package(X11 REQUIRED)
find_package(LibFakeKey REQUIRED)
+find_package(Qt5X11Extras REQUIRED)
kdeconnect_add_plugin(kdeconnect_mousepad JSON kdeconnect_mousepad.json SOURCES ${kdeconnect_mousepad_SRCS})
include_directories(${XTEST_INCLUDE_DIRS} ${X11_INCLUDE_DIR} ${LibFakeKey_INCLUDE_DIRS})
-target_link_libraries(kdeconnect_mousepad kdeconnectcore Qt5::Gui ${X11_LIBRARIES} ${XTEST_LIBRARIES} ${LibFakeKey_LIBRARIES})
+target_link_libraries(kdeconnect_mousepad kdeconnectcore Qt5::Gui Qt5::X11Extras ${X11_LIBRARIES} ${XTEST_LIBRARIES} ${LibFakeKey_LIBRARIES})
diff --git a/plugins/mousepad/fixx11h.h b/plugins/mousepad/fixx11h.h
deleted file mode 100644
index 8d69e15..0000000
--- a/plugins/mousepad/fixx11h.h
+++ /dev/null
@@ -1,301 +0,0 @@
-/****************************************************************************
-
- Copyright (C) 2003 Lubos Lunak <l.lunak at kde.org>
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-the rights to use, copy, modify, merge, publish, distribute, sublicense,
-and/or sell copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
-
-****************************************************************************/
-
-//#ifdef don't do this, this file is supposed to be included
-//#define multiple times
-
-#include <QtCore/QtGlobal>
-
-/* Usage:
-
- If you get compile errors caused by X11 includes (the line
- where first error appears contains word like None, Unsorted,
- Below, etc.), put #include <fixx11h.h> in the .cpp file
- (not .h file!) between the place where X11 headers are
- included and the place where the file with compile
- error is included (or the place where the compile error
- in the .cpp file occurs).
-
- This file remaps X11 #defines to const variables or
- inline functions. The side effect may be that these
- symbols may now refer to different variables
- (e.g. if X11 #defined NoButton, after this file
- is included NoButton would no longer be X11's
- NoButton, but Qt::NoButton instead). At this time,
- there's no conflict known that could cause problems.
-
- The original X11 symbols are still accessible
- (e.g. for None) as X::None, XNone, and also still
- None, unless name lookup finds different None
- first (in the current class, etc.)
-
- Use 'Unsorted', 'Bool' and 'index' as templates.
-
-*/
-
-namespace X
-{
-
-// template --->
-// Affects: Should be without side effects.
-#ifdef Unsorted
-#ifndef FIXX11H_Unsorted
-#define FIXX11H_Unsorted
-const int XUnsorted = Unsorted;
-#undef Unsorted
-const int Unsorted = XUnsorted;
-#endif
-#undef Unsorted
-#endif
-// template <---
-
-// Affects: Should be without side effects.
-#ifdef None
-#ifndef FIXX11H_None
-#define FIXX11H_None
-const XID XNone = None;
-#undef None
-const XID None = XNone;
-#endif
-#undef None
-#endif
-
-// template --->
-// Affects: Should be without side effects.
-#ifdef Bool
-#ifndef FIXX11H_Bool
-#define FIXX11H_Bool
-#ifdef _XTYPEDEF_BOOL /* Xdefs.h has typedef'ed Bool already */
-#undef Bool
-#else
-typedef Bool XBool;
-#undef Bool
-typedef XBool Bool;
-#endif
-#endif
-#undef Bool
-#define _XTYPEDEF_BOOL
-#endif
-// template <---
-
-// Affects: Should be without side effects.
-#ifdef KeyPress
-#ifndef FIXX11H_KeyPress
-#define FIXX11H_KeyPress
-const int XKeyPress = KeyPress;
-#undef KeyPress
-const int KeyPress = XKeyPress;
-#endif
-#undef KeyPress
-#endif
-
-// Affects: Should be without side effects.
-#ifdef KeyRelease
-#ifndef FIXX11H_KeyRelease
-#define FIXX11H_KeyRelease
-const int XKeyRelease = KeyRelease;
-#undef KeyRelease
-const int KeyRelease = XKeyRelease;
-#endif
-#undef KeyRelease
-#endif
-
-// Affects: Should be without side effects.
-#ifdef Above
-#ifndef FIXX11H_Above
-#define FIXX11H_Above
-const int XAbove = Above;
-#undef Above
-const int Above = XAbove;
-#endif
-#undef Above
-#endif
-
-// Affects: Should be without side effects.
-#ifdef Below
-#ifndef FIXX11H_Below
-#define FIXX11H_Below
-const int XBelow = Below;
-#undef Below
-const int Below = XBelow;
-#endif
-#undef Below
-#endif
-
-// Affects: Should be without side effects.
-#ifdef FocusIn
-#ifndef FIXX11H_FocusIn
-#define FIXX11H_FocusIn
-const int XFocusIn = FocusIn;
-#undef FocusIn
-const int FocusIn = XFocusIn;
-#endif
-#undef FocusIn
-#endif
-
-// Affects: Should be without side effects.
-#ifdef FocusOut
-#ifndef FIXX11H_FocusOut
-#define FIXX11H_FocusOut
-const int XFocusOut = FocusOut;
-#undef FocusOut
-const int FocusOut = XFocusOut;
-#endif
-#undef FocusOut
-#endif
-
-// Affects: Should be without side effects.
-#ifdef Always
-#ifndef FIXX11H_Always
-#define FIXX11H_Always
-const int XAlways = Always;
-#undef Always
-const int Always = XAlways;
-#endif
-#undef Always
-#endif
-
-// Affects: Should be without side effects.
-#ifdef Expose
-#ifndef FIXX11H_Expose
-#define FIXX11H_Expose
-const int XExpose = Expose;
-#undef Expose
-const int Expose = XExpose;
-#endif
-#undef Expose
-#endif
-
-// Affects: Should be without side effects.
-#ifdef Success
-#ifndef FIXX11H_Success
-#define FIXX11H_Success
-const int XSuccess = Success;
-#undef Success
-const int Success = XSuccess;
-#endif
-#undef Success
-#endif
-
-// Affects: Should be without side effects.
-#ifdef GrayScale
-#ifndef FIXX11H_GrayScale
-#define FIXX11H_GrayScale
-const int XGrayScale = GrayScale;
-#undef GrayScale
-const int GrayScale = XGrayScale;
-#endif
-#undef GrayScale
-#endif
-
-// Affects: Should be without side effects.
-#ifdef Status
-#ifndef FIXX11H_Status
-#define FIXX11H_Status
-typedef Status XStatus;
-#undef Status
-typedef XStatus Status;
-#endif
-#undef Status
-#endif
-
-// template --->
-// Affects: Should be without side effects.
-#ifdef CursorShape
-#ifndef FIXX11H_CursorShape
-#define FIXX11H_CursorShape
-const int XCursorShape = CursorShape;
-#undef CursorShape
-const int CursorShape = XCursorShape;
-#endif
-#undef CursorShape
-#endif
-// template <---
-
-// template --->
-// Affects: Should be without side effects.
-#ifdef FontChange
-#ifndef FIXX11H_FontChange
-#define FIXX11H_FontChange
-const int XFontChange = FontChange;
-#undef FontChange
-const int FontChange = XFontChange;
-#endif
-#undef FontChange
-#endif
-// template <---
-
-// Affects: Should be without side effects.
-#ifdef NormalState
-#ifndef FIXX11H_NormalState
-#define FIXX11H_NormalState
-const int XNormalState = NormalState;
-#undef NormalState
-const int NormalState = XNormalState;
-#endif
-#undef NormalState
-#endif
-
-// template --->
-// Affects: Should be without side effects.
-#ifdef index
-#ifndef FIXX11H_index
-#define FIXX11H_index
-inline
-const char *Xindex(const char *s, int c)
-{
- return index(s, c);
-}
-#undef index
-inline
-const char *index(const char *s, int c)
-{
- return Xindex(s, c);
-}
-#endif
-#undef index
-#endif
-// template <---
-
-#ifdef rindex
-// Affects: Should be without side effects.
-#ifndef FIXX11H_rindex
-#define FIXX11H_rindex
-inline
-const char *Xrindex(const char *s, int c)
-{
- return rindex(s, c);
-}
-#undef rindex
-inline
-const char *rindex(const char *s, int c)
-{
- return Xrindex(s, c);
-}
-#endif
-#undef rindex
-#endif
-}
-
-using namespace X;
diff --git a/plugins/mousepad/mousepadplugin.cpp b/plugins/mousepad/mousepadplugin.cpp
index f49aa7f..3d69959 100644
--- a/plugins/mousepad/mousepadplugin.cpp
+++ b/plugins/mousepad/mousepadplugin.cpp
@@ -21,6 +21,7 @@
#include "mousepadplugin.h"
#include <KPluginFactory>
#include <QDebug>
+#include <QX11Info>
#include <X11/extensions/XTest.h>
#include <X11/keysym.h>
#include <fakekey/fakekey.h>
@@ -76,17 +77,13 @@ template <typename T, size_t N>
size_t arraySize(T(&arr)[N]) { (void)arr; return N; }
MousepadPlugin::MousepadPlugin(QObject* parent, const QVariantList& args)
- : KdeConnectPlugin(parent, args), m_display(0), m_fakekey(0)
+ : KdeConnectPlugin(parent, args), m_fakekey(0), m_x11(QX11Info::isPlatformX11())
{
}
MousepadPlugin::~MousepadPlugin()
{
- if (m_display) {
- XCloseDisplay(m_display);
- m_display = 0;
- }
if (m_fakekey) {
free(m_fakekey);
m_fakekey = 0;
@@ -114,41 +111,41 @@ bool MousepadPlugin::receivePackage(const NetworkPackage& np)
if (isSingleClick || isDoubleClick || isMiddleClick || isRightClick || isSingleHold || isScroll || !key.isEmpty() || specialKey) {
- if(!m_display) {
- m_display = XOpenDisplay(NULL);
- if(!m_display) {
- qWarning() << "Failed to open X11 display";
- return false;
- }
+ if (!m_x11) {
+ return false;
+ }
+ Display *display = QX11Info::display();
+ if(!display) {
+ return false;
}
if (isSingleClick) {
- XTestFakeButtonEvent(m_display, LeftMouseButton, True, 0);
- XTestFakeButtonEvent(m_display, LeftMouseButton, False, 0);
+ XTestFakeButtonEvent(display, LeftMouseButton, True, 0);
+ XTestFakeButtonEvent(display, LeftMouseButton, False, 0);
} else if (isDoubleClick) {
- XTestFakeButtonEvent(m_display, LeftMouseButton, True, 0);
- XTestFakeButtonEvent(m_display, LeftMouseButton, False, 0);
- XTestFakeButtonEvent(m_display, LeftMouseButton, True, 0);
- XTestFakeButtonEvent(m_display, LeftMouseButton, False, 0);
+ XTestFakeButtonEvent(display, LeftMouseButton, True, 0);
+ XTestFakeButtonEvent(display, LeftMouseButton, False, 0);
+ XTestFakeButtonEvent(display, LeftMouseButton, True, 0);
+ XTestFakeButtonEvent(display, LeftMouseButton, False, 0);
} else if (isMiddleClick) {
- XTestFakeButtonEvent(m_display, MiddleMouseButton, True, 0);
- XTestFakeButtonEvent(m_display, MiddleMouseButton, False, 0);
+ XTestFakeButtonEvent(display, MiddleMouseButton, True, 0);
+ XTestFakeButtonEvent(display, MiddleMouseButton, False, 0);
} else if (isRightClick) {
- XTestFakeButtonEvent(m_display, RightMouseButton, True, 0);
- XTestFakeButtonEvent(m_display, RightMouseButton, False, 0);
+ XTestFakeButtonEvent(display, RightMouseButton, True, 0);
+ XTestFakeButtonEvent(display, RightMouseButton, False, 0);
} else if (isSingleHold){
//For drag'n drop
- XTestFakeButtonEvent(m_display, LeftMouseButton, True, 0);
+ XTestFakeButtonEvent(display, LeftMouseButton, True, 0);
} else if (isSingleRelease){
//For drag'n drop. NEVER USED (release is done by tapping, which actually triggers a isSingleClick). Kept here for future-proofnes.
- XTestFakeButtonEvent(m_display, LeftMouseButton, False, 0);
+ XTestFakeButtonEvent(display, LeftMouseButton, False, 0);
} else if (isScroll) {
if (dy < 0) {
- XTestFakeButtonEvent(m_display, MouseWheelDown, True, 0);
- XTestFakeButtonEvent(m_display, MouseWheelDown, False, 0);
+ XTestFakeButtonEvent(display, MouseWheelDown, True, 0);
+ XTestFakeButtonEvent(display, MouseWheelDown, False, 0);
} else if (dy > 0) {
- XTestFakeButtonEvent(m_display, MouseWheelUp, True, 0);
- XTestFakeButtonEvent(m_display, MouseWheelUp, False, 0);
+ XTestFakeButtonEvent(display, MouseWheelUp, True, 0);
+ XTestFakeButtonEvent(display, MouseWheelUp, False, 0);
}
} else if (!key.isEmpty() || specialKey) {
@@ -156,9 +153,9 @@ bool MousepadPlugin::receivePackage(const NetworkPackage& np)
bool alt = np.get<bool>("alt", false);
bool shift = np.get<bool>("shift", false);
- if (ctrl) XTestFakeKeyEvent (m_display, XKeysymToKeycode(m_display, XK_Control_L), True, 0);
- if (alt) XTestFakeKeyEvent (m_display, XKeysymToKeycode(m_display, XK_Alt_L), True, 0);
- if (shift) XTestFakeKeyEvent (m_display, XKeysymToKeycode(m_display, XK_Shift_L), True, 0);
+ if (ctrl) XTestFakeKeyEvent (display, XKeysymToKeycode(display, XK_Control_L), True, 0);
+ if (alt) XTestFakeKeyEvent (display, XKeysymToKeycode(display, XK_Alt_L), True, 0);
+ if (shift) XTestFakeKeyEvent (display, XKeysymToKeycode(display, XK_Shift_L), True, 0);
if (specialKey)
{
@@ -167,15 +164,15 @@ bool MousepadPlugin::receivePackage(const NetworkPackage& np)
return false;
}
- int keycode = XKeysymToKeycode(m_display, SpecialKeysMap[specialKey]);
+ int keycode = XKeysymToKeycode(display, SpecialKeysMap[specialKey]);
- XTestFakeKeyEvent (m_display, keycode, True, 0);
- XTestFakeKeyEvent (m_display, keycode, False, 0);
+ XTestFakeKeyEvent (display, keycode, True, 0);
+ XTestFakeKeyEvent (display, keycode, False, 0);
} else {
if (!m_fakekey) {
- m_fakekey = fakekey_init(m_display);
+ m_fakekey = fakekey_init(display);
if (!m_fakekey) {
qWarning() << "Failed to initialize libfakekey";
return false;
@@ -187,13 +184,13 @@ bool MousepadPlugin::receivePackage(const NetworkPackage& np)
fakekey_release(m_fakekey);
}
- if (ctrl) XTestFakeKeyEvent (m_display, XKeysymToKeycode(m_display, XK_Control_L), False, 0);
- if (alt) XTestFakeKeyEvent (m_display, XKeysymToKeycode(m_display, XK_Alt_L), False, 0);
- if (shift) XTestFakeKeyEvent (m_display, XKeysymToKeycode(m_display, XK_Shift_L), False, 0);
+ if (ctrl) XTestFakeKeyEvent (display, XKeysymToKeycode(display, XK_Control_L), False, 0);
+ if (alt) XTestFakeKeyEvent (display, XKeysymToKeycode(display, XK_Alt_L), False, 0);
+ if (shift) XTestFakeKeyEvent (display, XKeysymToKeycode(display, XK_Shift_L), False, 0);
}
- XFlush(m_display);
+ XFlush(display);
} else { //Is a mouse move event
QPoint point = QCursor::pos();
diff --git a/plugins/mousepad/mousepadplugin.h b/plugins/mousepad/mousepadplugin.h
index e8ce480..b1ebcaa 100644
--- a/plugins/mousepad/mousepadplugin.h
+++ b/plugins/mousepad/mousepadplugin.h
@@ -23,8 +23,6 @@
#include <QtGui/QCursor>
#include <core/kdeconnectplugin.h>
-#include <X11/Xlib.h>
-#include "fixx11h.h"
#define PACKAGE_TYPE_MOUSEPAD QLatin1String("kdeconnect.mousepad")
@@ -43,8 +41,8 @@ public:
virtual void connected() { }
private:
- Display *m_display;
FakeKey* m_fakekey;
+ bool m_x11;
};
--
kdeconnect packaging
More information about the pkg-kde-commits
mailing list