]> Dogcows Code - chaz/openbox/blob - tests/fullscreen.c
add a hand built changelog
[chaz/openbox] / tests / fullscreen.c
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3 fullscreen.c for the Openbox window manager
4 Copyright (c) 2003 Ben Jansens
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 See the COPYING file for a copy of the GNU General Public License.
17 */
18
19 #include <stdio.h>
20 #include <unistd.h>
21 #include <X11/Xlib.h>
22
23 int main () {
24 Display *display;
25 Window win;
26 XEvent report;
27 Atom _net_fs, _net_state;
28 XEvent msg;
29 int x=10,y=10,h=100,w=400;
30
31 display = XOpenDisplay(NULL);
32
33 if (display == NULL) {
34 fprintf(stderr, "couldn't connect to X server :0\n");
35 return 0;
36 }
37
38 _net_state = XInternAtom(display, "_NET_WM_STATE", False);
39 _net_fs = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", False);
40
41 win = XCreateWindow(display, RootWindow(display, 0),
42 x, y, w, h, 10, CopyFromParent, CopyFromParent,
43 CopyFromParent, 0, NULL);
44
45 XSetWindowBackground(display,win,WhitePixel(display,0));
46
47 XMapWindow(display, win);
48 XFlush(display);
49 sleep(2);
50
51 printf("fullscreen\n");
52 msg.xclient.type = ClientMessage;
53 msg.xclient.message_type = _net_state;
54 msg.xclient.display = display;
55 msg.xclient.window = win;
56 msg.xclient.format = 32;
57 msg.xclient.data.l[0] = 2; // toggle
58 msg.xclient.data.l[1] = _net_fs;
59 msg.xclient.data.l[2] = 0l;
60 msg.xclient.data.l[3] = 0l;
61 msg.xclient.data.l[4] = 0l;
62 XSendEvent(display, RootWindow(display, 0), False,
63 SubstructureNotifyMask | SubstructureRedirectMask, &msg);
64 XFlush(display);
65 sleep(2);
66
67 printf("restore\n");
68 msg.xclient.type = ClientMessage;
69 msg.xclient.message_type = _net_state;
70 msg.xclient.display = display;
71 msg.xclient.window = win;
72 msg.xclient.format = 32;
73 msg.xclient.data.l[0] = 2; // toggle
74 msg.xclient.data.l[1] = _net_fs;
75 msg.xclient.data.l[2] = 0l;
76 msg.xclient.data.l[3] = 0l;
77 msg.xclient.data.l[4] = 0l;
78 XSendEvent(display, RootWindow(display, 0), False,
79 SubstructureNotifyMask | SubstructureRedirectMask, &msg);
80
81 XSelectInput(display, win, ExposureMask | StructureNotifyMask);
82
83 while (1) {
84 XNextEvent(display, &report);
85
86 switch (report.type) {
87 case Expose:
88 printf("exposed\n");
89 break;
90 case ConfigureNotify:
91 x = report.xconfigure.x;
92 y = report.xconfigure.y;
93 w = report.xconfigure.width;
94 h = report.xconfigure.height;
95 printf("confignotify %i,%i-%ix%i\n",x,y,w,h);
96 break;
97 }
98
99 }
100
101 return 1;
102 }
This page took 0.04016 seconds and 4 git commands to generate.