]> Dogcows Code - chaz/openbox/blob - src/blackbox.hh
add capability to stick a window from input, and make close buttons work.
[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
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)
62
63 #define StackTop (0)
64 #define StackNormal (1)
65 #define StackBottom (2)
66
67 #define DecorNone (0)
68 #define DecorNormal (1)
69 #define DecorTiny (2)
70 #define DecorTool (3)
71
72 struct BlackboxHints {
73 unsigned long flags, attrib, workspace, stack, decoration;
74 };
75
76 struct BlackboxAttributes {
77 unsigned long flags, attrib, workspace, stack, decoration;
78 int premax_x, premax_y;
79 unsigned int premax_w, premax_h;
80 };
81
82 #define PropBlackboxHintsElements (5)
83 #define PropBlackboxAttributesElements (9)
84
85
86 //forward declaration
87 class BScreen;
88 class Blackbox;
89 class BlackboxWindow;
90 class BWindowGroup;
91 class Basemenu;
92 class Toolbar;
93 class Slit;
94 class XAtom;
95 class BInput;
96
97 extern I18n i18n;
98
99 class Blackbox : public BaseDisplay, public TimeoutHandler {
100 private:
101 struct BCursor {
102 Cursor session, move, ll_angle, lr_angle, ul_angle, ur_angle;
103 };
104 BCursor cursor;
105
106 struct MenuTimestamp {
107 std::string filename;
108 time_t timestamp;
109 };
110
111 struct BResource {
112 Time double_click_interval;
113
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;
119 } resource;
120
121 typedef std::map<Window, BlackboxWindow*> WindowLookup;
122 typedef WindowLookup::value_type WindowLookupPair;
123 WindowLookup windowSearchList;
124
125 typedef std::map<Window, BScreen*> WindowScreenLookup;
126 typedef WindowScreenLookup::value_type WindowScreenLookupPair;
127 WindowScreenLookup systraySearchList, desktopSearchList;
128
129 typedef std::map<Window, BWindowGroup*> GroupLookup;
130 typedef GroupLookup::value_type GroupLookupPair;
131 GroupLookup groupSearchList;
132
133 typedef std::map<Window, Basemenu*> MenuLookup;
134 typedef MenuLookup::value_type MenuLookupPair;
135 MenuLookup menuSearchList;
136
137 typedef std::map<Window, Toolbar*> ToolbarLookup;
138 typedef ToolbarLookup::value_type ToolbarLookupPair;
139 ToolbarLookup toolbarSearchList;
140
141 typedef std::map<Window, Slit*> SlitLookup;
142 typedef SlitLookup::value_type SlitLookupPair;
143 SlitLookup slitSearchList;
144
145 typedef std::list<MenuTimestamp*> MenuTimestampList;
146 MenuTimestampList menuTimestamps;
147
148 typedef std::list<BScreen*> ScreenList;
149 ScreenList screenList;
150
151 BScreen *active_screen;
152 BlackboxWindow *focused_window, *changing_window;
153 BTimer *timer;
154 Configuration config;
155 XAtom *xatom;
156 BInput *input;
157
158 bool no_focus, reconfigure_wait, reread_menu_wait;
159 Time last_time;
160 char **argv;
161 std::string menu_file, rc_file;
162
163 Blackbox(const Blackbox&);
164 Blackbox& operator=(const Blackbox&);
165
166 void load_rc(void);
167 void save_rc(void);
168 void real_rereadMenu(void);
169 void real_reconfigure(void);
170
171 virtual void process_event(XEvent *);
172
173
174 public:
175 Blackbox(char **m_argv, char *dpy_name = 0, char *rc = 0, char *menu = 0);
176 virtual ~Blackbox(void);
177
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);
186
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);
201
202 inline XAtom *getXAtom(void) { return xatom; }
203 inline BInput *getInput(void) { return input; }
204
205 inline BScreen *getFocusedScreen(void) { return active_screen; }
206 inline BlackboxWindow *getFocusedWindow(void) { return focused_window; }
207 inline BlackboxWindow *getChangingWindow(void) { return changing_window; }
208
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; }
213
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(); }
218
219 inline int getColorsPerChannel(void) const
220 { return resource.colors_per_channel; }
221
222 inline std::string getTitlebarLayout(void) const
223 { return resource.titlebar_layout; }
224
225 inline const timeval &getAutoRaiseDelay(void) const
226 { return resource.auto_raise_delay; }
227
228 inline unsigned long getCacheLife(void) const
229 { return resource.cache_life; }
230 inline unsigned long getCacheMax(void) const
231 { return resource.cache_max; }
232
233 inline void setNoFocus(bool f) { no_focus = f; }
234
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; }
247
248 void setFocusedWindow(BlackboxWindow *win);
249 void setChangingWindow(BlackboxWindow *win);
250 void shutdown(void);
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);
257
258 bool validateWindow(Window window);
259
260 virtual bool handleSignal(int sig);
261
262 virtual void timeout(void);
263
264 #ifndef HAVE_STRFTIME
265 enum { B_AmericanDate = 1, B_EuropeanDate };
266 #endif // HAVE_STRFTIME
267 };
268
269
270 #endif // __blackbox_hh
This page took 0.04523 seconds and 5 git commands to generate.