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