diff options
author | Mathias Gumz <akira@fluxbox.org> | 2015-01-22 15:28:53 (GMT) |
---|---|---|
committer | Mathias Gumz <akira@fluxbox.org> | 2015-01-22 15:28:53 (GMT) |
commit | ab2eef49371b2c9e45efea128fc84f3d556d1901 (patch) | |
tree | 4054a47639da3cf7ac262b1122110d38cb3aad41 /src/fluxbox.hh | |
parent | 3cda1099e265fd8d08bf5f19a0cbd15d6ad5f0d3 (diff) | |
download | fluxbox-ab2eef49371b2c9e45efea128fc84f3d556d1901.zip fluxbox-ab2eef49371b2c9e45efea128fc84f3d556d1901.tar.bz2 |
Add -no-slit and -no-toolbar flags
Sometimes fluxbox is used as a component of a desktop environment (
e.g., the "Lumina Desktop"). It's easier and more stable for this kind
of "users" to disable the toolbar or the slit alltogether. Why not
configure these features out? Because then they would need 2 installations
of fluxbox: One without the slit and the toolbar (and perhaps other
components) and one with them.
This implements feature request #314, at least partially.
This commit also looks bigger than it actually is: I refactored and cleaned
up classes Fluxbox and BScreen.
Diffstat (limited to 'src/fluxbox.hh')
-rw-r--r-- | src/fluxbox.hh | 190 |
1 files changed, 100 insertions, 90 deletions
diff --git a/src/fluxbox.hh b/src/fluxbox.hh index d0bc239..df0335a 100644 --- a/src/fluxbox.hh +++ b/src/fluxbox.hh | |||
@@ -34,16 +34,6 @@ | |||
34 | 34 | ||
35 | #include <X11/Xresource.h> | 35 | #include <X11/Xresource.h> |
36 | 36 | ||
37 | #ifdef HAVE_CONFIG_H | ||
38 | #include "config.h" | ||
39 | #endif // HAVE_CONFIG_H | ||
40 | |||
41 | #ifdef HAVE_CSTDIO | ||
42 | #include <cstdio> | ||
43 | #else | ||
44 | #include <stdio.h> | ||
45 | #endif | ||
46 | |||
47 | #ifdef TIME_WITH_SYS_TIME | 37 | #ifdef TIME_WITH_SYS_TIME |
48 | #include <sys/time.h> | 38 | #include <sys/time.h> |
49 | #include <time.h> | 39 | #include <time.h> |
@@ -60,6 +50,7 @@ | |||
60 | #include <memory> | 50 | #include <memory> |
61 | #include <string> | 51 | #include <string> |
62 | #include <vector> | 52 | #include <vector> |
53 | #include <cstdio> | ||
63 | 54 | ||
64 | class AtomHandler; | 55 | class AtomHandler; |
65 | class FluxboxWindow; | 56 | class FluxboxWindow; |
@@ -75,61 +66,71 @@ class FbAtoms; | |||
75 | class Fluxbox : public FbTk::App, | 66 | class Fluxbox : public FbTk::App, |
76 | private FbTk::SignalTracker { | 67 | private FbTk::SignalTracker { |
77 | public: | 68 | public: |
69 | |||
70 | typedef std::list<BScreen *> ScreenList; | ||
71 | |||
72 | enum { | ||
73 | OPT_TOOLBAR = 1 << 0, | ||
74 | OPT_SLIT = 1 << 1 | ||
75 | }; | ||
76 | |||
77 | /// obsolete | ||
78 | enum TabsAttachArea{ATTACH_AREA_WINDOW= 0, ATTACH_AREA_TITLEBAR}; | ||
79 | |||
80 | |||
81 | static Fluxbox *instance(); | ||
82 | |||
83 | |||
78 | Fluxbox(int argc, char **argv, | 84 | Fluxbox(int argc, char **argv, |
79 | const std::string& dpy_name, | 85 | const std::string& dpy_name, |
80 | const std::string& rc_path, const std::string& rc_filename, | 86 | const std::string& rc_path, const std::string& rc_filename, |
81 | bool xsync = false); | 87 | bool xsync = false); |
82 | virtual ~Fluxbox(); | 88 | virtual ~Fluxbox(); |
83 | 89 | ||
84 | static Fluxbox *instance(); | ||
85 | 90 | ||
86 | /// main event loop | 91 | /// main event loop |
87 | void eventLoop(); | 92 | void eventLoop(); |
88 | bool validateWindow(Window win) const; | ||
89 | bool validateClient(const WinClient *client) const; | ||
90 | 93 | ||
91 | void grab(); | 94 | void grab(); |
92 | void ungrab(); | 95 | void ungrab(); |
93 | Keys *keys() { return m_key.get(); } | 96 | Keys *keys() { return m_key.get(); } |
94 | Atom getFluxboxPidAtom() const { return m_fluxbox_pid; } | 97 | Atom getFluxboxPidAtom() const { return m_fluxbox_pid; } |
95 | 98 | ||
96 | // Not currently implemented until we decide how it'll be used | ||
97 | //WinClient *searchGroup(Window); | ||
98 | WinClient *searchWindow(Window); | ||
99 | 99 | ||
100 | void initScreen(BScreen *screen); | 100 | void initScreen(BScreen *screen); |
101 | |||
102 | WinClient *searchWindow(Window); | ||
101 | BScreen *searchScreen(Window w); | 103 | BScreen *searchScreen(Window w); |
104 | bool validateWindow(Window win) const; | ||
105 | bool validateClient(const WinClient *client) const; | ||
106 | |||
107 | // Not currently implemented until we decide how it'll be used | ||
108 | //WinClient *searchGroup(Window); | ||
102 | 109 | ||
103 | unsigned int getDoubleClickInterval() const { return *m_rc_double_click_interval; } | ||
104 | Time getLastTime() const { return m_last_time; } | 110 | Time getLastTime() const { return m_last_time; } |
105 | 111 | ||
106 | AtomHandler *getAtomHandler(const std::string &name); | 112 | AtomHandler *getAtomHandler(const std::string &name); |
107 | void addAtomHandler(AtomHandler *atomh); | 113 | void addAtomHandler(AtomHandler *atomh); |
108 | void removeAtomHandler(AtomHandler *atomh); | 114 | void removeAtomHandler(AtomHandler *atomh); |
109 | 115 | ||
110 | /// obsolete | ||
111 | enum TabsAttachArea{ATTACH_AREA_WINDOW= 0, ATTACH_AREA_TITLEBAR}; | ||
112 | |||
113 | |||
114 | bool getIgnoreBorder() const { return *m_rc_ignoreborder; } | ||
115 | bool &getPseudoTrans() { return *m_rc_pseudotrans; } | ||
116 | |||
117 | Fluxbox::TabsAttachArea getTabsAttachArea() const { return *m_rc_tabs_attach_area; } | ||
118 | const std::string &getStyleFilename() const { return *m_rc_stylefile; } | ||
119 | const std::string &getStyleOverlayFilename() const { return *m_rc_styleoverlayfile; } | ||
120 | |||
121 | const std::string &getMenuFilename() const { return *m_rc_menufile; } | ||
122 | const std::string &getSlitlistFilename() const { return *m_rc_slitlistfile; } | ||
123 | const std::string &getAppsFilename() const { return *m_rc_appsfile; } | ||
124 | const std::string &getKeysFilename() const { return *m_rc_keyfile; } | ||
125 | int colorsPerChannel() const { return *m_rc_colors_per_channel; } | ||
126 | int getTabsPadding() const { return *m_rc_tabs_padding; } | ||
127 | |||
128 | 116 | ||
129 | time_t getAutoRaiseDelay() const { return *m_rc_auto_raise_delay; } | 117 | std::string getDefaultDataFilename(const char *name) const; |
130 | 118 | ||
131 | unsigned int getCacheLife() const { return *m_rc_cache_life * 60000; } | 119 | bool &getPseudoTrans() { return *m_config.pseudotrans; } |
132 | unsigned int getCacheMax() const { return *m_rc_cache_max; } | 120 | bool getIgnoreBorder() const { return *m_config.ignore_border; } |
121 | Fluxbox::TabsAttachArea getTabsAttachArea() const { return *m_config.tabs_attach_area; } | ||
122 | const std::string &getStyleFilename() const { return *m_config.style_file; } | ||
123 | const std::string &getStyleOverlayFilename() const { return *m_config.overlay_file; } | ||
124 | const std::string &getMenuFilename() const { return *m_config.menu_file; } | ||
125 | const std::string &getSlitlistFilename() const { return *m_config.slit_file; } | ||
126 | const std::string &getAppsFilename() const { return *m_config.apps_file; } | ||
127 | const std::string &getKeysFilename() const { return *m_config.key_file; } | ||
128 | int colorsPerChannel() const { return *m_config.colors_per_channel; } | ||
129 | int getTabsPadding() const { return *m_config.tabs_padding; } | ||
130 | unsigned int getDoubleClickInterval() const { return *m_config.double_click_interval; } | ||
131 | time_t getAutoRaiseDelay() const { return *m_config.auto_raise_delay; } | ||
132 | unsigned int getCacheLife() const { return *m_config.cache_life * 60000; } | ||
133 | unsigned int getCacheMax() const { return *m_config.cache_max; } | ||
133 | 134 | ||
134 | 135 | ||
135 | void maskWindowEvents(Window w, FluxboxWindow *bw) | 136 | void maskWindowEvents(Window w, FluxboxWindow *bw) |
@@ -137,7 +138,7 @@ public: | |||
137 | 138 | ||
138 | void shutdown(int x_wants_down = 0); | 139 | void shutdown(int x_wants_down = 0); |
139 | void load_rc(BScreen &scr); | 140 | void load_rc(BScreen &scr); |
140 | void saveStyleFilename(const char *val) { m_rc_stylefile = (val == 0 ? "" : val); } | 141 | void saveStyleFilename(const char *val) { m_config.style_file = (val == 0 ? "" : val); } |
141 | void saveWindowSearch(Window win, WinClient *winclient); | 142 | void saveWindowSearch(Window win, WinClient *winclient); |
142 | // some windows relate to the group, not the client, so we record separately | 143 | // some windows relate to the group, not the client, so we record separately |
143 | // searchWindow on these windows will give the active client in the group | 144 | // searchWindow on these windows will give the active client in the group |
@@ -162,25 +163,23 @@ public: | |||
162 | m_showing_dialog = value; if (!value) revertFocus(); | 163 | m_showing_dialog = value; if (!value) revertFocus(); |
163 | } | 164 | } |
164 | 165 | ||
165 | bool isStartup() const { return m_starting; } | 166 | bool isStartup() const { return m_state.starting; } |
166 | bool isRestarting() const { return m_restarting; } | 167 | bool isRestarting() const { return m_state.restarting; } |
167 | bool isShuttingDown() const { return m_shutdown; } | 168 | bool isShuttingDown() const { return m_state.shutdown; } |
168 | 169 | ||
169 | const std::string &getRestartArgument() const { return m_restart_argument; } | 170 | const std::string &getRestartArgument() const { return m_restart_argument; } |
170 | 171 | ||
171 | /// get screen from number | 172 | /// get screen from number |
172 | BScreen *findScreen(int num); | 173 | BScreen *findScreen(int num); |
173 | 174 | ||
174 | typedef std::list<BScreen *> ScreenList; | 175 | const ScreenList screenList() const { return m_screens; } |
175 | const ScreenList screenList() const { return m_screen_list; } | ||
176 | 176 | ||
177 | bool haveShape() const; | 177 | bool haveShape() const; |
178 | int shapeEventbase() const; | 178 | int shapeEventbase() const; |
179 | std::string getDefaultDataFilename(const char *name) const; | 179 | |
180 | // screen mouse was in at last key event | 180 | |
181 | BScreen *mouseScreen() { return m_mousescreen; } | 181 | BScreen *mouseScreen() { return m_active_screen.mouse; } |
182 | // screen of window that last key event (i.e. focused window) went to | 182 | BScreen *keyScreen() { return m_active_screen.key; } |
183 | BScreen *keyScreen() { return m_keyscreen; } | ||
184 | const XEvent &lastEvent() const { return m_last_event; } | 183 | const XEvent &lastEvent() const { return m_last_event; } |
185 | 184 | ||
186 | AttentionNoticeHandler &attentionHandler() { return m_attention_handler; } | 185 | AttentionNoticeHandler &attentionHandler() { return m_attention_handler; } |
@@ -188,11 +187,8 @@ public: | |||
188 | private: | 187 | private: |
189 | std::string getRcFilename(); | 188 | std::string getRcFilename(); |
190 | void load_rc(); | 189 | void load_rc(); |
191 | |||
192 | void real_reconfigure(); | 190 | void real_reconfigure(); |
193 | |||
194 | void handleEvent(XEvent *xe); | 191 | void handleEvent(XEvent *xe); |
195 | |||
196 | void handleUnmapNotify(XUnmapEvent &ue); | 192 | void handleUnmapNotify(XUnmapEvent &ue); |
197 | void handleClientMessage(XClientMessageEvent &ce); | 193 | void handleClientMessage(XClientMessageEvent &ce); |
198 | 194 | ||
@@ -222,33 +218,53 @@ private: | |||
222 | /// Called when a window layer changes | 218 | /// Called when a window layer changes |
223 | void windowLayerChanged(FluxboxWindow &win); | 219 | void windowLayerChanged(FluxboxWindow &win); |
224 | 220 | ||
225 | std::auto_ptr<FbAtoms> m_fbatoms; | ||
226 | 221 | ||
227 | FbTk::ResourceManager m_resourcemanager, &m_screen_rm; | 222 | typedef std::map<Window, WinClient *> WinClientMap; |
223 | typedef std::map<Window, FluxboxWindow *> WindowMap; | ||
224 | typedef std::set<AtomHandler *> AtomHandlerContainer; | ||
225 | typedef AtomHandlerContainer::iterator AtomHandlerContainerIt; | ||
228 | 226 | ||
229 | std::string m_RC_PATH; | ||
230 | 227 | ||
231 | //--- Resources | 228 | //--- Resources |
232 | 229 | ||
233 | FbTk::Resource<bool> m_rc_ignoreborder; | 230 | std::auto_ptr<FbAtoms> m_fbatoms; |
234 | FbTk::Resource<bool> m_rc_pseudotrans; | 231 | FbTk::ResourceManager m_resourcemanager; |
235 | FbTk::Resource<int> m_rc_colors_per_channel, | 232 | FbTk::ResourceManager& m_screen_rm; |
236 | m_rc_double_click_interval, | ||
237 | m_rc_tabs_padding; | ||
238 | FbTk::Resource<std::string> m_rc_stylefile, | ||
239 | m_rc_styleoverlayfile, | ||
240 | m_rc_menufile, m_rc_keyfile, m_rc_slitlistfile, | ||
241 | m_rc_appsfile; | ||
242 | 233 | ||
234 | struct Config { | ||
235 | Config(FbTk::ResourceManager& rm, const std::string& path); | ||
243 | 236 | ||
244 | FbTk::Resource<TabsAttachArea> m_rc_tabs_attach_area; | 237 | std::string path; |
245 | FbTk::Resource<unsigned int> m_rc_cache_life, m_rc_cache_max; | 238 | std::string file; |
246 | FbTk::Resource<time_t> m_rc_auto_raise_delay; | 239 | |
240 | FbTk::Resource<bool> ignore_border; | ||
241 | FbTk::Resource<bool> pseudotrans; | ||
242 | FbTk::Resource<int> colors_per_channel; | ||
243 | FbTk::Resource<int> double_click_interval; | ||
244 | FbTk::Resource<int> tabs_padding; | ||
245 | |||
246 | FbTk::Resource<std::string> style_file; | ||
247 | FbTk::Resource<std::string> overlay_file; | ||
248 | FbTk::Resource<std::string> menu_file; | ||
249 | FbTk::Resource<std::string> key_file; | ||
250 | FbTk::Resource<std::string> slit_file; | ||
251 | FbTk::Resource<std::string> apps_file; | ||
252 | |||
253 | FbTk::Resource<TabsAttachArea> tabs_attach_area; | ||
254 | FbTk::Resource<unsigned int> cache_life; | ||
255 | FbTk::Resource<unsigned int> cache_max; | ||
256 | FbTk::Resource<time_t> auto_raise_delay; | ||
257 | } m_config; | ||
258 | |||
259 | |||
260 | std::auto_ptr<Keys> m_key; | ||
261 | AtomHandlerContainer m_atomhandler; | ||
262 | AttentionNoticeHandler m_attention_handler; | ||
263 | |||
264 | ScreenList m_screens; | ||
265 | WinClientMap m_window_search; | ||
266 | WindowMap m_window_search_group; | ||
247 | 267 | ||
248 | typedef std::map<Window, WinClient *> WinClientMap; | ||
249 | WinClientMap m_window_search; | ||
250 | typedef std::map<Window, FluxboxWindow *> WindowMap; | ||
251 | WindowMap m_window_search_group; | ||
252 | // A window is the group leader, which can map to several | 268 | // A window is the group leader, which can map to several |
253 | // WinClients in the group, it is *not* fluxbox's concept of groups | 269 | // WinClients in the group, it is *not* fluxbox's concept of groups |
254 | // See ICCCM section 4.1.11 | 270 | // See ICCCM section 4.1.11 |
@@ -256,43 +272,37 @@ private: | |||
256 | // will have it's window being the group index | 272 | // will have it's window being the group index |
257 | std::multimap<Window, WinClient *> m_group_search; | 273 | std::multimap<Window, WinClient *> m_group_search; |
258 | 274 | ||
259 | ScreenList m_screen_list; | ||
260 | 275 | ||
276 | Time m_last_time; | ||
277 | XEvent m_last_event; | ||
278 | |||
279 | Window m_masked; | ||
261 | FluxboxWindow *m_masked_window; | 280 | FluxboxWindow *m_masked_window; |
262 | 281 | ||
263 | BScreen *m_mousescreen, *m_keyscreen; | 282 | struct { |
283 | BScreen* mouse; | ||
284 | BScreen* key; | ||
285 | } m_active_screen; | ||
264 | 286 | ||
265 | Atom m_fluxbox_pid; | 287 | Atom m_fluxbox_pid; |
266 | 288 | ||
267 | bool m_reconfigure_wait; | 289 | bool m_reconfigure_wait; |
268 | Time m_last_time; | ||
269 | Window m_masked; | ||
270 | std::string m_rc_file; ///< resource filename | ||
271 | char **m_argv; | 290 | char **m_argv; |
272 | int m_argc; | 291 | int m_argc; |
273 | |||
274 | std::string m_restart_argument; ///< what to restart | 292 | std::string m_restart_argument; ///< what to restart |
275 | 293 | ||
276 | XEvent m_last_event; | ||
277 | |||
278 | ///< when we execute reconfig command we must wait until next event round | 294 | ///< when we execute reconfig command we must wait until next event round |
279 | FbTk::Timer m_reconfig_timer; | 295 | FbTk::Timer m_reconfig_timer; |
280 | FbTk::Timer m_key_reload_timer; | 296 | FbTk::Timer m_key_reload_timer; |
281 | bool m_showing_dialog; | 297 | bool m_showing_dialog; |
282 | 298 | ||
283 | std::auto_ptr<Keys> m_key; | 299 | struct { |
284 | 300 | bool starting; | |
285 | typedef std::set<AtomHandler *> AtomHandlerContainer; | 301 | bool restarting; |
286 | typedef AtomHandlerContainer::iterator AtomHandlerContainerIt; | 302 | bool shutdown; |
287 | 303 | } m_state; | |
288 | AtomHandlerContainer m_atomhandler; | ||
289 | 304 | ||
290 | bool m_starting; | ||
291 | bool m_restarting; | ||
292 | bool m_shutdown; | ||
293 | int m_server_grabs; | 305 | int m_server_grabs; |
294 | |||
295 | AttentionNoticeHandler m_attention_handler; | ||
296 | }; | 306 | }; |
297 | 307 | ||
298 | 308 | ||