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