aboutsummaryrefslogtreecommitdiff
path: root/src/fluxbox.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/fluxbox.hh')
-rw-r--r--src/fluxbox.hh311
1 files changed, 146 insertions, 165 deletions
diff --git a/src/fluxbox.hh b/src/fluxbox.hh
index 95be304..e877805 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,88 +22,71 @@
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.27 2002/08/17 22:13:00 fluxgen Exp $
25 26
27#ifndef FLUXBOX_HH
28#define FLUXBOX_HH
26 29
27#ifndef _FLUXBOX_HH_ 30#include "Resource.hh"
28#define _FLUXBOX_HH_ 31#include "Keys.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" 32#include "BaseDisplay.hh"
53#endif
54
55#ifndef _IMAGE_HH_
56#include "Image.hh" 33#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" 34#include "Timer.hh"
65#endif
66
67#ifndef _WINDOW_HH_
68#include "Window.hh" 35#include "Window.hh"
69#endif
70
71#ifndef _TAB_HH_
72#include "Tab.hh" 36#include "Tab.hh"
73#endif
74
75#ifndef _TOOLBAR_HH_
76#include "Toolbar.hh" 37#include "Toolbar.hh"
77#endif
78 38
79#ifndef _KEYS_HH_ 39#ifdef SLIT
80#include "Keys.hh" 40#include "Slit.hh"
81#endif
82
83#ifdef SLIT
84# include "Slit.hh"
85#endif // SLIT 41#endif // SLIT
86 42
43#include "SignalHandler.hh"
44#include "FbAtoms.hh"
45
46#include <X11/Xlib.h>
47#include <X11/Xresource.h>
48
49#include <cstdio>
50
51#ifdef TIME_WITH_SYS_TIME
52#include <sys/time.h>
53#include <time.h>
54#else // !TIME_WITH_SYS_TIME
55#ifdef HAVE_SYS_TIME_H
56#include <sys/time.h>
57#else // !HAVE_SYS_TIME_H
58#include <time.h>
59#endif // HAVE_SYS_TIME_H
60#endif // TIME_WITH_SYS_TIME
61
87#include <string> 62#include <string>
88#include <vector> 63#include <vector>
89 64#include <map>
90class Fluxbox : public BaseDisplay, public TimeoutHandler { 65#include <list>
66
67/**
68 main class for the window manager.
69 singleton type
70*/
71class Fluxbox : public BaseDisplay, public TimeoutHandler,
72 public FbTk::EventHandler<FbTk::SignalEvent>,
73 public FbAtoms {
91public: 74public:
75 Fluxbox(int argc, char **argv, const char * dpy_name= 0, const char *rc = 0);
76 virtual ~Fluxbox();
92 77
78 static Fluxbox *instance() { return singleton; }
93 79
94 static Fluxbox *instance(int m_argc=0, char **m_argv=0, char *dpy_name=0, char *rc=0); 80 inline bool useTabs() { return *m_rc_tabs; }
95 81 inline bool useIconBar() { return *m_rc_iconbar; }
96 inline bool useTabs() const { return resource.tabs; } 82 inline void saveTabs(bool value) { *m_rc_tabs = value; }
97// inline TabType &getTabType() { return resource.tabtype; } 83 inline void saveIconBar(bool value) { m_rc_iconbar = value; }
98 inline bool useIconBar() const { return resource.iconbar; } 84#ifdef HAVE_GETPID
99 inline void saveTabs(bool value) { resource.tabs = value; } 85 inline Atom getFluxboxPidAtom() const { return fluxbox_pid; }
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 86 #ifdef KDE
104 //For KDE dock applets 87 //For KDE dock applets
105 inline const Atom &getKWM1DockwindowAtom(void) const { return kwm1_dockwindow; } //KDE v1.x 88 inline Atom getKWM1DockwindowAtom() const { return kwm1_dockwindow; } //KDE v1.x
106 inline const Atom &getKWM2DockwindowAtom(void) const { return kwm2_dockwindow; } //KDE v2.x 89 inline Atom getKWM2DockwindowAtom() const { return kwm2_dockwindow; } //KDE v2.x
107 #endif 90 #endif
108#endif // HAVE_GETPID 91#endif // HAVE_GETPID
109 92
@@ -111,75 +94,75 @@ public:
111 94
112 FluxboxWindow *searchGroup(Window, FluxboxWindow *); 95 FluxboxWindow *searchGroup(Window, FluxboxWindow *);
113 FluxboxWindow *searchWindow(Window); 96 FluxboxWindow *searchWindow(Window);
114 inline FluxboxWindow *getFocusedWindow(void) { return focused_window; } 97 inline FluxboxWindow *getFocusedWindow() { return focused_window; }
115 98
116 99
117 BScreen *searchScreen(Window); 100 BScreen *searchScreen(Window w);
118 101
119 inline const Time &getDoubleClickInterval(void) const 102 inline const Time &getDoubleClickInterval() const { return resource.double_click_interval; }
120 { return resource.double_click_interval; } 103 inline const Time &getLastTime() const { return last_time; }
121 inline const Time &getLastTime(void) const { return last_time; }
122 104
123 Toolbar *searchToolbar(Window); 105 Toolbar *searchToolbar(Window w);
124 Tab *searchTab(Window); 106 Tab *searchTab(Window);
125 107
126 enum Titlebar{Shade=0, Minimize, Maximize, Close, Stick, Menu, Empty}; 108 /// obsolete
109 enum Titlebar{SHADE=0, MINIMIZE, MAXIMIZE, CLOSE, STICK, MENU, EMPTY};
127 110
128 inline const std::vector<Fluxbox::Titlebar>& getTitlebarRight() { return titlebar.right; } 111 inline const std::vector<Fluxbox::Titlebar>& getTitlebarRight() { return *m_rc_titlebar_right; }
129 inline const std::vector<Fluxbox::Titlebar>& getTitlebarLeft() { return titlebar.left; } 112 inline const std::vector<Fluxbox::Titlebar>& getTitlebarLeft() { return *m_rc_titlebar_left; }
130 inline const char *getStyleFilename(void) const 113 inline const char *getStyleFilename() 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
137 inline const int &getColorsPerChannel(void) const
138 { return resource.colors_per_channel; }
139 114
140 inline const timeval &getAutoRaiseDelay(void) const 115 inline const char *getMenuFilename() const { return m_rc_menufile->c_str(); }
141 { return resource.auto_raise_delay; } 116 inline const std::string &getSlitlistFilename() const { return *m_rc_slitlistfile; }
117 inline int colorsPerChannel() const { return *m_rc_colors_per_channel; }
142 118
143 inline const unsigned long &getCacheLife(void) const 119 inline const timeval &getAutoRaiseDelay() 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 120
121 inline unsigned int getCacheLife() const { return *m_rc_cache_life * 60000; }
122 inline unsigned int getCacheMax() const { return *m_rc_cache_max; }
150 123
151 inline void maskWindowEvents(Window w, FluxboxWindow *bw) 124 inline void maskWindowEvents(Window w, FluxboxWindow *bw)
152 { masked = w; masked_window = bw; } 125 { masked = w; masked_window = bw; }
153 inline void setNoFocus(Bool f) { no_focus = f; } 126 inline void setNoFocus(Bool f) { no_focus = f; }
154 127
155 void setFocusedWindow(FluxboxWindow *w); 128 void setFocusedWindow(FluxboxWindow *w);
156 void shutdown(void); 129 void shutdown();
157 void load_rc(BScreen *); 130 void load_rc(BScreen *);
131 void loadRootCommand(BScreen *);
158 void loadTitlebar(); 132 void loadTitlebar();
159 void saveStyleFilename(const char *); 133 void saveStyleFilename(const char *val) { m_rc_stylefile = (val == 0 ? "" : val); }
160 void saveMenuFilename(const char *); 134 void saveMenuFilename(const char *);
161 void saveTitlebarFilename(const char *); 135 void saveTitlebarFilename(const char *);
136 void saveSlitlistFilename(const char *val) { m_rc_slitlistfile = (val == 0 ? "" : val); }
162 void saveMenuSearch(Window, Basemenu *); 137 void saveMenuSearch(Window, Basemenu *);
163 void saveWindowSearch(Window, FluxboxWindow *); 138 void saveWindowSearch(Window, FluxboxWindow *);
164 void saveToolbarSearch(Window, Toolbar *); 139 void saveToolbarSearch(Window, Toolbar *);
165 void saveTabSearch(Window, Tab *); 140 void saveTabSearch(Window, Tab *);
166 void saveGroupSearch(Window, FluxboxWindow *); 141 void saveGroupSearch(Window, FluxboxWindow *);
142 void save_rc();
167 void removeMenuSearch(Window); 143 void removeMenuSearch(Window);
168 void removeWindowSearch(Window); 144 void removeWindowSearch(Window);
169 void removeToolbarSearch(Window); 145 void removeToolbarSearch(Window);
170 void removeTabSearch(Window); 146 void removeTabSearch(Window);
171 void removeGroupSearch(Window); 147 void removeGroupSearch(Window);
172 void restart(const char * = 0); 148 void restart(const char * = 0);
173 void reconfigure(void); 149 void reconfigure();
174 void reconfigureTabs(void); 150 void reconfigureTabs();
175 void rereadMenu(void); 151 void rereadMenu();
176 void checkMenu(void); 152 void checkMenu();
153
154 /// handle any system signal sent to the application
155 void handleEvent(FbTk::SignalEvent * const signum);
177 156
178 virtual Bool handleSignal(int); 157 virtual void timeout();
158
159 inline const Cursor &getSessionCursor() const { return cursor.session; }
160 inline const Cursor &getMoveCursor() const { return cursor.move; }
161 inline const Cursor &getLowerLeftAngleCursor() const { return cursor.ll_angle; }
162 inline const Cursor &getLowerRightAngleCursor() const { return cursor.lr_angle; }
179 163
180 virtual void timeout(void);
181 164
182#ifdef SLIT 165#ifdef SLIT
183 Slit *searchSlit(Window); 166 Slit *searchSlit(Window);
184 167
185 void saveSlitSearch(Window, Slit *); 168 void saveSlitSearch(Window, Slit *);
@@ -188,102 +171,100 @@ public:
188 171
189#ifndef HAVE_STRFTIME 172#ifndef HAVE_STRFTIME
190 173
191 enum { B_AmericanDate = 1, B_EuropeanDate }; 174 enum { B_AMERICANDATE = 1, B_EUROPEANDATE };
192#endif // HAVE_STRFTIME 175#endif // HAVE_STRFTIME
193 176
194 template <class Z> 177 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 178
209private: 179private:
180 struct cursor {
181 Cursor session, move, ll_angle, lr_angle;
182 } cursor;
183
184 void setupConfigFiles();
185 void handleButtonEvent(XButtonEvent &be);
186 void handleUnmapNotify(XUnmapEvent &ue);
187 void handleClientMessage(XClientMessageEvent &ce);
188 void handleKeyEvent(XKeyEvent &ke);
189 void doWindowAction(Keys::KeyAction action, const int param);
190 #ifdef GNOME
191 bool checkGnomeAtoms(XClientMessageEvent &ce);
192 #endif
193 #ifdef NEWWMSPEC
194 bool checkNETWMAtoms(XClientMessageEvent &ce);
195 #endif
210 typedef struct MenuTimestamp { 196 typedef struct MenuTimestamp {
211 char *filename; 197 char *filename;
212 time_t timestamp; 198 time_t timestamp;
213 } MenuTimestamp; 199 } MenuTimestamp;
214 200
215 struct resource { 201 struct resource {
216 Time double_click_interval; 202 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; 203 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; 204 } resource;
205
206 ResourceManager m_resourcemanager, m_screen_rm;
226 207
227 struct titlebar_t { 208 //--- Resources
228 std::vector<Fluxbox::Titlebar> left; 209 Resource<bool> m_rc_tabs, m_rc_iconbar;
229 std::vector<Fluxbox::Titlebar> right; 210 Resource<int> m_rc_colors_per_channel;
230 }; 211 Resource<std::string> m_rc_stylefile,
212 m_rc_menufile, m_rc_keyfile, m_rc_slitlistfile,
213 m_rc_groupfile;
231 214
232 titlebar_t titlebar; 215 Resource<TitlebarList> m_rc_titlebar_left, m_rc_titlebar_right;
233 std::vector<std::string> parseTitleArgs(const char *arg); 216 Resource<unsigned int> m_rc_cache_life, m_rc_cache_max;
217
234 void setTitlebar(std::vector<Fluxbox::Titlebar>& dir, const char *arg); 218 void setTitlebar(std::vector<Fluxbox::Titlebar>& dir, const char *arg);
235 219
236 typedef DataSearch<FluxboxWindow> WindowSearch; 220 std::map<Window, FluxboxWindow *> windowSearch;
237 LinkedList<WindowSearch> *windowSearchList, *groupSearchList; 221 std::map<Window, FluxboxWindow *> groupSearch;
238 typedef DataSearch<Basemenu> MenuSearch; 222 std::map<Window, Basemenu *> menuSearch;
239 LinkedList<MenuSearch> *menuSearchList; 223 std::map<Window, Toolbar *> toolbarSearch;
240 typedef DataSearch<Toolbar> ToolbarSearch; 224 typedef std::map<Window, Tab *> TabList;
241 LinkedList<ToolbarSearch> *toolbarSearchList; 225 TabList tabSearch;
242 typedef DataSearch<Tab> TabSearch;
243 LinkedList<TabSearch> *tabSearchList;
244 226
245#ifdef SLIT 227#ifdef SLIT
246 typedef DataSearch<Slit> SlitSearch; 228 std::map<Window, Slit *> slitSearch;
247 LinkedList<SlitSearch> *slitSearchList; 229#ifdef KDE
248 #ifdef KDE
249 //For KDE dock applets 230 //For KDE dock applets
250 Atom kwm1_dockwindow; //KDE v1.x 231 Atom kwm1_dockwindow; //KDE v1.x
251 Atom kwm2_dockwindow; //KDE v2.x 232 Atom kwm2_dockwindow; //KDE v2.x
252 #endif//KDE 233#endif//KDE
253#endif // SLIT 234#endif // SLIT
254 235
255 LinkedList<MenuTimestamp> *menuTimestamps; 236 std::list<MenuTimestamp *> menuTimestamps;
256 LinkedList<BScreen> *screenList; 237 typedef std::list<BScreen *> ScreenList;
238 ScreenList screenList;
257 239
258 FluxboxWindow *focused_window, *masked_window; 240 FluxboxWindow *focused_window, *masked_window;
259 BTimer *timer; 241 BTimer timer;
260 242
261#ifdef HAVE_GETPID 243#ifdef HAVE_GETPID
262 Atom fluxbox_pid; 244 Atom fluxbox_pid;
263#endif // HAVE_GETPID 245#endif // HAVE_GETPID
264 246
265 Bool no_focus, reconfigure_wait, reread_menu_wait; 247 bool no_focus, reconfigure_wait, reread_menu_wait;
266 Time last_time; 248 Time last_time;
267 Window masked; 249 Window masked;
268 char *rc_file, **argv; 250 std::string rc_file; ///< resource filename
251 char **argv;
269 int argc; 252 int argc;
270 Keys *key; 253 Keys *key;
271 char *expandFilename(char *filename); 254 std::string slitlist_path;
272 void doWindowAction(Keys::KeyAction action); 255 //default arguments for titlebar left and right
273protected: 256 static Fluxbox::Titlebar m_titlebar_left[], m_titlebar_right[];
274 Fluxbox(int, char **, char * = 0, char * = 0); 257
275 char *getRcFilename(); 258 std::string getRcFilename();
276 void load_rc(void); 259 void getDefaultDataFilename(char *, std::string &);
277 void save_rc(void); 260 void load_rc();
278 void reload_rc(void); 261
279 void real_rereadMenu(void); 262 void reload_rc();
280 void real_reconfigure(void); 263 void real_rereadMenu();
281 264 void real_reconfigure();
282 virtual void process_event(XEvent *); 265
283 //only main should be able to creat new blackbox object 266 void handleEvent(XEvent *xe);
284 friend int main(int,char **); 267 static Fluxbox *singleton;
285 static Fluxbox *singleton; //singleton object ( can only be destroyed by main )
286 virtual ~Fluxbox(void);
287 268
288}; 269};
289 270