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"
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)
99 class Blackbox
: public BaseDisplay
, public TimeoutHandler
{
102 Cursor session
, move
, ll_angle
, lr_angle
, ul_angle
, ur_angle
;
106 struct MenuTimestamp
{
107 std::string filename
;
112 Time double_click_interval
;
114 std::string style_file
;
115 int colors_per_channel
;
116 timeval auto_raise_delay
;
117 unsigned long cache_life
, cache_max
;
118 std::string titlebar_layout
;
121 typedef std::map
<Window
, BlackboxWindow
*> WindowLookup
;
122 typedef WindowLookup::value_type WindowLookupPair
;
123 WindowLookup windowSearchList
;
125 typedef std::map
<Window
, BScreen
*> WindowScreenLookup
;
126 typedef WindowScreenLookup::value_type WindowScreenLookupPair
;
127 WindowScreenLookup systraySearchList
, desktopSearchList
;
129 typedef std::map
<Window
, BWindowGroup
*> GroupLookup
;
130 typedef GroupLookup::value_type GroupLookupPair
;
131 GroupLookup groupSearchList
;
133 typedef std::map
<Window
, Basemenu
*> MenuLookup
;
134 typedef MenuLookup::value_type MenuLookupPair
;
135 MenuLookup menuSearchList
;
137 typedef std::map
<Window
, Toolbar
*> ToolbarLookup
;
138 typedef ToolbarLookup::value_type ToolbarLookupPair
;
139 ToolbarLookup toolbarSearchList
;
141 typedef std::map
<Window
, Slit
*> SlitLookup
;
142 typedef SlitLookup::value_type SlitLookupPair
;
143 SlitLookup slitSearchList
;
145 typedef std::list
<MenuTimestamp
*> MenuTimestampList
;
146 MenuTimestampList menuTimestamps
;
148 typedef std::list
<BScreen
*> ScreenList
;
149 ScreenList screenList
;
151 BScreen
*active_screen
;
152 BlackboxWindow
*focused_window
, *changing_window
;
154 Configuration config
;
158 bool no_focus
, reconfigure_wait
, reread_menu_wait
;
161 std::string menu_file
, rc_file
;
163 Blackbox(const Blackbox
&);
164 Blackbox
& operator=(const Blackbox
&);
168 void real_rereadMenu(void);
169 void real_reconfigure(void);
171 virtual void process_event(XEvent
*);
175 Blackbox(char **m_argv
, char *dpy_name
= 0, char *rc
= 0, char *menu
= 0);
176 virtual ~Blackbox(void);
178 Basemenu
*searchMenu(Window window
);
179 BWindowGroup
*searchGroup(Window window
);
180 BScreen
*searchDesktopWindow(Window window
);
181 BScreen
*searchSystrayWindow(Window window
);
182 BlackboxWindow
*searchWindow(Window window
);
183 BScreen
*searchScreen(Window window
);
184 Toolbar
*searchToolbar(Window
);
185 Slit
*searchSlit(Window
);
187 void saveMenuSearch(Window window
, Basemenu
*data
);
188 void saveDesktopWindowSearch(Window window
, BScreen
*screen
);
189 void saveSystrayWindowSearch(Window window
, BScreen
*screen
);
190 void saveWindowSearch(Window window
, BlackboxWindow
*data
);
191 void saveGroupSearch(Window window
, BWindowGroup
*data
);
192 void saveToolbarSearch(Window window
, Toolbar
*data
);
193 void saveSlitSearch(Window window
, Slit
*data
);
194 void removeMenuSearch(Window window
);
195 void removeDesktopWindowSearch(Window window
);
196 void removeSystrayWindowSearch(Window window
);
197 void removeWindowSearch(Window window
);
198 void removeGroupSearch(Window window
);
199 void removeToolbarSearch(Window window
);
200 void removeSlitSearch(Window window
);
202 inline XAtom
*getXAtom(void) { return xatom
; }
203 inline BInput
*getInput(void) { return input
; }
205 inline BScreen
*getFocusedScreen(void) { return active_screen
; }
206 inline BlackboxWindow
*getFocusedWindow(void) { return focused_window
; }
207 inline BlackboxWindow
*getChangingWindow(void) { return changing_window
; }
209 inline Configuration
*getConfig() { return &config
; }
210 inline const Time
&getDoubleClickInterval(void) const
211 { return resource
.double_click_interval
; }
212 inline const Time
&getLastTime(void) const { return last_time
; }
214 inline const char *getStyleFilename(void) const
215 { return resource
.style_file
.c_str(); }
216 inline const char *getMenuFilename(void) const
217 { return menu_file
.c_str(); }
219 inline int getColorsPerChannel(void) const
220 { return resource
.colors_per_channel
; }
222 inline std::string
getTitlebarLayout(void) const
223 { return resource
.titlebar_layout
; }
225 inline const timeval
&getAutoRaiseDelay(void) const
226 { return resource
.auto_raise_delay
; }
228 inline unsigned long getCacheLife(void) const
229 { return resource
.cache_life
; }
230 inline unsigned long getCacheMax(void) const
231 { return resource
.cache_max
; }
233 inline void setNoFocus(bool f
) { no_focus
= f
; }
235 inline Cursor
getSessionCursor(void) const
236 { return cursor
.session
; }
237 inline Cursor
getMoveCursor(void) const
238 { return cursor
.move
; }
239 inline Cursor
getLowerLeftAngleCursor(void) const
240 { return cursor
.ll_angle
; }
241 inline Cursor
getLowerRightAngleCursor(void) const
242 { return cursor
.lr_angle
; }
243 inline Cursor
getUpperLeftAngleCursor(void) const
244 { return cursor
.ul_angle
; }
245 inline Cursor
getUpperRightAngleCursor(void) const
246 { return cursor
.ur_angle
; }
248 void setFocusedWindow(BlackboxWindow
*win
);
249 void setChangingWindow(BlackboxWindow
*win
);
251 void saveStyleFilename(const std::string
& filename
);
252 void addMenuTimestamp(const std::string
& filename
);
253 void restart(const char *prog
= 0);
254 void reconfigure(void);
255 void rereadMenu(void);
256 void checkMenu(void);
258 bool validateWindow(Window window
);
260 virtual bool handleSignal(int sig
);
262 virtual void timeout(void);
264 #ifndef HAVE_STRFTIME
265 enum { B_AmericanDate
= 1, B_EuropeanDate
};
266 #endif // HAVE_STRFTIME
270 #endif // __blackbox_hh