]> icculus.org git repositories - dana/openbox.git/blob - tests/grav.c
only hide menus if theyre supposed to when executing
[dana/openbox.git] / tests / grav.c
1 #include <stdio.h>
2 #include <X11/Xlib.h>
3
4 int main () {
5   XSetWindowAttributes xswa;
6   unsigned long        xswamask;
7   Display   *display;
8   Window     win;
9   XEvent     report;
10   int        x=10,y=10,h=100,w=400;
11
12   display = XOpenDisplay(NULL);
13
14   if (display == NULL) {
15     fprintf(stderr, "couldn't connect to X server :0\n");
16     return 0;
17   }
18
19   xswa.win_gravity = StaticGravity;
20   xswamask = CWWinGravity;
21
22   win = XCreateWindow(display, RootWindow(display, 0),
23                       x, y, w, h, 10, CopyFromParent, CopyFromParent,
24                       CopyFromParent, xswamask, &xswa);
25
26   XSetWindowBackground(display,win,WhitePixel(display,0)); 
27
28   XMapWindow(display, win);
29   XFlush(display);
30
31   XSelectInput(display, win, ExposureMask | StructureNotifyMask);
32
33   while (1) {
34     XNextEvent(display, &report);
35
36     switch (report.type) {
37     case Expose:
38       printf("exposed\n");
39       break;
40     case ConfigureNotify:
41       x = report.xconfigure.x;
42       y = report.xconfigure.y;
43       w = report.xconfigure.width;
44       h = report.xconfigure.height;
45       printf("confignotify %i,%i-%ix%i\n",x,y,w,h);
46       break;
47     }
48
49   }
50
51   return 1;
52 }