fix draw order in x_paint
[openbox.git] / tests / fullscreen.c
blobc5f686d9cb892f33c1b86ce6465df9de6a09830c
1 #include <stdio.h>
2 #include <unistd.h>
3 #include <X11/Xlib.h>
5 int main () {
6 Display *display;
7 Window win;
8 XEvent report;
9 Atom _net_fs, _net_state;
10 XEvent msg;
11 int x=10,y=10,h=100,w=400;
13 display = XOpenDisplay(NULL);
15 if (display == NULL) {
16 fprintf(stderr, "couldn't connect to X server :0\n");
17 return 0;
20 _net_state = XInternAtom(display, "_NET_WM_STATE", False);
21 _net_fs = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", False);
23 win = XCreateWindow(display, RootWindow(display, 0),
24 x, y, w, h, 10, CopyFromParent, CopyFromParent,
25 CopyFromParent, 0, NULL);
27 XSetWindowBackground(display,win,WhitePixel(display,0));
29 XMapWindow(display, win);
30 XFlush(display);
31 sleep(2);
33 msg.xclient.type = ClientMessage;
34 msg.xclient.message_type = _net_state;
35 msg.xclient.display = display;
36 msg.xclient.window = win;
37 msg.xclient.format = 32;
38 msg.xclient.data.l[0] = 2; // toggle
39 msg.xclient.data.l[1] = _net_fs;
40 msg.xclient.data.l[2] = 0l;
41 msg.xclient.data.l[3] = 0l;
42 msg.xclient.data.l[4] = 0l;
43 XSendEvent(display, RootWindow(display, 0), False,
44 StructureNotifyMask | SubstructureNotifyMask, &msg);
45 XFlush(display);
46 sleep(2);
48 msg.xclient.type = ClientMessage;
49 msg.xclient.message_type = _net_state;
50 msg.xclient.display = display;
51 msg.xclient.window = win;
52 msg.xclient.format = 32;
53 msg.xclient.data.l[0] = 2; // toggle
54 msg.xclient.data.l[1] = _net_fs;
55 msg.xclient.data.l[2] = 0l;
56 msg.xclient.data.l[3] = 0l;
57 msg.xclient.data.l[4] = 0l;
58 XSendEvent(display, RootWindow(display, 0), False,
59 StructureNotifyMask | SubstructureNotifyMask, &msg);
61 XSelectInput(display, win, ExposureMask | StructureNotifyMask);
63 while (1) {
64 XNextEvent(display, &report);
66 switch (report.type) {
67 case Expose:
68 printf("exposed\n");
69 break;
70 case ConfigureNotify:
71 x = report.xconfigure.x;
72 y = report.xconfigure.y;
73 w = report.xconfigure.width;
74 h = report.xconfigure.height;
75 printf("confignotify %i,%i-%ix%i\n",x,y,w,h);
76 break;
81 return 1;