]> icculus.org git repositories - dana/openbox.git/blob - src/screen.hh
rm a debug print
[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 "otk/strut.hh"
14 #include "otk/rect.hh"
15 #include "otk/screeninfo.hh"
16 #include "otk/eventhandler.hh"
17 #include "otk/property.hh"
18 #include "otk/ustring.hh"
19
20 #include <string>
21 #include <list>
22
23 namespace ob {
24
25 class Client;
26
27 //! Manages a single screen
28 /*!
29 */
30 class Screen : public otk::EventHandler {
31 public:
32   //! Holds a list of otk::Strut objects
33   typedef std::vector<otk::Strut> StrutList;
34   //! Holds a list of otk::Rect objects
35   typedef std::vector<otk::Rect> RectList;
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   //! Is the root colormap currently installed?
62   bool _root_cmap_installed;
63
64   //! Area usable for placement etc (total - struts), one per desktop,
65   //! plus one extra for windows on all desktops
66   RectList _area;
67
68   //! Combined strut from all of the clients' struts, one per desktop,
69   //! plus one extra for windows on all desktops
70   StrutList _struts;
71
72   //!  An offscreen window which gets focus when nothing else has it
73   Window _focuswindow;
74
75   //! An offscreen window which shows that a NETWM compliant window manager is
76   //! running
77   Window _supportwindow;
78
79   //! A list of all managed clients on the screen, in their stacking order
80   ClientList _stacking;
81
82   //! The desktop currently being displayed
83   unsigned int _desktop;
84
85   //! The number of desktops
86   unsigned int _num_desktops;
87
88   //! The names of all desktops
89   otk::Property::StringVect _desktop_names;
90
91   //! Calculate the Screen::_area member
92   void calcArea();
93   //! Set the list of supported NETWM atoms on the root window
94   void changeSupportedAtoms();
95   //! Set the client list on the root window
96   /*!
97     Sets the _NET_CLIENT_LIST root window property.<br>
98     Also calls Screen::updateStackingList.
99   */
100   void changeClientList();
101   //! Set the client stacking list on the root window
102   /*!
103     Set the _NET_CLIENT_LIST_STACKING root window property.
104   */
105   void changeStackingList();
106   //! Set the work area hint on the root window
107   /*!
108     Set the _NET_WORKAREA root window property.
109   */
110   void changeWorkArea();
111
112   //! Get desktop names from the root window property
113   void updateDesktopNames();
114
115   //! Changes to the specified desktop, displaying windows on it and hiding
116   //! windows on the others.
117   /*!
118     @param desktop The number of the desktop to switch to (starts from 0).
119     If the desktop is out of valid range, it is ignored.
120   */
121   void changeDesktop(unsigned int desktop);
122
123   //! Changes the number of desktops.
124   /*!
125     @param num The number of desktops that should exist. This value must be
126                greater than 0 or it will be ignored.
127   */
128   void changeNumDesktops(unsigned int num);
129
130 public:
131 #ifndef SWIG
132   //! Constructs a new Screen object
133   Screen(int screen);
134   //! Destroys the Screen object
135   virtual ~Screen();
136 #endif
137
138   inline int number() const { return _number; }
139   
140   //! Returns if the screen was successfully managed
141   /*!
142     If this is false, then the screen should be deleted and should NOT be
143     used.
144   */
145   inline bool managed() const { return _managed; }
146   //!  An offscreen window which gets focus when nothing else has it
147   inline Window focuswindow() const { return _focuswindow; }
148   //! Returns the desktop being displayed
149   inline unsigned int desktop() const { return _desktop; }
150   //! Returns the number of desktops
151   inline unsigned int numDesktops() const { return _num_desktops; }
152
153   //! Returns the area of the screen not reserved by applications' Struts
154   /*!
155     @param desktop The desktop number of the area to retrieve for. A value of
156                    0xffffffff will return an area that combines all struts
157                    on all desktops.
158   */
159   const otk::Rect& area(unsigned int desktop) const;
160
161   //! Update's the screen's combined strut of all the clients.
162   /*!
163     Clients should call this whenever they change their strut.
164   */
165   void updateStruts();
166
167   //! Manage any pre-existing windows on the screen
168   void manageExisting();
169   //! Manage a client window
170   /*!
171     This gives the window a frame, reparents it, selects events on it, etc.
172   */
173   void manageWindow(Window window);
174   //! Unmanage a client
175   /*!
176     This removes the window's frame, reparents it to root, unselects events on
177     it, etc.
178     @param client The client to unmanage
179   */
180   void unmanageWindow(Client *client);
181
182   //! Raises a client window above all others in its stacking layer
183   /*!
184     raiseWindow has a couple of constraints that lowerWindow does not.<br>
185     1) raiseWindow can be called after changing a Client's stack layer, and
186        the list will be reorganized properly.<br>
187     2) raiseWindow guarantees that XRestackWindows() will <i>always</i> be
188        called for the specified client.
189   */
190   void raiseWindow(Client *client);
191
192   //! Lowers a client window below all others in its stacking layer
193   void lowerWindow(Client *client);
194
195   //! Sets the name of a desktop by changing the root window property
196   /*!
197     @param i The index of the desktop to set the name for (starts at 0)
198     @param name The name to set for the desktop
199     If the index is too large, it is simply ignored.
200   */
201   void setDesktopName(unsigned int i, const otk::ustring &name);
202
203   void installColormap(bool install) const;
204
205   virtual void propertyHandler(const XPropertyEvent &e);
206   virtual void clientMessageHandler(const XClientMessageEvent &e);
207   virtual void mapRequestHandler(const XMapRequestEvent &e);
208 };
209
210 }
211
212 #endif// __screen_hh