aboutsummaryrefslogtreecommitdiff
path: root/src/fluxbox.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/fluxbox.hh')
-rw-r--r--src/fluxbox.hh181
1 files changed, 72 insertions, 109 deletions
diff --git a/src/fluxbox.hh b/src/fluxbox.hh
index 95be304..73daa94 100644
--- a/src/fluxbox.hh
+++ b/src/fluxbox.hh
@@ -1,6 +1,6 @@
1// fluxbox.hh for fluxbox 1// fluxbox.hh for Fluxbox Window Manager
2// Copyright (c) 2001 Henrik Kinnunen (fluxgen@linuxmail.org) 2// Copyright (c) 2001 - 2002 Henrik Kinnunen (fluxgen@linuxmail.org)
3 3//
4// blackbox.hh for Blackbox - an X11 Window manager 4// blackbox.hh for Blackbox - an X11 Window manager
5// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) 5// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
6// 6//
@@ -22,10 +22,10 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: fluxbox.hh,v 1.19 2002/05/17 11:07:36 fluxgen Exp $
25 26
26 27#ifndef FLUXBOX_HH
27#ifndef _FLUXBOX_HH_ 28#define FLUXBOX_HH
28#define _FLUXBOX_HH_
29 29
30#include <X11/Xlib.h> 30#include <X11/Xlib.h>
31#include <X11/Xresource.h> 31#include <X11/Xresource.h>
@@ -45,47 +45,22 @@
45# endif // HAVE_SYS_TIME_H 45# endif // HAVE_SYS_TIME_H
46#endif // TIME_WITH_SYS_TIME 46#endif // TIME_WITH_SYS_TIME
47 47
48//forward declaration 48#include "Resource.hh"
49class Fluxbox; 49#include "Keys.hh"
50
51#ifndef _BASEDISPLAY_HH_
52#include "BaseDisplay.hh" 50#include "BaseDisplay.hh"
53#endif
54
55#ifndef _IMAGE_HH_
56#include "Image.hh" 51#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" 52#include "Timer.hh"
65#endif
66
67#ifndef _WINDOW_HH_
68#include "Window.hh" 53#include "Window.hh"
69#endif
70
71#ifndef _TAB_HH_
72#include "Tab.hh" 54#include "Tab.hh"
73#endif
74
75#ifndef _TOOLBAR_HH_
76#include "Toolbar.hh" 55#include "Toolbar.hh"
77#endif
78
79#ifndef _KEYS_HH_
80#include "Keys.hh"
81#endif
82
83#ifdef SLIT 56#ifdef SLIT
84# include "Slit.hh" 57# include "Slit.hh"
85#endif // SLIT 58#endif // SLIT
86 59
87#include <string> 60#include <string>
88#include <vector> 61#include <vector>
62#include <map>
63#include <list>
89 64
90class Fluxbox : public BaseDisplay, public TimeoutHandler { 65class Fluxbox : public BaseDisplay, public TimeoutHandler {
91public: 66public:
@@ -93,11 +68,10 @@ public:
93 68
94 static Fluxbox *instance(int m_argc=0, char **m_argv=0, char *dpy_name=0, char *rc=0); 69 static Fluxbox *instance(int m_argc=0, char **m_argv=0, char *dpy_name=0, char *rc=0);
95 70
96 inline bool useTabs() const { return resource.tabs; } 71 inline bool useTabs() { return *m_rc_tabs; }
97// inline TabType &getTabType() { return resource.tabtype; } 72 inline bool useIconBar() { return *m_rc_iconbar; }
98 inline bool useIconBar() const { return resource.iconbar; } 73 inline void saveTabs(bool value) { *m_rc_tabs = value; }
99 inline void saveTabs(bool value) { resource.tabs = value; } 74 inline void saveIconBar(bool value) { m_rc_iconbar = value; }
100 inline void saveIconBar(bool value) { resource.iconbar = value; }
101#ifdef HAVE_GETPID 75#ifdef HAVE_GETPID
102 inline const Atom &getFluxboxPidAtom(void) const { return fluxbox_pid; } 76 inline const Atom &getFluxboxPidAtom(void) const { return fluxbox_pid; }
103 #ifdef KDE 77 #ifdef KDE
@@ -123,30 +97,20 @@ public:
123 Toolbar *searchToolbar(Window); 97 Toolbar *searchToolbar(Window);
124 Tab *searchTab(Window); 98 Tab *searchTab(Window);
125 99
126 enum Titlebar{Shade=0, Minimize, Maximize, Close, Stick, Menu, Empty}; 100 enum Titlebar{SHADE=0, MINIMIZE, MAXIMIZE, CLOSE, STICK, MENU, EMPTY};
127 101
128 inline const std::vector<Fluxbox::Titlebar>& getTitlebarRight() { return titlebar.right; } 102 inline const std::vector<Fluxbox::Titlebar>& getTitlebarRight() { return *m_rc_titlebar_right; }
129 inline const std::vector<Fluxbox::Titlebar>& getTitlebarLeft() { return titlebar.left; } 103 inline const std::vector<Fluxbox::Titlebar>& getTitlebarLeft() { return *m_rc_titlebar_left; }
130 inline const char *getStyleFilename(void) const 104 inline const char *getStyleFilename(void) const { return m_rc_stylefile->c_str(); }
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 105
137 inline const int &getColorsPerChannel(void) const 106 inline const char *getMenuFilename(void) const { return m_rc_menufile->c_str(); }
138 { return resource.colors_per_channel; }
139 107
140 inline const timeval &getAutoRaiseDelay(void) const 108 inline int getColorsPerChannel(void) const { return *m_rc_colors_per_channel; }
141 { return resource.auto_raise_delay; }
142 109
143 inline const unsigned long &getCacheLife(void) const 110 inline const timeval &getAutoRaiseDelay(void) const { return resource.auto_raise_delay; }
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 111
112 inline unsigned int getCacheLife(void) const { return *m_rc_cache_life * 60000; }
113 inline unsigned int getCacheMax(void) const { return *m_rc_cache_max; }
150 114
151 inline void maskWindowEvents(Window w, FluxboxWindow *bw) 115 inline void maskWindowEvents(Window w, FluxboxWindow *bw)
152 { masked = w; masked_window = bw; } 116 { masked = w; masked_window = bw; }
@@ -155,8 +119,9 @@ public:
155 void setFocusedWindow(FluxboxWindow *w); 119 void setFocusedWindow(FluxboxWindow *w);
156 void shutdown(void); 120 void shutdown(void);
157 void load_rc(BScreen *); 121 void load_rc(BScreen *);
122 void loadRootCommand(BScreen *);
158 void loadTitlebar(); 123 void loadTitlebar();
159 void saveStyleFilename(const char *); 124 void saveStyleFilename(const char *val) { m_rc_stylefile = (val == 0 ? "" : val); }
160 void saveMenuFilename(const char *); 125 void saveMenuFilename(const char *);
161 void saveTitlebarFilename(const char *); 126 void saveTitlebarFilename(const char *);
162 void saveMenuSearch(Window, Basemenu *); 127 void saveMenuSearch(Window, Basemenu *);
@@ -164,6 +129,7 @@ public:
164 void saveToolbarSearch(Window, Toolbar *); 129 void saveToolbarSearch(Window, Toolbar *);
165 void saveTabSearch(Window, Tab *); 130 void saveTabSearch(Window, Tab *);
166 void saveGroupSearch(Window, FluxboxWindow *); 131 void saveGroupSearch(Window, FluxboxWindow *);
132 void save_rc(void);
167 void removeMenuSearch(Window); 133 void removeMenuSearch(Window);
168 void removeWindowSearch(Window); 134 void removeWindowSearch(Window);
169 void removeToolbarSearch(Window); 135 void removeToolbarSearch(Window);
@@ -188,99 +154,96 @@ public:
188 154
189#ifndef HAVE_STRFTIME 155#ifndef HAVE_STRFTIME
190 156
191 enum { B_AmericanDate = 1, B_EuropeanDate }; 157 enum { B_AMERICANDATE = 1, B_EUROPEANDATE };
192#endif // HAVE_STRFTIME 158#endif // HAVE_STRFTIME
193 159
194 template <class Z> 160 typedef std::vector<Fluxbox::Titlebar> TitlebarList;
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 161
209private: 162private:
163 void setupConfigFiles();
164 void handleButtonEvent(XButtonEvent &be);
165 void handleUnmapNotify(XUnmapEvent &ue);
166 void handleClientMessage(XClientMessageEvent &ce);
167 void handleKeyEvent(XKeyEvent &ke);
168 void doWindowAction(Keys::KeyAction action, const int param);
169 #ifdef GNOME
170 bool checkGnomeAtoms(XClientMessageEvent &ce);
171 #endif
172 #ifdef NEWWMSPEC
173 bool checkNETWMAtoms(XClientMessageEvent &ce);
174 #endif
210 typedef struct MenuTimestamp { 175 typedef struct MenuTimestamp {
211 char *filename; 176 char *filename;
212 time_t timestamp; 177 time_t timestamp;
213 } MenuTimestamp; 178 } MenuTimestamp;
214 179
215 struct resource { 180 struct resource {
216 Time double_click_interval; 181 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; 182 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; 183 } resource;
184
185 ResourceManager m_resourcemanager, m_screen_rm;
226 186
227 struct titlebar_t { 187 //--- Resources
228 std::vector<Fluxbox::Titlebar> left; 188 Resource<bool> m_rc_tabs, m_rc_iconbar;
229 std::vector<Fluxbox::Titlebar> right; 189 Resource<int> m_rc_colors_per_channel;
230 }; 190 Resource<std::string> m_rc_stylefile,
191 m_rc_menufile, m_rc_keyfile;
231 192
232 titlebar_t titlebar; 193 Resource<TitlebarList> m_rc_titlebar_left, m_rc_titlebar_right;
233 std::vector<std::string> parseTitleArgs(const char *arg); 194 Resource<unsigned int> m_rc_cache_life, m_rc_cache_max;
195
196 //std::vector<std::string> parseTitleArgs(const char *arg);
234 void setTitlebar(std::vector<Fluxbox::Titlebar>& dir, const char *arg); 197 void setTitlebar(std::vector<Fluxbox::Titlebar>& dir, const char *arg);
235 198
236 typedef DataSearch<FluxboxWindow> WindowSearch; 199 std::map<Window, FluxboxWindow *> windowSearch;
237 LinkedList<WindowSearch> *windowSearchList, *groupSearchList; 200 std::map<Window, FluxboxWindow *> groupSearch;
238 typedef DataSearch<Basemenu> MenuSearch; 201 std::map<Window, Basemenu *> menuSearch;
239 LinkedList<MenuSearch> *menuSearchList; 202 std::map<Window, Toolbar *> toolbarSearch;
240 typedef DataSearch<Toolbar> ToolbarSearch; 203 typedef std::map<Window, Tab *> TabList;
241 LinkedList<ToolbarSearch> *toolbarSearchList; 204 TabList tabSearch;
242 typedef DataSearch<Tab> TabSearch;
243 LinkedList<TabSearch> *tabSearchList;
244 205
245#ifdef SLIT 206#ifdef SLIT
246 typedef DataSearch<Slit> SlitSearch; 207 std::map<Window, Slit *> slitSearch;
247 LinkedList<SlitSearch> *slitSearchList; 208#ifdef KDE
248 #ifdef KDE
249 //For KDE dock applets 209 //For KDE dock applets
250 Atom kwm1_dockwindow; //KDE v1.x 210 Atom kwm1_dockwindow; //KDE v1.x
251 Atom kwm2_dockwindow; //KDE v2.x 211 Atom kwm2_dockwindow; //KDE v2.x
252 #endif//KDE 212#endif//KDE
253#endif // SLIT 213#endif // SLIT
254 214
255 LinkedList<MenuTimestamp> *menuTimestamps; 215 std::list<MenuTimestamp *> menuTimestamps;
256 LinkedList<BScreen> *screenList; 216 typedef std::list<BScreen *> ScreenList;
217 ScreenList screenList;
257 218
258 FluxboxWindow *focused_window, *masked_window; 219 FluxboxWindow *focused_window, *masked_window;
259 BTimer *timer; 220 BTimer timer;
260 221
261#ifdef HAVE_GETPID 222#ifdef HAVE_GETPID
262 Atom fluxbox_pid; 223 Atom fluxbox_pid;
263#endif // HAVE_GETPID 224#endif // HAVE_GETPID
264 225
265 Bool no_focus, reconfigure_wait, reread_menu_wait; 226 bool no_focus, reconfigure_wait, reread_menu_wait;
266 Time last_time; 227 Time last_time;
267 Window masked; 228 Window masked;
268 char *rc_file, **argv; 229 char *rc_file, **argv;
269 int argc; 230 int argc;
270 Keys *key; 231 Keys *key;
271 char *expandFilename(char *filename); 232 //default arguments for titlebar left and right
272 void doWindowAction(Keys::KeyAction action); 233 static Fluxbox::Titlebar m_titlebar_left[], m_titlebar_right[];
234
273protected: 235protected:
274 Fluxbox(int, char **, char * = 0, char * = 0); 236 Fluxbox(int, char **, char * = 0, char * = 0);
275 char *getRcFilename(); 237 char *getRcFilename();
276 void load_rc(void); 238 void load_rc(void);
277 void save_rc(void); 239
278 void reload_rc(void); 240 void reload_rc(void);
279 void real_rereadMenu(void); 241 void real_rereadMenu(void);
280 void real_reconfigure(void); 242 void real_reconfigure(void);
281 243
282 virtual void process_event(XEvent *); 244 virtual void process_event(XEvent *);
283 //only main should be able to creat new blackbox object 245 //only main should be able to creat new blackbox object
246 //TODO this must be removed!
284 friend int main(int,char **); 247 friend int main(int,char **);
285 static Fluxbox *singleton; //singleton object ( can only be destroyed by main ) 248 static Fluxbox *singleton; //singleton object ( can only be destroyed by main )
286 virtual ~Fluxbox(void); 249 virtual ~Fluxbox(void);