1
// Screen.hh for Blackbox - an X11 Window manager
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.hh"
41
#include "Configmenu.hh"
42
#include "Iconmenu.hh"
43
#include "LinkedList.hh"
45
#include "Rootmenu.hh"
47
#include "Workspace.hh"
48
#include "Workspacemenu.hh"
49
#include "blackbox.hh"
55
// forward declaration
59
BColor f_focus, f_unfocus, l_text_focus, l_text_unfocus, b_pic_focus,
61
BTexture t_focus, t_unfocus, l_focus, l_unfocus, h_focus, h_unfocus,
62
b_focus, b_unfocus, b_pressed, g_focus, g_unfocus;
63
GC l_text_focus_gc, l_text_unfocus_gc, b_pic_focus_gc, b_pic_unfocus_gc;
66
XFontSetExtents *fontset_extents;
73
BColor l_text, w_text, c_text, b_pic;
74
BTexture toolbar, label, window, button, pressed, clock;
75
GC l_text_gc, w_text_gc, c_text_gc, b_pic_gc;
78
XFontSetExtents *fontset_extents;
85
BColor t_text, f_text, h_text, d_text;
86
BTexture title, frame, hilite;
87
GC t_text_gc, f_text_gc, h_text_gc, d_text_gc, hilite_gc;
89
XFontSet t_fontset, f_fontset;
90
XFontSetExtents *t_fontset_extents, *f_fontset_extents;
91
XFontStruct *t_font, *f_font;
93
int t_justify, f_justify, bullet, bullet_pos;
97
class BScreen : public ScreenInfo {
99
Bool root_colormap_installed, managed, geom_visible;
105
BImageControl *image_control;
106
Configmenu *configmenu;
110
LinkedList<Rootmenu> *rootmenuList;
111
LinkedList<Netizen> *netizenList;
112
LinkedList<BlackboxWindow> *iconList;
119
Workspace *current_workspace;
120
Workspacemenu *workspacemenu;
122
unsigned int geom_w, geom_h;
123
unsigned long event_mask;
125
LinkedList<char> *workspaceNames;
126
LinkedList<Workspace> *workspacesList;
133
Bool toolbar_on_top, toolbar_auto_hide, sloppy_focus, auto_raise,
134
auto_edge_balance, image_dither, ordered_dither, opaque_move, full_max,
135
focus_new, focus_last;
139
int workspaces, toolbar_placement, toolbar_width_percent, placement_policy,
140
edge_snap_threshold, row_direction, col_direction;
143
Bool slit_on_top, slit_auto_hide;
144
int slit_placement, slit_direction;
147
unsigned int handle_width, bevel_width, frame_width, border_width;
150
char *strftime_format;
151
#else // !HAVE_STRFTIME
154
#endif // HAVE_STRFTIME
160
Bool parseMenuFile(FILE *, Rootmenu *);
162
void readDatabaseTexture(char *, char *, BTexture *, unsigned long);
163
void readDatabaseColor(char *, char *, BColor *, unsigned long);
165
void readDatabaseFontSet(char *, char *, XFontSet *);
166
XFontSet createFontSet(char *);
167
void readDatabaseFont(char *, char *, XFontStruct **);
170
void LoadStyle(void);
174
BScreen(Blackbox *, int);
177
inline const Bool &isToolbarOnTop(void) const
178
{ return resource.toolbar_on_top; }
179
inline const Bool &doToolbarAutoHide(void) const
180
{ return resource.toolbar_auto_hide; }
181
inline const Bool &isSloppyFocus(void) const
182
{ return resource.sloppy_focus; }
183
inline const Bool &isRootColormapInstalled(void) const
184
{ return root_colormap_installed; }
185
inline const Bool &doAutoRaise(void) const { return resource.auto_raise; }
186
inline const Bool &isScreenManaged(void) const { return managed; }
187
inline const Bool &doImageDither(void) const
188
{ return resource.image_dither; }
189
inline const Bool &doOrderedDither(void) const
190
{ return resource.ordered_dither; }
191
inline const Bool &doOpaqueMove(void) const { return resource.opaque_move; }
192
inline const Bool &doFullMax(void) const { return resource.full_max; }
193
inline const Bool &doFocusNew(void) const { return resource.focus_new; }
194
inline const Bool &doFocusLast(void) const { return resource.focus_last; }
196
inline const GC &getOpGC() const { return opGC; }
198
inline Blackbox *getBlackbox(void) { return blackbox; }
199
inline BColor *getBorderColor(void) { return &resource.border_color; }
200
inline BImageControl *getImageControl(void) { return image_control; }
201
inline Rootmenu *getRootmenu(void) { return rootmenu; }
204
inline const Bool &isSlitOnTop(void) const { return resource.slit_on_top; }
205
inline const Bool &doSlitAutoHide(void) const
206
{ return resource.slit_auto_hide; }
207
inline Slit *getSlit(void) { return slit; }
208
inline const int &getSlitPlacement(void) const
209
{ return resource.slit_placement; }
210
inline const int &getSlitDirection(void) const
211
{ return resource.slit_direction; }
212
inline void saveSlitPlacement(int p) { resource.slit_placement = p; }
213
inline void saveSlitDirection(int d) { resource.slit_direction = d; }
214
inline void saveSlitOnTop(Bool t) { resource.slit_on_top = t; }
215
inline void saveSlitAutoHide(Bool t) { resource.slit_auto_hide = t; }
218
inline Toolbar *getToolbar(void) { return toolbar; }
220
inline Workspace *getWorkspace(int w) { return workspacesList->find(w); }
221
inline Workspace *getCurrentWorkspace(void) { return current_workspace; }
223
inline Workspacemenu *getWorkspacemenu(void) { return workspacemenu; }
225
inline const unsigned int &getHandleWidth(void) const
226
{ return resource.handle_width; }
227
inline const unsigned int &getBevelWidth(void) const
228
{ return resource.bevel_width; }
229
inline const unsigned int &getFrameWidth(void) const
230
{ return resource.frame_width; }
231
inline const unsigned int &getBorderWidth(void) const
232
{ return resource.border_width; }
234
inline const int getCurrentWorkspaceID()
235
{ return current_workspace->getWorkspaceID(); }
236
inline const int getCount(void) { return workspacesList->count(); }
237
inline const int getIconCount(void) { return iconList->count(); }
238
inline const int &getNumberOfWorkspaces(void) const
239
{ return resource.workspaces; }
240
inline const int &getToolbarPlacement(void) const
241
{ return resource.toolbar_placement; }
242
inline const int &getToolbarWidthPercent(void) const
243
{ return resource.toolbar_width_percent; }
244
inline const int &getPlacementPolicy(void) const
245
{ return resource.placement_policy; }
246
inline const int &getEdgeSnapThreshold(void) const
247
{ return resource.edge_snap_threshold; }
248
inline const int &getRowPlacementDirection(void) const
249
{ return resource.row_direction; }
250
inline const int &getColPlacementDirection(void) const
251
{ return resource.col_direction; }
253
inline void setRootColormapInstalled(Bool r) { root_colormap_installed = r; }
254
inline void saveSloppyFocus(Bool s) { resource.sloppy_focus = s; }
255
inline void saveAutoRaise(Bool a) { resource.auto_raise = a; }
256
inline void saveWorkspaces(int w) { resource.workspaces = w; }
257
inline void saveToolbarOnTop(Bool r) { resource.toolbar_on_top = r; }
258
inline void saveToolbarAutoHide(Bool r) { resource.toolbar_auto_hide = r; }
259
inline void saveToolbarWidthPercent(int w)
260
{ resource.toolbar_width_percent = w; }
261
inline void saveToolbarPlacement(int p) { resource.toolbar_placement = p; }
262
inline void savePlacementPolicy(int p) { resource.placement_policy = p; }
263
inline void saveRowPlacementDirection(int d) { resource.row_direction = d; }
264
inline void saveColPlacementDirection(int d) { resource.col_direction = d; }
265
inline void saveEdgeSnapThreshold(int t)
266
{ resource.edge_snap_threshold = t; }
267
inline void saveImageDither(Bool d) { resource.image_dither = d; }
268
inline void saveOpaqueMove(Bool o) { resource.opaque_move = o; }
269
inline void saveFullMax(Bool f) { resource.full_max = f; }
270
inline void saveFocusNew(Bool f) { resource.focus_new = f; }
271
inline void saveFocusLast(Bool f) { resource.focus_last = f; }
272
inline void iconUpdate(void) { iconmenu->update(); }
275
inline char *getStrftimeFormat(void) { return resource.strftime_format; }
276
void saveStrftimeFormat(char *);
277
#else // !HAVE_STRFTIME
278
inline int getDateFormat(void) { return resource.date_format; }
279
inline void saveDateFormat(int f) { resource.date_format = f; }
280
inline Bool isClock24Hour(void) { return resource.clock24hour; }
281
inline void saveClock24Hour(Bool c) { resource.clock24hour = c; }
282
#endif // HAVE_STRFTIME
284
inline WindowStyle *getWindowStyle(void) { return &resource.wstyle; }
285
inline MenuStyle *getMenuStyle(void) { return &resource.mstyle; }
286
inline ToolbarStyle *getToolbarStyle(void) { return &resource.tstyle; }
288
BlackboxWindow *getIcon(int);
290
int addWorkspace(void);
291
int removeLastWorkspace(void);
293
void removeWorkspaceNames(void);
294
void addWorkspaceName(char *);
295
void addNetizen(Netizen *);
296
void removeNetizen(Window);
297
void addIcon(BlackboxWindow *);
298
void removeIcon(BlackboxWindow *);
299
char* getNameOfWorkspace(int);
300
void changeWorkspaceID(int);
301
void raiseWindows(Window *, int);
302
void reassociateWindow(BlackboxWindow *, int, Bool);
303
void prevFocus(void);
304
void nextFocus(void);
305
void raiseFocus(void);
306
void reconfigure(void);
307
void rereadMenu(void);
309
void showPosition(int, int);
310
void showGeometry(unsigned int, unsigned int);
311
void hideGeometry(void);
313
void updateNetizenCurrentWorkspace(void);
314
void updateNetizenWorkspaceCount(void);
315
void updateNetizenWindowFocus(void);
316
void updateNetizenWindowAdd(Window, unsigned long);
317
void updateNetizenWindowDel(Window);
318
void updateNetizenConfigNotify(XEvent *);
319
void updateNetizenWindowRaise(Window);
320
void updateNetizenWindowLower(Window);
322
enum { RowSmartPlacement = 1, ColSmartPlacement, CascadePlacement, LeftRight,
323
RightLeft, TopBottom, BottomTop };
324
enum { LeftJustify = 1, RightJustify, CenterJustify };
325
enum { RoundBullet = 1, TriangleBullet, SquareBullet, NoBullet };
326
enum { Restart = 1, RestartOther, Exit, Shutdown, Execute, Reconfigure,
327
WindowShade, WindowIconify, WindowMaximize, WindowClose, WindowRaise,
328
WindowLower, WindowStick, WindowKill, SetStyle };
332
#endif // __Screen_hh