]> icculus.org git repositories - dana/openbox.git/blob - src/screen.hh
add/lower work
[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 OBScreen manages a single screen
7 */
8
9 extern "C" {
10 #include <X11/Xlib.h>
11 }
12
13 #include "rootwindow.hh"
14 #include "otk/image.hh"
15 #include "otk/strut.hh"
16 #include "otk/rect.hh"
17 #include "otk/style.hh"
18 #include "otk/configuration.hh" // TEMPORARY
19
20 #include <string>
21
22 namespace ob {
23
24 class OBClient;
25 class OBRootWindow;
26
27 //! Manages a single screen
28 /*!
29 */
30 class OBScreen {
31 public:
32   //! Holds a list of OBClient objects
33   typedef std::list<OBClient*> ClientList;
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   enum StackLayer {
47     Layer_Icon,       // 0 - iconified windows, in any order at all
48     Layer_Desktop,    // 1 - desktop windows
49     Layer_Below,      // 2 - normal windows w/ below
50     Layer_Normal,     // 3 - normal windows
51     Layer_Above,      // 4 - normal windows w/ above
52     Layer_Top,        // 5 - always-on-top-windows (docks?)
53     Layer_Fullscreen, // 6 - fullscreeen windows
54     Layer_Internal,   // 7 - openbox windows/menus
55     NUM_LAYERS
56   };
57
58   //! All managed clients on the screen (in order of being mapped)
59   ClientList clients;
60   
61 private:
62   //! Was %Openbox able to manage the screen?
63   bool _managed;
64
65   //! The number of the screen on the X server
66   int _number;
67
68   //! Information about this screen
69   const otk::ScreenInfo *_info;
70   
71   //! The Image Control used for rendering on the screen
72   otk::BImageControl *_image_control;
73
74   //! The style with which to render on the screen
75   otk::Style _style;
76
77   //! The screen's root window
78   OBRootWindow _root;
79   
80   //! Is the root colormap currently installed?
81   bool _root_cmap_installed;
82
83   //! Area usable for placement etc (total - struts)
84   otk::Rect _area;
85
86   //! Areas of the screen reserved by applications
87   StrutList _struts;
88
89   //!  An offscreen window which gets focus when nothing else has it
90   Window _focuswindow;
91
92   //! A list of all managed clients on the screen, in their stacking order
93   ClientList _stacking;
94
95   //! Calculate the OBScreen::_area member
96   void calcArea();
97   //! Set the client list on the root window
98   /*!
99     Sets the _NET_CLIENT_LIST root window property.<br>
100     Also calls OBScreen::updateStackingList.
101   */
102   void setClientList();
103   //! Set the client stacking list on the root window
104   /*!
105     Set the _NET_CLIENT_LIST_STACKING root window property.
106   */
107   void setStackingList();
108   //! Set the work area hint on the root window
109   /*!
110     Set the _NET_WORKAREA root window property.
111   */
112   void setWorkArea();
113
114 public:
115 #ifndef SWIG
116   //! Constructs a new OBScreen object
117   OBScreen(int screen);
118   //! Destroys the OBScreen object
119   virtual ~OBScreen();
120 #endif
121
122   //! Returns if the screen was successfully managed
123   /*!
124     If this is false, then the screen should be deleted and should NOT be
125     used.
126   */
127   inline bool managed() const { return _managed; }
128   //! Returns the Image Control used for rendering on the screen
129   inline otk::BImageControl *imageControl() { return _image_control; }
130   //! Returns the area of the screen not reserved by applications' Struts
131   inline const otk::Rect &area() const { return _area; }
132   //! Returns the style in use on the screen
133   inline const otk::Style *style() const { return &_style; }
134   //!  An offscreen window which gets focus when nothing else has it
135   inline Window focuswindow() const { return _focuswindow; }
136
137   //! Adds a window's strut to the screen's list of reserved spaces
138   void addStrut(otk::Strut *strut);
139   //! Removes a window's strut from the screen's list of reserved spaces
140   void removeStrut(otk::Strut *strut);
141
142   //! Manage any pre-existing windows on the screen
143   void manageExisting();
144   //! Manage a client window
145   /*!
146     This gives the window a frame, reparents it, selects events on it, etc.
147   */
148   void manageWindow(Window window);
149   //! Unmanage a client
150   /*!
151     This removes the window's frame, reparents it to root, unselects events on
152     it, etc.
153   */
154   void unmanageWindow(OBClient *client);
155
156   //! Raises a client window above all others in its stacking layer
157   void raise(OBClient *client);
158
159   //! Lowers a client window below all others in its stacking layer
160   void lower(OBClient *client);
161 };
162
163 }
164
165 #endif// __screen_hh