aboutsummaryrefslogtreecommitdiff
path: root/src/Keys.cc
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2008-08-14 05:52:39 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2008-08-14 05:52:39 (GMT)
commite169d33552c8e7070aa6e13da0187f2013b4cfc3 (patch)
treeae9e92c7e885791c7f47645184070cbcd441ab94 /src/Keys.cc
parentc82e7c0080f8a5c14dcf95ec92dc42f59ea9dd8b (diff)
parent91ca3bc5c8e2b892a9a81b18246f72aba7deebfd (diff)
downloadfluxbox-e169d33552c8e7070aa6e13da0187f2013b4cfc3.zip
fluxbox-e169d33552c8e7070aa6e13da0187f2013b4cfc3.tar.bz2
Merge branch 'master' into to_push
Diffstat (limited to 'src/Keys.cc')
-rw-r--r--src/Keys.cc39
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
173Keys::Keys() : next_key(0) { } 173Keys::Keys(): next_key(0) {
174 m_reloader.setReloadCmd(FbTk::RefCount<FbTk::Command<void> >(new FbTk::SimpleCommand<Keys>(*this, &Keys::reload)));
175}
174 176
175Keys::~Keys() { 177Keys::~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*/
260bool Keys::load(const char *filename) { 261void 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
324bool 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
337bool Keys::addBinding(const string &linebuffer) { 322bool 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*/
584bool Keys::reconfigure(const char *filename) { 571void 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
588void Keys::keyMode(const string& keyMode) { 577void Keys::keyMode(const string& keyMode) {