]> icculus.org git repositories - mikachu/openbox.git/blob - src/Screen.h
that segfaulted. oops. added a workaround so setImageDither doesnt reconfig when...
[mikachu/openbox.git] / src / Screen.h
1 // Screen.h for Openbox
2 // Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
3 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a
6 // copy of this software and associated documentation files (the "Software"),
7 // to deal in the Software without restriction, including without limitation
8 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 // and/or sell copies of the Software, and to permit persons to whom the
10 // Software is furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 // DEALINGS IN THE SOFTWARE.
22
23 #ifndef   __Screen_hh
24 #define   __Screen_hh
25
26 #include <X11/Xlib.h>
27 #include <X11/Xresource.h>
28
29 #ifdef    TIME_WITH_SYS_TIME
30 #  include <sys/time.h>
31 #  include <time.h>
32 #else // !TIME_WITH_SYS_TIME
33 #  ifdef    HAVE_SYS_TIME_H
34 #    include <sys/time.h>
35 #  else // !HAVE_SYS_TIME_H
36 #    include <time.h>
37 #  endif // HAVE_SYS_TIME_H
38 #endif // TIME_WITH_SYS_TIME
39
40 #include "BaseDisplay.h"
41 #include "Configmenu.h"
42 #include "Iconmenu.h"
43 #include "LinkedList.h"
44 #include "Netizen.h"
45 #include "Rootmenu.h"
46 #include "Timer.h"
47 #include "Workspace.h"
48 #include "Workspacemenu.h"
49 #include "openbox.h"
50 #ifdef    SLIT
51 #  include "Slit.h"
52 #endif // SLIT
53 #include "Image.h"
54 #include "Resource.h"
55
56 // forward declaration
57 class BScreen;
58
59 struct WindowStyle {
60   BColor f_focus, f_unfocus, l_text_focus, l_text_unfocus, b_pic_focus,
61     b_pic_unfocus;
62   BTexture t_focus, t_unfocus, l_focus, l_unfocus, h_focus, h_unfocus,
63     b_focus, b_unfocus, b_pressed, g_focus, g_unfocus;
64   GC l_text_focus_gc, l_text_unfocus_gc, b_pic_focus_gc, b_pic_unfocus_gc;
65
66   XFontSet fontset;
67   XFontSetExtents *fontset_extents;
68   XFontStruct *font;
69   
70   int justify;
71 };
72
73 struct ToolbarStyle {
74   BColor l_text, w_text, c_text, b_pic;
75   BTexture toolbar, label, window, button, pressed, clock;
76   GC l_text_gc, w_text_gc, c_text_gc, b_pic_gc;
77
78   XFontSet fontset;
79   XFontSetExtents *fontset_extents;
80   XFontStruct *font;
81   
82   int justify;
83 };
84
85 struct MenuStyle {
86   BColor t_text, f_text, h_text, d_text;
87   BTexture title, frame, hilite;
88   GC t_text_gc, f_text_gc, h_text_gc, d_text_gc, hilite_gc;
89
90   XFontSet t_fontset, f_fontset;
91   XFontSetExtents *t_fontset_extents, *f_fontset_extents;
92   XFontStruct *t_font, *f_font;
93
94   int t_justify, f_justify, bullet, bullet_pos;
95 };
96
97
98 class BScreen : public ScreenInfo {
99 private:
100   Bool root_colormap_installed, managed, geom_visible;
101   GC opGC;
102   Pixmap geom_pixmap;
103   Window geom_window;
104
105   Openbox &openbox;
106   Resource &config;
107   BImageControl *image_control;
108   Configmenu *configmenu;
109   Iconmenu *iconmenu;
110   Rootmenu *rootmenu;
111
112   LinkedList<Rootmenu> *rootmenuList;
113   LinkedList<Netizen> *netizenList;
114   LinkedList<OpenboxWindow> *iconList;
115
116 #ifdef    SLIT
117   Slit *slit;
118 #endif // SLIT
119
120   Toolbar *toolbar;
121   Workspace *current_workspace;
122   Workspacemenu *workspacemenu;
123
124   unsigned int geom_w, geom_h;
125   unsigned long event_mask;
126
127   LinkedList<char> *workspaceNames;
128   LinkedList<Workspace> *workspacesList;
129
130   struct resource {
131     WindowStyle wstyle;
132     ToolbarStyle tstyle;
133     MenuStyle mstyle;
134
135     bool sloppy_focus, auto_raise, auto_edge_balance, image_dither, focus_last,
136       ordered_dither, opaque_move, hide_toolbar, full_max, focus_new;
137     BColor border_color;
138     Resource styleconfig;
139
140     int workspaces, placement_policy, edge_snap_threshold, row_direction,
141       col_direction;
142
143     unsigned int handle_width, bevel_width, frame_width, border_width;
144     int zones; // number of zones to be used when alt-resizing a window
145
146 #ifdef    HAVE_STRFTIME
147     char *strftime_format;
148 #else // !HAVE_STRFTIME
149     bool clock24hour;
150     int date_format;
151 #endif // HAVE_STRFTIME
152
153     char *root_command;
154   } resource;
155
156
157 protected:
158   Bool parseMenuFile(FILE *, Rootmenu *);
159
160   void readDatabaseTexture(const char *, const char *, BTexture *,
161                            unsigned long);
162   void readDatabaseColor(const char *, const char *, BColor *, unsigned long);
163
164   void readDatabaseFontSet(const char *, const char *, XFontSet *);
165   XFontSet createFontSet(const char *);
166   void readDatabaseFont(const char *, const char *, XFontStruct **);
167
168   void InitMenu();
169   void LoadStyle();
170
171
172 public:
173   BScreen(Openbox &, int, Resource &);
174   ~BScreen();
175
176   inline const Bool &isScreenManaged() const { return managed; }
177   inline const GC &getOpGC() const { return opGC; }
178
179   inline Openbox &getOpenbox() { return openbox; }
180   inline BColor *getBorderColor() { return &resource.border_color; }
181   inline BImageControl *getImageControl() { return image_control; }
182   inline Rootmenu *getRootmenu() { return rootmenu; }
183
184 #ifdef   SLIT
185   inline Slit *getSlit() { return slit; }
186 #endif // SLIT
187
188   inline Toolbar *getToolbar() { return toolbar; }
189
190   inline Workspace *getWorkspace(int w) { return workspacesList->find(w); }
191   inline Workspace *getCurrentWorkspace() { return current_workspace; }
192
193   inline Workspacemenu *getWorkspacemenu() { return workspacemenu; }
194   
195   inline void iconUpdate() { iconmenu->update(); }
196
197   inline const unsigned int &getHandleWidth() const
198   { return resource.handle_width; }
199   inline const unsigned int &getBevelWidth() const
200   { return resource.bevel_width; }
201   inline const unsigned int &getFrameWidth() const
202   { return resource.frame_width; }
203   inline const unsigned int &getBorderWidth() const
204   { return resource.border_width; }
205
206   inline const int getCurrentWorkspaceID()
207   { return current_workspace->getWorkspaceID(); }
208   inline const int getWorkspaceCount() { return workspacesList->count(); }
209   inline const int getIconCount() { return iconList->count(); }
210
211   inline const Bool &isRootColormapInstalled() const
212     { return root_colormap_installed; }
213   inline void setRootColormapInstalled(Bool r) { root_colormap_installed = r; }
214   
215   inline bool sloppyFocus() const { return resource.sloppy_focus; }
216   void setSloppyFocus(bool s);
217   
218   inline bool autoRaise() const { return resource.auto_raise; }
219   void setAutoRaise(bool a);
220   
221   inline bool imageDither() const { return resource.image_dither; }
222   void setImageDither(bool d, bool reconfig = true);
223   
224   inline bool orderedDither() const { return resource.ordered_dither; }
225   
226   inline bool opaqueMove() const { return resource.opaque_move; }
227   void setOpaqueMove(bool o);
228   
229   inline bool fullMax() const { return resource.full_max; }
230   void setFullMax(bool f);
231   
232   inline bool focusNew() const { return resource.focus_new; }
233   void setFocusNew(bool f);
234   
235   inline bool focusLast() const { return resource.focus_last; }
236   void setFocusLast(bool f);
237   
238   inline int getWindowZones() const { return resource.zones; }
239   void setWindowZones(int z);
240   
241   inline int workspaceCount() const { return resource.workspaces; }
242   void setWorkspaceCount(int w);
243
244   inline int placementPolicy() const { return resource.placement_policy; }
245   void setPlacementPolicy(int p);
246
247   inline int edgeSnapThreshold() const { return resource.edge_snap_threshold; }
248   void setEdgeSnapThreshold(int t);
249   
250   inline int rowPlacementDirection() const { return resource.row_direction; }
251   void setRowPlacementDirection(int d);
252   
253   inline int colPlacementDirection() const { return resource.col_direction; }
254   void setColPlacementDirection(int d);
255   
256   inline char *rootCommand() const { return resource.root_command; }
257   inline void setRootCommand(const char *cmd);
258   
259 #ifdef    HAVE_STRFTIME
260   inline char *strftimeFormat() { return resource.strftime_format; }
261   void setStrftimeFormat(const char *);
262 #else // !HAVE_STRFTIME
263   inline int dateFormat() { return resource.date_format; }
264   void setDateFormat(int f);
265   inline bool clock24Hour() { return resource.clock24hour; }
266   void setClock24Hour(Bool c);
267 #endif // HAVE_STRFTIME
268
269   inline bool hideToolbar() const { return resource.hide_toolbar; }
270   void setHideToolbar(bool);
271
272   inline WindowStyle *getWindowStyle() { return &resource.wstyle; }
273   inline MenuStyle *getMenuStyle() { return &resource.mstyle; }
274   inline ToolbarStyle *getToolbarStyle() { return &resource.tstyle; }
275
276   OpenboxWindow *getIcon(int);
277
278   int addWorkspace();
279   int removeLastWorkspace();
280
281   void removeWorkspaceNames();
282   void addWorkspaceName(const char *);
283   void saveWorkspaceNames();
284   void addNetizen(Netizen *);
285   void removeNetizen(Window);
286   void addIcon(OpenboxWindow *);
287   void removeIcon(OpenboxWindow *);
288   char* getNameOfWorkspace(int);
289   void changeWorkspaceID(int);
290   void raiseWindows(Window *, int);
291   void reassociateWindow(OpenboxWindow *, int, Bool);
292   void prevFocus();
293   void nextFocus();
294   void raiseFocus();
295   void reconfigure();
296   void load();
297   void save();
298   void rereadMenu();
299   void shutdown();
300   void showPosition(int, int);
301   void showGeometry(unsigned int, unsigned int);
302   void hideGeometry();
303   void updateNetizenCurrentWorkspace();
304   void updateNetizenWorkspaceCount();
305   void updateNetizenWindowFocus();
306   void updateNetizenWindowAdd(Window, unsigned long);
307   void updateNetizenWindowDel(Window);
308   void updateNetizenConfigNotify(XEvent *);
309   void updateNetizenWindowRaise(Window);
310   void updateNetizenWindowLower(Window);
311
312   enum { RowSmartPlacement = 1, ColSmartPlacement, CascadePlacement,
313          BestFitPlacement, LeftRight, RightLeft, TopBottom, BottomTop };
314   enum { LeftJustify = 1, RightJustify, CenterJustify };
315   enum { RoundBullet = 1, TriangleBullet, SquareBullet, NoBullet };
316   enum { Restart = 1, RestartOther, Exit, Shutdown, Execute, Reconfigure,
317          WindowShade, WindowIconify, WindowMaximize, WindowClose, WindowRaise,
318          WindowLower, WindowStick, WindowKill, SetStyle };
319 };
320
321
322 #endif // __Screen_hh