diff options
Diffstat (limited to 'src/Keys.cc')
-rw-r--r-- | src/Keys.cc | 59 |
1 files changed, 49 insertions, 10 deletions
diff --git a/src/Keys.cc b/src/Keys.cc index f3cd092..06a0d48 100644 --- a/src/Keys.cc +++ b/src/Keys.cc | |||
@@ -212,7 +212,7 @@ bool Keys::load(const char *filename) { | |||
212 | // free memory of previous grabs | 212 | // free memory of previous grabs |
213 | deleteTree(); | 213 | deleteTree(); |
214 | 214 | ||
215 | m_map["default:"] = new t_key(0,0,0,0); | 215 | m_map["default:"] = new t_key(0,0,0,0,false); |
216 | 216 | ||
217 | unsigned int current_line = 0; //so we can tell the user where the fault is | 217 | unsigned int current_line = 0; //so we can tell the user where the fault is |
218 | 218 | ||
@@ -245,7 +245,7 @@ void Keys::loadDefaults() { | |||
245 | cerr<<"Loading default key bindings"<<endl; | 245 | cerr<<"Loading default key bindings"<<endl; |
246 | #endif | 246 | #endif |
247 | deleteTree(); | 247 | deleteTree(); |
248 | m_map["default:"] = new t_key(0,0,0,0); | 248 | m_map["default:"] = new t_key(0,0,0,0,false); |
249 | addBinding("OnDesktop Mouse1 :HideMenus"); | 249 | addBinding("OnDesktop Mouse1 :HideMenus"); |
250 | addBinding("OnDesktop Mouse2 :WorkspaceMenu"); | 250 | addBinding("OnDesktop Mouse2 :WorkspaceMenu"); |
251 | addBinding("OnDesktop Mouse3 :RootMenu"); | 251 | addBinding("OnDesktop Mouse3 :RootMenu"); |
@@ -280,6 +280,7 @@ bool Keys::addBinding(const string &linebuffer) { | |||
280 | 280 | ||
281 | unsigned int key = 0, mod = 0; | 281 | unsigned int key = 0, mod = 0; |
282 | int type = 0, context = 0; | 282 | int type = 0, context = 0; |
283 | bool isdouble = false; | ||
283 | size_t argc = 0; | 284 | size_t argc = 0; |
284 | t_key *current_key=m_map["default:"]; | 285 | t_key *current_key=m_map["default:"]; |
285 | t_key *first_new_keylist = current_key, *first_new_key=0; | 286 | t_key *first_new_keylist = current_key, *first_new_key=0; |
@@ -288,7 +289,7 @@ bool Keys::addBinding(const string &linebuffer) { | |||
288 | argc++; | 289 | argc++; |
289 | keyspace_t::iterator it = m_map.find(val[0]); | 290 | keyspace_t::iterator it = m_map.find(val[0]); |
290 | if (it == m_map.end()) | 291 | if (it == m_map.end()) |
291 | m_map[val[0]] = new t_key(0,0,0,0); | 292 | m_map[val[0]] = new t_key(0,0,0,0,false); |
292 | current_key = m_map[val[0]]; | 293 | current_key = m_map[val[0]]; |
293 | } | 294 | } |
294 | // for each argument | 295 | // for each argument |
@@ -305,6 +306,10 @@ bool Keys::addBinding(const string &linebuffer) { | |||
305 | context |= ON_TOOLBAR; | 306 | context |= ON_TOOLBAR; |
306 | else if (strcasecmp("onwindow", val[argc].c_str()) == 0) | 307 | else if (strcasecmp("onwindow", val[argc].c_str()) == 0) |
307 | context |= ON_WINDOW; | 308 | context |= ON_WINDOW; |
309 | else if (strcasecmp("ontitlebar", val[argc].c_str()) == 0) | ||
310 | context |= ON_TITLEBAR; | ||
311 | else if (strcasecmp("double", val[argc].c_str()) == 0) | ||
312 | isdouble = true; | ||
308 | else if (strcasecmp("NONE",val[argc].c_str())) { | 313 | else if (strcasecmp("NONE",val[argc].c_str())) { |
309 | // check if it's a mouse button | 314 | // check if it's a mouse button |
310 | if (strcasecmp("focusin", val[argc].c_str()) == 0) { | 315 | if (strcasecmp("focusin", val[argc].c_str()) == 0) { |
@@ -358,16 +363,21 @@ bool Keys::addBinding(const string &linebuffer) { | |||
358 | 363 | ||
359 | if (key == 0 && (type == KeyPress || type == ButtonPress)) | 364 | if (key == 0 && (type == KeyPress || type == ButtonPress)) |
360 | return false; | 365 | return false; |
366 | if (type != ButtonPress) | ||
367 | isdouble = false; | ||
361 | if (!first_new_key) { | 368 | if (!first_new_key) { |
362 | first_new_keylist = current_key; | 369 | first_new_keylist = current_key; |
363 | current_key = current_key->find(type, mod, key, context); | 370 | current_key = current_key->find(type, mod, key, context, |
371 | isdouble); | ||
364 | if (!current_key) { | 372 | if (!current_key) { |
365 | first_new_key = new t_key(type, mod, key, context); | 373 | first_new_key = new t_key(type, mod, key, context, |
374 | isdouble); | ||
366 | current_key = first_new_key; | 375 | current_key = first_new_key; |
367 | } else if (*current_key->m_command) // already being used | 376 | } else if (*current_key->m_command) // already being used |
368 | return false; | 377 | return false; |
369 | } else { | 378 | } else { |
370 | t_key *temp_key = new t_key(type, mod, key, context); | 379 | t_key *temp_key = new t_key(type, mod, key, context, |
380 | isdouble); | ||
371 | current_key->keylist.push_back(temp_key); | 381 | current_key->keylist.push_back(temp_key); |
372 | current_key = temp_key; | 382 | current_key = temp_key; |
373 | } | 383 | } |
@@ -375,6 +385,7 @@ bool Keys::addBinding(const string &linebuffer) { | |||
375 | key = 0; | 385 | key = 0; |
376 | type = 0; | 386 | type = 0; |
377 | context = 0; | 387 | context = 0; |
388 | isdouble = false; | ||
378 | } | 389 | } |
379 | 390 | ||
380 | } else { // parse command line | 391 | } else { // parse command line |
@@ -402,14 +413,40 @@ bool Keys::addBinding(const string &linebuffer) { | |||
402 | 413 | ||
403 | // return true if bound to a command, else false | 414 | // return true if bound to a command, else false |
404 | bool Keys::doAction(int type, unsigned int mods, unsigned int key, | 415 | bool Keys::doAction(int type, unsigned int mods, unsigned int key, |
405 | int context) { | 416 | int context, Time time) { |
417 | |||
418 | static Time last_button_time = 0; | ||
419 | static unsigned int last_button = 0; | ||
420 | |||
421 | // need to remember whether or not this is a double-click, e.g. when | ||
422 | // double-clicking on the titlebar when there's an OnWindow Double command | ||
423 | // we just don't update it if timestamp is the same | ||
424 | static bool double_click = false; | ||
425 | |||
426 | // actual value used for searching | ||
427 | bool isdouble = false; | ||
428 | |||
429 | if (type == ButtonPress) { | ||
430 | if (time > last_button_time) | ||
431 | double_click = (time - last_button_time < | ||
432 | Fluxbox::instance()->getDoubleClickInterval()) && | ||
433 | last_button == key; | ||
434 | last_button_time = time; | ||
435 | last_button = key; | ||
436 | isdouble = double_click; | ||
437 | } | ||
406 | 438 | ||
407 | static t_key* next_key = m_keylist; | 439 | static t_key* next_key = m_keylist; |
408 | if (!next_key) | 440 | if (!next_key) |
409 | next_key = m_keylist; | 441 | next_key = m_keylist; |
410 | 442 | ||
411 | mods = FbTk::KeyUtil::instance().cleanMods(mods); | 443 | mods = FbTk::KeyUtil::instance().cleanMods(mods); |
412 | t_key *temp_key = next_key->find(type, mods, key, context); | 444 | t_key *temp_key = next_key->find(type, mods, key, context, isdouble); |
445 | |||
446 | // just because we double-clicked doesn't mean we shouldn't look for single | ||
447 | // click commands | ||
448 | if (!temp_key && isdouble) | ||
449 | temp_key = next_key->find(type, mods, key, context, false); | ||
413 | 450 | ||
414 | // need to save this for emacs-style keybindings | 451 | // need to save this for emacs-style keybindings |
415 | static t_key *saved_keymode = 0; | 452 | static t_key *saved_keymode = 0; |
@@ -506,12 +543,13 @@ void Keys::setKeyMode(t_key *keyMode) { | |||
506 | } | 543 | } |
507 | 544 | ||
508 | Keys::t_key::t_key(int type_, unsigned int mod_, unsigned int key_, | 545 | Keys::t_key::t_key(int type_, unsigned int mod_, unsigned int key_, |
509 | int context_, FbTk::RefCount<FbTk::Command> command) { | 546 | int context_, bool isdouble_) { |
510 | key = key_; | 547 | key = key_; |
511 | mod = mod_; | 548 | mod = mod_; |
512 | type = type_; | 549 | type = type_; |
513 | context = context_ ? context_ : GLOBAL; | 550 | context = context_ ? context_ : GLOBAL; |
514 | m_command = command; | 551 | isdouble = isdouble_; |
552 | m_command = 0; | ||
515 | } | 553 | } |
516 | 554 | ||
517 | Keys::t_key::t_key(t_key *k) { | 555 | Keys::t_key::t_key(t_key *k) { |
@@ -519,6 +557,7 @@ Keys::t_key::t_key(t_key *k) { | |||
519 | mod = k->mod; | 557 | mod = k->mod; |
520 | type = k->type; | 558 | type = k->type; |
521 | context = k->context; | 559 | context = k->context; |
560 | isdouble = k->isdouble; | ||
522 | m_command = k->m_command; | 561 | m_command = k->m_command; |
523 | } | 562 | } |
524 | 563 | ||