]> Dogcows Code - chaz/openbox/blob - src/openbox.h
fix compiling with --disable-nls
[chaz/openbox] / src / openbox.h
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)
4 //
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:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
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.
22
23 #ifndef __openbox_hh
24 #define __openbox_hh
25
26 #include <X11/Xlib.h>
27 #include <X11/Xresource.h>
28
29 #ifdef HAVE_STDIO_H
30 # include <stdio.h>
31 #endif // HAVE_STDIO_H
32
33 #ifdef TIME_WITH_SYS_TIME
34 # include <sys/time.h>
35 # include <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
40 # include <time.h>
41 # endif // HAVE_SYS_TIME_H
42 #endif // TIME_WITH_SYS_TIME
43
44 #include "Resource.h"
45 #include "BaseDisplay.h"
46 #include "Timer.h"
47
48 #include <map>
49 #include <list>
50 #include <vector>
51
52 //forward declaration
53 class BScreen;
54 class Openbox;
55 class BImageControl;
56 class OpenboxWindow;
57 class Basemenu;
58 class Toolbar;
59 #ifdef SLIT
60 class Slit;
61 #endif // SLIT
62
63 template <class Z>
64 class DataSearch {
65 private:
66 Window window;
67 Z *data;
68
69 public:
70 DataSearch(Window w, Z *d): window(w), data(d) {}
71
72 inline const Window &getWindow() const { return window; }
73 inline Z *getData() { return data; }
74 };
75
76
77 class Openbox : public BaseDisplay, public TimeoutHandler {
78 private:
79 typedef struct MenuTimestamp {
80 virtual ~MenuTimestamp() {
81 if (filename != (char *) 0)
82 delete [] filename;
83 }
84 char *filename;
85 time_t timestamp;
86 } MenuTimestamp;
87
88 struct resource {
89 Time double_click_interval;
90
91 char *style_file;
92 char *titlebar_layout;
93 int colors_per_channel;
94 timeval auto_raise_delay;
95 unsigned long cache_life, cache_max;
96 } resource;
97
98 typedef std::map<Window, OpenboxWindow*> WindowLookup;
99 typedef WindowLookup::value_type WindowLookupPair;
100 WindowLookup windowSearchList, groupSearchList;
101
102 typedef std::map<Window, Basemenu*> MenuLookup;
103 typedef MenuLookup::value_type MenuLookupPair;
104 MenuLookup menuSearchList;
105
106 typedef std::map<Window, Toolbar*> ToolbarLookup;
107 typedef ToolbarLookup::value_type ToolbarLookupPair;
108 ToolbarLookup toolbarSearchList;
109
110 #ifdef SLIT
111 typedef std::map<Window, Slit*> SlitLookup;
112 typedef SlitLookup::value_type SlitLookupPair;
113 SlitLookup slitSearchList;
114 #endif // SLIT
115
116 typedef std::list<MenuTimestamp*> MenuTimestampList;
117 MenuTimestampList menuTimestamps;
118
119 typedef std::vector<BScreen*> ScreenList;
120 ScreenList screenList;
121
122 BScreen *current_screen;
123 OpenboxWindow *masked_window;
124 BTimer *timer;
125
126 #ifdef HAVE_GETPID
127 Atom openbox_pid;
128 #endif // HAVE_GETPID
129
130 Bool no_focus, reconfigure_wait, reread_menu_wait;
131 Time last_time;
132 Window masked;
133 char *menu_file, *rc_file, **argv;
134 int argc;
135 Resource config;
136
137
138 protected:
139 void load();
140 void save();
141 void real_rereadMenu();
142 void real_reconfigure();
143
144 virtual void process_event(XEvent *);
145
146
147 public:
148 Openbox(int, char **, char * = 0, char * = 0, char * = 0);
149 virtual ~Openbox();
150
151 #ifdef HAVE_GETPID
152 inline const Atom &getOpenboxPidAtom() const { return openbox_pid; }
153 #endif // HAVE_GETPID
154
155 Basemenu *searchMenu(Window);
156
157 OpenboxWindow *searchGroup(Window, OpenboxWindow *);
158 OpenboxWindow *searchWindow(Window);
159 OpenboxWindow *focusedWindow();
160 void focusWindow(OpenboxWindow *w);
161
162 inline BScreen *getScreen(unsigned int s) {
163 ASSERT(s < screenList.size());
164 return screenList[s];
165 }
166 BScreen *searchScreen(Window);
167 inline unsigned int managedScreenCount() const {
168 return screenList.size();
169 }
170
171 inline Resource &getConfig() {
172 return config;
173 }
174 inline const Time &getDoubleClickInterval() const
175 { return resource.double_click_interval; }
176 inline const Time &getLastTime() const { return last_time; }
177
178 Toolbar *searchToolbar(Window);
179
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);
185
186 inline const int &getColorsPerChannel() const
187 { return resource.colors_per_channel; }
188
189 inline const timeval &getAutoRaiseDelay() const
190 { return resource.auto_raise_delay; }
191
192 inline const char *getTitleBarLayout() const
193 { return resource.titlebar_layout; }
194
195 inline const unsigned long &getCacheLife() const
196 { return resource.cache_life; }
197 inline const unsigned long &getCacheMax() const
198 { return resource.cache_max; }
199
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; }
205
206 void shutdown();
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);
217 void reconfigure();
218 void rereadMenu();
219 void checkMenu();
220
221 virtual Bool handleSignal(int);
222
223 virtual void timeout();
224
225 #ifdef SLIT
226 Slit *searchSlit(Window);
227
228 void saveSlitSearch(Window, Slit *);
229 void removeSlitSearch(Window);
230 #endif // SLIT
231
232 #ifndef HAVE_STRFTIME
233
234 enum { B_AmericanDate = 1, B_EuropeanDate };
235 #endif // HAVE_STRFTIME
236 };
237
238
239 #endif // __openbox_hh
This page took 0.041463 seconds and 4 git commands to generate.