summaryrefslogtreecommitdiff
path: root/src/wm-tester
diff options
context:
space:
mode:
Diffstat (limited to 'src/wm-tester')
-rw-r--r--src/wm-tester/Makefile.am8
-rw-r--r--src/wm-tester/focus-window.c37
2 files changed, 43 insertions, 2 deletions
diff --git a/src/wm-tester/Makefile.am b/src/wm-tester/Makefile.am
index e6ec267..8673127 100644
--- a/src/wm-tester/Makefile.am
+++ b/src/wm-tester/Makefile.am
@@ -7,7 +7,11 @@ wm_tester_SOURCES= \
test_gravity_SOURCES= \
test-gravity.c
-noinst_PROGRAMS=wm-tester test-gravity
+focus_window_SOURCES= \
+ focus-window.c
+
+noinst_PROGRAMS=wm-tester test-gravity focus-window
wm_tester_LDADD= @METACITY_LIBS@
-test_gravity_LDADD= @METACITY_LIBS@ \ No newline at end of file
+test_gravity_LDADD= @METACITY_LIBS@
+focus_window_LDADD= @METACITY_LIBS@ \ No newline at end of file
diff --git a/src/wm-tester/focus-window.c b/src/wm-tester/focus-window.c
new file mode 100644
index 0000000..dc33bd2
--- /dev/null
+++ b/src/wm-tester/focus-window.c
@@ -0,0 +1,37 @@
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int main (int argc, char **argv)
+{
+ Display *d;
+ Window w;
+ const char *w_str;
+ char *end;
+
+ if (argc != 2)
+ {
+ fprintf (stderr, "Usage: focus-window WINDOWID\n");
+ exit (1);
+ }
+
+ d = XOpenDisplay (NULL);
+
+ w_str = argv[1];
+ end = NULL;
+
+ w = strtoul (w_str, &end, 16);
+ if (end == w_str)
+ {
+ fprintf (stderr, "Usage: focus-window WINDOWID\n");
+ exit (1);
+ }
+
+ printf ("Setting input focus to 0x%lx\n", w);
+ XSetInputFocus (d, w, RevertToPointerRoot, CurrentTime);
+ XFlush (d);
+
+ return 0;
+}
+