1 // openbox.h for Openbox
2 // Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
3 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
5 // Permission is hereby granted, free of charge, to any person obtaining a
6 // copy of this software and associated documentation files (the "Software"),
7 // to deal in the Software without restriction, including without limitation
8 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 // and/or sell copies of the Software, and to permit persons to whom the
10 // Software is furnished to do so, subject to the following conditions:
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 // DEALINGS IN THE SOFTWARE.
27 #include <X11/Xresource.h>
31 #endif // HAVE_STDIO_H
33 #ifdef TIME_WITH_SYS_TIME
34 # include <sys/time.h>
36 #else // !TIME_WITH_SYS_TIME
37 # ifdef HAVE_SYS_TIME_H
38 # include <sys/time.h>
39 # else // !HAVE_SYS_TIME_H
41 # endif // HAVE_SYS_TIME_H
42 #endif // TIME_WITH_SYS_TIME
45 #include "BaseDisplay.h"
70 DataSearch(Window w, Z *d): window(w), data(d) {}
72 inline const Window &getWindow() const { return window; }
73 inline Z *getData() { return data; }
77 class Openbox : public BaseDisplay, public TimeoutHandler {
79 typedef struct MenuTimestamp {
80 virtual ~MenuTimestamp() {
81 if (filename != (char *) 0)
89 Time double_click_interval;
92 char *titlebar_layout;
93 int colors_per_channel;
94 timeval auto_raise_delay;
95 unsigned long cache_life, cache_max;
98 typedef std::map<Window, OpenboxWindow*> WindowLookup;
99 typedef WindowLookup::value_type WindowLookupPair;
100 WindowLookup windowSearchList, groupSearchList;
102 typedef std::map<Window, Basemenu*> MenuLookup;
103 typedef MenuLookup::value_type MenuLookupPair;
104 MenuLookup menuSearchList;
106 typedef std::map<Window, Toolbar*> ToolbarLookup;
107 typedef ToolbarLookup::value_type ToolbarLookupPair;
108 ToolbarLookup toolbarSearchList;
111 typedef std::map<Window, Slit*> SlitLookup;
112 typedef SlitLookup::value_type SlitLookupPair;
113 SlitLookup slitSearchList;
116 typedef std::list<MenuTimestamp*> MenuTimestampList;
117 MenuTimestampList menuTimestamps;
119 typedef std::vector<BScreen*> ScreenList;
120 ScreenList screenList;
122 BScreen *current_screen;
123 OpenboxWindow *masked_window;
128 #endif // HAVE_GETPID
130 Bool no_focus, reconfigure_wait, reread_menu_wait;
133 char *menu_file, *rc_file, **argv;
141 void real_rereadMenu();
142 void real_reconfigure();
144 virtual void process_event(XEvent *);
148 Openbox(int, char **, char * = 0, char * = 0, char * = 0);
152 inline const Atom &getOpenboxPidAtom() const { return openbox_pid; }
153 #endif // HAVE_GETPID
155 Basemenu *searchMenu(Window);
157 OpenboxWindow *searchGroup(Window, OpenboxWindow *);
158 OpenboxWindow *searchWindow(Window);
159 OpenboxWindow *focusedWindow();
160 void focusWindow(OpenboxWindow *w);
162 inline BScreen *getScreen(unsigned int s) {
163 ASSERT(s < screenList.size());
164 return screenList[s];
166 BScreen *searchScreen(Window);
167 inline unsigned int managedScreenCount() const {
168 return screenList.size();
171 inline Resource &getConfig() {
174 inline const Time &getDoubleClickInterval() const
175 { return resource.double_click_interval; }
176 inline const Time &getLastTime() const { return last_time; }
178 Toolbar *searchToolbar(Window);
180 inline const char *getStyleFilename() const
181 { return resource.style_file; }
182 inline const char *getMenuFilename() const
183 { return menu_file; }
184 void addMenuTimestamp(const char *filename);
186 inline const int &getColorsPerChannel() const
187 { return resource.colors_per_channel; }
189 inline const timeval &getAutoRaiseDelay() const
190 { return resource.auto_raise_delay; }
192 inline const char *getTitleBarLayout() const
193 { return resource.titlebar_layout; }
195 inline const unsigned long &getCacheLife() const
196 { return resource.cache_life; }
197 inline const unsigned long &getCacheMax() const
198 { return resource.cache_max; }
200 inline OpenboxWindow *getMaskedWindow() const
201 { return masked_window; }
202 inline void maskWindowEvents(Window w, OpenboxWindow *bw)
203 { masked = w; masked_window = bw; }
204 inline void setNoFocus(Bool f) { no_focus = f; }
207 void setStyleFilename(const char *);
208 void saveMenuSearch(Window, Basemenu *);
209 void saveWindowSearch(Window, OpenboxWindow *);
210 void saveToolbarSearch(Window, Toolbar *);
211 void saveGroupSearch(Window, OpenboxWindow *);
212 void removeMenuSearch(Window);
213 void removeWindowSearch(Window);
214 void removeToolbarSearch(Window);
215 void removeGroupSearch(Window);
216 void restart(const char * = 0);
221 virtual Bool handleSignal(int);
223 virtual void timeout();
226 Slit *searchSlit(Window);
228 void saveSlitSearch(Window, Slit *);
229 void removeSlitSearch(Window);
232 #ifndef HAVE_STRFTIME
234 enum { B_AmericanDate = 1, B_EuropeanDate };
235 #endif // HAVE_STRFTIME
239 #endif // __openbox_hh