From 2497c1392b81e093f4de2541a98746aebd449a7f Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Wed, 26 Sep 2012 15:04:18 +0200 Subject: Initial commit --- grab.cpp | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 grab.cpp (limited to 'grab.cpp') diff --git a/grab.cpp b/grab.cpp new file mode 100644 index 0000000..6071c2f --- /dev/null +++ b/grab.cpp @@ -0,0 +1,59 @@ +/** + * Attempt to display picture fullscreen, capturing input (failed at capture kbd keys) + * Author: Peter Wu + * Date: 2012-09-24 + */ +#include +#include +#include +#include +#include + +#define WITH_XGRAB +//#undef WITH_XGRAB +#ifdef WITH_XGRAB +# include +#endif + +class Application: public QApplication { +public: + Application(int argc, char **argv): QApplication(argc, argv) {} + ~Application(){} + bool notify(QObject *object, QEvent *event) { + std::cerr << "Event: " << event->type() << std::endl; + return object->event(event); + } +}; + +int main(int argc, char **argv) { + Application app(argc, argv); + QLabel lbl; + //lbl.setCursor(QCursor(Qt::BlankCursor)); + lbl.resize(300, 200); + lbl.setWindowTitle(*argv); + lbl.show(); + lbl.grabKeyboard(); +#ifdef WITH_XGRAB + Display *dpy = XOpenDisplay(NULL); + if (!dpy) fprintf(stderr, "Could not open DISPLAY\n"); + else{ + Window win = DefaultRootWindow(dpy); + XGrabKeyboard(dpy, win, False, + GrabModeAsync, + GrabModeAsync, + CurrentTime); +#if 0 + XGrabPointer(dpy, win, True, + 0, + GrabModeAsync, + GrabModeAsync, + win, + None, + CurrentTime); +#endif + } +#endif + return app.exec(); + //std::cerr << "Closing" << std::endl; + //return 0; +} -- cgit v1.2.1