]> icculus.org git repositories - mikachu/openbox.git/blob - src/screen.hh
add doxygen to the project. 'make doc' builds the doxygen stuff. you need doxygen...
[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 extern "C" {
6 #include <X11/Xlib.h>
7
8 #ifdef    TIME_WITH_SYS_TIME
9 #  include <sys/time.h>
10 #  include <time.h>
11 #else // !TIME_WITH_SYS_TIME
12 #  ifdef    HAVE_SYS_TIME_H
13 #    include <sys/time.h>
14 #  else // !HAVE_SYS_TIME_H
15 #    include <time.h>
16 #  endif // HAVE_SYS_TIME_H
17 #endif // TIME_WITH_SYS_TIME
18 }
19
20 #include <list>
21 #include <vector>
22
23 #include "otk/color.hh"
24 #include "otk/font.hh"
25 #include "otk/texture.hh"
26 #include "otk/image.hh"
27 #include "timer.hh"
28 #include "workspace.hh"
29 #include "blackbox.hh"
30
31 namespace ob {
32
33 class XAtom;
34 struct Strut;
35
36 enum TextJustify { LeftJustify = 1, RightJustify, CenterJustify };
37
38 struct PixmapMask {
39   Pixmap mask;
40   unsigned int w, h;
41 };
42
43 struct WindowStyle {
44   otk::BColor l_text_focus, l_text_unfocus, b_pic_focus,
45     b_pic_unfocus;
46   otk::BTexture f_focus, f_unfocus, t_focus, t_unfocus, l_focus, l_unfocus,
47     h_focus, h_unfocus, b_focus, b_unfocus, b_pressed, b_pressed_focus,
48     b_pressed_unfocus, g_focus, g_unfocus;
49
50   PixmapMask close_button, max_button, icon_button, stick_button;
51   otk::BFont *font;
52
53   TextJustify justify;
54
55   void doJustify(const std::string &text, int &start_pos,
56                  unsigned int max_length, unsigned int modifier) const;
57 };
58
59 class BScreen : public otk::ScreenInfo {
60 private:
61   bool root_colormap_installed, managed, geom_visible;
62   GC opGC;
63   Pixmap geom_pixmap;
64   Window geom_window;
65
66   Blackbox *blackbox;
67   otk::BImageControl *image_control;
68   Configuration *config;
69   XAtom *xatom;
70
71   BlackboxWindowList iconList, windowList;
72
73   typedef std::vector<Window> WindowList;
74   WindowList specialWindowList, desktopWindowList, systrayWindowList;
75
76   Workspace *current_workspace;
77
78   unsigned int geom_w, geom_h;
79   unsigned long event_mask;
80
81   otk::Rect usableArea;
82 #ifdef    XINERAMA
83   RectList xineramaUsableArea;
84 #endif // XINERAMA
85
86   typedef std::list<Strut*> StrutList;
87   StrutList strutList;
88   typedef std::vector<Workspace*> WorkspaceList;
89   WorkspaceList workspacesList;
90
91   struct screen_resource {
92     WindowStyle wstyle;
93
94     bool sloppy_focus, auto_raise, auto_edge_balance, ordered_dither,
95       opaque_move, full_max, focus_new, focus_last, click_raise,
96       allow_scroll_lock, window_corner_snap, aa_fonts,
97       ignore_shaded, ignore_maximized, workspace_warping, shadow_fonts;
98
99     int snap_to_windows, snap_to_edges;
100     unsigned int snap_offset;
101
102     otk::BColor border_color;
103
104     unsigned int workspaces;
105     int placement_policy,
106       snap_threshold, row_direction, col_direction, root_scroll,
107       resistance_size;
108
109     unsigned int handle_width, bevel_width, frame_width, border_width,
110       resize_zones;
111
112     std::string strftime_format;
113
114   } resource;
115   std::string screenstr;
116
117   BScreen(const BScreen&);
118   BScreen& operator=(const BScreen&);
119
120   void readDatabaseMask(const std::string &rname,
121                         PixmapMask &pixmapMask,
122                         const Configuration &style);
123   
124   otk::BTexture readDatabaseTexture(const std::string &rname,
125                                const std::string &default_color,
126                                const Configuration &style, 
127                                bool allowNoTexture = false);
128   otk::BColor readDatabaseColor(const std::string &rname,
129                            const std::string &default_color,
130                            const Configuration &style);
131   otk::BFont *readDatabaseFont(const std::string &rbasename,
132                                const Configuration &style);
133
134   void LoadStyle(void);
135
136   void updateWorkArea(void);
137
138 public:
139   // XXX: temporary
140   void updateNetizenWorkspaceCount();
141   void updateNetizenWindowFocus();
142   
143
144   enum { WindowNoSnap = 0, WindowSnap, WindowResistance };
145   enum { RowSmartPlacement = 1, ColSmartPlacement, CascadePlacement,
146          UnderMousePlacement, ClickMousePlacement, LeftRight, RightLeft,
147          TopBottom, BottomTop, IgnoreShaded, IgnoreMaximized };
148   enum { RoundBullet = 1, TriangleBullet, SquareBullet, NoBullet };
149   enum { Restart = 1, RestartOther, Exit, Shutdown, Execute, Reconfigure,
150          WindowShade, WindowIconify, WindowMaximize, WindowClose, WindowRaise,
151          WindowLower, WindowStick, WindowKill, SetStyle };
152   enum FocusModel { SloppyFocus, ClickToFocus };
153   enum RootScrollDirection { NoScroll = 0, NormalScroll, ReverseScroll };
154
155   BScreen(Blackbox *bb, unsigned int scrn);
156   ~BScreen(void);
157
158   inline bool isSloppyFocus(void) const { return resource.sloppy_focus; }
159   inline bool isRootColormapInstalled(void) const
160   { return root_colormap_installed; }
161   inline bool doAutoRaise(void) const { return resource.auto_raise; }
162   inline bool doClickRaise(void) const { return resource.click_raise; }
163   inline bool isScreenManaged(void) const { return managed; }
164   inline bool doShadowFonts(void) const { return resource.shadow_fonts; }
165   inline bool doAAFonts(void) const { return resource.aa_fonts; }
166   inline bool doImageDither(void) const { return image_control->doDither(); }
167   inline bool doOrderedDither(void) const { return resource.ordered_dither; }
168   inline bool doOpaqueMove(void) const { return resource.opaque_move; }
169   inline bool doFullMax(void) const { return resource.full_max; }
170   inline bool doFocusNew(void) const { return resource.focus_new; }
171   inline bool doFocusLast(void) const { return resource.focus_last; }
172   inline int getWindowToWindowSnap(void) const
173     { return resource.snap_to_windows; }
174   inline int getWindowToEdgeSnap(void) const
175     { return resource.snap_to_edges; }
176   inline bool getWindowCornerSnap(void) const
177     { return resource.window_corner_snap; }
178   inline bool allowScrollLock(void) const { return resource.allow_scroll_lock; }
179   inline bool doWorkspaceWarping(void) const
180     { return resource.workspace_warping; }
181   inline int rootScrollDirection(void) const { return resource.root_scroll; }
182
183   inline const GC &getOpGC(void) const { return opGC; }
184
185   inline Blackbox *getBlackbox(void) { return blackbox; }
186   inline otk::BColor *getBorderColor(void) { return &resource.border_color; }
187   inline otk::BImageControl *getImageControl(void) { return image_control; }
188
189   Workspace *getWorkspace(unsigned int index) const;
190
191   inline Workspace *getCurrentWorkspace(void) { return current_workspace; }
192
193   inline unsigned int getHandleWidth(void) const
194   { return resource.handle_width; }
195   inline unsigned int getBevelWidth(void) const
196   { return resource.bevel_width; }
197   inline unsigned int getFrameWidth(void) const
198   { return resource.frame_width; }
199   inline unsigned int getBorderWidth(void) const
200   { return resource.border_width; }
201   inline unsigned int getResizeZones(void) const
202   { return resource.resize_zones; }
203   inline bool getPlaceIgnoreShaded(void) const
204   { return resource.ignore_shaded; }
205   inline bool getPlaceIgnoreMaximized(void) const
206   { return resource.ignore_maximized; }
207
208   inline unsigned int getCurrentWorkspaceID(void) const
209   { return current_workspace->getID(); }
210   inline unsigned int getWorkspaceCount(void) const
211   { return workspacesList.size(); }
212   inline unsigned int getIconCount(void) const { return iconList.size(); }
213   inline unsigned int getNumberOfWorkspaces(void) const
214   { return resource.workspaces; }
215   inline int getPlacementPolicy(void) const
216   { return resource.placement_policy; }
217   inline int getSnapOffset(void) const
218   { return resource.snap_offset; }
219   inline int getSnapThreshold(void) const
220   { return resource.snap_threshold; }
221   inline int getResistanceSize(void) const
222   { return resource.resistance_size; }
223   inline int getRowPlacementDirection(void) const
224   { return resource.row_direction; }
225   inline int getColPlacementDirection(void) const
226   { return resource.col_direction; }
227
228   void changeWorkspaceCount(unsigned int new_count);
229   
230   inline void setRootColormapInstalled(bool r) { root_colormap_installed = r; }
231   void saveSloppyFocus(bool s);
232   void saveAutoRaise(bool a);
233   void saveClickRaise(bool c);
234   void saveWorkspaces(unsigned int w);
235   void savePlacementPolicy(int p);
236   void saveRowPlacementDirection(int d);
237   void saveColPlacementDirection(int d);
238   void saveSnapThreshold(int t);
239   void saveSnapOffset(int o);
240   void saveResistanceSize(int s);
241   void saveImageDither(bool d);
242   void saveShadowFonts(bool f);
243   void saveAAFonts(bool f);
244   void saveOpaqueMove(bool o);
245   void saveFullMax(bool f);
246   void saveFocusNew(bool f);
247   void saveFocusLast(bool f);
248   void saveWindowToEdgeSnap(int s);
249   void saveWindowToWindowSnap(int s);
250   void saveWindowCornerSnap(bool s);
251   void saveResizeZones(unsigned int z);
252   void savePlaceIgnoreShaded(bool i);
253   void savePlaceIgnoreMaximized(bool i);
254   void saveAllowScrollLock(bool a);
255   void saveWorkspaceWarping(bool w);
256   void saveRootScrollDirection(int d);
257
258   inline const char *getStrftimeFormat(void)
259   { return resource.strftime_format.c_str(); }
260   void saveStrftimeFormat(const std::string& format);
261
262   inline WindowStyle *getWindowStyle(void) { return &resource.wstyle; }
263
264   BlackboxWindow *getIcon(unsigned int index);
265
266   // allAvailableAreas should be used whenever possible instead of this function
267   // as then Xinerama will work correctly.
268   const otk::Rect& availableArea(void) const;
269 #ifdef    XINERAMA
270   const RectList& allAvailableAreas(void) const;
271 #endif // XINERAMA
272   void updateAvailableArea(void);
273   void addStrut(Strut *strut);
274   void removeStrut(Strut *strut);
275
276   unsigned int addWorkspace(void);
277   unsigned int removeLastWorkspace(void);
278   void changeWorkspaceID(unsigned int id);
279   void saveWorkspaceNames(void);
280
281   void addSystrayWindow(Window window);
282   void removeSystrayWindow(Window window);
283
284   void addIcon(BlackboxWindow *w);
285   void removeIcon(BlackboxWindow *w);
286
287   void updateClientList(void);
288   void updateStackingList(void);
289   void manageWindow(Window w);
290   void unmanageWindow(BlackboxWindow *w, bool remap);
291   void raiseWindows(Window *workspace_stack, unsigned int num);
292   void lowerWindows(Window *workspace_stack, unsigned int num);
293   void reassociateWindow(BlackboxWindow *w, unsigned int wkspc_id,
294                          bool ignore_sticky);
295   void propagateWindowName(const BlackboxWindow *bw);
296   void prevFocus(void) const;
297   void nextFocus(void) const;
298   void raiseFocus(void) const;
299   void load_rc(void);
300   void save_rc(void);
301   void reconfigure(void);
302   void toggleFocusModel(FocusModel model);
303   void shutdown(void);
304   void showPosition(int x, int y);
305   void showGeometry(unsigned int gx, unsigned int gy);
306   void hideGeometry(void);
307
308   void buttonPressEvent(const XButtonEvent *xbutton);
309   void propertyNotifyEvent(const XPropertyEvent *pe);
310 };
311
312 }
313
314 #endif // __Screen_hh