]> Dogcows Code - chaz/openbox/blob - src/blackbox.hh
merging in netwm changes at merge point "netwm-merge1". This add the XAtom class...
[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 #include "XAtom.hh"
55
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)
63
64 #define StackTop (0)
65 #define StackNormal (1)
66 #define StackBottom (2)
67
68 #define DecorNone (0)
69 #define DecorNormal (1)
70 #define DecorTiny (2)
71 #define DecorTool (3)
72
73 struct BlackboxHints {
74 unsigned long flags, attrib, workspace, stack, decoration;
75 };
76
77 struct BlackboxAttributes {
78 unsigned long flags, attrib, workspace, stack, decoration;
79 int premax_x, premax_y;
80 unsigned int premax_w, premax_h;
81 };
82
83 #define PropBlackboxHintsElements (5)
84 #define PropBlackboxAttributesElements (9)
85
86
87 //forward declaration
88 class BScreen;
89 class Blackbox;
90 class BlackboxWindow;
91 class BWindowGroup;
92 class Basemenu;
93 class Toolbar;
94 class Slit;
95
96 extern I18n i18n;
97
98 class Blackbox : public BaseDisplay, public TimeoutHandler {
99 private:
100 struct BCursor {
101 Cursor session, move, ll_angle, lr_angle;
102 };
103 BCursor cursor;
104
105 struct MenuTimestamp {
106 std::string filename;
107 time_t timestamp;
108 };
109
110 struct BResource {
111 Time double_click_interval;
112
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 } resource;
119
120 typedef std::map<Window, BlackboxWindow*> WindowLookup;
121 typedef WindowLookup::value_type WindowLookupPair;
122 WindowLookup windowSearchList;
123
124 typedef std::map<Window, BWindowGroup*> GroupLookup;
125 typedef GroupLookup::value_type GroupLookupPair;
126 GroupLookup groupSearchList;
127
128 typedef std::map<Window, Basemenu*> MenuLookup;
129 typedef MenuLookup::value_type MenuLookupPair;
130 MenuLookup menuSearchList;
131
132 typedef std::map<Window, Toolbar*> ToolbarLookup;
133 typedef ToolbarLookup::value_type ToolbarLookupPair;
134 ToolbarLookup toolbarSearchList;
135
136 typedef std::map<Window, Slit*> SlitLookup;
137 typedef SlitLookup::value_type SlitLookupPair;
138 SlitLookup slitSearchList;
139
140 typedef std::list<MenuTimestamp*> MenuTimestampList;
141 MenuTimestampList menuTimestamps;
142
143 typedef std::list<BScreen*> ScreenList;
144 ScreenList screenList;
145
146 BScreen *active_screen;
147 BlackboxWindow *focused_window;
148 BTimer *timer;
149 Configuration config;
150 XAtom *xatom;
151
152 bool no_focus, reconfigure_wait, reread_menu_wait;
153 Time last_time;
154 char **argv;
155 std::string menu_file, rc_file;
156
157 Blackbox(const Blackbox&);
158 Blackbox& operator=(const Blackbox&);
159
160 void load_rc(void);
161 void save_rc(void);
162 void real_rereadMenu(void);
163 void real_reconfigure(void);
164
165 virtual void process_event(XEvent *);
166
167
168 public:
169 Blackbox(char **m_argv, char *dpy_name = 0, char *rc = 0, char *menu = 0);
170 virtual ~Blackbox(void);
171
172 Basemenu *searchMenu(Window window);
173 BWindowGroup *searchGroup(Window window);
174 BlackboxWindow *searchWindow(Window window);
175 BScreen *searchScreen(Window window);
176 Toolbar *searchToolbar(Window);
177 Slit *searchSlit(Window);
178
179 void saveMenuSearch(Window window, Basemenu *data);
180 void saveWindowSearch(Window window, BlackboxWindow *data);
181 void saveGroupSearch(Window window, BWindowGroup *data);
182 void saveToolbarSearch(Window window, Toolbar *data);
183 void saveSlitSearch(Window window, Slit *data);
184 void removeMenuSearch(Window window);
185 void removeWindowSearch(Window window);
186 void removeGroupSearch(Window window);
187 void removeToolbarSearch(Window window);
188 void removeSlitSearch(Window window);
189
190 inline XAtom *getXAtom(void) { return xatom; }
191
192 inline BlackboxWindow *getFocusedWindow(void) { return focused_window; }
193
194 inline Configuration *getConfig() { return &config; }
195 inline const Time &getDoubleClickInterval(void) const
196 { return resource.double_click_interval; }
197 inline const Time &getLastTime(void) const { return last_time; }
198
199 inline const char *getStyleFilename(void) const
200 { return resource.style_file.c_str(); }
201 inline const char *getMenuFilename(void) const
202 { return menu_file.c_str(); }
203
204 inline int getColorsPerChannel(void) const
205 { return resource.colors_per_channel; }
206
207 inline std::string getTitlebarLayout(void) const
208 { return resource.titlebar_layout; }
209
210 inline const timeval &getAutoRaiseDelay(void) const
211 { return resource.auto_raise_delay; }
212
213 inline unsigned long getCacheLife(void) const
214 { return resource.cache_life; }
215 inline unsigned long getCacheMax(void) const
216 { return resource.cache_max; }
217
218 inline void setNoFocus(bool f) { no_focus = f; }
219
220 inline Cursor getSessionCursor(void) const
221 { return cursor.session; }
222 inline Cursor getMoveCursor(void) const
223 { return cursor.move; }
224 inline Cursor getLowerLeftAngleCursor(void) const
225 { return cursor.ll_angle; }
226 inline Cursor getLowerRightAngleCursor(void) const
227 { return cursor.lr_angle; }
228
229 void setFocusedWindow(BlackboxWindow *w);
230 void shutdown(void);
231 void saveStyleFilename(const std::string& filename);
232 void addMenuTimestamp(const std::string& filename);
233 void restart(const char *prog = 0);
234 void reconfigure(void);
235 void rereadMenu(void);
236 void checkMenu(void);
237
238 bool validateWindow(Window window);
239
240 virtual bool handleSignal(int sig);
241
242 virtual void timeout(void);
243
244 #ifndef HAVE_STRFTIME
245 enum { B_AmericanDate = 1, B_EuropeanDate };
246 #endif // HAVE_STRFTIME
247
248 inline Atom getWMChangeStateAtom(void) const
249 { return xatom->getAtom(XAtom::wm_change_state); }
250 inline Atom getWMStateAtom(void) const
251 { return xatom->getAtom(XAtom::wm_state); }
252 inline Atom getWMDeleteAtom(void) const
253 { return xatom->getAtom(XAtom::wm_delete_window); }
254 inline Atom getWMProtocolsAtom(void) const
255 { return xatom->getAtom(XAtom::wm_protocols); }
256 inline Atom getWMTakeFocusAtom(void) const
257 { return xatom->getAtom(XAtom::wm_take_focus); }
258 inline Atom getWMColormapAtom(void) const
259 { return xatom->getAtom(XAtom::wm_colormap_windows); }
260 inline Atom getMotifWMHintsAtom(void) const
261 { return xatom->getAtom(XAtom::motif_wm_hints); }
262
263 // this atom is for normal app->WM hints about decorations, stacking,
264 // starting workspace etc...
265 inline Atom getBlackboxHintsAtom(void) const
266 { return xatom->getAtom(XAtom::blackbox_hints); }
267
268 // these atoms are for normal app->WM interaction beyond the scope of the
269 // ICCCM...
270 inline Atom getBlackboxAttributesAtom(void) const
271 { return xatom->getAtom(XAtom::blackbox_attributes); }
272 inline Atom getBlackboxChangeAttributesAtom(void) const
273 { return xatom->getAtom(XAtom::blackbox_change_attributes); }
274
275 // these atoms are for window->WM interaction, with more control and
276 // information on window "structure"... common examples are
277 // notifying apps when windows are raised/lowered... when the user changes
278 // workspaces... i.e. "pager talk"
279 inline Atom getBlackboxStructureMessagesAtom(void) const
280 { return xatom->getAtom(XAtom::blackbox_structure_messages); }
281
282 // *Notify* portions of the NETStructureMessages protocol
283 inline Atom getBlackboxNotifyStartupAtom(void) const
284 { return xatom->getAtom(XAtom::blackbox_notify_startup); }
285 inline Atom getBlackboxNotifyWindowAddAtom(void) const
286 { return xatom->getAtom(XAtom::blackbox_notify_window_add); }
287 inline Atom getBlackboxNotifyWindowDelAtom(void) const
288 { return xatom->getAtom(XAtom::blackbox_notify_window_del); }
289 inline Atom getBlackboxNotifyWindowFocusAtom(void) const
290 { return xatom->getAtom(XAtom::blackbox_notify_window_focus); }
291 inline Atom getBlackboxNotifyCurrentWorkspaceAtom(void) const
292 { return xatom->getAtom(XAtom::blackbox_notify_current_workspace); }
293 inline Atom getBlackboxNotifyWorkspaceCountAtom(void) const
294 { return xatom->getAtom(XAtom::blackbox_notify_workspace_count); }
295 inline Atom getBlackboxNotifyWindowRaiseAtom(void) const
296 { return xatom->getAtom(XAtom::blackbox_notify_window_raise); }
297 inline Atom getBlackboxNotifyWindowLowerAtom(void) const
298 { return xatom->getAtom(XAtom::blackbox_notify_window_lower); }
299
300 // atoms to change that request changes to the desktop environment during
301 // runtime... these messages can be sent by any client... as the sending
302 // client window id is not included in the ClientMessage event...
303 inline Atom getBlackboxChangeWorkspaceAtom(void) const
304 { return xatom->getAtom(XAtom::blackbox_change_workspace); }
305 inline Atom getBlackboxChangeWindowFocusAtom(void) const
306 { return xatom->getAtom(XAtom::blackbox_change_window_focus); }
307 inline Atom getBlackboxCycleWindowFocusAtom(void) const
308 { return xatom->getAtom(XAtom::blackbox_cycle_window_focus); }
309 };
310
311
312 #endif // __blackbox_hh
This page took 0.04701 seconds and 5 git commands to generate.