aboutsummaryrefslogtreecommitdiff
path: root/src/fluxbox.hh
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2001-12-11 20:47:02 (GMT)
committerfluxgen <fluxgen>2001-12-11 20:47:02 (GMT)
commit18830ac9add80cbd3bf7369307d7e35a519dca9b (patch)
tree4759a5434a34ba317fe77bbf8b0ed9bb57bb6018 /src/fluxbox.hh
parent1523b48bff07dead084af3064ad11c79a9b25df0 (diff)
downloadfluxbox-18830ac9add80cbd3bf7369307d7e35a519dca9b.zip
fluxbox-18830ac9add80cbd3bf7369307d7e35a519dca9b.tar.bz2
Initial revision
Diffstat (limited to 'src/fluxbox.hh')
-rw-r--r--src/fluxbox.hh291
1 files changed, 291 insertions, 0 deletions
diff --git a/src/fluxbox.hh b/src/fluxbox.hh
new file mode 100644
index 0000000..95be304
--- /dev/null
+++ b/src/fluxbox.hh
@@ -0,0 +1,291 @@
1// fluxbox.hh for fluxbox
2// Copyright (c) 2001 Henrik Kinnunen (fluxgen@linuxmail.org)
3
4// blackbox.hh for Blackbox - an X11 Window manager
5// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
6//
7// Permission is hereby granted, free of charge, to any person obtaining a
8// copy of this software and associated documentation files (the "Software"),
9// to deal in the Software without restriction, including without limitation
10// the rights to use, copy, modify, merge, publish, distribute, sublicense,
11// and/or sell copies of the Software, and to permit persons to whom the
12// Software is furnished to do so, subject to the following conditions:
13//
14// The above copyright notice and this permission notice shall be included in
15// all copies or substantial portions of the Software.
16//
17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE.
24
25
26
27#ifndef _FLUXBOX_HH_
28#define _FLUXBOX_HH_
29
30#include <X11/Xlib.h>
31#include <X11/Xresource.h>
32
33#ifdef HAVE_STDIO_H
34# include <stdio.h>
35#endif // HAVE_STDIO_H
36
37#ifdef TIME_WITH_SYS_TIME
38# include <sys/time.h>
39# include <time.h>
40#else // !TIME_WITH_SYS_TIME
41# ifdef HAVE_SYS_TIME_H
42# include <sys/time.h>
43# else // !HAVE_SYS_TIME_H
44# include <time.h>
45# endif // HAVE_SYS_TIME_H
46#endif // TIME_WITH_SYS_TIME
47
48//forward declaration
49class Fluxbox;
50
51#ifndef _BASEDISPLAY_HH_
52#include "BaseDisplay.hh"
53#endif
54
55#ifndef _IMAGE_HH_
56#include "Image.hh"
57#endif
58
59#ifndef _LINKEDLIST_HH_
60#include "LinkedList.hh"
61#endif
62
63#ifndef _TIMER_HH_
64#include "Timer.hh"
65#endif
66
67#ifndef _WINDOW_HH_
68#include "Window.hh"
69#endif
70
71#ifndef _TAB_HH_
72#include "Tab.hh"
73#endif
74
75#ifndef _TOOLBAR_HH_
76#include "Toolbar.hh"
77#endif
78
79#ifndef _KEYS_HH_
80#include "Keys.hh"
81#endif
82
83#ifdef SLIT
84# include "Slit.hh"
85#endif // SLIT
86
87#include <string>
88#include <vector>
89
90class Fluxbox : public BaseDisplay, public TimeoutHandler {
91public:
92
93
94 static Fluxbox *instance(int m_argc=0, char **m_argv=0, char *dpy_name=0, char *rc=0);
95
96 inline bool useTabs() const { return resource.tabs; }
97// inline TabType &getTabType() { return resource.tabtype; }
98 inline bool useIconBar() const { return resource.iconbar; }
99 inline void saveTabs(bool value) { resource.tabs = value; }
100 inline void saveIconBar(bool value) { resource.iconbar = value; }
101#ifdef HAVE_GETPID
102 inline const Atom &getFluxboxPidAtom(void) const { return fluxbox_pid; }
103 #ifdef KDE
104 //For KDE dock applets
105 inline const Atom &getKWM1DockwindowAtom(void) const { return kwm1_dockwindow; } //KDE v1.x
106 inline const Atom &getKWM2DockwindowAtom(void) const { return kwm2_dockwindow; } //KDE v2.x
107 #endif
108#endif // HAVE_GETPID
109
110 Basemenu *searchMenu(Window);
111
112 FluxboxWindow *searchGroup(Window, FluxboxWindow *);
113 FluxboxWindow *searchWindow(Window);
114 inline FluxboxWindow *getFocusedWindow(void) { return focused_window; }
115
116
117 BScreen *searchScreen(Window);
118
119 inline const Time &getDoubleClickInterval(void) const
120 { return resource.double_click_interval; }
121 inline const Time &getLastTime(void) const { return last_time; }
122
123 Toolbar *searchToolbar(Window);
124 Tab *searchTab(Window);
125
126 enum Titlebar{Shade=0, Minimize, Maximize, Close, Stick, Menu, Empty};
127
128 inline const std::vector<Fluxbox::Titlebar>& getTitlebarRight() { return titlebar.right; }
129 inline const std::vector<Fluxbox::Titlebar>& getTitlebarLeft() { return titlebar.left; }
130 inline const char *getStyleFilename(void) const
131 { return resource.style_file; }
132 inline const char *getRootCommand() const
133 { return resource.root_cmd; }
134 inline const char *getMenuFilename(void) const
135 { return resource.menu_file; }
136
137 inline const int &getColorsPerChannel(void) const
138 { return resource.colors_per_channel; }
139
140 inline const timeval &getAutoRaiseDelay(void) const
141 { return resource.auto_raise_delay; }
142
143 inline const unsigned long &getCacheLife(void) const
144 { return resource.cache_life; }
145 inline const unsigned long &getCacheMax(void) const
146 { return resource.cache_max; }
147 inline const unsigned int &getTabWidth(void) const { return resource.tabwidth; }
148 inline const unsigned int &getTabHeight(void) const { return resource.tabheight; }
149
150
151 inline void maskWindowEvents(Window w, FluxboxWindow *bw)
152 { masked = w; masked_window = bw; }
153 inline void setNoFocus(Bool f) { no_focus = f; }
154
155 void setFocusedWindow(FluxboxWindow *w);
156 void shutdown(void);
157 void load_rc(BScreen *);
158 void loadTitlebar();
159 void saveStyleFilename(const char *);
160 void saveMenuFilename(const char *);
161 void saveTitlebarFilename(const char *);
162 void saveMenuSearch(Window, Basemenu *);
163 void saveWindowSearch(Window, FluxboxWindow *);
164 void saveToolbarSearch(Window, Toolbar *);
165 void saveTabSearch(Window, Tab *);
166 void saveGroupSearch(Window, FluxboxWindow *);
167 void removeMenuSearch(Window);
168 void removeWindowSearch(Window);
169 void removeToolbarSearch(Window);
170 void removeTabSearch(Window);
171 void removeGroupSearch(Window);
172 void restart(const char * = 0);
173 void reconfigure(void);
174 void reconfigureTabs(void);
175 void rereadMenu(void);
176 void checkMenu(void);
177
178 virtual Bool handleSignal(int);
179
180 virtual void timeout(void);
181
182#ifdef SLIT
183 Slit *searchSlit(Window);
184
185 void saveSlitSearch(Window, Slit *);
186 void removeSlitSearch(Window);
187#endif // SLIT
188
189#ifndef HAVE_STRFTIME
190
191 enum { B_AmericanDate = 1, B_EuropeanDate };
192#endif // HAVE_STRFTIME
193
194 template <class Z>
195 class DataSearch {
196 private:
197 Window window;
198 Z *data;
199
200
201 public:
202 DataSearch(Window w, Z *d) { window = w; data = d; }
203
204 inline const Window &getWindow(void) const { return window; }
205 inline Z *getData(void) { return data; }
206 };
207
208
209private:
210 typedef struct MenuTimestamp {
211 char *filename;
212 time_t timestamp;
213 } MenuTimestamp;
214
215 struct resource {
216 Time double_click_interval;
217
218 char *menu_file, *style_file, *titlebar_file, *keys_file, *root_cmd;
219 int colors_per_channel;
220 timeval auto_raise_delay;
221 unsigned long cache_life, cache_max;
222 bool tabs, iconbar;
223 //TabType tabtype;
224 unsigned int tabwidth, tabheight;
225 } resource;
226
227 struct titlebar_t {
228 std::vector<Fluxbox::Titlebar> left;
229 std::vector<Fluxbox::Titlebar> right;
230 };
231
232 titlebar_t titlebar;
233 std::vector<std::string> parseTitleArgs(const char *arg);
234 void setTitlebar(std::vector<Fluxbox::Titlebar>& dir, const char *arg);
235
236 typedef DataSearch<FluxboxWindow> WindowSearch;
237 LinkedList<WindowSearch> *windowSearchList, *groupSearchList;
238 typedef DataSearch<Basemenu> MenuSearch;
239 LinkedList<MenuSearch> *menuSearchList;
240 typedef DataSearch<Toolbar> ToolbarSearch;
241 LinkedList<ToolbarSearch> *toolbarSearchList;
242 typedef DataSearch<Tab> TabSearch;
243 LinkedList<TabSearch> *tabSearchList;
244
245#ifdef SLIT
246 typedef DataSearch<Slit> SlitSearch;
247 LinkedList<SlitSearch> *slitSearchList;
248 #ifdef KDE
249 //For KDE dock applets
250 Atom kwm1_dockwindow; //KDE v1.x
251 Atom kwm2_dockwindow; //KDE v2.x
252 #endif//KDE
253#endif // SLIT
254
255 LinkedList<MenuTimestamp> *menuTimestamps;
256 LinkedList<BScreen> *screenList;
257
258 FluxboxWindow *focused_window, *masked_window;
259 BTimer *timer;
260
261#ifdef HAVE_GETPID
262 Atom fluxbox_pid;
263#endif // HAVE_GETPID
264
265 Bool no_focus, reconfigure_wait, reread_menu_wait;
266 Time last_time;
267 Window masked;
268 char *rc_file, **argv;
269 int argc;
270 Keys *key;
271 char *expandFilename(char *filename);
272 void doWindowAction(Keys::KeyAction action);
273protected:
274 Fluxbox(int, char **, char * = 0, char * = 0);
275 char *getRcFilename();
276 void load_rc(void);
277 void save_rc(void);
278 void reload_rc(void);
279 void real_rereadMenu(void);
280 void real_reconfigure(void);
281
282 virtual void process_event(XEvent *);
283 //only main should be able to creat new blackbox object
284 friend int main(int,char **);
285 static Fluxbox *singleton; //singleton object ( can only be destroyed by main )
286 virtual ~Fluxbox(void);
287
288};
289
290
291#endif // _FLUXBOX_HH_