summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Klinger2016-06-01 14:47:40 +0200
committerChristian Klinger2016-06-01 14:47:40 +0200
commitc04f102458227e41e8ef13064f5ace371a0cd9ba (patch)
tree4528fcc6dddb72cdd8c389e300f0dd572356dd66
parent[printergui] Interpret --error message as utf8 (diff)
downloadprintergui-c04f102458227e41e8ef13064f5ace371a0cd9ba.tar.gz
printergui-c04f102458227e41e8ef13064f5ace371a0cd9ba.tar.xz
printergui-c04f102458227e41e8ef13064f5ace371a0cd9ba.zip
added x11 workaround.
-rw-r--r--CMakeLists.txt3
-rw-r--r--src/maingui/main.cpp2
-rw-r--r--src/pwgui/main.cpp3
-rw-r--r--src/x11workaround.cpp23
-rw-r--r--src/x11workaround.h10
5 files changed, 41 insertions, 0 deletions
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 <fcntl.h>
#include <sys/stat.h>
+#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 <grp.h>
#include <errno.h>
+#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 <stdio.h>
+#include <X11/Xlib.h>
+
+
+void movePointer(int x, int y);
+void wiggle();
+#endif