]> Dogcows Code - chaz/openbox/blob - src/blackbox.hh
xinerama support for window placement
[chaz/openbox] / src / blackbox.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 // blackbox.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 __blackbox_hh
25 #define __blackbox_hh
26
27 extern "C" {
28 #include <X11/Xlib.h>
29
30 #ifdef HAVE_STDIO_H
31 # include <stdio.h>
32 #endif // HAVE_STDIO_H
33
34 #ifdef TIME_WITH_SYS_TIME
35 # include <sys/time.h>
36 # include <time.h>
37 #else // !TIME_WITH_SYS_TIME
38 # ifdef HAVE_SYS_TIME_H
39 # include <sys/time.h>
40 # else // !HAVE_SYS_TIME_H
41 # include <time.h>
42 # endif // HAVE_SYS_TIME_H
43 #endif // TIME_WITH_SYS_TIME
44 }
45
46 #include <list>
47 #include <map>
48 #include <string>
49
50 #include "i18n.hh"
51 #include "BaseDisplay.hh"
52 #include "Configuration.hh"
53 #include "Timer.hh"
54 #include "XAtom.hh"
55
56 #define AttribShaded (1l << 0)
57 #define AttribMaxHoriz (1l << 1)
58 #define AttribMaxVert (1l << 2)
59 #define AttribOmnipresent (1l << 3)
60 #define AttribWorkspace (1l << 4)
61 #define AttribStack (1l << 5)
62 #define AttribDecoration (1l << 6)
63
64 #define StackTop (0)
65 #define StackNormal (1)
66 #define StackBottom (2)
67
68 #define DecorNone (0)
69 #define DecorNormal (1)
70 #define DecorTiny (2)
71 #define DecorTool (3)
72
73 struct BlackboxHints {
74 unsigned long flags, attrib, workspace, stack, decoration;
75 };
76
77 struct BlackboxAttributes {
78 unsigned long flags, attrib, workspace, stack, decoration;
79 int premax_x, premax_y;
80 unsigned int premax_w, premax_h;
81 };
82
83 #define PropBlackboxHintsElements (5)
84 #define PropBlackboxAttributesElements (9)
85
86
87 //forward declaration
88 class BScreen;
89 class Blackbox;
90 class BlackboxWindow;
91 class BWindowGroup;
92 class Basemenu;
93 class Toolbar;
94 class Slit;
95
96 extern I18n i18n;
97
98 class Blackbox : public BaseDisplay, public TimeoutHandler {
99 private:
100 struct BCursor {
101 Cursor session, move, ll_angle, lr_angle, ul_angle, ur_angle;
102 };
103 BCursor cursor;
104
105 struct MenuTimestamp {
106 std::string filename;
107 time_t timestamp;
108 };
109
110 struct BResource {
111 Time double_click_interval;
112
113 std::string style_file;
114 int colors_per_channel;
115 timeval auto_raise_delay;
116 unsigned long cache_life, cache_max;
117 std::string titlebar_layout;
118
119 #ifdef XINERAMA
120 bool xinerama_placement, xinerama_maximize, xinerama_snap;
121 #endif // XINERAMA
122 } resource;
123
124 typedef std::map<Window, BlackboxWindow*> WindowLookup;
125 typedef WindowLookup::value_type WindowLookupPair;
126 WindowLookup windowSearchList;
127
128 typedef std::map<Window, BScreen*> WindowScreenLookup;
129 typedef WindowScreenLookup::value_type WindowScreenLookupPair;
130 WindowScreenLookup systraySearchList;
131
132 typedef std::map<Window, BWindowGroup*> GroupLookup;
133 typedef GroupLookup::value_type GroupLookupPair;
134 GroupLookup groupSearchList;
135
136 typedef std::map<Window, Basemenu*> MenuLookup;
137 typedef MenuLookup::value_type MenuLookupPair;
138 MenuLookup menuSearchList;
139
140 typedef std::map<Window, Toolbar*> ToolbarLookup;
141 typedef ToolbarLookup::value_type ToolbarLookupPair;
142 ToolbarLookup toolbarSearchList;
143
144 typedef std::map<Window, Slit*> SlitLookup;
145 typedef SlitLookup::value_type SlitLookupPair;
146 SlitLookup slitSearchList;
147
148 typedef std::list<MenuTimestamp*> MenuTimestampList;
149 MenuTimestampList menuTimestamps;
150
151 typedef std::list<BScreen*> ScreenList;
152 ScreenList screenList;
153
154 BScreen *active_screen;
155 BlackboxWindow *focused_window, *changing_window;
156 BTimer *timer;
157 Configuration config;
158 XAtom *xatom;
159
160 bool no_focus, reconfigure_wait, reread_menu_wait;
161 Time last_time;
162 char **argv;
163 std::string menu_file, rc_file;
164
165 Blackbox(const Blackbox&);
166 Blackbox& operator=(const Blackbox&);
167
168 void load_rc(void);
169 void save_rc(void);
170 void real_rereadMenu(void);
171 void real_reconfigure(void);
172
173 virtual void process_event(XEvent *);
174
175
176 public:
177 Blackbox(char **m_argv, char *dpy_name = 0, char *rc = 0, char *menu = 0);
178 virtual ~Blackbox(void);
179
180 Basemenu *searchMenu(Window window);
181 BWindowGroup *searchGroup(Window window);
182 BScreen *searchSystrayWindow(Window window);
183 BlackboxWindow *searchWindow(Window window);
184 BScreen *searchScreen(Window window);
185 Toolbar *searchToolbar(Window);
186 Slit *searchSlit(Window);
187
188 #ifdef XINERAMA
189 inline bool doXineramaPlacement(void) const
190 { return resource.xinerama_placement; }
191 inline bool doXineramaMaximizing(void) const
192 { return resource.xinerama_maximize; }
193 inline bool doXineramaSnapping(void) const
194 { return resource.xinerama_snap; }
195
196 void saveXineramaPlacement(bool x);
197 void saveXineramaMaximizing(bool x);
198 void saveXineramaSnapping(bool x);
199 #endif // XINERAMA
200
201 void saveMenuSearch(Window window, Basemenu *data);
202 void saveSystrayWindowSearch(Window window, BScreen *screen);
203 void saveWindowSearch(Window window, BlackboxWindow *data);
204 void saveGroupSearch(Window window, BWindowGroup *data);
205 void saveToolbarSearch(Window window, Toolbar *data);
206 void saveSlitSearch(Window window, Slit *data);
207 void removeMenuSearch(Window window);
208 void removeSystrayWindowSearch(Window window);
209 void removeWindowSearch(Window window);
210 void removeGroupSearch(Window window);
211 void removeToolbarSearch(Window window);
212 void removeSlitSearch(Window window);
213
214 inline XAtom *getXAtom(void) { return xatom; }
215
216 inline BlackboxWindow *getFocusedWindow(void) { return focused_window; }
217 inline BlackboxWindow *getChangingWindow(void) { return changing_window; }
218
219 inline Configuration *getConfig() { return &config; }
220 inline const Time &getDoubleClickInterval(void) const
221 { return resource.double_click_interval; }
222 inline const Time &getLastTime(void) const { return last_time; }
223
224 inline const char *getStyleFilename(void) const
225 { return resource.style_file.c_str(); }
226 inline const char *getMenuFilename(void) const
227 { return menu_file.c_str(); }
228
229 inline int getColorsPerChannel(void) const
230 { return resource.colors_per_channel; }
231
232 inline std::string getTitlebarLayout(void) const
233 { return resource.titlebar_layout; }
234
235 inline const timeval &getAutoRaiseDelay(void) const
236 { return resource.auto_raise_delay; }
237
238 inline unsigned long getCacheLife(void) const
239 { return resource.cache_life; }
240 inline unsigned long getCacheMax(void) const
241 { return resource.cache_max; }
242
243 inline void setNoFocus(bool f) { no_focus = f; }
244
245 inline Cursor getSessionCursor(void) const
246 { return cursor.session; }
247 inline Cursor getMoveCursor(void) const
248 { return cursor.move; }
249 inline Cursor getLowerLeftAngleCursor(void) const
250 { return cursor.ll_angle; }
251 inline Cursor getLowerRightAngleCursor(void) const
252 { return cursor.lr_angle; }
253 inline Cursor getUpperLeftAngleCursor(void) const
254 { return cursor.ul_angle; }
255 inline Cursor getUpperRightAngleCursor(void) const
256 { return cursor.ur_angle; }
257
258 void setFocusedWindow(BlackboxWindow *win);
259 void setChangingWindow(BlackboxWindow *win);
260 void shutdown(void);
261 void saveStyleFilename(const std::string& filename);
262 void addMenuTimestamp(const std::string& filename);
263 void restart(const char *prog = 0);
264 void reconfigure(void);
265 void rereadMenu(void);
266 void checkMenu(void);
267
268 bool validateWindow(Window window);
269
270 virtual bool handleSignal(int sig);
271
272 virtual void timeout(void);
273
274 #ifndef HAVE_STRFTIME
275 enum { B_AmericanDate = 1, B_EuropeanDate };
276 #endif // HAVE_STRFTIME
277 };
278
279
280 #endif // __blackbox_hh
This page took 0.046874 seconds and 5 git commands to generate.