diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/FbTk/LResource.cc | 52 | ||||
-rw-r--r-- | src/FbTk/LResource.hh | 3 | ||||
-rw-r--r-- | src/Keys.cc | 2 | ||||
-rw-r--r-- | src/fluxbox.cc | 28 | ||||
-rw-r--r-- | src/fluxbox.hh | 4 |
5 files changed, 50 insertions, 39 deletions
diff --git a/src/FbTk/LResource.cc b/src/FbTk/LResource.cc index d7627c9..0909520 100644 --- a/src/FbTk/LResource.cc +++ b/src/FbTk/LResource.cc | |||
@@ -101,17 +101,8 @@ void LResourceManager::convert(ResourceManager &old, const std::string &new_file | |||
101 | } | 101 | } |
102 | 102 | ||
103 | LResourceManager::LResourceManager(const std::string &root, Lua &l) | 103 | LResourceManager::LResourceManager(const std::string &root, Lua &l) |
104 | : ResourceManager_base(root), m_l(&l) { | 104 | : ResourceManager_base(root), m_l(&l) { |
105 | l.checkstack(2); | 105 | setLua(l); |
106 | lua::stack_sentry s(l); | ||
107 | |||
108 | l.pushstring(root); | ||
109 | |||
110 | l.getfield(lua::REGISTRYINDEX, make_root); | ||
111 | l.pushstring(root); | ||
112 | l.call(1, 1); | ||
113 | |||
114 | l.readOnlySet(lua::GLOBALSINDEX); | ||
115 | } | 106 | } |
116 | 107 | ||
117 | bool LResourceManager::save(const char *filename, const char *) { | 108 | bool LResourceManager::save(const char *filename, const char *) { |
@@ -127,11 +118,20 @@ bool LResourceManager::save(const char *filename, const char *) { | |||
127 | } | 118 | } |
128 | 119 | ||
129 | void LResourceManager::addResource(Resource_base &r) { | 120 | void LResourceManager::addResource(Resource_base &r) { |
121 | ResourceManager_base::addResource(r); | ||
122 | try { | ||
123 | doAddResource(r); | ||
124 | } | ||
125 | catch(...) { | ||
126 | ResourceManager_base::removeResource(r); | ||
127 | throw; | ||
128 | } | ||
129 | } | ||
130 | |||
131 | void LResourceManager::doAddResource(Resource_base &r) { | ||
130 | m_l->checkstack(5); | 132 | m_l->checkstack(5); |
131 | lua::stack_sentry s(*m_l); | 133 | lua::stack_sentry s(*m_l); |
132 | 134 | ||
133 | ResourceManager_base::addResource(r); | ||
134 | |||
135 | m_l->getfield(lua::REGISTRYINDEX, register_resource); | 135 | m_l->getfield(lua::REGISTRYINDEX, register_resource); |
136 | m_l->getfield(lua::GLOBALSINDEX, m_root.c_str()); | 136 | m_l->getfield(lua::GLOBALSINDEX, m_root.c_str()); |
137 | m_l->pushstring(r.name()); | 137 | m_l->pushstring(r.name()); |
@@ -143,7 +143,12 @@ void LResourceManager::addResource(Resource_base &r) { | |||
143 | } | 143 | } |
144 | 144 | ||
145 | void LResourceManager::removeResource(Resource_base &r) { | 145 | void LResourceManager::removeResource(Resource_base &r) { |
146 | m_l->checkstack(5); | 146 | doRemoveResource(r); |
147 | ResourceManager_base::removeResource(r); | ||
148 | } | ||
149 | |||
150 | void LResourceManager::doRemoveResource(Resource_base &r) { | ||
151 | m_l->checkstack(4); | ||
147 | lua::stack_sentry s(*m_l); | 152 | lua::stack_sentry s(*m_l); |
148 | 153 | ||
149 | m_l->getfield(lua::REGISTRYINDEX, register_resource); | 154 | m_l->getfield(lua::REGISTRYINDEX, register_resource); |
@@ -153,8 +158,25 @@ void LResourceManager::removeResource(Resource_base &r) { | |||
153 | m_l->call(3, 1); | 158 | m_l->call(3, 1); |
154 | *static_cast<Resource_base **>(m_l->touserdata(-1)) = NULL; | 159 | *static_cast<Resource_base **>(m_l->touserdata(-1)) = NULL; |
155 | m_l->pop(); | 160 | m_l->pop(); |
161 | } | ||
156 | 162 | ||
157 | ResourceManager_base::removeResource(r); | 163 | void LResourceManager::setLua(Lua &l) { |
164 | l.checkstack(2); | ||
165 | lua::stack_sentry s(l); | ||
166 | |||
167 | for(ResourceList::const_iterator i = begin(); i != end(); ++i) | ||
168 | doRemoveResource(**i); | ||
169 | |||
170 | l.getfield(lua::REGISTRYINDEX, make_root); | ||
171 | l.pushstring(m_root); | ||
172 | l.call(1, 1); | ||
173 | |||
174 | l.readOnlySetField(lua::GLOBALSINDEX, m_root.c_str()); | ||
175 | |||
176 | m_l = &l; | ||
177 | |||
178 | for(ResourceList::const_iterator i = begin(); i != end(); ++i) | ||
179 | doAddResource(**i); | ||
158 | } | 180 | } |
159 | 181 | ||
160 | } // end namespace FbTk | 182 | } // end namespace FbTk |
diff --git a/src/FbTk/LResource.hh b/src/FbTk/LResource.hh index 1567269..bb7f224 100644 --- a/src/FbTk/LResource.hh +++ b/src/FbTk/LResource.hh | |||
@@ -41,8 +41,11 @@ public: | |||
41 | virtual bool save(const char *filename, const char *); | 41 | virtual bool save(const char *filename, const char *); |
42 | virtual void addResource(Resource_base &r); | 42 | virtual void addResource(Resource_base &r); |
43 | virtual void removeResource(Resource_base &r); | 43 | virtual void removeResource(Resource_base &r); |
44 | void setLua(Lua &l); | ||
44 | 45 | ||
45 | private: | 46 | private: |
47 | void doAddResource(Resource_base &r); | ||
48 | void doRemoveResource(Resource_base &r); | ||
46 | 49 | ||
47 | Lua *m_l; | 50 | Lua *m_l; |
48 | }; | 51 | }; |
diff --git a/src/Keys.cc b/src/Keys.cc index f741be6..fcf8150 100644 --- a/src/Keys.cc +++ b/src/Keys.cc | |||
@@ -223,6 +223,7 @@ int Keys::t_key::newindex(lua::state *l) | |||
223 | } else if(l->isnil(3)) | 223 | } else if(l->isnil(3)) |
224 | k2.reset(); | 224 | k2.reset(); |
225 | else { | 225 | else { |
226 | _FB_USES_NLS; | ||
226 | throw KeyError(_FB_CONSOLETEXT(Keys, Bad3rdArg, "3rd argument is not a command.", | 227 | throw KeyError(_FB_CONSOLETEXT(Keys, Bad3rdArg, "3rd argument is not a command.", |
227 | "3rd argument is not a command.")); | 228 | "3rd argument is not a command.")); |
228 | } | 229 | } |
@@ -580,6 +581,7 @@ void Keys::reload() { | |||
580 | l.call(0, 0); | 581 | l.call(0, 0); |
581 | } | 582 | } |
582 | catch(std::runtime_error &e) { | 583 | catch(std::runtime_error &e) { |
584 | _FB_USES_NLS; | ||
583 | cerr << _FB_CONSOLETEXT(Keys, LoadError, "Error loading keys file: ", | 585 | cerr << _FB_CONSOLETEXT(Keys, LoadError, "Error loading keys file: ", |
584 | "Actual error message follows") << e.what() << endl; | 586 | "Actual error message follows") << e.what() << endl; |
585 | loadDefaults(l); | 587 | loadDefaults(l); |
diff --git a/src/fluxbox.cc b/src/fluxbox.cc index e293606..f66d83d 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc | |||
@@ -310,7 +310,7 @@ Fluxbox::Fluxbox(int argc, char **argv, | |||
310 | // Because when the command is executed we shouldn't do reconfig directly | 310 | // Because when the command is executed we shouldn't do reconfig directly |
311 | // because it could affect ongoing menu stuff so we need to reconfig in | 311 | // because it could affect ongoing menu stuff so we need to reconfig in |
312 | // the next event "round". | 312 | // the next event "round". |
313 | FbTk::RefCount<FbTk::Command<void> > reconfig_cmd(new FbTk::SimpleCommand<Fluxbox>(*this, &Fluxbox::timed_reconfigure)); | 313 | FbTk::RefCount<FbTk::Command<void> > reconfig_cmd(new FbTk::SimpleCommand<Fluxbox>(*this, &Fluxbox::reconfigure)); |
314 | m_reconfig_timer.setTimeout(1); | 314 | m_reconfig_timer.setTimeout(1); |
315 | m_reconfig_timer.setCommand(reconfig_cmd); | 315 | m_reconfig_timer.setCommand(reconfig_cmd); |
316 | m_reconfig_timer.fireOnce(true); | 316 | m_reconfig_timer.fireOnce(true); |
@@ -438,8 +438,6 @@ Fluxbox::Fluxbox(int argc, char **argv, | |||
438 | //XSynchronize(disp, False); | 438 | //XSynchronize(disp, False); |
439 | sync(false); | 439 | sync(false); |
440 | 440 | ||
441 | m_reconfigure_wait = false; | ||
442 | |||
443 | ungrab(); | 441 | ungrab(); |
444 | 442 | ||
445 | m_starting = false; | 443 | m_starting = false; |
@@ -905,7 +903,7 @@ void Fluxbox::handleSignal(int signum) { | |||
905 | load_rc(); | 903 | load_rc(); |
906 | break; | 904 | break; |
907 | case SIGUSR2: | 905 | case SIGUSR2: |
908 | reconfigure(); | 906 | m_reconfig_timer.start(); |
909 | break; | 907 | break; |
910 | #endif | 908 | #endif |
911 | case SIGSEGV: | 909 | case SIGSEGV: |
@@ -1190,17 +1188,6 @@ void Fluxbox::load_rc() { | |||
1190 | *m_rc_stylefile = DEFAULTSTYLE; | 1188 | *m_rc_stylefile = DEFAULTSTYLE; |
1191 | } | 1189 | } |
1192 | 1190 | ||
1193 | void Fluxbox::reconfigure() { | ||
1194 | load_rc(); | ||
1195 | m_reconfigure_wait = true; | ||
1196 | m_reconfig_timer.start(); | ||
1197 | } | ||
1198 | |||
1199 | |||
1200 | void Fluxbox::real_reconfigure() { | ||
1201 | STLUtil::forAll(m_screen_list, mem_fun(&BScreen::reconfigure)); | ||
1202 | } | ||
1203 | |||
1204 | BScreen *Fluxbox::findScreen(int id) { | 1191 | BScreen *Fluxbox::findScreen(int id) { |
1205 | 1192 | ||
1206 | BScreen* result = 0; | 1193 | BScreen* result = 0; |
@@ -1213,11 +1200,12 @@ BScreen *Fluxbox::findScreen(int id) { | |||
1213 | return result; | 1200 | return result; |
1214 | } | 1201 | } |
1215 | 1202 | ||
1216 | void Fluxbox::timed_reconfigure() { | 1203 | void Fluxbox::reconfigure() { |
1217 | if (m_reconfigure_wait) | 1204 | std::auto_ptr<FbTk::Lua> t = m_l; |
1218 | real_reconfigure(); | 1205 | m_l.reset(new Lua); |
1219 | 1206 | m_resourcemanager.setLua(*m_l); | |
1220 | m_reconfigure_wait = false; | 1207 | load_rc(); |
1208 | STLUtil::forAll(m_screen_list, mem_fun(&BScreen::reconfigure)); | ||
1221 | } | 1209 | } |
1222 | 1210 | ||
1223 | void Fluxbox::revertFocus() { | 1211 | void Fluxbox::revertFocus() { |
diff --git a/src/fluxbox.hh b/src/fluxbox.hh index 68e4fb5..c24d581 100644 --- a/src/fluxbox.hh +++ b/src/fluxbox.hh | |||
@@ -159,7 +159,6 @@ public: | |||
159 | void attachSignals(FluxboxWindow &win); | 159 | void attachSignals(FluxboxWindow &win); |
160 | void attachSignals(WinClient &winclient); | 160 | void attachSignals(WinClient &winclient); |
161 | 161 | ||
162 | void timed_reconfigure(); | ||
163 | void revertFocus(); | 162 | void revertFocus(); |
164 | void setShowingDialog(bool value) { | 163 | void setShowingDialog(bool value) { |
165 | m_showing_dialog = value; if (!value) revertFocus(); | 164 | m_showing_dialog = value; if (!value) revertFocus(); |
@@ -193,8 +192,6 @@ private: | |||
193 | std::string getRcFilename(); | 192 | std::string getRcFilename(); |
194 | void load_rc(); | 193 | void load_rc(); |
195 | 194 | ||
196 | void real_reconfigure(); | ||
197 | |||
198 | void handleEvent(XEvent *xe); | 195 | void handleEvent(XEvent *xe); |
199 | 196 | ||
200 | void handleUnmapNotify(XUnmapEvent &ue); | 197 | void handleUnmapNotify(XUnmapEvent &ue); |
@@ -272,7 +269,6 @@ private: | |||
272 | 269 | ||
273 | Atom m_fluxbox_pid; | 270 | Atom m_fluxbox_pid; |
274 | 271 | ||
275 | bool m_reconfigure_wait; | ||
276 | Time m_last_time; | 272 | Time m_last_time; |
277 | Window m_masked; | 273 | Window m_masked; |
278 | std::string m_rc_file; ///< resource filename | 274 | std::string m_rc_file; ///< resource filename |