diff options
Diffstat (limited to 'src/fluxbox.hh')
-rw-r--r-- | src/fluxbox.hh | 120 |
1 files changed, 65 insertions, 55 deletions
diff --git a/src/fluxbox.hh b/src/fluxbox.hh index 95be304..4ba3e67 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.13 2002/03/01 15:28:56 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,8 +45,13 @@ | |||
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 | #ifndef _RESOURCE_HH_ |
49 | class Fluxbox; | 49 | #include "Resource.hh" |
50 | #endif | ||
51 | |||
52 | #ifndef _KEYS_HH_ | ||
53 | #include "Keys.hh" | ||
54 | #endif | ||
50 | 55 | ||
51 | #ifndef _BASEDISPLAY_HH_ | 56 | #ifndef _BASEDISPLAY_HH_ |
52 | #include "BaseDisplay.hh" | 57 | #include "BaseDisplay.hh" |
@@ -76,10 +81,6 @@ class Fluxbox; | |||
76 | #include "Toolbar.hh" | 81 | #include "Toolbar.hh" |
77 | #endif | 82 | #endif |
78 | 83 | ||
79 | #ifndef _KEYS_HH_ | ||
80 | #include "Keys.hh" | ||
81 | #endif | ||
82 | |||
83 | #ifdef SLIT | 84 | #ifdef SLIT |
84 | # include "Slit.hh" | 85 | # include "Slit.hh" |
85 | #endif // SLIT | 86 | #endif // SLIT |
@@ -93,11 +94,10 @@ public: | |||
93 | 94 | ||
94 | static Fluxbox *instance(int m_argc=0, char **m_argv=0, char *dpy_name=0, char *rc=0); | 95 | static Fluxbox *instance(int m_argc=0, char **m_argv=0, char *dpy_name=0, char *rc=0); |
95 | 96 | ||
96 | inline bool useTabs() const { return resource.tabs; } | 97 | inline bool useTabs() { return *m_rc_tabs; } |
97 | // inline TabType &getTabType() { return resource.tabtype; } | 98 | inline bool useIconBar() { return *m_rc_iconbar; } |
98 | inline bool useIconBar() const { return resource.iconbar; } | 99 | inline void saveTabs(bool value) { *m_rc_tabs = value; } |
99 | inline void saveTabs(bool value) { resource.tabs = value; } | 100 | inline void saveIconBar(bool value) { m_rc_iconbar = value; } |
100 | inline void saveIconBar(bool value) { resource.iconbar = value; } | ||
101 | #ifdef HAVE_GETPID | 101 | #ifdef HAVE_GETPID |
102 | inline const Atom &getFluxboxPidAtom(void) const { return fluxbox_pid; } | 102 | inline const Atom &getFluxboxPidAtom(void) const { return fluxbox_pid; } |
103 | #ifdef KDE | 103 | #ifdef KDE |
@@ -123,30 +123,26 @@ public: | |||
123 | Toolbar *searchToolbar(Window); | 123 | Toolbar *searchToolbar(Window); |
124 | Tab *searchTab(Window); | 124 | Tab *searchTab(Window); |
125 | 125 | ||
126 | enum Titlebar{Shade=0, Minimize, Maximize, Close, Stick, Menu, Empty}; | 126 | enum Titlebar{SHADE=0, MINIMIZE, MAXIMIZE, CLOSE, STICK, MENU, EMPTY}; |
127 | 127 | ||
128 | inline const std::vector<Fluxbox::Titlebar>& getTitlebarRight() { return titlebar.right; } | 128 | inline const std::vector<Fluxbox::Titlebar>& getTitlebarRight() { return *m_rc_titlebar_right; } |
129 | inline const std::vector<Fluxbox::Titlebar>& getTitlebarLeft() { return titlebar.left; } | 129 | inline const std::vector<Fluxbox::Titlebar>& getTitlebarLeft() { return *m_rc_titlebar_left; } |
130 | inline const char *getStyleFilename(void) const | 130 | inline const char *getStyleFilename(void) |
131 | { return resource.style_file; } | 131 | { return m_rc_stylefile->c_str(); } |
132 | inline const char *getRootCommand() const | 132 | |
133 | { return resource.root_cmd; } | 133 | inline const char *getMenuFilename(void) |
134 | inline const char *getMenuFilename(void) const | 134 | { return m_rc_menufile->c_str(); } |
135 | { return resource.menu_file; } | 135 | |
136 | 136 | inline const int &getColorsPerChannel(void) | |
137 | inline const int &getColorsPerChannel(void) const | 137 | { return *m_rc_colors_per_channel; } |
138 | { return resource.colors_per_channel; } | ||
139 | 138 | ||
140 | inline const timeval &getAutoRaiseDelay(void) const | 139 | inline const timeval &getAutoRaiseDelay(void) const |
141 | { return resource.auto_raise_delay; } | 140 | { return resource.auto_raise_delay; } |
142 | 141 | ||
143 | inline const unsigned long &getCacheLife(void) const | 142 | inline const unsigned int getCacheLife(void) |
144 | { return resource.cache_life; } | 143 | { return *m_rc_cache_life * 60000; } |
145 | inline const unsigned long &getCacheMax(void) const | 144 | inline const unsigned int getCacheMax(void) |
146 | { return resource.cache_max; } | 145 | { return *m_rc_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 | 146 | ||
151 | inline void maskWindowEvents(Window w, FluxboxWindow *bw) | 147 | inline void maskWindowEvents(Window w, FluxboxWindow *bw) |
152 | { masked = w; masked_window = bw; } | 148 | { masked = w; masked_window = bw; } |
@@ -155,8 +151,9 @@ public: | |||
155 | void setFocusedWindow(FluxboxWindow *w); | 151 | void setFocusedWindow(FluxboxWindow *w); |
156 | void shutdown(void); | 152 | void shutdown(void); |
157 | void load_rc(BScreen *); | 153 | void load_rc(BScreen *); |
154 | void loadRootCommand(BScreen *); | ||
158 | void loadTitlebar(); | 155 | void loadTitlebar(); |
159 | void saveStyleFilename(const char *); | 156 | void saveStyleFilename(const char *val) { m_rc_stylefile = (val == 0 ? "" : val); } |
160 | void saveMenuFilename(const char *); | 157 | void saveMenuFilename(const char *); |
161 | void saveTitlebarFilename(const char *); | 158 | void saveTitlebarFilename(const char *); |
162 | void saveMenuSearch(Window, Basemenu *); | 159 | void saveMenuSearch(Window, Basemenu *); |
@@ -188,7 +185,7 @@ public: | |||
188 | 185 | ||
189 | #ifndef HAVE_STRFTIME | 186 | #ifndef HAVE_STRFTIME |
190 | 187 | ||
191 | enum { B_AmericanDate = 1, B_EuropeanDate }; | 188 | enum { B_AMERICANDATE = 1, B_EUROPEANDATE }; |
192 | #endif // HAVE_STRFTIME | 189 | #endif // HAVE_STRFTIME |
193 | 190 | ||
194 | template <class Z> | 191 | template <class Z> |
@@ -205,32 +202,43 @@ public: | |||
205 | inline Z *getData(void) { return data; } | 202 | inline Z *getData(void) { return data; } |
206 | }; | 203 | }; |
207 | 204 | ||
205 | typedef std::vector<Fluxbox::Titlebar> TitlebarList; | ||
208 | 206 | ||
209 | private: | 207 | private: |
208 | void setupConfigFiles(); | ||
209 | void handleButtonEvent(XButtonEvent &be); | ||
210 | void handleUnmapNotify(XUnmapEvent &ue); | ||
211 | void handleClientMessage(XClientMessageEvent &ce); | ||
212 | void handleKeyEvent(XKeyEvent &ke); | ||
213 | void doWindowAction(Keys::KeyAction action, const int param); | ||
214 | #ifdef GNOME | ||
215 | bool checkGnomeAtoms(XClientMessageEvent &ce); | ||
216 | #endif | ||
217 | #ifdef NEWWMSPEC | ||
218 | bool checkNETWMAtoms(XClientMessageEvent &ce); | ||
219 | #endif | ||
210 | typedef struct MenuTimestamp { | 220 | typedef struct MenuTimestamp { |
211 | char *filename; | 221 | char *filename; |
212 | time_t timestamp; | 222 | time_t timestamp; |
213 | } MenuTimestamp; | 223 | } MenuTimestamp; |
214 | 224 | ||
215 | struct resource { | 225 | struct resource { |
216 | Time double_click_interval; | 226 | 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; | 227 | 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; | 228 | } resource; |
229 | |||
230 | ResourceManager m_resourcemanager, m_screen_rm; | ||
226 | 231 | ||
227 | struct titlebar_t { | 232 | //--- Resources |
228 | std::vector<Fluxbox::Titlebar> left; | 233 | Resource<bool> m_rc_tabs, m_rc_iconbar; |
229 | std::vector<Fluxbox::Titlebar> right; | 234 | Resource<int> m_rc_colors_per_channel; |
230 | }; | 235 | Resource<std::string> m_rc_stylefile, |
236 | m_rc_menufile, m_rc_keyfile; | ||
231 | 237 | ||
232 | titlebar_t titlebar; | 238 | Resource<TitlebarList> m_rc_titlebar_left, m_rc_titlebar_right; |
233 | std::vector<std::string> parseTitleArgs(const char *arg); | 239 | Resource<unsigned int> m_rc_cache_life, m_rc_cache_max; |
240 | |||
241 | //std::vector<std::string> parseTitleArgs(const char *arg); | ||
234 | void setTitlebar(std::vector<Fluxbox::Titlebar>& dir, const char *arg); | 242 | void setTitlebar(std::vector<Fluxbox::Titlebar>& dir, const char *arg); |
235 | 243 | ||
236 | typedef DataSearch<FluxboxWindow> WindowSearch; | 244 | typedef DataSearch<FluxboxWindow> WindowSearch; |
@@ -262,14 +270,15 @@ private: | |||
262 | Atom fluxbox_pid; | 270 | Atom fluxbox_pid; |
263 | #endif // HAVE_GETPID | 271 | #endif // HAVE_GETPID |
264 | 272 | ||
265 | Bool no_focus, reconfigure_wait, reread_menu_wait; | 273 | bool no_focus, reconfigure_wait, reread_menu_wait; |
266 | Time last_time; | 274 | Time last_time; |
267 | Window masked; | 275 | Window masked; |
268 | char *rc_file, **argv; | 276 | char *rc_file, **argv; |
269 | int argc; | 277 | int argc; |
270 | Keys *key; | 278 | Keys *key; |
271 | char *expandFilename(char *filename); | 279 | //default arguments for titlebar left and right |
272 | void doWindowAction(Keys::KeyAction action); | 280 | static Fluxbox::Titlebar m_titlebar_left[], m_titlebar_right[]; |
281 | |||
273 | protected: | 282 | protected: |
274 | Fluxbox(int, char **, char * = 0, char * = 0); | 283 | Fluxbox(int, char **, char * = 0, char * = 0); |
275 | char *getRcFilename(); | 284 | char *getRcFilename(); |
@@ -281,6 +290,7 @@ protected: | |||
281 | 290 | ||
282 | virtual void process_event(XEvent *); | 291 | virtual void process_event(XEvent *); |
283 | //only main should be able to creat new blackbox object | 292 | //only main should be able to creat new blackbox object |
293 | //TODO this must be removed! | ||
284 | friend int main(int,char **); | 294 | friend int main(int,char **); |
285 | static Fluxbox *singleton; //singleton object ( can only be destroyed by main ) | 295 | static Fluxbox *singleton; //singleton object ( can only be destroyed by main ) |
286 | virtual ~Fluxbox(void); | 296 | virtual ~Fluxbox(void); |