]> icculus.org git repositories - dana/openbox.git/blob - src/screen.hh
compress config req's
[dana/openbox.git] / src / screen.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 #ifndef   __screen_hh
3 #define   __screen_hh
4
5 /*! @file screen.hh
6   @brief Screen manages a single screen
7 */
8
9 extern "C" {
10 #include <X11/Xlib.h>
11 }
12
13 #include "widgetbase.hh"
14 #include "otk/renderstyle.hh"
15 #include "otk/strut.hh"
16 #include "otk/rect.hh"
17 #include "otk/screeninfo.hh"
18 #include "otk/eventhandler.hh"
19 #include "otk/property.hh"
20 #include "otk/ustring.hh"
21
22 #include <string>
23 #include <list>
24
25 namespace ob {
26
27 class Client;
28
29 //! Manages a single screen
30 /*!
31 */
32 class Screen : public otk::EventHandler, public WidgetBase {
33 public:
34   //! Holds a list of otk::Strut objects
35   typedef std::list<otk::Strut*> StrutList;
36
37   static const unsigned long event_mask = ColormapChangeMask |
38                                           EnterWindowMask |
39                                           LeaveWindowMask |
40                                           PropertyChangeMask |
41                                           SubstructureNotifyMask |
42                                           SubstructureRedirectMask |
43                                           ButtonPressMask |
44                                           ButtonReleaseMask;
45
46   //! Holds a list of Clients
47   typedef std::list<Client*> ClientList;
48   //! All managed clients on the screen (in order of being mapped)
49   ClientList clients;
50   
51 private:
52   //! Was %Openbox able to manage the screen?
53   bool _managed;
54
55   //! The number of the screen on the X server
56   int _number;
57
58   //! Information about this screen
59   const otk::ScreenInfo *_info;
60   
61   //! The style with which to render on the screen
62   otk::RenderStyle _style;
63
64   //! Is the root colormap currently installed?
65   bool _root_cmap_installed;
66
67   //! Area usable for placement etc (total - struts)
68   otk::Rect _area;
69
70   //! Combined strut from all of the clients' struts
71   otk::Strut _strut;
72
73   //!  An offscreen window which gets focus when nothing else has it
74   Window _focuswindow;
75
76   //! An offscreen window which shows that a NETWM compliant window manager is
77   //! running
78   Window _supportwindow;
79
80   //! A list of all managed clients on the screen, in their stacking order
81   ClientList _stacking;
82
83   //! The desktop currently being displayed
84   long _desktop;
85
86   //! The number of desktops
87   long _num_desktops;
88
89   //! The names of all desktops
90   otk::Property::StringVect _desktop_names;
91
92   //! Calculate the Screen::_area member
93   void calcArea();
94   //! Set the list of supported NETWM atoms on the root window
95   void changeSupportedAtoms();
96   //! Set the client list on the root window
97   /*!
98     Sets the _NET_CLIENT_LIST root window property.<br>
99     Also calls Screen::updateStackingList.
100   */
101   void changeClientList();
102   //! Set the client stacking list on the root window
103   /*!
104     Set the _NET_CLIENT_LIST_STACKING root window property.
105   */
106   void changeStackingList();
107   //! Set the work area hint on the root window
108   /*!
109     Set the _NET_WORKAREA root window property.
110   */
111   void changeWorkArea();
112
113   //! Get desktop names from the root window property
114   void updateDesktopNames();
115
116   //! Changes to the specified desktop, displaying windows on it and hiding
117   //! windows on the others.
118   /*!
119     @param desktop The number of the desktop to switch to (starts from 0).
120     If the desktop is out of valid range, it is ignored.
121   */
122   void changeDesktop(long desktop);
123
124   //! Changes the number of desktops.
125   /*!
126     @param num The number of desktops that should exist. This value must be
127                greater than 0 or it will be ignored.
128   */
129   void changeNumDesktops(long num);
130
131 public:
132 #ifndef SWIG
133   //! Constructs a new Screen object
134   Screen(int screen);
135   //! Destroys the Screen object
136   virtual ~Screen();
137 #endif
138
139   inline int number() const { return _number; }
140   
141   //! Returns if the screen was successfully managed
142   /*!
143     If this is false, then the screen should be deleted and should NOT be
144     used.
145   */
146   inline bool managed() const { return _managed; }
147   //! Returns the area of the screen not reserved by applications' Struts
148   inline const otk::Rect &area() const { return _area; }
149   //! Returns the style in use on the screen
150   inline const otk::RenderStyle *style() const { return &_style; }
151   //!  An offscreen window which gets focus when nothing else has it
152   inline Window focuswindow() const { return _focuswindow; }
153   //! Returns the desktop being displayed
154   inline long desktop() const { return _desktop; }
155   //! Returns the number of desktops
156   inline long numDesktops() const { return _num_desktops; }
157
158   //! Update's the screen's combined strut of all the clients.
159   /*!
160     Clients should call this whenever they change their strut.
161   */
162   void updateStrut();
163
164   //! Manage any pre-existing windows on the screen
165   void manageExisting();
166   //! Manage a client window
167   /*!
168     This gives the window a frame, reparents it, selects events on it, etc.
169   */
170   void manageWindow(Window window);
171   //! Unmanage a client
172   /*!
173     This removes the window's frame, reparents it to root, unselects events on
174     it, etc.
175     @param client The client to unmanage
176   */
177   void unmanageWindow(Client *client);
178
179   //! Raises a client window above all others in its stacking layer
180   /*!
181     raiseWindow has a couple of constraints that lowerWindow does not.<br>
182     1) raiseWindow can be called after changing a Client's stack layer, and
183        the list will be reorganized properly.<br>
184     2) raiseWindow guarantees that XRestackWindows() will <i>always</i> be
185        called for the specified client.
186   */
187   void raiseWindow(Client *client);
188
189   //! Lowers a client window below all others in its stacking layer
190   void lowerWindow(Client *client);
191
192   //! Sets the name of a desktop by changing the root window property
193   /*!
194     @param i The index of the desktop to set the name for (starts at 0)
195     @param name The name to set for the desktop
196     If the index is too large, it is simply ignored.
197   */
198   void setDesktopName(long i, const otk::ustring &name);
199
200   void installColormap(bool install) const;
201
202   virtual void propertyHandler(const XPropertyEvent &e);
203   virtual void clientMessageHandler(const XClientMessageEvent &e);
204   virtual void mapRequestHandler(const XMapRequestEvent &e);
205 };
206
207 }
208
209 #endif// __screen_hh