aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/FbCommands.cc2
-rw-r--r--src/Keys.cc21
-rw-r--r--src/Keys.hh6
-rw-r--r--src/fluxbox.cc2
-rw-r--r--src/fluxbox.hh2
5 files changed, 12 insertions, 21 deletions
diff --git a/src/FbCommands.cc b/src/FbCommands.cc
index c74cce6..4db6af7 100644
--- a/src/FbCommands.cc
+++ b/src/FbCommands.cc
@@ -448,7 +448,7 @@ BindKeyCmd::BindKeyCmd(const string &keybind):m_keybind(keybind) { }
448void BindKeyCmd::execute() { 448void BindKeyCmd::execute() {
449 if (Fluxbox::instance()->keys() != 0) { 449 if (Fluxbox::instance()->keys() != 0) {
450 if (Fluxbox::instance()->keys()->addBinding(m_keybind)) { 450 if (Fluxbox::instance()->keys()->addBinding(m_keybind)) {
451 ofstream ofile(Fluxbox::instance()->keys()->filename().c_str(), ios::app); 451 ofstream ofile(Fluxbox::instance()->getKeysResource()->c_str(), ios::app);
452 if (!ofile) 452 if (!ofile)
453 return; 453 return;
454 ofile<<m_keybind<<endl; 454 ofile<<m_keybind<<endl;
diff --git a/src/Keys.cc b/src/Keys.cc
index 79c273b..64eb05d 100644
--- a/src/Keys.cc
+++ b/src/Keys.cc
@@ -201,7 +201,11 @@ Keys::Keys():
201 m_reloader(new FbTk::AutoReloadHelper()), 201 m_reloader(new FbTk::AutoReloadHelper()),
202 m_keylist(0), 202 m_keylist(0),
203 next_key(0), saved_keymode(0) { 203 next_key(0), saved_keymode(0) {
204
204 m_reloader->setReloadCmd(FbTk::RefCount<FbTk::Command<void> >(new FbTk::SimpleCommand<Keys>(*this, &Keys::reload))); 205 m_reloader->setReloadCmd(FbTk::RefCount<FbTk::Command<void> >(new FbTk::SimpleCommand<Keys>(*this, &Keys::reload)));
206 m_reloader->setMainFile(*Fluxbox::instance()->getKeysResource());
207 join(Fluxbox::instance()->getKeysResource().modifiedSig(),
208 MemFun(*m_reloader, &FbTk::AutoReloadHelper::setMainFile));
205} 209}
206 210
207Keys::~Keys() { 211Keys::~Keys() {
@@ -295,8 +299,9 @@ void Keys::grabWindow(Window win) {
295void Keys::reload() { 299void Keys::reload() {
296 // an intentionally empty file will still have one root mapping 300 // an intentionally empty file will still have one root mapping
297 bool firstload = m_map.empty(); 301 bool firstload = m_map.empty();
302 const std::string filename = FbTk::StringUtil::expandFilename(*Fluxbox::instance()->getKeysResource());
298 303
299 if (m_filename.empty()) { 304 if (filename.empty()) {
300 if (firstload) 305 if (firstload)
301 loadDefaults(); 306 loadDefaults();
302 return; 307 return;
@@ -304,12 +309,12 @@ void Keys::reload() {
304 309
305 FbTk::App::instance()->sync(false); 310 FbTk::App::instance()->sync(false);
306 311
307 if (! FbTk::FileUtil::isRegularFile(m_filename.c_str())) { 312 if (! FbTk::FileUtil::isRegularFile(filename.c_str())) {
308 return; 313 return;
309 } 314 }
310 315
311 // open the file 316 // open the file
312 ifstream infile(m_filename.c_str()); 317 ifstream infile(filename.c_str());
313 if (!infile) { 318 if (!infile) {
314 if (firstload) 319 if (firstload)
315 loadDefaults(); 320 loadDefaults();
@@ -619,16 +624,6 @@ void Keys::unregisterWindow(Window win) {
619 m_window_map.erase(win); 624 m_window_map.erase(win);
620} 625}
621 626
622/**
623 deletes the tree and load configuration
624 returns true on success else false
625*/
626void Keys::reconfigure() {
627 m_filename = FbTk::StringUtil::expandFilename(Fluxbox::instance()->getKeysFilename());
628 m_reloader->setMainFile(m_filename);
629 m_reloader->checkReload();
630}
631
632void Keys::regrab() { 627void Keys::regrab() {
633 setKeyMode(m_keylist); 628 setKeyMode(m_keylist);
634} 629}
diff --git a/src/Keys.hh b/src/Keys.hh
index 43f4445..2dc1c10 100644
--- a/src/Keys.hh
+++ b/src/Keys.hh
@@ -23,6 +23,7 @@
23#define KEYS_HH 23#define KEYS_HH
24 24
25#include "FbTk/NotCopyable.hh" 25#include "FbTk/NotCopyable.hh"
26#include "FbTk/Signal.hh"
26 27
27#include <X11/Xlib.h> 28#include <X11/Xlib.h>
28#include <string> 29#include <string>
@@ -35,7 +36,7 @@ namespace FbTk {
35 class AutoReloadHelper; 36 class AutoReloadHelper;
36} 37}
37 38
38class Keys:private FbTk::NotCopyable { 39class Keys: private FbTk::NotCopyable, private FbTk::SignalTracker {
39public: 40public:
40 41
41 // contexts for events 42 // contexts for events
@@ -79,7 +80,6 @@ public:
79 /// grab keys again when keymap changes 80 /// grab keys again when keymap changes
80 void regrab(); 81 void regrab();
81 82
82 const std::string& filename() const { return m_filename; }
83 /** 83 /**
84 Load configuration from file 84 Load configuration from file
85 */ 85 */
@@ -87,7 +87,6 @@ public:
87 /** 87 /**
88 Reload configuration if keys file has changed 88 Reload configuration if keys file has changed
89 */ 89 */
90 void reconfigure();
91 void keyMode(const std::string& keyMode); 90 void keyMode(const std::string& keyMode);
92 91
93 bool inKeychain() const { return saved_keymode != 0; } 92 bool inKeychain() const { return saved_keymode != 0; }
@@ -112,7 +111,6 @@ private:
112 111
113 112
114 // member variables 113 // member variables
115 std::string m_filename;
116 FbTk::AutoReloadHelper* m_reloader; 114 FbTk::AutoReloadHelper* m_reloader;
117 t_key *m_keylist; 115 t_key *m_keylist;
118 keyspace_t m_map; 116 keyspace_t m_map;
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index 5032a32..4f41e4d 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.cc
@@ -356,7 +356,6 @@ Fluxbox::Fluxbox(int argc, char **argv,
356 // Create keybindings handler and load keys file 356 // Create keybindings handler and load keys file
357 // Note: this needs to be done before creating screens 357 // Note: this needs to be done before creating screens
358 m_key.reset(new Keys); 358 m_key.reset(new Keys);
359 m_key->reconfigure();
360 359
361 vector<int> screens; 360 vector<int> screens;
362 int i; 361 int i;
@@ -1194,7 +1193,6 @@ void Fluxbox::reconfigure() {
1194 1193
1195void Fluxbox::real_reconfigure() { 1194void Fluxbox::real_reconfigure() {
1196 STLUtil::forAll(m_screen_list, mem_fun(&BScreen::reconfigure)); 1195 STLUtil::forAll(m_screen_list, mem_fun(&BScreen::reconfigure));
1197 m_key->reconfigure();
1198} 1196}
1199 1197
1200BScreen *Fluxbox::findScreen(int id) { 1198BScreen *Fluxbox::findScreen(int id) {
diff --git a/src/fluxbox.hh b/src/fluxbox.hh
index f8a27bc..3e9e8d6 100644
--- a/src/fluxbox.hh
+++ b/src/fluxbox.hh
@@ -121,8 +121,8 @@ public:
121 const std::string &getStyleOverlayFilename() const { return *m_rc_styleoverlayfile; } 121 const std::string &getStyleOverlayFilename() const { return *m_rc_styleoverlayfile; }
122 122
123 const std::string &getMenuFilename() const { return *m_rc_menufile; } 123 const std::string &getMenuFilename() const { return *m_rc_menufile; }
124 const std::string &getKeysFilename() const { return *m_rc_keyfile; }
125 FbTk::StringResource &getAppsResource() { return m_rc_appsfile; } 124 FbTk::StringResource &getAppsResource() { return m_rc_appsfile; }
125 FbTk::StringResource &getKeysResource() { return m_rc_keyfile; }
126 int colorsPerChannel() const { return *m_rc_colors_per_channel; } 126 int colorsPerChannel() const { return *m_rc_colors_per_channel; }
127 int getTabsPadding() const { return *m_rc_tabs_padding; } 127 int getTabsPadding() const { return *m_rc_tabs_padding; }
128 128