diff options
author | Peter Wu <lekensteyn@gmail.com> | 2012-09-26 15:04:18 +0200 |
---|---|---|
committer | Peter Wu <lekensteyn@gmail.com> | 2012-09-26 15:04:18 +0200 |
commit | 2497c1392b81e093f4de2541a98746aebd449a7f (patch) | |
tree | db87e59d4c70c677ddb1899d9161b004f6e454ac /grab.cpp | |
download | c-files-2497c1392b81e093f4de2541a98746aebd449a7f.tar.gz |
Initial commit
Diffstat (limited to 'grab.cpp')
-rw-r--r-- | grab.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
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 <QApplication> +#include <QLabel> +#include <iostream> +#include <stdio.h> +#include <unistd.h> + +#define WITH_XGRAB +//#undef WITH_XGRAB +#ifdef WITH_XGRAB +# include <X11/Xlib.h> +#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; +} |