]> Dogcows Code - chaz/openbox/blob - tests/fullscreen.c
set "Openbox" as the name no "Openbox3"
[chaz/openbox] / 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 printf("fullscreen\n");
34 msg.xclient.type = ClientMessage;
35 msg.xclient.message_type = _net_state;
36 msg.xclient.display = display;
37 msg.xclient.window = win;
38 msg.xclient.format = 32;
39 msg.xclient.data.l[0] = 2; // toggle
40 msg.xclient.data.l[1] = _net_fs;
41 msg.xclient.data.l[2] = 0l;
42 msg.xclient.data.l[3] = 0l;
43 msg.xclient.data.l[4] = 0l;
44 XSendEvent(display, RootWindow(display, 0), False,
45 SubstructureNotifyMask | SubstructureRedirectMask, &msg);
46 XFlush(display);
47 sleep(2);
48
49 printf("restore\n");
50 msg.xclient.type = ClientMessage;
51 msg.xclient.message_type = _net_state;
52 msg.xclient.display = display;
53 msg.xclient.window = win;
54 msg.xclient.format = 32;
55 msg.xclient.data.l[0] = 2; // toggle
56 msg.xclient.data.l[1] = _net_fs;
57 msg.xclient.data.l[2] = 0l;
58 msg.xclient.data.l[3] = 0l;
59 msg.xclient.data.l[4] = 0l;
60 XSendEvent(display, RootWindow(display, 0), False,
61 SubstructureNotifyMask | SubstructureRedirectMask, &msg);
62
63 XSelectInput(display, win, ExposureMask | StructureNotifyMask);
64
65 while (1) {
66 XNextEvent(display, &report);
67
68 switch (report.type) {
69 case Expose:
70 printf("exposed\n");
71 break;
72 case ConfigureNotify:
73 x = report.xconfigure.x;
74 y = report.xconfigure.y;
75 w = report.xconfigure.width;
76 h = report.xconfigure.height;
77 printf("confignotify %i,%i-%ix%i\n",x,y,w,h);
78 break;
79 }
80
81 }
82
83 return 1;
84 }
This page took 0.039992 seconds and 4 git commands to generate.