1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 // Display.hh for Blackbox - an X11 Window manager
3 // Copyright (c) 2001 - 2005 Sean 'Shaleh' Perry <shaleh at debian.org>
4 // Copyright (c) 1997 - 2000, 2002 - 2005
5 //         Bradley T Hughes <bhughes at trolltech.com>
6 //
7 // Permission is hereby granted, free of charge, to any person obtaining a
8 // copy of this software and associated documentation files (the "Software"),
9 // to deal in the Software without restriction, including without limitation
10 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 // and/or sell copies of the Software, and to permit persons to whom the
12 // Software is furnished to do so, subject to the following conditions:
13 //
14 // The above copyright notice and this permission notice shall be included in
15 // all copies or substantial portions of the Software.
16 //
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 // DEALINGS IN THE SOFTWARE.
24 
25 #ifndef   __Display_hh
26 #define   __Display_hh
27 
28 #include "Rect.hh"
29 #include "Util.hh"
30 
31 #include <X11/Xlib.h>
32 
33 namespace bt {
34 
35   // forward declarations
36   class ScreenInfo;
37 
38   class Display : public NoCopy {
39   private:
40     ::Display *xdisplay;
41     ScreenInfo** screen_info_list;
42     size_t screen_info_count;
43 
44   public:
45     Display(const char *dpy_name, bool multi_head);
46     ~Display(void);
47 
XDisplay(void) const48     inline ::Display* XDisplay(void) const
49     { return xdisplay; }
50 
screenCount(void) const51     inline unsigned int screenCount(void) const
52     { return screen_info_count; }
53     const ScreenInfo &screenInfo(unsigned int i) const;
54   };
55 
56   class ScreenInfo: public NoCopy {
57   private:
58     Display& _display;
59     Visual *_visual;
60     Window _rootwindow;
61     Colormap _colormap;
62     int _depth;
63     unsigned int _screennumber;
64     std::string _displaystring;
65     Rect _rect;
66 
67   public:
68     ScreenInfo(Display& d, unsigned int num);
69 
display(void) const70     inline Display& display(void) const
71     { return _display; }
72 
visual(void) const73     inline Visual *visual(void) const
74     { return _visual; }
rootWindow(void) const75     inline Window rootWindow(void) const
76     { return _rootwindow; }
colormap(void) const77     inline Colormap colormap(void) const
78     { return _colormap; }
79 
depth(void) const80     inline int depth(void) const
81     { return _depth; }
82 
screenNumber(void) const83     inline unsigned int screenNumber(void) const
84     { return _screennumber; }
85 
rect(void) const86     inline const Rect& rect(void) const
87     { return _rect; }
width(void) const88     inline unsigned int width(void) const
89     { return _rect.width(); }
height(void) const90     inline unsigned int height(void) const
91     { return _rect.height(); }
92 
displayString(void) const93     inline const std::string& displayString(void) const
94     { return _displaystring; }
95   };
96 
97 } // namespace bt
98 
99 #endif // __Display_hh
100