2 Copyright (C) 2012 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "pbd/gstdio_compat.h"
23 #include <gtkmm/accelmap.h>
24 #include <gtkmm/uimanager.h>
26 #include "pbd/convert.h"
27 #include "pbd/debug.h"
28 #include "pbd/error.h"
29 #include "pbd/replace_all.h"
30 #include "pbd/xml++.h"
32 #include "gtkmm2ext/actions.h"
33 #include "gtkmm2ext/bindings.h"
34 #include "gtkmm2ext/debug.h"
35 #include "gtkmm2ext/keyboard.h"
36 #include "gtkmm2ext/utils.h"
43 using namespace Gtkmm2ext;
46 list<Bindings*> Bindings::bindings; /* global. Gulp */
47 PBD::Signal1<void,Bindings*> Bindings::BindingsChanged;
49 template <typename IteratorValueType>
50 struct ActionNameRegistered
52 ActionNameRegistered(std::string const& name)
56 bool operator()(IteratorValueType elem) const {
57 return elem.second.action_name == action_name;
59 std::string const& action_name;
62 MouseButton::MouseButton (uint32_t state, uint32_t keycode)
64 uint32_t ignore = ~Keyboard::RelevantModifierKeyMask;
66 /* this is a slightly wierd test that relies on
67 * gdk_keyval_is_{upper,lower}() returning true for keys that have no
68 * case-sensitivity. This covers mostly non-alphanumeric keys.
71 if (gdk_keyval_is_upper (keycode) && gdk_keyval_is_lower (keycode)) {
72 /* key is not subject to case, so ignore SHIFT
74 ignore |= GDK_SHIFT_MASK;
77 _val = (state & ~ignore);
83 MouseButton::make_button (const string& str, MouseButton& b)
87 if (str.find ("Primary") != string::npos) {
88 s |= Keyboard::PrimaryModifier;
91 if (str.find ("Secondary") != string::npos) {
92 s |= Keyboard::SecondaryModifier;
95 if (str.find ("Tertiary") != string::npos) {
96 s |= Keyboard::TertiaryModifier;
99 if (str.find ("Level4") != string::npos) {
100 s |= Keyboard::Level4Modifier;
103 string::size_type lastmod = str.find_last_of ('-');
104 uint32_t button_number;
106 if (lastmod == string::npos) {
107 button_number = PBD::atoi (str);
109 button_number = PBD::atoi (str.substr (lastmod+1));
112 b = MouseButton (s, button_number);
117 MouseButton::name () const
123 if (s & Keyboard::PrimaryModifier) {
126 if (s & Keyboard::SecondaryModifier) {
132 if (s & Keyboard::TertiaryModifier) {
138 if (s & Keyboard::Level4Modifier) {
150 snprintf (buf, sizeof (buf), "%u", button());
156 /*================================ KeyboardKey ================================*/
157 KeyboardKey::KeyboardKey (uint32_t state, uint32_t keycode)
159 uint32_t ignore = ~Keyboard::RelevantModifierKeyMask;
161 _val = (state & ~ignore);
167 KeyboardKey::display_label () const
173 /* This magically returns a string that will display the right thing
174 * on all platforms, notably the command key on OS X.
177 uint32_t mod = state();
179 return gtk_accelerator_get_label (key(), (GdkModifierType) mod);
183 KeyboardKey::name () const
189 if (s & Keyboard::PrimaryModifier) {
192 if (s & Keyboard::SecondaryModifier) {
198 if (s & Keyboard::TertiaryModifier) {
204 if (s & Keyboard::Level4Modifier) {
215 char const *gdk_name = gdk_keyval_name (key());
228 KeyboardKey::native_name () const
234 if (s & Keyboard::PrimaryModifier) {
235 str += Keyboard::primary_modifier_name ();
237 if (s & Keyboard::SecondaryModifier) {
241 str += Keyboard::secondary_modifier_name ();
243 if (s & Keyboard::TertiaryModifier) {
247 str += Keyboard::tertiary_modifier_name ();
249 if (s & Keyboard::Level4Modifier) {
253 str += Keyboard::level4_modifier_name ();
260 char const *gdk_name = gdk_keyval_name (key());
273 KeyboardKey::native_short_name () const
279 if (s & Keyboard::PrimaryModifier) {
280 str += Keyboard::primary_modifier_short_name ();
282 if (s & Keyboard::SecondaryModifier) {
286 str += Keyboard::secondary_modifier_short_name ();
288 if (s & Keyboard::TertiaryModifier) {
292 str += Keyboard::tertiary_modifier_short_name ();
294 if (s & Keyboard::Level4Modifier) {
298 str += Keyboard::level4_modifier_short_name ();
305 char const *gdk_name = gdk_keyval_name (key());
318 KeyboardKey::make_key (const string& str, KeyboardKey& k)
322 if (str.find ("Primary") != string::npos) {
323 s |= Keyboard::PrimaryModifier;
326 if (str.find ("Secondary") != string::npos) {
327 s |= Keyboard::SecondaryModifier;
330 if (str.find ("Tertiary") != string::npos) {
331 s |= Keyboard::TertiaryModifier;
334 if (str.find ("Level4") != string::npos) {
335 s |= Keyboard::Level4Modifier;
338 /* since all SINGLE key events keycodes are changed to lower case
339 * before looking them up, make sure we only store lower case here. The
340 * Shift part will be stored in the modifier part of the KeyboardKey.
342 * And yes Mildred, this doesn't cover CapsLock cases. Oh well.
347 string::size_type lastmod = str.find_last_of ('-');
349 if (lastmod != string::npos) {
350 actual = str.substr (lastmod+1);
356 if (actual.size() == 1) {
357 actual = PBD::downcase (actual);
361 keyval = gdk_keyval_from_name (actual.c_str());
363 if (keyval == GDK_VoidSymbol || keyval == 0) {
367 k = KeyboardKey (s, keyval);
372 /*================================= Bindings =================================*/
373 Bindings::Bindings (std::string const& name)
376 bindings.push_back (this);
379 Bindings::~Bindings()
381 bindings.remove (this);
385 Bindings::ardour_action_name (RefPtr<Action> action)
387 /* Skip "<Actions>/" */
388 return action->get_accel_path ().substr (10);
392 Bindings::get_binding_for_action (RefPtr<Action> action, Operation& op)
394 const string action_name = ardour_action_name (action);
396 for (KeybindingMap::iterator k = press_bindings.begin(); k != press_bindings.end(); ++k) {
398 /* option one: action has already been associated with the
402 if (k->second.action == action) {
406 /* option two: action name matches, so lookup the action,
407 * setup the association while we're here, and return the binding.
410 if (k->second.action_name == action_name) {
411 k->second.action = ActionManager::get_action (action_name, false);
417 for (KeybindingMap::iterator k = release_bindings.begin(); k != release_bindings.end(); ++k) {
419 /* option one: action has already been associated with the
423 if (k->second.action == action) {
427 /* option two: action name matches, so lookup the action,
428 * setup the association while we're here, and return the binding.
431 if (k->second.action_name == action_name) {
432 k->second.action = ActionManager::get_action (action_name, false);
438 return KeyboardKey::null_key();
442 Bindings::reassociate ()
449 Bindings::empty_keys() const
451 return press_bindings.empty() && release_bindings.empty();
455 Bindings::empty_mouse () const
457 return button_press_bindings.empty() && button_release_bindings.empty();
461 Bindings::empty() const
463 return empty_keys() && empty_mouse ();
467 Bindings::activate (KeyboardKey kb, Operation op)
469 KeybindingMap& kbm = get_keymap (op);
471 /* if shift was pressed, GDK will send us (e.g) 'E' rather than 'e'.
472 Our bindings all use the lower case character/keyname, so switch
473 to the lower case before doing the lookup.
476 KeyboardKey unshifted (kb.state(), gdk_keyval_to_lower (kb.key()));
478 KeybindingMap::iterator k = kbm.find (unshifted);
480 if (k == kbm.end()) {
481 /* no entry for this key in the state map */
482 DEBUG_TRACE (DEBUG::Bindings, string_compose ("no binding for %1\n", unshifted));
486 RefPtr<Action> action;
488 if (k->second.action) {
489 action = k->second.action;
491 action = ActionManager::get_action (k->second.action_name, false);
496 DEBUG_TRACE (DEBUG::Bindings, string_compose ("binding for %1: %2\n", unshifted, k->second.action_name));
500 /* return true even if the action could not be found */
506 Bindings::associate ()
508 KeybindingMap::iterator k;
510 for (k = press_bindings.begin(); k != press_bindings.end(); ++k) {
511 k->second.action = ActionManager::get_action (k->second.action_name, false);
512 if (k->second.action) {
513 push_to_gtk (k->first, k->second.action);
515 cerr << _name << " didn't find " << k->second.action_name << endl;
519 for (k = release_bindings.begin(); k != release_bindings.end(); ++k) {
520 k->second.action = ActionManager::get_action (k->second.action_name, false);
521 /* no working support in GTK for release bindings */
524 MouseButtonBindingMap::iterator b;
526 for (b = button_press_bindings.begin(); b != button_press_bindings.end(); ++b) {
527 b->second.action = ActionManager::get_action (b->second.action_name, false);
530 for (b = button_release_bindings.begin(); b != button_release_bindings.end(); ++b) {
531 b->second.action = ActionManager::get_action (b->second.action_name, false);
536 Bindings::dissociate ()
538 KeybindingMap::iterator k;
540 for (k = press_bindings.begin(); k != press_bindings.end(); ++k) {
541 k->second.action.clear ();
543 for (k = release_bindings.begin(); k != release_bindings.end(); ++k) {
544 k->second.action.clear ();
549 Bindings::push_to_gtk (KeyboardKey kb, RefPtr<Action> what)
551 /* GTK has the useful feature of showing key bindings for actions in
552 * menus. As of August 2015, we have no interest in trying to
553 * reimplement this functionality, so we will use it even though we no
554 * longer use GTK accelerators for handling key events. To do this, we
555 * need to make sure that there is a fully populated GTK AccelMap set
556 * up with all bindings/actions.
559 Gtk::AccelKey gtk_key;
560 bool entry_exists = Gtk::AccelMap::lookup_entry (what->get_accel_path(), gtk_key);
564 /* there is a trick happening here. It turns out that
565 * gtk_accel_map_add_entry() performs no validation checks on
566 * the accelerator keyval. This means we can use it to define
567 * ANY accelerator, even if they violate GTK's rules
568 * (e.g. about not using navigation keys). This works ONLY when
569 * the entry in the GTK accelerator map has not already been
570 * added. The entries will be added by the GTK UIManager when
571 * building menus, so this code must be called before that
576 int mod = kb.state();
578 Gtk::AccelMap::add_entry (what->get_accel_path(), kb.key(), (Gdk::ModifierType) mod);
583 Bindings::replace (KeyboardKey kb, Operation op, string const & action_name, bool can_save)
585 if (is_registered(op, action_name)) {
586 remove (op, action_name, can_save);
589 /* XXX need a way to get the old group name */
590 add (kb, op, action_name, 0, can_save);
596 Bindings::add (KeyboardKey kb, Operation op, string const& action_name, XMLProperty const* group, bool can_save)
598 if (is_registered (op, action_name)) {
602 KeybindingMap& kbm = get_keymap (op);
604 KeybindingMap::value_type new_pair = make_pair (kb, ActionInfo (action_name, group->value()));
605 (void) kbm.insert (new_pair).first;
607 KeybindingMap::value_type new_pair = make_pair (kb, ActionInfo (action_name));
608 (void) kbm.insert (new_pair).first;
611 DEBUG_TRACE (DEBUG::Bindings, string_compose ("add binding between %1 and %2, group [%3]\n",
612 kb, action_name, (group ? group->value() : string())));
615 Keyboard::keybindings_changed ();
618 BindingsChanged (this); /* EMIT SIGNAL */
623 Bindings::remove (Operation op, std::string const& action_name, bool can_save)
625 bool erased_action = false;
626 KeybindingMap& kbm = get_keymap (op);
627 for (KeybindingMap::iterator k = kbm.begin(); k != kbm.end(); ++k) {
628 if (k->second.action_name == action_name) {
630 erased_action = true;
635 if (!erased_action) {
636 return erased_action;
640 Keyboard::keybindings_changed ();
643 BindingsChanged (this); /* EMIT SIGNAL */
644 return erased_action;
649 Bindings::activate (MouseButton bb, Operation op)
651 MouseButtonBindingMap& bbm = get_mousemap(op);
653 MouseButtonBindingMap::iterator b = bbm.find (bb);
655 if (b == bbm.end()) {
656 /* no entry for this key in the state map */
660 RefPtr<Action> action;
662 if (b->second.action) {
663 action = b->second.action;
665 action = ActionManager::get_action (b->second.action_name, false);
670 DEBUG_TRACE (DEBUG::Bindings, string_compose ("activating action %1\n", ardour_action_name (action)));
674 /* return true even if the action could not be found */
680 Bindings::add (MouseButton bb, Operation op, string const& action_name, XMLProperty const* /*group*/)
682 MouseButtonBindingMap& bbm = get_mousemap(op);
684 MouseButtonBindingMap::value_type newpair (bb, ActionInfo (action_name));
685 bbm.insert (newpair);
689 Bindings::remove (MouseButton bb, Operation op)
691 MouseButtonBindingMap& bbm = get_mousemap(op);
692 MouseButtonBindingMap::iterator b = bbm.find (bb);
694 if (b != bbm.end()) {
700 Bindings::save (XMLNode& root)
702 XMLNode* presses = new XMLNode (X_("Press"));
704 for (KeybindingMap::iterator k = press_bindings.begin(); k != press_bindings.end(); ++k) {
707 if (k->first.name().empty()) {
711 child = new XMLNode (X_("Binding"));
712 child->set_property (X_("key"), k->first.name());
713 child->set_property (X_("action"), k->second.action_name);
714 presses->add_child_nocopy (*child);
717 for (MouseButtonBindingMap::iterator k = button_press_bindings.begin(); k != button_press_bindings.end(); ++k) {
719 child = new XMLNode (X_("Binding"));
720 child->set_property (X_("button"), k->first.name());
721 child->set_property (X_("action"), k->second.action_name);
722 presses->add_child_nocopy (*child);
725 XMLNode* releases = new XMLNode (X_("Release"));
727 for (KeybindingMap::iterator k = release_bindings.begin(); k != release_bindings.end(); ++k) {
730 if (k->first.name().empty()) {
734 child = new XMLNode (X_("Binding"));
735 child->set_property (X_("key"), k->first.name());
736 child->set_property (X_("action"), k->second.action_name);
737 releases->add_child_nocopy (*child);
740 for (MouseButtonBindingMap::iterator k = button_release_bindings.begin(); k != button_release_bindings.end(); ++k) {
742 child = new XMLNode (X_("Binding"));
743 child->set_property (X_("button"), k->first.name());
744 child->set_property (X_("action"), k->second.action_name);
745 releases->add_child_nocopy (*child);
748 root.add_child_nocopy (*presses);
749 root.add_child_nocopy (*releases);
753 Bindings::save_all_bindings_as_html (ostream& ostr)
755 if (bindings.empty()) {
760 ostr << "<html>\n<head>\n<title>";
761 ostr << PROGRAM_NAME;
762 ostr << "</title>\n";
763 ostr << "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n";
765 ostr << "</head>\n<body>\n";
767 ostr << "<table border=\"2\" cellpadding=\"6\"><tbody>\n\n";
770 /* first column: separate by group */
772 for (list<Bindings*>::const_iterator b = bindings.begin(); b != bindings.end(); ++b) {
773 (*b)->save_as_html (ostr, true);
778 ostr << "<td style=\"vertical-align:top\">\n\n";
779 for (list<Bindings*>::const_iterator b = bindings.begin(); b != bindings.end(); ++b) {
780 (*b)->save_as_html (ostr, false);
786 ostr << "</tbody></table>\n\n";
788 ostr << "</br></br>\n\n";
789 ostr << "<table border=\"2\" cellpadding=\"6\"><tbody>\n\n";
792 ostr << "<h2><u> Partial List of Available Actions { => with current shortcut, where applicable } </u></h2>\n\n";
794 vector<string> paths;
795 vector<string> labels;
796 vector<string> tooltips;
798 vector<Glib::RefPtr<Gtk::Action> > actions;
800 ActionManager::get_all_actions (paths, labels, tooltips, keys, actions);
802 vector<string>::iterator k;
803 vector<string>::iterator p;
804 vector<string>::iterator l;
806 for (p = paths.begin(), k = keys.begin(), l = labels.begin(); p != paths.end(); ++k, ++p, ++l) {
808 string print_path = *p;
809 /* strip <Actions>/ from the start */
810 print_path = print_path.substr (10);
813 ostr << print_path << " ( " << *l << " ) " << "</br>" << endl;
815 ostr << print_path << " ( " << *l << " ) " << " => " << *k << "</br>" << endl;
821 ostr << "</tbody></table>\n\n";
828 Bindings::save_as_html (ostream& ostr, bool categorize) const
831 if (!press_bindings.empty()) {
835 ostr << _("Window") << ": " << name() << _(" (Categorized)");
837 ostr << _("Window") << ": " << name() << _(" (Alphabetical)");
838 ostr << "</u></h2>\n\n";
840 typedef std::map<std::string, std::vector<KeybindingMap::const_iterator> > GroupMap;
843 for (KeybindingMap::const_iterator k = press_bindings.begin(); k != press_bindings.end(); ++k) {
845 if (k->first.name().empty()) {
850 if (categorize && !k->second.group_name.empty()) {
851 group_name = k->second.group_name;
853 group_name = _("Uncategorized");
856 GroupMap::iterator gm = group_map.find (group_name);
857 if (gm == group_map.end()) {
858 std::vector<KeybindingMap::const_iterator> li;
860 group_map.insert (make_pair (group_name,li));
862 gm->second.push_back (k);
867 for (GroupMap::const_iterator gm = group_map.begin(); gm != group_map.end(); ++gm) {
870 ostr << "<h3>" << gm->first << "</h3>\n";
873 for (vector<KeybindingMap::const_iterator>::const_iterator k = gm->second.begin(); k != gm->second.end(); ++k) {
875 if ((*k)->first.name().empty()) {
879 RefPtr<Action> action;
881 if ((*k)->second.action) {
882 action = (*k)->second.action;
884 action = ActionManager::get_action ((*k)->second.action_name, false);
891 string key_name = (*k)->first.native_short_name ();
892 replace_all (key_name, X_("KP_"), X_("Numpad "));
893 replace_all (key_name, X_("nabla"), X_("Tab"));
895 string::size_type pos;
897 char const *targets[] = { X_("Separator"), X_("Add"), X_("Subtract"), X_("Decimal"), X_("Divide"),
898 X_("grave"), X_("comma"), X_("period"), X_("asterisk"), X_("backslash"),
899 X_("apostrophe"), X_("minus"), X_("plus"), X_("slash"), X_("semicolon"),
900 X_("colon"), X_("equal"), X_("bracketleft"), X_("bracketright"),
901 X_("ampersand"), X_("numbersign"), X_("parenleft"), X_("parenright"),
902 X_("quoteright"), X_("quoteleft"), X_("exclam"), X_("quotedbl"),
906 char const *replacements[] = { X_("-"), X_("+"), X_("-"), X_("."), X_("/"),
907 X_("`"), X_(","), X_("."), X_("*"), X_("\\"),
908 X_("'"), X_("-"), X_("+"), X_("/"), X_(";"),
909 X_(":"), X_("="), X_("{"), X_("{"),
910 X_("&"), X_("#"), X_("("), X_(")"),
911 X_("`"), X_("'"), X_("!"), X_("\""),
914 for (size_t n = 0; targets[n]; ++n) {
915 if ((pos = key_name.find (targets[n])) != string::npos) {
916 key_name.replace (pos, strlen (targets[n]), replacements[n]);
920 key_name.append(" ");
922 while (key_name.length()<28)
923 key_name.append("-");
925 ostr << "<span style=\"font-family:monospace;\">" << key_name;
926 ostr << "<i>" << action->get_label() << "</i></span></br>\n";
937 Bindings::load (XMLNode const& node)
939 const XMLNodeList& children (node.children());
941 press_bindings.clear ();
942 release_bindings.clear ();
944 for (XMLNodeList::const_iterator i = children.begin(); i != children.end(); ++i) {
945 /* each node could be Press or Release */
946 load_operation (**i);
953 Bindings::load_operation (XMLNode const& node)
955 if (node.name() == X_("Press") || node.name() == X_("Release")) {
959 if (node.name() == X_("Press")) {
965 const XMLNodeList& children (node.children());
967 for (XMLNodeList::const_iterator p = children.begin(); p != children.end(); ++p) {
969 XMLProperty const * ap;
970 XMLProperty const * kp;
971 XMLProperty const * bp;
972 XMLProperty const * gp;
973 XMLNode const * child = *p;
975 ap = child->property ("action");
976 kp = child->property ("key");
977 bp = child->property ("button");
978 gp = child->property ("group");
980 if (!ap || (!kp && !bp)) {
986 if (!KeyboardKey::make_key (kp->value(), k)) {
989 add (k, op, ap->value(), gp);
992 if (!MouseButton::make_button (bp->value(), b)) {
995 add (b, op, ap->value(), gp);
1002 Bindings::get_all_actions (std::vector<std::string>& paths,
1003 std::vector<std::string>& labels,
1004 std::vector<std::string>& tooltips,
1005 std::vector<std::string>& keys,
1006 std::vector<RefPtr<Action> >& actions)
1008 /* build a reverse map from actions to bindings */
1010 typedef map<Glib::RefPtr<Gtk::Action>,KeyboardKey> ReverseMap;
1013 for (KeybindingMap::const_iterator k = press_bindings.begin(); k != press_bindings.end(); ++k) {
1014 rmap.insert (make_pair (k->second.action, k->first));
1019 /* get a list of all actions XXX relevant for these bindings */
1021 ActionMap::Actions all_actions;
1022 ActionManager::get_actions (all_actions);
1024 for (ActionMap::Actions::const_iterator act = all_actions.begin(); act != all_actions.end(); ++act) {
1026 paths.push_back ((*act)->get_accel_path());
1027 labels.push_back ((*act)->get_label());
1028 tooltips.push_back ((*act)->get_tooltip());
1030 ReverseMap::iterator r = rmap.find (*act);
1032 if (r != rmap.end()) {
1033 keys.push_back (r->second.display_label());
1035 keys.push_back (string());
1038 actions.push_back (*act);
1044 Bindings::get_bindings (string const& name)
1046 for (list<Bindings*>::iterator b = bindings.begin(); b != bindings.end(); b++) {
1047 if ((*b)->name() == name) {
1056 Bindings::associate_all ()
1058 for (list<Bindings*>::iterator b = bindings.begin(); b != bindings.end(); b++) {
1064 Bindings::is_bound (KeyboardKey const& kb, Operation op) const
1066 const KeybindingMap& km = get_keymap(op);
1067 return km.find(kb) != km.end();
1071 Bindings::bound_name (KeyboardKey const& kb, Operation op) const
1073 const KeybindingMap& km = get_keymap(op);
1074 KeybindingMap::const_iterator b = km.find(kb);
1075 if (b == km.end()) {
1078 return b->second.action_name;
1082 Bindings::is_registered (Operation op, std::string const& action_name) const
1084 const KeybindingMap& km = get_keymap(op);
1085 return std::find_if(km.begin(), km.end(), ActionNameRegistered<KeybindingMap::const_iterator::value_type>(action_name)) != km.end();
1088 Bindings::KeybindingMap&
1089 Bindings::get_keymap (Operation op)
1093 return press_bindings;
1096 return release_bindings;
1100 const Bindings::KeybindingMap&
1101 Bindings::get_keymap (Operation op) const
1105 return press_bindings;
1108 return release_bindings;
1112 Bindings::MouseButtonBindingMap&
1113 Bindings::get_mousemap (Operation op)
1117 return button_press_bindings;
1120 return button_release_bindings;
1124 std::ostream& operator<<(std::ostream& out, Gtkmm2ext::KeyboardKey const & k) {
1125 char const *gdk_name = gdk_keyval_name (k.key());
1126 return out << "Key " << k.key() << " (" << (gdk_name ? gdk_name : "no-key") << ") state "
1127 << hex << k.state() << dec << ' ' << show_gdk_event_state (k.state());