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 "LinkedList.h"
46 #include "BaseDisplay.h"
67 DataSearch(Window w
, Z
*d
): window(w
), data(d
) {}
69 inline const Window
&getWindow() const { return window
; }
70 inline Z
*getData() { return data
; }
74 class Openbox
: public BaseDisplay
, public TimeoutHandler
{
76 typedef struct MenuTimestamp
{
82 Time double_click_interval
;
84 char *menu_file
, *style_file
;
85 char *titlebar_layout
;
86 int colors_per_channel
;
87 timeval auto_raise_delay
;
88 unsigned long cache_life
, cache_max
;
91 typedef DataSearch
<OpenboxWindow
> WindowSearch
;
92 LinkedList
<WindowSearch
> *windowSearchList
, *groupSearchList
;
93 typedef DataSearch
<Basemenu
> MenuSearch
;
94 LinkedList
<MenuSearch
> *menuSearchList
;
95 typedef DataSearch
<Toolbar
> ToolbarSearch
;
96 LinkedList
<ToolbarSearch
> *toolbarSearchList
;
99 typedef DataSearch
<Slit
> SlitSearch
;
100 LinkedList
<SlitSearch
> *slitSearchList
;
103 LinkedList
<MenuTimestamp
> *menuTimestamps
;
104 LinkedList
<BScreen
> *screenList
;
106 BScreen
*focused_screen
;
107 OpenboxWindow
*masked_window
;
112 #endif // HAVE_GETPID
114 Bool no_focus
, reconfigure_wait
, reread_menu_wait
;
117 char *rc_file
, **argv
;
125 void real_rereadMenu();
126 void real_reconfigure();
128 virtual void process_event(XEvent
*);
132 Openbox(int, char **, char * = 0, char * = 0);
136 inline const Atom
&getOpenboxPidAtom() const { return openbox_pid
; }
137 #endif // HAVE_GETPID
139 Basemenu
*searchMenu(Window
);
141 OpenboxWindow
*searchGroup(Window
, OpenboxWindow
*);
142 OpenboxWindow
*searchWindow(Window
);
143 OpenboxWindow
*focusedWindow();
144 void focusWindow(OpenboxWindow
*w
);
146 BScreen
*getScreen(int);
147 BScreen
*searchScreen(Window
);
149 inline Resource
&getConfig() {
152 inline const Time
&getDoubleClickInterval() const
153 { return resource
.double_click_interval
; }
154 inline const Time
&getLastTime() const { return last_time
; }
156 Toolbar
*searchToolbar(Window
);
158 inline const char *getStyleFilename() const
159 { return resource
.style_file
; }
160 inline const char *getMenuFilename() const
161 { return resource
.menu_file
; }
163 inline const int &getColorsPerChannel() const
164 { return resource
.colors_per_channel
; }
166 inline const timeval
&getAutoRaiseDelay() const
167 { return resource
.auto_raise_delay
; }
169 inline const char *getTitleBarLayout() const
170 { return resource
.titlebar_layout
; }
172 inline const unsigned long &getCacheLife() const
173 { return resource
.cache_life
; }
174 inline const unsigned long &getCacheMax() const
175 { return resource
.cache_max
; }
177 inline OpenboxWindow
*getMaskedWindow() const
178 { return masked_window
; }
179 inline void maskWindowEvents(Window w
, OpenboxWindow
*bw
)
180 { masked
= w
; masked_window
= bw
; }
181 inline void setNoFocus(Bool f
) { no_focus
= f
; }
184 void setStyleFilename(const char *);
185 void setMenuFilename(const char *);
186 void saveMenuSearch(Window
, Basemenu
*);
187 void saveWindowSearch(Window
, OpenboxWindow
*);
188 void saveToolbarSearch(Window
, Toolbar
*);
189 void saveGroupSearch(Window
, OpenboxWindow
*);
190 void removeMenuSearch(Window
);
191 void removeWindowSearch(Window
);
192 void removeToolbarSearch(Window
);
193 void removeGroupSearch(Window
);
194 void restart(const char * = 0);
199 virtual Bool
handleSignal(int);
201 virtual void timeout();
204 Slit
*searchSlit(Window
);
206 void saveSlitSearch(Window
, Slit
*);
207 void removeSlitSearch(Window
);
210 #ifndef HAVE_STRFTIME
212 enum { B_AmericanDate
= 1, B_EuropeanDate
};
213 #endif // HAVE_STRFTIME
217 #endif // __openbox_hh