]> Dogcows Code - chaz/openbox/blob - tests/aspect.c
add some tests
[chaz/openbox] / tests / aspect.c
1 #include <stdio.h>
2 #include <X11/Xlib.h>
3 #include <X11/Xutil.h>
4
5 int main () {
6 XSetWindowAttributes xswa;
7 unsigned long xswamask;
8 Display *display;
9 Window win;
10 XEvent report;
11 int x=10,y=10,h=100,w=400;
12 XSizeHints size;
13
14 display = XOpenDisplay(NULL);
15
16 if (display == NULL) {
17 fprintf(stderr, "couldn't connect to X server :0\n");
18 return 0;
19 }
20
21 xswa.win_gravity = StaticGravity;
22 xswamask = CWWinGravity;
23
24 win = XCreateWindow(display, RootWindow(display, 0),
25 x, y, w, h, 10, CopyFromParent, CopyFromParent,
26 CopyFromParent, xswamask, &xswa);
27
28 XSetWindowBackground(display,win,WhitePixel(display,0));
29
30 size.flags = PAspect;
31 size.min_aspect.x = 3;
32 size.min_aspect.y = 3;
33 size.max_aspect.x = 3;
34 size.max_aspect.y = 3;
35 XSetWMNormalHints(display, win, &size);
36
37 XMapWindow(display, win);
38 XFlush(display);
39
40 XSelectInput(display, win, ExposureMask | StructureNotifyMask);
41
42 while (1) {
43 XNextEvent(display, &report);
44
45 switch (report.type) {
46 case Expose:
47 printf("exposed\n");
48 break;
49 case ConfigureNotify:
50 x = report.xconfigure.x;
51 y = report.xconfigure.y;
52 w = report.xconfigure.width;
53 h = report.xconfigure.height;
54 printf("confignotify %i,%i-%ix%i\n",x,y,w,h);
55 break;
56 }
57
58 }
59
60 return 1;
61 }
This page took 0.042902 seconds and 5 git commands to generate.