summaryrefslogtreecommitdiff
path: root/libs/gtkmm2ext/bindings.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2016-02-26 15:47:50 -0500
committerPaul Davis <paul@linuxaudiosystems.com>2016-02-26 15:47:50 -0500
commite5340dc258e11a4acc0f7abce7652d515f207560 (patch)
treea269f4b80297eef6192a48020a0c072b79b16854 /libs/gtkmm2ext/bindings.cc
parentb77236d4b40467eafbad230938e78012ba777313 (diff)
when looking up a key event, switch to the lowercase keyval
Our bindings always use the lowercase form. Shift-e generates the GDK keyval for 'E' rather than 'e' (with the event state including GDK_SHIFT_MODIFIER). So we have to take this into account when doing the lookup
Diffstat (limited to 'libs/gtkmm2ext/bindings.cc')
-rw-r--r--libs/gtkmm2ext/bindings.cc15
1 files changed, 11 insertions, 4 deletions
diff --git a/libs/gtkmm2ext/bindings.cc b/libs/gtkmm2ext/bindings.cc
index 667c2cfaaa..a570ec2f85 100644
--- a/libs/gtkmm2ext/bindings.cc
+++ b/libs/gtkmm2ext/bindings.cc
@@ -374,11 +374,18 @@ Bindings::activate (KeyboardKey kb, Operation op)
break;
}
- KeybindingMap::iterator k = kbm->find (kb);
+ /* if shift was pressed, GDK will send us (e.g) 'E' rather than 'e'.
+ Our bindings all use the lower case character/keyname, so switch
+ to the lower case before doing the lookup.
+ */
+
+ KeyboardKey unshifted (kb.state(), gdk_keyval_to_lower (kb.key()));
+
+ KeybindingMap::iterator k = kbm->find (unshifted);
if (k == kbm->end()) {
/* no entry for this key in the state map */
- DEBUG_TRACE (DEBUG::Bindings, string_compose ("no binding for %1\n", kb));
+ DEBUG_TRACE (DEBUG::Bindings, string_compose ("no binding for %1\n", unshifted));
return false;
}
@@ -394,7 +401,7 @@ Bindings::activate (KeyboardKey kb, Operation op)
if (action) {
/* lets do it ... */
- DEBUG_TRACE (DEBUG::Bindings, string_compose ("binding for %1: %2\n", kb, k->second.action_name));
+ DEBUG_TRACE (DEBUG::Bindings, string_compose ("binding for %1: %2\n", unshifted, k->second.action_name));
action->activate ();
}
@@ -478,7 +485,7 @@ Bindings::push_to_gtk (KeyboardKey kb, RefPtr<Action> what)
*/
Gtk::AccelMap::add_entry (what->get_accel_path(), kb.key(), (Gdk::ModifierType) kb.state());
- }
+ }
}
bool