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)
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:
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
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.
27 #include <X11/Xresource.h>
29 #ifdef TIME_WITH_SYS_TIME
30 # include <sys/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
37 # endif // HAVE_SYS_TIME_H
38 #endif // TIME_WITH_SYS_TIME
40 #include "BaseDisplay.h"
41 #include "Configmenu.h"
46 #include "Workspace.h"
47 #include "Workspacemenu.h"
58 typedef std::list<Rootmenu *> menuList;
59 typedef std::list<Netizen *> netList;
60 typedef std::vector<Workspace *> wkspList;
61 typedef std::vector<std::string> wkspNameList;
63 // forward declaration
67 BColor f_focus, f_unfocus, l_text_focus, l_text_unfocus, b_pic_focus,
69 BTexture t_focus, t_unfocus, l_focus, l_unfocus, h_focus, h_unfocus,
70 b_focus, b_unfocus, b_pressed, g_focus, g_unfocus;
71 GC l_text_focus_gc, l_text_unfocus_gc, b_pic_focus_gc, b_pic_unfocus_gc;
74 XFontSetExtents *fontset_extents;
81 BColor l_text, w_text, c_text, b_pic;
82 BTexture toolbar, label, window, button, pressed, clock;
83 GC l_text_gc, w_text_gc, c_text_gc, b_pic_gc;
86 XFontSetExtents *fontset_extents;
93 BColor t_text, f_text, h_text, d_text;
94 BTexture title, frame, hilite;
95 GC t_text_gc, f_text_gc, h_text_gc, d_text_gc, hilite_gc;
97 XFontSet t_fontset, f_fontset;
98 XFontSetExtents *t_fontset_extents, *f_fontset_extents;
99 XFontStruct *t_font, *f_font;
101 int t_justify, f_justify, bullet, bullet_pos;
105 class BScreen : public ScreenInfo {
107 Bool root_colormap_installed, managed, geom_visible;
114 BImageControl *image_control;
115 Configmenu *configmenu;
119 menuList rootmenuList;
121 winList iconList; // winList is declared in Workspace.h
128 Workspace *current_workspace;
129 Workspacemenu *workspacemenu;
131 unsigned int geom_w, geom_h;
132 unsigned long event_mask;
134 wkspNameList workspaceNames;
135 wkspList workspacesList;
142 bool sloppy_focus, auto_raise, auto_edge_balance, focus_last,
143 ordered_dither, opaque_move, hide_toolbar, full_max, focus_new;
145 Resource styleconfig;
147 int workspaces, placement_policy, edge_snap_threshold, row_direction,
150 unsigned int handle_width, bevel_width, frame_width, border_width;
151 int zones; // number of zones to be used when alt-resizing a window
154 char *strftime_format;
155 #else // !HAVE_STRFTIME
158 #endif // HAVE_STRFTIME
165 Bool parseMenuFile(FILE *, Rootmenu *);
167 void readDatabaseTexture(const char *, const char *, BTexture *,
169 void readDatabaseColor(const char *, const char *, BColor *, unsigned long);
171 void readDatabaseFontSet(const char *, const char *, XFontSet *);
172 XFontSet createFontSet(const char *);
173 void readDatabaseFont(const char *, const char *, XFontStruct **);
180 BScreen(Openbox &, int, Resource &);
183 inline const Bool &isScreenManaged() const { return managed; }
184 inline const GC &getOpGC() const { return opGC; }
186 inline Openbox &getOpenbox() { return openbox; }
187 inline BColor *getBorderColor() { return &resource.border_color; }
188 inline BImageControl *getImageControl() { return image_control; }
189 inline Rootmenu *getRootmenu() { return rootmenu; }
192 inline Slit *getSlit() { return slit; }
195 inline Toolbar *getToolbar() { return toolbar; }
197 Rect availableArea() const;
199 inline Workspace *getWorkspace(int w) {
200 ASSERT(w < workspacesList.size());
201 return workspacesList[w];
203 inline Workspace *getCurrentWorkspace() { return current_workspace; }
205 inline Workspacemenu *getWorkspacemenu() { return workspacemenu; }
207 inline void iconUpdate() { iconmenu->update(); }
209 inline const unsigned int &getHandleWidth() const
210 { return resource.handle_width; }
211 inline const unsigned int &getBevelWidth() const
212 { return resource.bevel_width; }
213 inline const unsigned int &getFrameWidth() const
214 { return resource.frame_width; }
215 inline const unsigned int &getBorderWidth() const
216 { return resource.border_width; }
218 inline const int getCurrentWorkspaceID()
219 { return current_workspace->getWorkspaceID(); }
220 inline const int getWorkspaceCount() { return workspacesList.size(); }
221 inline const int getIconCount() { return iconList.size(); }
223 inline const Bool &isRootColormapInstalled() const
224 { return root_colormap_installed; }
225 inline void setRootColormapInstalled(Bool r) { root_colormap_installed = r; }
227 inline bool sloppyFocus() const { return resource.sloppy_focus; }
228 void setSloppyFocus(bool s);
230 inline bool autoRaise() const { return resource.auto_raise; }
231 void setAutoRaise(bool a);
233 inline bool imageDither() const { return image_control->doDither(); }
234 void setImageDither(bool d, bool reconfig = true);
236 inline bool orderedDither() const { return resource.ordered_dither; }
238 inline bool opaqueMove() const { return resource.opaque_move; }
239 void setOpaqueMove(bool o);
241 inline bool fullMax() const { return resource.full_max; }
242 void setFullMax(bool f);
244 inline bool focusNew() const { return resource.focus_new; }
245 void setFocusNew(bool f);
247 inline bool focusLast() const { return resource.focus_last; }
248 void setFocusLast(bool f);
250 inline int getWindowZones() const { return resource.zones; }
251 void setWindowZones(int z);
253 inline int workspaceCount() const { return resource.workspaces; }
254 void setWorkspaceCount(int w);
256 inline int placementPolicy() const { return resource.placement_policy; }
257 void setPlacementPolicy(int p);
259 inline int edgeSnapThreshold() const { return resource.edge_snap_threshold; }
260 void setEdgeSnapThreshold(int t);
262 inline int rowPlacementDirection() const { return resource.row_direction; }
263 void setRowPlacementDirection(int d);
265 inline int colPlacementDirection() const { return resource.col_direction; }
266 void setColPlacementDirection(int d);
268 inline char *rootCommand() const { return resource.root_command; }
269 inline void setRootCommand(const char *cmd);
272 inline char *strftimeFormat() { return resource.strftime_format; }
273 void setStrftimeFormat(const char *);
274 #else // !HAVE_STRFTIME
275 inline int dateFormat() { return resource.date_format; }
276 void setDateFormat(int f);
277 inline bool clock24Hour() { return resource.clock24hour; }
278 void setClock24Hour(Bool c);
279 #endif // HAVE_STRFTIME
281 inline bool hideToolbar() const { return resource.hide_toolbar; }
282 void setHideToolbar(bool);
284 inline WindowStyle *getWindowStyle() { return &resource.wstyle; }
285 inline MenuStyle *getMenuStyle() { return &resource.mstyle; }
286 inline ToolbarStyle *getToolbarStyle() { return &resource.tstyle; }
288 OpenboxWindow *getIcon(int);
291 int removeLastWorkspace();
293 void removeWorkspaceNames();
294 void addWorkspaceName(const char *);
295 void saveWorkspaceNames();
296 void addNetizen(Netizen *);
297 void removeNetizen(Window);
298 void addIcon(OpenboxWindow *);
299 void removeIcon(OpenboxWindow *);
300 const char *getNameOfWorkspace(int);
301 void changeWorkspaceID(int);
302 void raiseWindows(Window *, int);
303 void reassociateWindow(OpenboxWindow *, int, Bool);
312 void showPosition(int, int);
313 void showGeometry(unsigned int, unsigned int);
315 void updateNetizenCurrentWorkspace();
316 void updateNetizenWorkspaceCount();
317 void updateNetizenWindowFocus();
318 void updateNetizenWindowAdd(Window, unsigned long);
319 void updateNetizenWindowDel(Window);
320 void updateNetizenConfigNotify(XEvent *);
321 void updateNetizenWindowRaise(Window);
322 void updateNetizenWindowLower(Window);
324 enum { RowSmartPlacement = 1, ColSmartPlacement, CascadePlacement,
325 BestFitPlacement, UnderMousePlacement, ClickMousePlacement,
326 LeftRight, RightLeft, TopBottom, BottomTop };
327 enum { LeftJustify = 1, RightJustify, CenterJustify };
328 enum { RoundBullet = 1, TriangleBullet, SquareBullet, NoBullet };
329 enum { Restart = 1, RestartOther, Exit, Shutdown, Execute, Reconfigure,
330 WindowShade, WindowIconify, WindowMaximize, WindowClose, WindowRaise,
331 WindowLower, WindowStick, WindowKill, SetStyle };
335 #endif // __Screen_hh