aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsimonb <simonb>2007-10-03 22:44:08 (GMT)
committersimonb <simonb>2007-10-03 22:44:08 (GMT)
commitf76da171aa060f1367a5deaf1aec3b3294302b5e (patch)
tree4814387d1f9dfc155efa84e91194a07054b88fac /src
parentb5d0c3f8fa735a6dbac6cfa452cd44df6adcd77d (diff)
downloadfluxbox-f76da171aa060f1367a5deaf1aec3b3294302b5e.zip
fluxbox-f76da171aa060f1367a5deaf1aec3b3294302b5e.tar.bz2
load some default key bindings on error
Diffstat (limited to 'src')
-rw-r--r--src/Keys.cc45
-rw-r--r--src/Keys.hh3
2 files changed, 38 insertions, 10 deletions
diff --git a/src/Keys.cc b/src/Keys.cc
index 86cb4d5..6d13cd4 100644
--- a/src/Keys.cc
+++ b/src/Keys.cc
@@ -187,22 +187,32 @@ void Keys::grabWindow(Window win) {
187 @return true on success else false 187 @return true on success else false
188*/ 188*/
189bool Keys::load(const char *filename) { 189bool Keys::load(const char *filename) {
190 if (!filename) 190 // an intentionally empty file will still have one root mapping
191 return false; 191 bool firstload = m_map.empty();
192
193 //free memory of previous grabs
194 deleteTree();
195 192
196 m_map["default:"] = new t_key(0,0,0,0); 193 if (!filename) {
194 if (firstload)
195 loadDefaults();
196 return false;
197 }
197 198
198 FbTk::App::instance()->sync(false); 199 FbTk::App::instance()->sync(false);
199 200
200 //open the file 201 // open the file
201 ifstream infile(filename); 202 ifstream infile(filename);
202 if (!infile) 203 if (!infile) {
203 return false; // faild to open file 204 if (firstload)
205 loadDefaults();
204 206
205 unsigned int current_line = 0;//so we can tell the user where the fault is 207 return false; // failed to open file
208 }
209
210 // free memory of previous grabs
211 deleteTree();
212
213 m_map["default:"] = new t_key(0,0,0,0);
214
215 unsigned int current_line = 0; //so we can tell the user where the fault is
206 216
207 while (!infile.eof()) { 217 while (!infile.eof()) {
208 string linebuffer; 218 string linebuffer;
@@ -225,6 +235,21 @@ bool Keys::load(const char *filename) {
225 return true; 235 return true;
226} 236}
227 237
238/**
239 * Load critical key/mouse bindings for when there are fatal errors reading the keyFile.
240 */
241void Keys::loadDefaults() {
242#ifdef DEBUG
243 cerr<<"Loading default key bindings"<<endl;
244#endif
245 deleteTree();
246 m_map["default:"] = new t_key(0,0,0,0);
247 addBinding("OnDesktop Mouse1 :HideMenus");
248 addBinding("OnDesktop Mouse2 :WorkspaceMenu");
249 addBinding("OnDesktop Mouse3 :RootMenu");
250 keyMode("default");
251}
252
228bool Keys::save(const char *filename) const { 253bool Keys::save(const char *filename) const {
229 //!! 254 //!!
230 //!! TODO: fix keybinding saving 255 //!! TODO: fix keybinding saving
diff --git a/src/Keys.hh b/src/Keys.hh
index 2d022c6..2fca460 100644
--- a/src/Keys.hh
+++ b/src/Keys.hh
@@ -98,6 +98,9 @@ private:
98 void ungrabButtons(); 98 void ungrabButtons();
99 void grabWindow(Window win); 99 void grabWindow(Window win);
100 100
101 // Load default keybindings for when there are errors loading the initial one
102 void loadDefaults();
103
101 std::string m_filename; 104 std::string m_filename;
102 105
103 class t_key; 106 class t_key;