]> Dogcows Code - chaz/openbox/blob - otk/screeninfo.cc
merge the C branch into HEAD
[chaz/openbox] / otk / screeninfo.cc
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2
3 #include "config.h"
4
5 extern "C" {
6 #include <X11/Xlib.h>
7 #include <X11/Xutil.h>
8 }
9
10 #include "screeninfo.hh"
11 #include "display.hh"
12 #include "util.hh"
13
14 using std::string;
15
16 namespace otk {
17
18 ScreenInfo::ScreenInfo(int num) {
19 assert(num >= 0 && num < ScreenCount(**display));
20
21 _screen = num;
22
23 _root_window = RootWindow(**display, _screen);
24
25 _size = Size(WidthOfScreen(ScreenOfDisplay(**display,
26 _screen)),
27 HeightOfScreen(ScreenOfDisplay(**display,
28 _screen)));
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);
34
35 _display_string = string("DISPLAY=") + default_string + '.' +
36 itostring(static_cast<unsigned long>(_screen));
37
38 #if 0 //def XINERAMA
39 _xinerama_active = False;
40
41 if (d->hasXineramaExtensions()) {
42 if (d->getXineramaMajorVersion() == 1) {
43 // we know the version 1(.1?) protocol
44
45 /*
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.
49 */
50 if (XineramaIsActive(**display)) {
51 /*
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.
56 */
57 int num;
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));
64 }
65 XFree(info);
66
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;
70 }
71 }
72 }
73 }
74 #else
75 _xinerama_active = false;
76 #endif // XINERAMA
77 if (!_xinerama_active)
78 _xinerama_areas.push_back(Rect(Point(0, 0), _size));
79 }
80
81 }
This page took 0.034312 seconds and 4 git commands to generate.