summaryrefslogtreecommitdiffstats
path: root/sesman/tools/xcon.c
blob: 7a45a1cd0de2ad1d55df42cffee97085c3f6b537 (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

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <X11/Xlib.h>

Display* g_display = 0;
int g_x_socket = 0;

int main(int argc, char** argv)
{
  fd_set rfds;
  int i1;
  XEvent xevent;

  g_display = XOpenDisplay(0);
  if (g_display == 0)
  {
    printf("XOpenDisplay failed\n");
    return 0;
  }
  g_x_socket = XConnectionNumber(g_display);
  while (1)
  {
    FD_ZERO(&rfds);
    FD_SET(g_x_socket, &rfds);
    i1 = select(g_x_socket + 1, &rfds, 0, 0, 0);
    if (i1 < 0)
    {
      break;
    }
    XNextEvent(g_display, &xevent);
  }
  return 0;
}