]>
Dogcows Code - chaz/openbox/blob - tests/extentsrequest.c
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 extentsrequest.c for the Openbox window manager
4 Copyright (c) 2003-2007 Dana Jansens
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.
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.
16 See the COPYING file for a copy of the GNU General Public License.
22 #include <X11/Xatom.h>
28 Atom _request
, _extents
, _type
, _normal
, _desktop
;
30 int x
=10,y
=10,h
=100,w
=400;
32 display
= XOpenDisplay(NULL
);
34 if (display
== NULL
) {
35 fprintf(stderr
, "couldn't connect to X server :0\n");
39 _type
= XInternAtom(display
, "_NET_WM_WINDOW_TYPE", False
);
40 _normal
= XInternAtom(display
, "_NET_WM_WINDOW_TYPE_NORMAL", False
);
41 _desktop
= XInternAtom(display
, "_NET_WM_WINDOW_TYPE_DESKTOP", False
);
42 _request
= XInternAtom(display
, "_NET_REQUEST_FRAME_EXTENTS", False
);
43 _extents
= XInternAtom(display
, "_NET_FRAME_EXTENTS", False
);
45 win
= XCreateWindow(display
, RootWindow(display
, 0),
46 x
, y
, w
, h
, 10, CopyFromParent
, CopyFromParent
,
47 CopyFromParent
, 0, NULL
);
48 XSelectInput(display
, win
, PropertyChangeMask
);
50 printf("requesting for type normal\n");
51 XChangeProperty(display
, win
, _type
, XA_ATOM
, 32,
52 PropModeReplace
, (unsigned char*)&_normal
, 1);
53 msg
.xclient
.type
= ClientMessage
;
54 msg
.xclient
.message_type
= _request
;
55 msg
.xclient
.display
= display
;
56 msg
.xclient
.window
= win
;
57 msg
.xclient
.format
= 32;
58 msg
.xclient
.data
.l
[0] = 0l;
59 msg
.xclient
.data
.l
[1] = 0l;
60 msg
.xclient
.data
.l
[2] = 0l;
61 msg
.xclient
.data
.l
[3] = 0l;
62 msg
.xclient
.data
.l
[4] = 0l;
63 XSendEvent(display
, RootWindow(display
, 0), False
,
64 SubstructureNotifyMask
| SubstructureRedirectMask
, &msg
);
67 printf("waiting for extents\n");
69 XNextEvent(display
, &report
);
71 if (report
.type
== PropertyNotify
&&
72 report
.xproperty
.atom
== _extents
)
76 unsigned long ret_items
, ret_bytesleft
;
77 unsigned long *prop_return
;
78 XGetWindowProperty(display
, win
, _extents
, 0, 4,
79 False
, XA_CARDINAL
, &ret_type
, &ret_format
,
80 &ret_items
, &ret_bytesleft
,
81 (unsigned char**) &prop_return
);
82 if (ret_type
== XA_CARDINAL
&& ret_format
== 32 && ret_items
== 4)
83 printf("got new extents %d, %d, %d, %d\n",
84 prop_return
[0], prop_return
[1], prop_return
[2],
90 printf("requesting for type desktop\n");
91 XChangeProperty(display
, win
, _type
, XA_ATOM
, 32,
92 PropModeReplace
, (unsigned char*)&_desktop
, 1);
93 msg
.xclient
.type
= ClientMessage
;
94 msg
.xclient
.message_type
= _request
;
95 msg
.xclient
.display
= display
;
96 msg
.xclient
.window
= win
;
97 msg
.xclient
.format
= 32;
98 msg
.xclient
.data
.l
[0] = 0l;
99 msg
.xclient
.data
.l
[1] = 0l;
100 msg
.xclient
.data
.l
[2] = 0l;
101 msg
.xclient
.data
.l
[3] = 0l;
102 msg
.xclient
.data
.l
[4] = 0l;
103 XSendEvent(display
, RootWindow(display
, 0), False
,
104 SubstructureNotifyMask
| SubstructureRedirectMask
, &msg
);
107 printf("waiting for extents\n");
109 XNextEvent(display
, &report
);
111 if (report
.type
== PropertyNotify
&&
112 report
.xproperty
.atom
== _extents
)
116 unsigned long ret_items
, ret_bytesleft
;
117 unsigned long *prop_return
;
118 XGetWindowProperty(display
, win
, _extents
, 0, 4,
119 False
, XA_CARDINAL
, &ret_type
, &ret_format
,
120 &ret_items
, &ret_bytesleft
,
121 (unsigned char**) &prop_return
);
122 if (ret_type
== XA_CARDINAL
&& ret_format
== 32 && ret_items
== 4)
123 printf("got new extents %d, %d, %d, %d\n",
124 prop_return
[0], prop_return
[1], prop_return
[2],
This page took 0.041674 seconds and 4 git commands to generate.