1 // XScreen.cc for Openbox
2 // Copyright (c) 2002 - 2002 Ben Janens (ben at orodu.net)
4 // Permission is hereby granted, free of charge, to any person obtaining a
5 // copy of this software and associated documentation files (the "Software"),
6 // to deal in the Software without restriction, including without limitation
7 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 // and/or sell copies of the Software, and to permit persons to whom the
9 // Software is furnished to do so, subject to the following conditions:
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 // DEALINGS IN THE SOFTWARE.
25 XScreen::XScreen(const Display
*display
, const unsigned int number
) {
29 _root
= RootWindow(_display
, _number
);
30 _size
= Size(WidthOfScreen(ScreenOfDisplay(_display
, _number
)),
31 HeightOfScreen(ScreenOfDisplay(_display
, _number
)));
37 * This sets up the _depth, _visual, and _colormap properties.
39 void XScreen::setColorData() {
40 _depth
= DefaultDepth(_display
, _number
);
41 _visual
= (Visual
*) 0;
43 // search for a TrueColor Visual. If we can't find one, use the default
44 // visual for the screen
45 XVisualInfo vinfo_template
, *vinfo_return
;
48 vinfo_template
.screen
= _number
;
49 vinfo_template
.c_class
= TrueColor
;
51 vinfo_return
= XGetVisualInfo(_display
, VisualScreenMask
| VisualClassMask
,
52 &vinfo_template
, &vinfo_nitems
);
53 if (vinfo_return
&& vinfo_nitems
> 0) {
54 for (int i
= 0; i
< vinfo_nitems
; i
++)
55 if (_depth
< (vinfo_return
+ i
)->depth
) {
56 _depth
= (vinfo_return
+ i
)->depth
;
57 _visual
= (vinfo_return
+ i
)->visual
;
62 _colormap
= XCreateColormap(_display
, _root
, _visual
, AllocNone
);
64 _visual
= DefaultVisual(_display
, _number
);
65 _colormap
= DefaultColormap(_display
, _number
);