diff options
Diffstat (limited to 'src/Keys.cc')
-rw-r--r-- | src/Keys.cc | 39 |
1 files changed, 14 insertions, 25 deletions
diff --git a/src/Keys.cc b/src/Keys.cc index 76224ef..ec1fde0 100644 --- a/src/Keys.cc +++ b/src/Keys.cc | |||
@@ -170,7 +170,9 @@ Keys::t_key::~t_key() { | |||
170 | 170 | ||
171 | 171 | ||
172 | 172 | ||
173 | Keys::Keys() : next_key(0) { } | 173 | Keys::Keys(): next_key(0) { |
174 | m_reloader.setReloadCmd(FbTk::RefCount<FbTk::Command<void> >(new FbTk::SimpleCommand<Keys>(*this, &Keys::reload))); | ||
175 | } | ||
174 | 176 | ||
175 | Keys::~Keys() { | 177 | Keys::~Keys() { |
176 | ungrabKeys(); | 178 | ungrabKeys(); |
@@ -255,27 +257,25 @@ void Keys::grabWindow(Window win) { | |||
255 | /** | 257 | /** |
256 | Load and grab keys | 258 | Load and grab keys |
257 | TODO: error checking | 259 | TODO: error checking |
258 | @return true on success else false | ||
259 | */ | 260 | */ |
260 | bool Keys::load(const char *filename) { | 261 | void Keys::reload() { |
261 | // an intentionally empty file will still have one root mapping | 262 | // an intentionally empty file will still have one root mapping |
262 | bool firstload = m_map.empty(); | 263 | bool firstload = m_map.empty(); |
263 | 264 | ||
264 | if (!filename) { | 265 | if (m_filename.empty()) { |
265 | if (firstload) | 266 | if (firstload) |
266 | loadDefaults(); | 267 | loadDefaults(); |
267 | return false; | 268 | return; |
268 | } | 269 | } |
269 | 270 | ||
270 | FbTk::App::instance()->sync(false); | 271 | FbTk::App::instance()->sync(false); |
271 | 272 | ||
272 | // open the file | 273 | // open the file |
273 | ifstream infile(filename); | 274 | ifstream infile(m_filename.c_str()); |
274 | if (!infile) { | 275 | if (!infile) { |
275 | if (firstload) | 276 | if (firstload) |
276 | loadDefaults(); | 277 | loadDefaults(); |
277 | 278 | return; // failed to open file | |
278 | return false; // failed to open file | ||
279 | } | 279 | } |
280 | 280 | ||
281 | // free memory of previous grabs | 281 | // free memory of previous grabs |
@@ -301,9 +301,7 @@ bool Keys::load(const char *filename) { | |||
301 | } | 301 | } |
302 | } // end while eof | 302 | } // end while eof |
303 | 303 | ||
304 | m_filename = filename; | ||
305 | keyMode("default"); | 304 | keyMode("default"); |
306 | return true; | ||
307 | } | 305 | } |
308 | 306 | ||
309 | /** | 307 | /** |
@@ -321,19 +319,6 @@ void Keys::loadDefaults() { | |||
321 | keyMode("default"); | 319 | keyMode("default"); |
322 | } | 320 | } |
323 | 321 | ||
324 | bool Keys::save(const char *filename) const { | ||
325 | //!! | ||
326 | //!! TODO: fix keybinding saving | ||
327 | //!! (we probably need to save key actions | ||
328 | //!! as strings instead of creating new Commands) | ||
329 | |||
330 | // open file for writing | ||
331 | // ofstream outfile(filename); | ||
332 | // if (!outfile) | ||
333 | return false; | ||
334 | // return true; | ||
335 | } | ||
336 | |||
337 | bool Keys::addBinding(const string &linebuffer) { | 322 | bool Keys::addBinding(const string &linebuffer) { |
338 | 323 | ||
339 | vector<string> val; | 324 | vector<string> val; |
@@ -410,6 +395,8 @@ bool Keys::addBinding(const string &linebuffer) { | |||
410 | type = ButtonPress; | 395 | type = ButtonPress; |
411 | key = atoi(val[argc].substr(5, | 396 | key = atoi(val[argc].substr(5, |
412 | val[argc].length()-5).c_str()); | 397 | val[argc].length()-5).c_str()); |
398 | if (strstr(val[argc].c_str(), "top")) | ||
399 | context = ON_DESKTOP; | ||
413 | // keycode covers the following three two-byte cases: | 400 | // keycode covers the following three two-byte cases: |
414 | // 0x - hex | 401 | // 0x - hex |
415 | // +[1-9] - number between +1 and +9 | 402 | // +[1-9] - number between +1 and +9 |
@@ -581,8 +568,10 @@ void Keys::unregisterWindow(Window win) { | |||
581 | deletes the tree and load configuration | 568 | deletes the tree and load configuration |
582 | returns true on success else false | 569 | returns true on success else false |
583 | */ | 570 | */ |
584 | bool Keys::reconfigure(const char *filename) { | 571 | void Keys::reconfigure() { |
585 | return load(filename); | 572 | m_filename = FbTk::StringUtil::expandFilename(Fluxbox::instance()->getKeysFilename()); |
573 | m_reloader.setMainFile(m_filename); | ||
574 | m_reloader.checkReload(); | ||
586 | } | 575 | } |
587 | 576 | ||
588 | void Keys::keyMode(const string& keyMode) { | 577 | void Keys::keyMode(const string& keyMode) { |