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)
92 class Blackbox : public BaseDisplay, public TimeoutHandler {
95 Cursor session, move, ll_angle, lr_angle, ul_angle, ur_angle;
100 Time double_click_interval;
102 std::string style_file;
103 int colors_per_channel;
104 timeval auto_raise_delay;
105 unsigned long cache_life, cache_max;
106 std::string titlebar_layout;
107 unsigned int mod_mask; // modifier mask used for window-mouse interaction
111 bool xinerama_placement, xinerama_maximize, xinerama_snap;
115 typedef std::map<Window, BlackboxWindow*> WindowLookup;
116 typedef WindowLookup::value_type WindowLookupPair;
117 WindowLookup windowSearchList;
119 typedef std::map<Window, BScreen*> WindowScreenLookup;
120 typedef WindowScreenLookup::value_type WindowScreenLookupPair;
121 WindowScreenLookup systraySearchList;
123 typedef std::map<Window, BWindowGroup*> GroupLookup;
124 typedef GroupLookup::value_type GroupLookupPair;
125 GroupLookup groupSearchList;
127 typedef std::list<BScreen*> ScreenList;
128 ScreenList screenList;
130 BScreen *active_screen;
131 BlackboxWindow *focused_window, *changing_window;
133 Configuration config;
136 bool no_focus, reconfigure_wait;
141 Blackbox(const Blackbox&);
142 Blackbox& operator=(const Blackbox&);
146 void real_reconfigure(void);
148 virtual void process_event(XEvent *);
152 Blackbox(char **m_argv, char *dpy_name = 0, char *rc = 0);
153 virtual ~Blackbox(void);
155 BWindowGroup *searchGroup(Window window);
156 BScreen *searchSystrayWindow(Window window);
157 BlackboxWindow *searchWindow(Window window);
158 BScreen *searchScreen(Window window);
161 inline bool doXineramaPlacement(void) const
162 { return resource.xinerama_placement; }
163 inline bool doXineramaMaximizing(void) const
164 { return resource.xinerama_maximize; }
165 inline bool doXineramaSnapping(void) const
166 { return resource.xinerama_snap; }
168 void saveXineramaPlacement(bool x);
169 void saveXineramaMaximizing(bool x);
170 void saveXineramaSnapping(bool x);
173 void saveSystrayWindowSearch(Window window, BScreen *screen);
174 void saveWindowSearch(Window window, BlackboxWindow *data);
175 void saveGroupSearch(Window window, BWindowGroup *data);
176 void removeSystrayWindowSearch(Window window);
177 void removeWindowSearch(Window window);
178 void removeGroupSearch(Window window);
180 inline XAtom *getXAtom(void) { return xatom; }
182 inline BlackboxWindow *getFocusedWindow(void) { return focused_window; }
183 inline BlackboxWindow *getChangingWindow(void) { return changing_window; }
185 inline Configuration *getConfig() { return &config; }
186 inline const Time &getDoubleClickInterval(void) const
187 { return resource.double_click_interval; }
188 inline const Time &getLastTime(void) const { return last_time; }
190 inline const char *getStyleFilename(void) const
191 { return resource.style_file.c_str(); }
193 inline int getColorsPerChannel(void) const
194 { return resource.colors_per_channel; }
196 inline std::string getTitlebarLayout(void) const
197 { return resource.titlebar_layout; }
199 inline const timeval &getAutoRaiseDelay(void) const
200 { return resource.auto_raise_delay; }
202 inline unsigned long getCacheLife(void) const
203 { return resource.cache_life; }
204 inline unsigned long getCacheMax(void) const
205 { return resource.cache_max; }
207 inline void setNoFocus(bool f) { no_focus = f; }
209 inline Cursor getSessionCursor(void) const
210 { return cursor.session; }
211 inline Cursor getMoveCursor(void) const
212 { return cursor.move; }
213 inline Cursor getLowerLeftAngleCursor(void) const
214 { return cursor.ll_angle; }
215 inline Cursor getLowerRightAngleCursor(void) const
216 { return cursor.lr_angle; }
217 inline Cursor getUpperLeftAngleCursor(void) const
218 { return cursor.ul_angle; }
219 inline Cursor getUpperRightAngleCursor(void) const
220 { return cursor.ur_angle; }
222 inline unsigned int getMouseModMask(void) const
223 { return resource.mod_mask; }
225 void setFocusedWindow(BlackboxWindow *win);
226 void setChangingWindow(BlackboxWindow *win);
228 void saveStyleFilename(const std::string& filename);
229 void restart(const char *prog = 0);
230 void reconfigure(void);
232 bool validateWindow(Window window);
234 virtual bool handleSignal(int sig);
236 virtual void timeout(void);
238 enum { B_AmericanDate = 1, B_EuropeanDate };
242 #endif // __blackbox_hh