]>
Dogcows Code - chaz/openbox/blob - otk/screeninfo.cc
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
10 #include "screeninfo.hh"
18 ScreenInfo::ScreenInfo(int num
) {
19 assert(num
>= 0 && num
< ScreenCount(**display
));
23 _root_window
= RootWindow(**display
, _screen
);
25 _size
= Size(WidthOfScreen(ScreenOfDisplay(**display
,
27 HeightOfScreen(ScreenOfDisplay(**display
,
29 // get the default display string and strip the screen number
30 string default_string
= DisplayString(**display
);
31 const string::size_type pos
= default_string
.rfind(".");
32 if (pos
!= string::npos
)
33 default_string
.resize(pos
);
35 _display_string
= string("DISPLAY=") + default_string
+ '.' +
36 itostring(static_cast<unsigned long>(_screen
));
39 _xinerama_active
= False
;
41 if (d
->hasXineramaExtensions()) {
42 if (d
->getXineramaMajorVersion() == 1) {
43 // we know the version 1(.1?) protocol
46 in this version of Xinerama, we can't query on a per-screen basis, but
47 in future versions we should be able, so the 'activeness' is checked
48 on a pre-screen basis anyways.
50 if (XineramaIsActive(**display
)) {
52 If Xinerama is being used, there there is only going to be one screen
53 present. We still, of course, want to use the screen class, but that
54 is why no screen number is used in this function call. There should
55 never be more than one screen present with Xinerama active.
58 XineramaScreenInfo
*info
= XineramaQueryScreens(**display
, &num
);
59 if (num
> 0 && info
) {
60 _xinerama_areas
.reserve(num
);
61 for (int i
= 0; i
< num
; ++i
) {
62 _xinerama_areas
.push_back(Rect(info
[i
].x_org
, info
[i
].y_org
,
63 info
[i
].width
, info
[i
].height
));
67 // if we can't find any xinerama regions, then we act as if it is not
68 // active, even though it said it was
69 _xinerama_active
= true;
75 _xinerama_active
= false;
77 if (!_xinerama_active
)
78 _xinerama_areas
.push_back(Rect(Point(0, 0), _size
));
This page took 0.038475 seconds and 4 git commands to generate.