]> icculus.org git repositories - dana/openbox.git/blob - tests/fullscreen.c
set lbutton from clicks
[dana/openbox.git] / tests / fullscreen.c
1 #include <stdio.h>
2 #include <unistd.h>
3 #include <X11/Xlib.h>
4
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;
12
13   display = XOpenDisplay(NULL);
14
15   if (display == NULL) {
16     fprintf(stderr, "couldn't connect to X server :0\n");
17     return 0;
18   }
19
20   _net_state = XInternAtom(display, "_NET_WM_STATE", False);
21   _net_fs = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", False);
22
23   win = XCreateWindow(display, RootWindow(display, 0),
24                       x, y, w, h, 10, CopyFromParent, CopyFromParent,
25                       CopyFromParent, 0, NULL);
26
27   XSetWindowBackground(display,win,WhitePixel(display,0)); 
28
29   XMapWindow(display, win);
30   XFlush(display);
31   sleep(2);
32
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);
47
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);
60
61   XSelectInput(display, win, ExposureMask | StructureNotifyMask);
62
63   while (1) {
64     XNextEvent(display, &report);
65
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;
77     }
78
79   }
80
81   return 1;
82 }