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)
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:
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
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.
32 #endif // HAVE_STDIO_H
34 #ifdef TIME_WITH_SYS_TIME
35 # include <sys/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
42 # endif // HAVE_SYS_TIME_H
43 #endif // TIME_WITH_SYS_TIME
51 #include "BaseDisplay.hh"
52 #include "Configuration.hh"
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)
65 #define StackNormal (1)
66 #define StackBottom (2)
69 #define DecorNormal (1)
73 struct BlackboxHints
{
74 unsigned long flags
, attrib
, workspace
, stack
, decoration
;
77 struct BlackboxAttributes
{
78 unsigned long flags
, attrib
, workspace
, stack
, decoration
;
79 int premax_x
, premax_y
;
80 unsigned int premax_w
, premax_h
;
83 #define PropBlackboxHintsElements (5)
84 #define PropBlackboxAttributesElements (9)
98 class Blackbox
: public BaseDisplay
, public TimeoutHandler
{
101 Cursor session
, move
, ll_angle
, lr_angle
, ul_angle
, ur_angle
;
105 struct MenuTimestamp
{
106 std::string filename
;
111 Time double_click_interval
;
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 unsigned int mod_mask
; // modifier mask used for window-mouse interaction
122 bool xinerama_placement
, xinerama_maximize
, xinerama_snap
;
126 typedef std::map
<Window
, BlackboxWindow
*> WindowLookup
;
127 typedef WindowLookup::value_type WindowLookupPair
;
128 WindowLookup windowSearchList
;
130 typedef std::map
<Window
, BScreen
*> WindowScreenLookup
;
131 typedef WindowScreenLookup::value_type WindowScreenLookupPair
;
132 WindowScreenLookup systraySearchList
;
134 typedef std::map
<Window
, BWindowGroup
*> GroupLookup
;
135 typedef GroupLookup::value_type GroupLookupPair
;
136 GroupLookup groupSearchList
;
138 typedef std::map
<Window
, Basemenu
*> MenuLookup
;
139 typedef MenuLookup::value_type MenuLookupPair
;
140 MenuLookup menuSearchList
;
142 typedef std::map
<Window
, Toolbar
*> ToolbarLookup
;
143 typedef ToolbarLookup::value_type ToolbarLookupPair
;
144 ToolbarLookup toolbarSearchList
;
146 typedef std::map
<Window
, Slit
*> SlitLookup
;
147 typedef SlitLookup::value_type SlitLookupPair
;
148 SlitLookup slitSearchList
;
150 typedef std::list
<MenuTimestamp
*> MenuTimestampList
;
151 MenuTimestampList menuTimestamps
;
153 typedef std::list
<BScreen
*> ScreenList
;
154 ScreenList screenList
;
156 BScreen
*active_screen
;
157 BlackboxWindow
*focused_window
, *changing_window
;
159 Configuration config
;
162 bool no_focus
, reconfigure_wait
, reread_menu_wait
;
165 std::string menu_file
, rc_file
;
167 Blackbox(const Blackbox
&);
168 Blackbox
& operator=(const Blackbox
&);
172 void real_rereadMenu(void);
173 void real_reconfigure(void);
175 virtual void process_event(XEvent
*);
179 Blackbox(char **m_argv
, char *dpy_name
= 0, char *rc
= 0, char *menu
= 0);
180 virtual ~Blackbox(void);
182 Basemenu
*searchMenu(Window window
);
183 BWindowGroup
*searchGroup(Window window
);
184 BScreen
*searchSystrayWindow(Window window
);
185 BlackboxWindow
*searchWindow(Window window
);
186 BScreen
*searchScreen(Window window
);
187 Toolbar
*searchToolbar(Window
);
188 Slit
*searchSlit(Window
);
191 inline bool doXineramaPlacement(void) const
192 { return resource
.xinerama_placement
; }
193 inline bool doXineramaMaximizing(void) const
194 { return resource
.xinerama_maximize
; }
195 inline bool doXineramaSnapping(void) const
196 { return resource
.xinerama_snap
; }
198 void saveXineramaPlacement(bool x
);
199 void saveXineramaMaximizing(bool x
);
200 void saveXineramaSnapping(bool x
);
203 void saveMenuSearch(Window window
, Basemenu
*data
);
204 void saveSystrayWindowSearch(Window window
, BScreen
*screen
);
205 void saveWindowSearch(Window window
, BlackboxWindow
*data
);
206 void saveGroupSearch(Window window
, BWindowGroup
*data
);
207 void saveToolbarSearch(Window window
, Toolbar
*data
);
208 void saveSlitSearch(Window window
, Slit
*data
);
209 void removeMenuSearch(Window window
);
210 void removeSystrayWindowSearch(Window window
);
211 void removeWindowSearch(Window window
);
212 void removeGroupSearch(Window window
);
213 void removeToolbarSearch(Window window
);
214 void removeSlitSearch(Window window
);
216 inline XAtom
*getXAtom(void) { return xatom
; }
218 inline BlackboxWindow
*getFocusedWindow(void) { return focused_window
; }
219 inline BlackboxWindow
*getChangingWindow(void) { return changing_window
; }
221 inline Configuration
*getConfig() { return &config
; }
222 inline const Time
&getDoubleClickInterval(void) const
223 { return resource
.double_click_interval
; }
224 inline const Time
&getLastTime(void) const { return last_time
; }
226 inline const char *getStyleFilename(void) const
227 { return resource
.style_file
.c_str(); }
228 inline const char *getMenuFilename(void) const
229 { return menu_file
.c_str(); }
231 inline int getColorsPerChannel(void) const
232 { return resource
.colors_per_channel
; }
234 inline std::string
getTitlebarLayout(void) const
235 { return resource
.titlebar_layout
; }
237 inline const timeval
&getAutoRaiseDelay(void) const
238 { return resource
.auto_raise_delay
; }
240 inline unsigned long getCacheLife(void) const
241 { return resource
.cache_life
; }
242 inline unsigned long getCacheMax(void) const
243 { return resource
.cache_max
; }
245 inline void setNoFocus(bool f
) { no_focus
= f
; }
247 inline Cursor
getSessionCursor(void) const
248 { return cursor
.session
; }
249 inline Cursor
getMoveCursor(void) const
250 { return cursor
.move
; }
251 inline Cursor
getLowerLeftAngleCursor(void) const
252 { return cursor
.ll_angle
; }
253 inline Cursor
getLowerRightAngleCursor(void) const
254 { return cursor
.lr_angle
; }
255 inline Cursor
getUpperLeftAngleCursor(void) const
256 { return cursor
.ul_angle
; }
257 inline Cursor
getUpperRightAngleCursor(void) const
258 { return cursor
.ur_angle
; }
260 inline unsigned int getMouseModMask(void) const
261 { return resource
.mod_mask
; }
263 void setFocusedWindow(BlackboxWindow
*win
);
264 void setChangingWindow(BlackboxWindow
*win
);
266 void saveStyleFilename(const std::string
& filename
);
267 void addMenuTimestamp(const std::string
& filename
);
268 void restart(const char *prog
= 0);
269 void reconfigure(void);
270 void rereadMenu(void);
271 void checkMenu(void);
273 bool validateWindow(Window window
);
275 virtual bool handleSignal(int sig
);
277 virtual void timeout(void);
279 #ifndef HAVE_STRFTIME
280 enum { B_AmericanDate
= 1, B_EuropeanDate
};
281 #endif // HAVE_STRFTIME
285 #endif // __blackbox_hh