]> icculus.org git repositories - dana/openbox.git/blob - src/screen.hh
might not compile... ob uses its own widgets now, which subclass only the base otk...
[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   //! All managed clients on the screen
47   ClientList clients;
48   
49 private:
50   //! Was %Openbox able to manage the screen?
51   bool _managed;
52
53   //! The number of the screen on the X server
54   int _number;
55
56   //! Information about this screen
57   const otk::ScreenInfo *_info;
58   
59   //! The Image Control used for rendering on the screen
60   otk::BImageControl *_image_control;
61
62   //! The style with which to render on the screen
63   otk::Style _style;
64
65   //! The screen's root window
66   OBRootWindow _root;
67   
68   //! Is the root colormap currently installed?
69   bool _root_cmap_installed;
70
71   //! Area usable for placement etc (total - struts)
72   otk::Rect _area;
73
74   //! Areas of the screen reserved by applications
75   StrutList _struts;
76
77   //!  An offscreen window which gets focus when nothing else has it
78   Window _focuswindow;
79   
80
81   //! Calculate the OBScreen::_area member
82   void calcArea();
83   //! Set the client list on the root window
84   /*!
85     Sets the _NET_CLIENT_LIST root window property.<br>
86     Also calls OBScreen::updateStackingList.
87   */
88   void setClientList();
89   //! Set the client stacking list on the root window
90   /*!
91     Set the _NET_CLIENT_LIST_STACKING root window property.
92   */
93   void setStackingList();
94   //! Set the work area hint on the root window
95   /*!
96     Set the _NET_WORKAREA root window property.
97   */
98   void setWorkArea();
99   
100 public:
101 #ifndef SWIG
102   //! Constructs a new OBScreen object
103   OBScreen(int screen, const otk::Configuration &config);
104   //! Destroys the OBScreen object
105   virtual ~OBScreen();
106 #endif
107
108   //! Returns if the screen was successfully managed
109   /*!
110     If this is false, then the screen should be deleted and should NOT be
111     used.
112   */
113   inline bool managed() const { return _managed; }
114   //! Returns the Image Control used for rendering on the screen
115   inline otk::BImageControl *imageControl() { return _image_control; }
116   //! Returns the area of the screen not reserved by applications' Struts
117   inline const otk::Rect &area() const { return _area; }
118   //! Returns the style in use on the screen
119   inline const otk::Style *style() const { return &_style; }
120   //!  An offscreen window which gets focus when nothing else has it
121   inline Window focuswindow() const { return _focuswindow; }
122
123   //! Adds a window's strut to the screen's list of reserved spaces
124   void addStrut(otk::Strut *strut);
125   //! Removes a window's strut from the screen's list of reserved spaces
126   void removeStrut(otk::Strut *strut);
127
128   //! Loads a new style on the screen
129   void loadStyle(const otk::Configuration &config);
130
131   //! Manage any pre-existing windows on the screen
132   void manageExisting();
133   //! Manage a client window
134   /*!
135     This gives the window a frame, reparents it, selects events on it, etc.
136   */
137   void manageWindow(Window window);
138   //! Unmanage a client
139   /*!
140     This removes the window's frame, reparents it to root, unselects events on
141     it, etc.
142   */
143   void unmanageWindow(OBClient *client);
144 };
145
146 }
147
148 #endif// __screen_hh