From 45cd3482a2bfce98b7a4fff79c148ef2d2dbd847 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 19 Aug 2016 08:32:28 -0400 Subject: [PATCH] fix failure to remove keyvalue from Keyboard::state on key release --- libs/gtkmm2ext/keyboard.cc | 49 +++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/libs/gtkmm2ext/keyboard.cc b/libs/gtkmm2ext/keyboard.cc index fe7303b290..a68418b7bd 100644 --- a/libs/gtkmm2ext/keyboard.cc +++ b/libs/gtkmm2ext/keyboard.cc @@ -309,17 +309,44 @@ Keyboard::snooper (GtkWidget *widget, GdkEventKey *event) } } - /* Special keys that we want to handle in - any dialog, no matter whether it uses - the regular set of accelerators or not - */ - - if (event->type == GDK_KEY_RELEASE && modifier_state_equals (event->state, PrimaryModifier)) { - switch (event->keyval) { - case GDK_w: - close_current_dialog (); - ret = true; - break; + if (event->type == GDK_KEY_RELEASE) { + + State::iterator k = find (state.begin(), state.end(), keyval); + + if (k != state.end()) { + /* this cannot change the ordering, so need to sort */ + state.erase (k); + if (state.empty()) { + DEBUG_TRACE (DEBUG::Keyboard, "no keys down\n"); + } else { +#ifndef NDEBUG + if (DEBUG_ENABLED(DEBUG::Keyboard)) { + DEBUG_STR_DECL(a); + DEBUG_STR_APPEND(a, "keyboard, keys still down: "); + for (State::iterator i = state.begin(); i != state.end(); ++i) { + DEBUG_STR_APPEND(a, gdk_keyval_name (*i)); + DEBUG_STR_APPEND(a, ','); + } + DEBUG_STR_APPEND(a, '\n'); + DEBUG_TRACE (DEBUG::Keyboard, DEBUG_STR(a).str()); + } + } +#endif /* NDEBUG */ + } + + if (modifier_state_equals (event->state, PrimaryModifier)) { + + /* Special keys that we want to handle in + any dialog, no matter whether it uses + the regular set of accelerators or not + */ + + switch (event->keyval) { + case GDK_w: + close_current_dialog (); + ret = true; + break; + } } } -- 2.30.2