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
50 #include "basedisplay.hh"
51 #include "configuration.hh"
55 #define AttribShaded (1l << 0)
56 #define AttribMaxHoriz (1l << 1)
57 #define AttribMaxVert (1l << 2)
58 #define AttribOmnipresent (1l << 3)
59 #define AttribWorkspace (1l << 4)
60 #define AttribStack (1l << 5)
61 #define AttribDecoration (1l << 6)
64 #define StackNormal (1)
65 #define StackBottom (2)
68 #define DecorNormal (1)
72 struct BlackboxHints
{
73 unsigned long flags
, attrib
, workspace
, stack
, decoration
;
76 struct BlackboxAttributes
{
77 unsigned long flags
, attrib
, workspace
, stack
, decoration
;
78 int premax_x
, premax_y
;
79 unsigned int premax_w
, premax_h
;
82 #define PropBlackboxHintsElements (5)
83 #define PropBlackboxAttributesElements (9)
97 class Blackbox
: public BaseDisplay
, public TimeoutHandler
{
100 Cursor session
, move
, ll_angle
, lr_angle
, ul_angle
, ur_angle
;
104 struct MenuTimestamp
{
105 std::string filename
;
110 Time double_click_interval
;
112 std::string style_file
;
113 int colors_per_channel
;
114 timeval auto_raise_delay
;
115 unsigned long cache_life
, cache_max
;
116 std::string titlebar_layout
;
117 unsigned int mod_mask
; // modifier mask used for window-mouse interaction
121 bool xinerama_placement
, xinerama_maximize
, xinerama_snap
;
125 typedef std::map
<Window
, BlackboxWindow
*> WindowLookup
;
126 typedef WindowLookup::value_type WindowLookupPair
;
127 WindowLookup windowSearchList
;
129 typedef std::map
<Window
, BScreen
*> WindowScreenLookup
;
130 typedef WindowScreenLookup::value_type WindowScreenLookupPair
;
131 WindowScreenLookup systraySearchList
;
133 typedef std::map
<Window
, BWindowGroup
*> GroupLookup
;
134 typedef GroupLookup::value_type GroupLookupPair
;
135 GroupLookup groupSearchList
;
137 typedef std::map
<Window
, Basemenu
*> MenuLookup
;
138 typedef MenuLookup::value_type MenuLookupPair
;
139 MenuLookup menuSearchList
;
141 typedef std::map
<Window
, Toolbar
*> ToolbarLookup
;
142 typedef ToolbarLookup::value_type ToolbarLookupPair
;
143 ToolbarLookup toolbarSearchList
;
145 typedef std::map
<Window
, Slit
*> SlitLookup
;
146 typedef SlitLookup::value_type SlitLookupPair
;
147 SlitLookup slitSearchList
;
149 typedef std::list
<MenuTimestamp
*> MenuTimestampList
;
150 MenuTimestampList menuTimestamps
;
152 typedef std::list
<BScreen
*> ScreenList
;
153 ScreenList screenList
;
155 BScreen
*active_screen
;
156 BlackboxWindow
*focused_window
, *changing_window
;
158 Configuration config
;
161 bool no_focus
, reconfigure_wait
, reread_menu_wait
;
164 std::string menu_file
, rc_file
;
166 Blackbox(const Blackbox
&);
167 Blackbox
& operator=(const Blackbox
&);
171 void real_rereadMenu(void);
172 void real_reconfigure(void);
174 virtual void process_event(XEvent
*);
178 Blackbox(char **m_argv
, char *dpy_name
= 0, char *rc
= 0, char *menu
= 0);
179 virtual ~Blackbox(void);
181 Basemenu
*searchMenu(Window window
);
182 BWindowGroup
*searchGroup(Window window
);
183 BScreen
*searchSystrayWindow(Window window
);
184 BlackboxWindow
*searchWindow(Window window
);
185 BScreen
*searchScreen(Window window
);
186 Toolbar
*searchToolbar(Window
);
187 Slit
*searchSlit(Window
);
190 inline bool doXineramaPlacement(void) const
191 { return resource
.xinerama_placement
; }
192 inline bool doXineramaMaximizing(void) const
193 { return resource
.xinerama_maximize
; }
194 inline bool doXineramaSnapping(void) const
195 { return resource
.xinerama_snap
; }
197 void saveXineramaPlacement(bool x
);
198 void saveXineramaMaximizing(bool x
);
199 void saveXineramaSnapping(bool x
);
202 void saveMenuSearch(Window window
, Basemenu
*data
);
203 void saveSystrayWindowSearch(Window window
, BScreen
*screen
);
204 void saveWindowSearch(Window window
, BlackboxWindow
*data
);
205 void saveGroupSearch(Window window
, BWindowGroup
*data
);
206 void saveToolbarSearch(Window window
, Toolbar
*data
);
207 void saveSlitSearch(Window window
, Slit
*data
);
208 void removeMenuSearch(Window window
);
209 void removeSystrayWindowSearch(Window window
);
210 void removeWindowSearch(Window window
);
211 void removeGroupSearch(Window window
);
212 void removeToolbarSearch(Window window
);
213 void removeSlitSearch(Window window
);
215 inline XAtom
*getXAtom(void) { return xatom
; }
217 inline BlackboxWindow
*getFocusedWindow(void) { return focused_window
; }
218 inline BlackboxWindow
*getChangingWindow(void) { return changing_window
; }
220 inline Configuration
*getConfig() { return &config
; }
221 inline const Time
&getDoubleClickInterval(void) const
222 { return resource
.double_click_interval
; }
223 inline const Time
&getLastTime(void) const { return last_time
; }
225 inline const char *getStyleFilename(void) const
226 { return resource
.style_file
.c_str(); }
227 inline const char *getMenuFilename(void) const
228 { return menu_file
.c_str(); }
230 inline int getColorsPerChannel(void) const
231 { return resource
.colors_per_channel
; }
233 inline std::string
getTitlebarLayout(void) const
234 { return resource
.titlebar_layout
; }
236 inline const timeval
&getAutoRaiseDelay(void) const
237 { return resource
.auto_raise_delay
; }
239 inline unsigned long getCacheLife(void) const
240 { return resource
.cache_life
; }
241 inline unsigned long getCacheMax(void) const
242 { return resource
.cache_max
; }
244 inline void setNoFocus(bool f
) { no_focus
= f
; }
246 inline Cursor
getSessionCursor(void) const
247 { return cursor
.session
; }
248 inline Cursor
getMoveCursor(void) const
249 { return cursor
.move
; }
250 inline Cursor
getLowerLeftAngleCursor(void) const
251 { return cursor
.ll_angle
; }
252 inline Cursor
getLowerRightAngleCursor(void) const
253 { return cursor
.lr_angle
; }
254 inline Cursor
getUpperLeftAngleCursor(void) const
255 { return cursor
.ul_angle
; }
256 inline Cursor
getUpperRightAngleCursor(void) const
257 { return cursor
.ur_angle
; }
259 inline unsigned int getMouseModMask(void) const
260 { return resource
.mod_mask
; }
262 void setFocusedWindow(BlackboxWindow
*win
);
263 void setChangingWindow(BlackboxWindow
*win
);
265 void saveStyleFilename(const std::string
& filename
);
266 void addMenuTimestamp(const std::string
& filename
);
267 void restart(const char *prog
= 0);
268 void reconfigure(void);
269 void rereadMenu(void);
270 void checkMenu(void);
272 bool validateWindow(Window window
);
274 virtual bool handleSignal(int sig
);
276 virtual void timeout(void);
278 #ifndef HAVE_STRFTIME
279 enum { B_AmericanDate
= 1, B_EuropeanDate
};
280 #endif // HAVE_STRFTIME
284 #endif // __blackbox_hh