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"
69 DataSearch(Window w
, Z
*d
): window(w
), data(d
) {}
71 inline const Window
&getWindow() const { return window
; }
72 inline Z
*getData() { return data
; }
76 class Openbox
: public BaseDisplay
, public TimeoutHandler
{
78 typedef struct MenuTimestamp
{
79 virtual ~MenuTimestamp() {
80 if (filename
!= (char *) 0)
88 Time double_click_interval
;
90 char *menu_file
, *style_file
;
91 char *titlebar_layout
;
92 int colors_per_channel
;
93 timeval auto_raise_delay
;
94 unsigned long cache_life
, cache_max
;
97 typedef std::map
<Window
, OpenboxWindow
*> WindowLookup
;
98 typedef WindowLookup::value_type WindowLookupPair
;
99 WindowLookup windowSearchList
, groupSearchList
;
101 typedef std::map
<Window
, Basemenu
*> MenuLookup
;
102 typedef MenuLookup::value_type MenuLookupPair
;
103 MenuLookup menuSearchList
;
105 typedef std::map
<Window
, Toolbar
*> ToolbarLookup
;
106 typedef ToolbarLookup::value_type ToolbarLookupPair
;
107 ToolbarLookup toolbarSearchList
;
110 typedef std::map
<Window
, Slit
*> SlitLookup
;
111 typedef SlitLookup::value_type SlitLookupPair
;
112 SlitLookup slitSearchList
;
115 typedef std::list
<MenuTimestamp
*> MenuTimestampList
;
116 MenuTimestampList menuTimestamps
;
118 typedef std::list
<BScreen
*> ScreenList
;
119 ScreenList screenList
;
121 BScreen
*current_screen
;
122 OpenboxWindow
*masked_window
;
127 #endif // HAVE_GETPID
129 Bool no_focus
, reconfigure_wait
, reread_menu_wait
;
132 char *rc_file
, **argv
;
140 void real_rereadMenu();
141 void real_reconfigure();
143 virtual void process_event(XEvent
*);
147 Openbox(int, char **, char * = 0, char * = 0);
151 inline const Atom
&getOpenboxPidAtom() const { return openbox_pid
; }
152 #endif // HAVE_GETPID
154 Basemenu
*searchMenu(Window
);
156 OpenboxWindow
*searchGroup(Window
, OpenboxWindow
*);
157 OpenboxWindow
*searchWindow(Window
);
158 OpenboxWindow
*focusedWindow();
159 void focusWindow(OpenboxWindow
*w
);
161 BScreen
*getScreen(int);
162 BScreen
*searchScreen(Window
);
164 inline Resource
&getConfig() {
167 inline const Time
&getDoubleClickInterval() const
168 { return resource
.double_click_interval
; }
169 inline const Time
&getLastTime() const { return last_time
; }
171 Toolbar
*searchToolbar(Window
);
173 inline const char *getStyleFilename() const
174 { return resource
.style_file
; }
175 inline const char *getMenuFilename() const
176 { return resource
.menu_file
; }
178 inline const int &getColorsPerChannel() const
179 { return resource
.colors_per_channel
; }
181 inline const timeval
&getAutoRaiseDelay() const
182 { return resource
.auto_raise_delay
; }
184 inline const char *getTitleBarLayout() const
185 { return resource
.titlebar_layout
; }
187 inline const unsigned long &getCacheLife() const
188 { return resource
.cache_life
; }
189 inline const unsigned long &getCacheMax() const
190 { return resource
.cache_max
; }
192 inline OpenboxWindow
*getMaskedWindow() const
193 { return masked_window
; }
194 inline void maskWindowEvents(Window w
, OpenboxWindow
*bw
)
195 { masked
= w
; masked_window
= bw
; }
196 inline void setNoFocus(Bool f
) { no_focus
= f
; }
199 void setStyleFilename(const char *);
200 void setMenuFilename(const char *);
201 void saveMenuSearch(Window
, Basemenu
*);
202 void saveWindowSearch(Window
, OpenboxWindow
*);
203 void saveToolbarSearch(Window
, Toolbar
*);
204 void saveGroupSearch(Window
, OpenboxWindow
*);
205 void removeMenuSearch(Window
);
206 void removeWindowSearch(Window
);
207 void removeToolbarSearch(Window
);
208 void removeGroupSearch(Window
);
209 void restart(const char * = 0);
214 virtual Bool
handleSignal(int);
216 virtual void timeout();
219 Slit
*searchSlit(Window
);
221 void saveSlitSearch(Window
, Slit
*);
222 void removeSlitSearch(Window
);
225 #ifndef HAVE_STRFTIME
227 enum { B_AmericanDate
= 1, B_EuropeanDate
};
228 #endif // HAVE_STRFTIME
232 #endif // __openbox_hh