From c04f102458227e41e8ef13064f5ace371a0cd9ba Mon Sep 17 00:00:00 2001 From: Christian Klinger Date: Wed, 1 Jun 2016 14:47:40 +0200 Subject: added x11 workaround. --- CMakeLists.txt | 3 +++ src/maingui/main.cpp | 2 ++ src/pwgui/main.cpp | 3 +++ src/x11workaround.cpp | 23 +++++++++++++++++++++++ src/x11workaround.h | 10 ++++++++++ 5 files changed, 41 insertions(+) create mode 100644 src/x11workaround.cpp create mode 100644 src/x11workaround.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d9b9cb..7dfe756 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) # this command finds libraries and sets all required variables FIND_PACKAGE(Qt4 REQUIRED) FIND_PACKAGE(Cups REQUIRED) +FIND_PACKAGE(X11 REQUIRED) # some includes INCLUDE_DIRECTORIES( @@ -131,10 +132,12 @@ ADD_EXECUTABLE(printpwgui TARGET_LINK_LIBRARIES(printergui ${QT_LIBRARIES} ${CUPS_LIBRARIES} + ${X11_LIBRARIES} ) TARGET_LINK_LIBRARIES(printpwgui ${QT_LIBRARIES} + ${X11_LIBRARIES} ) # install diff --git a/src/maingui/main.cpp b/src/maingui/main.cpp index 1e7c2b2..06a165b 100644 --- a/src/maingui/main.cpp +++ b/src/maingui/main.cpp @@ -5,6 +5,7 @@ #include "../backdrop.h" #include #include +#include "../x11workaround.h" static Backdrop* showGrayBackground(); @@ -34,6 +35,7 @@ int main(int argc, char *argv[]) PrinterGui *w = new PrinterGui(argv, bgWin); bgWin->setMainWindow(w); w->show(); + wiggle(); } return a.exec(); } diff --git a/src/pwgui/main.cpp b/src/pwgui/main.cpp index 8a9833b..9f3bbef 100644 --- a/src/pwgui/main.cpp +++ b/src/pwgui/main.cpp @@ -20,6 +20,8 @@ #include #include +#include "../x11workaround.h" + #define NAMELEN 400 #define BUFLEN 9000 #define ENVLEN 20000 @@ -193,6 +195,7 @@ int main(int argc, char *argv[]) PwGui *w = new PwGui(pfd[1], creds); bg->setMainWindow(w); w->show(); + wiggle(); exit(a.exec()); return CUPS_BACKEND_CANCEL; } diff --git a/src/x11workaround.cpp b/src/x11workaround.cpp new file mode 100644 index 0000000..c093362 --- /dev/null +++ b/src/x11workaround.cpp @@ -0,0 +1,23 @@ +#include "x11workaround.h" + + +void movePointer(int x, int y) { + bool result; + int root_x, root_y, win_x, win_y; + unsigned int mask_return; + Display* dpy = XOpenDisplay(0); + Window root = DefaultRootWindow(dpy); + Window window_returned; + result = XQueryPointer(dpy, root, &window_returned, &window_returned, &root_x, &root_y, &win_x, &win_y, &mask_return); + if (result != true) { + fprintf(stderr, "No mouse found.\n"); + return; + } + XWarpPointer(dpy, None,root, 0, 0, 0, 0, root_x - x ,root_y - y); + XFlush(dpy); +} + +void wiggle() { + movePointer(5, 5); + movePointer(-5, -5); +} diff --git a/src/x11workaround.h b/src/x11workaround.h new file mode 100644 index 0000000..d0aef7d --- /dev/null +++ b/src/x11workaround.h @@ -0,0 +1,10 @@ +#ifndef X11_WORKAROUND_VMWARE +#define X11_WORKAROUND_VMWARE + +#include +#include + + +void movePointer(int x, int y); +void wiggle(); +#endif -- cgit v1.2.3-55-g7522