]> Dogcows Code - chaz/openbox/blob - src/Screen.hh
merge from netwm-merge2 to netwm-merge3. Basically, all of netwm that we intend to...
[chaz/openbox] / src / Screen.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 // Screen.hh for Blackbox - an X11 Window manager
3 // Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
4 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a
7 // copy of this software and associated documentation files (the "Software"),
8 // to deal in the Software without restriction, including without limitation
9 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 // and/or sell copies of the Software, and to permit persons to whom the
11 // Software is furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 // DEALINGS IN THE SOFTWARE.
23
24 #ifndef __Screen_hh
25 #define __Screen_hh
26
27 extern "C" {
28 #include <X11/Xlib.h>
29 #include <X11/Xresource.h>
30
31 #ifdef TIME_WITH_SYS_TIME
32 # include <sys/time.h>
33 # include <time.h>
34 #else // !TIME_WITH_SYS_TIME
35 # ifdef HAVE_SYS_TIME_H
36 # include <sys/time.h>
37 # else // !HAVE_SYS_TIME_H
38 # include <time.h>
39 # endif // HAVE_SYS_TIME_H
40 #endif // TIME_WITH_SYS_TIME
41 }
42
43 #include <list>
44 #include <vector>
45
46 #include "Color.hh"
47 #include "Texture.hh"
48 #include "Image.hh"
49 #include "Configmenu.hh"
50 #include "Iconmenu.hh"
51 #include "Netizen.hh"
52 #include "Rootmenu.hh"
53 #include "Timer.hh"
54 #include "Workspace.hh"
55 #include "Workspacemenu.hh"
56 #include "blackbox.hh"
57 class Slit; // forward reference
58 class XAtom;
59
60 enum TextJustify { LeftJustify = 1, RightJustify, CenterJustify };
61
62 struct WindowStyle {
63 BColor f_focus, f_unfocus, l_text_focus, l_text_unfocus, b_pic_focus,
64 b_pic_unfocus;
65 BTexture t_focus, t_unfocus, l_focus, l_unfocus, h_focus, h_unfocus,
66 b_focus, b_unfocus, b_pressed, g_focus, g_unfocus;
67
68 XFontSet fontset;
69 XFontSetExtents *fontset_extents;
70 XFontStruct *font;
71
72 TextJustify justify;
73
74 int doJustify(const char *text, int &start_pos, unsigned int max_length,
75 unsigned int modifier, bool multibyte) const;
76 };
77
78 struct ToolbarStyle {
79 BColor l_text, w_text, c_text, b_pic;
80 BTexture toolbar, label, window, button, pressed, clock;
81
82 XFontSet fontset;
83 XFontSetExtents *fontset_extents;
84 XFontStruct *font;
85
86 TextJustify justify;
87
88 int doJustify(const char *text, int &start_pos, unsigned int max_length,
89 unsigned int modifier, bool multibyte) const;
90 };
91
92 struct MenuStyle {
93 BColor t_text, f_text, h_text, d_text;
94 BTexture title, frame, hilite;
95
96 XFontSet t_fontset, f_fontset;
97 XFontSetExtents *t_fontset_extents, *f_fontset_extents;
98 XFontStruct *t_font, *f_font;
99
100 TextJustify t_justify, f_justify;
101 int bullet, bullet_pos;
102 };
103
104 struct Strut {
105 unsigned int top, bottom, left, right;
106
107 Strut(void): top(0), bottom(0), left(0), right(0) {}
108 };
109
110 class BScreen : public ScreenInfo {
111 private:
112 bool root_colormap_installed, managed, geom_visible;
113 GC opGC;
114 Pixmap geom_pixmap;
115 Window geom_window;
116
117 Blackbox *blackbox;
118 BImageControl *image_control;
119 Configmenu *configmenu;
120 Iconmenu *iconmenu;
121 Rootmenu *rootmenu;
122 Configuration *config;
123 XAtom *xatom;
124
125 typedef std::list<Rootmenu*> RootmenuList;
126 RootmenuList rootmenuList;
127
128 typedef std::list<Netizen*> NetizenList;
129 NetizenList netizenList;
130 BlackboxWindowList iconList, windowList;
131
132 typedef std::vector<Window> WindowList;
133 WindowList desktopWindowList, systrayWindowList;
134
135 Slit *slit;
136 Toolbar *toolbar;
137 Workspace *current_workspace;
138 Workspacemenu *workspacemenu;
139
140 unsigned int geom_w, geom_h;
141 unsigned long event_mask;
142
143 Rect usableArea;
144
145 typedef std::list<Strut*> StrutList;
146 StrutList strutList;
147 typedef std::vector<std::string> WorkspaceNamesList;
148 WorkspaceNamesList workspaceNames;
149 typedef std::vector<Workspace*> WorkspaceList;
150 WorkspaceList workspacesList;
151
152 struct screen_resource {
153 WindowStyle wstyle;
154 ToolbarStyle tstyle;
155 MenuStyle mstyle;
156
157 bool sloppy_focus, auto_raise, auto_edge_balance, ordered_dither,
158 opaque_move, full_max, focus_new, focus_last, click_raise,
159 hide_toolbar, window_to_window_snap, window_corner_snap;
160 BColor border_color;
161
162 unsigned int workspaces;
163 int toolbar_placement, toolbar_width_percent, placement_policy,
164 edge_snap_threshold, row_direction, col_direction;
165
166 unsigned int handle_width, bevel_width, frame_width, border_width;
167
168 #ifdef HAVE_STRFTIME
169 std::string strftime_format;
170 #else // !HAVE_STRFTIME
171 bool clock24hour;
172 int date_format;
173 #endif // HAVE_STRFTIME
174
175 } resource;
176 std::string screenstr;
177
178 BScreen(const BScreen&);
179 BScreen& operator=(const BScreen&);
180
181 bool parseMenuFile(FILE *file, Rootmenu *menu);
182
183 BTexture readDatabaseTexture(const std::string &rname,
184 const std::string &default_color,
185 Configuration &style);
186 BColor readDatabaseColor(const std::string &rname,
187 const std::string &default_color,
188 Configuration &style);
189 XFontSet readDatabaseFontSet(const std::string &rname, Configuration &style);
190 XFontStruct *readDatabaseFont(const std::string &rname, Configuration &style);
191 XFontSet createFontSet(const std::string &fontname);
192
193 void InitMenu(void);
194 void LoadStyle(void);
195
196 void updateWorkArea(void);
197 public:
198 enum { RowSmartPlacement = 1, ColSmartPlacement, CascadePlacement,
199 UnderMousePlacement, LeftRight, RightLeft, TopBottom, BottomTop };
200 enum { RoundBullet = 1, TriangleBullet, SquareBullet, NoBullet };
201 enum { Restart = 1, RestartOther, Exit, Shutdown, Execute, Reconfigure,
202 WindowShade, WindowIconify, WindowMaximize, WindowClose, WindowRaise,
203 WindowLower, WindowStick, WindowKill, SetStyle };
204 enum FocusModel { SloppyFocus, ClickToFocus };
205
206 BScreen(Blackbox *bb, unsigned int scrn);
207 ~BScreen(void);
208
209 inline bool isSloppyFocus(void) const { return resource.sloppy_focus; }
210 inline bool isRootColormapInstalled(void) const
211 { return root_colormap_installed; }
212 inline bool doAutoRaise(void) const { return resource.auto_raise; }
213 inline bool doClickRaise(void) const { return resource.click_raise; }
214 inline bool isScreenManaged(void) const { return managed; }
215 inline bool doImageDither(void) const { return image_control->doDither(); }
216 inline bool doOrderedDither(void) const { return resource.ordered_dither; }
217 inline bool doOpaqueMove(void) const { return resource.opaque_move; }
218 inline bool doFullMax(void) const { return resource.full_max; }
219 inline bool doFocusNew(void) const { return resource.focus_new; }
220 inline bool doFocusLast(void) const { return resource.focus_last; }
221 inline bool doHideToolbar(void) const { return resource.hide_toolbar; }
222 inline bool getWindowToWindowSnap(void) const
223 { return resource.window_to_window_snap; }
224 inline bool getWindowCornerSnap(void) const
225 { return resource.window_corner_snap; }
226
227 inline const GC &getOpGC(void) const { return opGC; }
228
229 inline Blackbox *getBlackbox(void) { return blackbox; }
230 inline BColor *getBorderColor(void) { return &resource.border_color; }
231 inline BImageControl *getImageControl(void) { return image_control; }
232 inline Rootmenu *getRootmenu(void) { return rootmenu; }
233
234 inline Slit *getSlit(void) { return slit; }
235 inline Toolbar *getToolbar(void) { return toolbar; }
236
237 Workspace *getWorkspace(unsigned int index);
238
239 inline Workspace *getCurrentWorkspace(void) { return current_workspace; }
240
241 inline Workspacemenu *getWorkspacemenu(void) { return workspacemenu; }
242
243 inline unsigned int getHandleWidth(void) const
244 { return resource.handle_width; }
245 inline unsigned int getBevelWidth(void) const
246 { return resource.bevel_width; }
247 inline unsigned int getFrameWidth(void) const
248 { return resource.frame_width; }
249 inline unsigned int getBorderWidth(void) const
250 { return resource.border_width; }
251
252 inline unsigned int getCurrentWorkspaceID(void)
253 { return current_workspace->getID(); }
254 inline unsigned int getWorkspaceCount(void)
255 { return workspacesList.size(); }
256 inline unsigned int getIconCount(void) { return iconList.size(); }
257 inline unsigned int getNumberOfWorkspaces(void) const
258 { return resource.workspaces; }
259 inline int getPlacementPolicy(void) const
260 { return resource.placement_policy; }
261 inline int getEdgeSnapThreshold(void) const
262 { return resource.edge_snap_threshold; }
263 inline int getRowPlacementDirection(void) const
264 { return resource.row_direction; }
265 inline int getColPlacementDirection(void) const
266 { return resource.col_direction; }
267
268 inline void setRootColormapInstalled(bool r) { root_colormap_installed = r; }
269 void saveSloppyFocus(bool s);
270 void saveAutoRaise(bool a);
271 void saveClickRaise(bool c);
272 void saveWorkspaces(unsigned int w);
273 void savePlacementPolicy(int p);
274 void saveRowPlacementDirection(int d);
275 void saveColPlacementDirection(int d);
276 void saveEdgeSnapThreshold(int t);
277 void saveImageDither(bool d);
278 void saveOpaqueMove(bool o);
279 void saveFullMax(bool f);
280 void saveFocusNew(bool f);
281 void saveFocusLast(bool f);
282 void saveHideToolbar(bool h);
283 void saveWindowToWindowSnap(bool s);
284 void saveWindowCornerSnap(bool s);
285 inline void iconUpdate(void) { iconmenu->update(); }
286
287 #ifdef HAVE_STRFTIME
288 inline const char *getStrftimeFormat(void)
289 { return resource.strftime_format.c_str(); }
290 void saveStrftimeFormat(const std::string& format);
291 #else // !HAVE_STRFTIME
292 inline int getDateFormat(void) { return resource.date_format; }
293 inline void saveDateFormat(int f);
294 inline bool isClock24Hour(void) { return resource.clock24hour; }
295 inline void saveClock24Hour(bool c);
296 #endif // HAVE_STRFTIME
297
298 inline WindowStyle *getWindowStyle(void) { return &resource.wstyle; }
299 inline MenuStyle *getMenuStyle(void) { return &resource.mstyle; }
300 inline ToolbarStyle *getToolbarStyle(void) { return &resource.tstyle; }
301
302 BlackboxWindow *getIcon(unsigned int index);
303
304 const Rect& availableArea(void) const;
305 void updateAvailableArea(void);
306 void addStrut(Strut *strut);
307 void removeStrut(Strut *strut);
308
309 unsigned int addWorkspace(void);
310 unsigned int removeLastWorkspace(void);
311 void removeWorkspaceNames(void);
312 void addWorkspaceName(const std::string& name);
313 const std::string getNameOfWorkspace(unsigned int id);
314 void changeWorkspaceID(unsigned int id);
315 void saveWorkspaceNames(void);
316 void updateDesktopNames(void);
317
318 void addNetizen(Netizen *n);
319 void removeNetizen(Window w);
320
321 void addDesktopWindow(Window window);
322 void removeDesktopWindow(Window window);
323
324 void addSystrayWindow(Window window);
325 void removeSystrayWindow(Window window);
326
327 void addIcon(BlackboxWindow *w);
328 void removeIcon(BlackboxWindow *w);
329
330 void updateClientList(void);
331 void updateStackingList(void);
332 void manageWindow(Window w);
333 void unmanageWindow(BlackboxWindow *w, bool remap);
334 void raiseWindows(Window *workspace_stack, unsigned int num);
335 void lowerDesktops(void);
336 void reassociateWindow(BlackboxWindow *w, unsigned int wkspc_id,
337 bool ignore_sticky);
338 void propagateWindowName(const BlackboxWindow *bw);
339 void prevFocus(void);
340 void nextFocus(void);
341 void raiseFocus(void);
342 void load_rc(void);
343 void save_rc(void);
344 void reconfigure(void);
345 void toggleFocusModel(FocusModel model);
346 void updateFocusModel(void);
347 void rereadMenu(void);
348 void shutdown(void);
349 void showPosition(int x, int y);
350 void showGeometry(unsigned int gx, unsigned int gy);
351 void hideGeometry(void);
352
353 void buttonPressEvent(XButtonEvent *xbutton);
354
355 void updateNetizenCurrentWorkspace(void);
356 void updateNetizenWorkspaceCount(void);
357 void updateNetizenWindowFocus(void);
358 void updateNetizenWindowAdd(Window w, unsigned long p);
359 void updateNetizenWindowDel(Window w);
360 void updateNetizenConfigNotify(XEvent *e);
361 void updateNetizenWindowRaise(Window w);
362 void updateNetizenWindowLower(Window w);
363 };
364
365
366 #endif // __Screen_hh
This page took 0.049343 seconds and 5 git commands to generate.