]> Dogcows Code - chaz/openbox/blob - src/openbox.h
took bsetroot from Blackbox moving_target.. "bsetroot now sets xrootpmap_id, pseudo...
[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 "LinkedList.h"
46 #include "BaseDisplay.h"
47 #include "Timer.h"
48
49 //forward declaration
50 class BScreen;
51 class Openbox;
52 class BImageControl;
53 class OpenboxWindow;
54 class Basemenu;
55 class Toolbar;
56 #ifdef SLIT
57 class Slit;
58 #endif // SLIT
59
60 template <class Z>
61 class DataSearch {
62 private:
63 Window window;
64 Z *data;
65
66 public:
67 DataSearch(Window w, Z *d): window(w), data(d) {}
68
69 inline const Window &getWindow() const { return window; }
70 inline Z *getData() { return data; }
71 };
72
73
74 class Openbox : public BaseDisplay, public TimeoutHandler {
75 private:
76 typedef struct MenuTimestamp {
77 char *filename;
78 time_t timestamp;
79 } MenuTimestamp;
80
81 struct resource {
82 Time double_click_interval;
83
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;
89 } resource;
90
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;
97
98 #ifdef SLIT
99 typedef DataSearch<Slit> SlitSearch;
100 LinkedList<SlitSearch> *slitSearchList;
101 #endif // SLIT
102
103 LinkedList<MenuTimestamp> *menuTimestamps;
104 LinkedList<BScreen> *screenList;
105
106 OpenboxWindow *focused_window, *masked_window;
107 BTimer *timer;
108
109 #ifdef HAVE_GETPID
110 Atom openbox_pid;
111 #endif // HAVE_GETPID
112
113 Bool no_focus, reconfigure_wait, reread_menu_wait;
114 Time last_time;
115 Window masked;
116 char *rc_file, **argv;
117 int argc;
118 Resource config;
119
120
121 protected:
122 void load();
123 void save();
124 void real_rereadMenu();
125 void real_reconfigure();
126
127 virtual void process_event(XEvent *);
128
129
130 public:
131 Openbox(int, char **, char * = 0, char * = 0);
132 virtual ~Openbox();
133
134 #ifdef HAVE_GETPID
135 inline const Atom &getOpenboxPidAtom() const { return openbox_pid; }
136 #endif // HAVE_GETPID
137
138 Basemenu *searchMenu(Window);
139
140 OpenboxWindow *searchGroup(Window, OpenboxWindow *);
141 OpenboxWindow *searchWindow(Window);
142 inline OpenboxWindow *getFocusedWindow() { return focused_window; }
143
144 BScreen *getScreen(int);
145 BScreen *searchScreen(Window);
146
147 inline Resource &getConfig() {
148 return config;
149 }
150 inline const Time &getDoubleClickInterval() const
151 { return resource.double_click_interval; }
152 inline const Time &getLastTime() const { return last_time; }
153
154 Toolbar *searchToolbar(Window);
155
156 inline const char *getStyleFilename() const
157 { return resource.style_file; }
158 inline const char *getMenuFilename() const
159 { return resource.menu_file; }
160
161 inline const int &getColorsPerChannel() const
162 { return resource.colors_per_channel; }
163
164 inline const timeval &getAutoRaiseDelay() const
165 { return resource.auto_raise_delay; }
166
167 inline const char *getTitleBarLayout() const
168 { return resource.titlebar_layout; }
169
170 inline const unsigned long &getCacheLife() const
171 { return resource.cache_life; }
172 inline const unsigned long &getCacheMax() const
173 { return resource.cache_max; }
174
175 inline void maskWindowEvents(Window w, OpenboxWindow *bw)
176 { masked = w; masked_window = bw; }
177 inline void setNoFocus(Bool f) { no_focus = f; }
178
179 void setFocusedWindow(OpenboxWindow *w);
180 void shutdown();
181 void setStyleFilename(const char *);
182 void setMenuFilename(const char *);
183 void saveMenuSearch(Window, Basemenu *);
184 void saveWindowSearch(Window, OpenboxWindow *);
185 void saveToolbarSearch(Window, Toolbar *);
186 void saveGroupSearch(Window, OpenboxWindow *);
187 void removeMenuSearch(Window);
188 void removeWindowSearch(Window);
189 void removeToolbarSearch(Window);
190 void removeGroupSearch(Window);
191 void restart(const char * = 0);
192 void reconfigure();
193 void rereadMenu();
194 void checkMenu();
195
196 virtual Bool handleSignal(int);
197
198 virtual void timeout();
199
200 #ifdef SLIT
201 Slit *searchSlit(Window);
202
203 void saveSlitSearch(Window, Slit *);
204 void removeSlitSearch(Window);
205 #endif // SLIT
206
207 #ifndef HAVE_STRFTIME
208
209 enum { B_AmericanDate = 1, B_EuropeanDate };
210 #endif // HAVE_STRFTIME
211 };
212
213
214 #endif // __openbox_hh
This page took 0.040554 seconds and 4 git commands to generate.