]> Dogcows Code - chaz/openbox/blob - tests/modal3.c
updates to changelog
[chaz/openbox] / tests / modal3.c
1 #include <stdio.h>
2 #include <X11/Xlib.h>
3 #include <X11/Xutil.h>
4 #include <X11/Xatom.h>
5
6 int main () {
7 Display *display;
8 Window parent, child;
9 XEvent report;
10 Atom state, modal;
11 int x=10,y=10,h=400,w=400;
12 XEvent ce;
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 state = XInternAtom(display, "_NET_WM_STATE", True);
22 modal = XInternAtom(display, "_NET_WM_STATE_MODAL", True);
23
24 parent = XCreateWindow(display, RootWindow(display, 0),
25 x, y, w, h, 10, CopyFromParent, CopyFromParent,
26 CopyFromParent, 0, 0);
27 child = XCreateWindow(display, RootWindow(display, 0),
28 x, y, w/2, h/2, 10, CopyFromParent, CopyFromParent,
29 CopyFromParent, 0, 0);
30
31 XSetWindowBackground(display,parent,WhitePixel(display,0));
32 XSetWindowBackground(display,child,BlackPixel(display,0));
33
34 XSetTransientForHint(display, child, parent);
35
36 XMapWindow(display, parent);
37 XMapWindow(display, child);
38 XFlush(display);
39
40 ce.xclient.type = ClientMessage;
41 ce.xclient.message_type = state;
42 ce.xclient.display = display;
43 ce.xclient.window = child;
44 ce.xclient.format = 32;
45 ce.xclient.data.l[0] = 1;
46 ce.xclient.data.l[1] = modal;
47 ce.xclient.data.l[2] = 0;
48 XSendEvent(display, RootWindow(display, DefaultScreen(display)),
49 False, SubstructureNotifyMask | SubstructureRedirectMask, &ce);
50
51 ce.xclient.data.l[0] = 0;
52 XSendEvent(display, RootWindow(display, DefaultScreen(display)),
53 False, SubstructureNotifyMask | SubstructureRedirectMask, &ce);
54
55 while (1) {
56 XNextEvent(display, &report);
57 }
58
59 return 1;
60 }
This page took 0.03675 seconds and 4 git commands to generate.