summaryrefslogtreecommitdiff
path: root/src/wm-tester/focus-window.c
blob: dc33bd25d7e995cd98c409c5c5745c3ab2b8cc46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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;
}