libgtkmm2ext: modify Keyboard handling of close-current-dialog

1) if there is no current dialog, allow some other window to handle the keyboard event
2) make the binding (which is hard coded) visible as static members of Keyboard
This commit is contained in:
Paul Davis
2021-04-26 10:48:20 -06:00
parent 54c135c8b9
commit 6db261d566
2 changed files with 15 additions and 5 deletions

View File

@@ -169,7 +169,7 @@ class LIBGTKMM2EXT_API Keyboard : public sigc::trackable, PBD::Stateful
static void magic_widget_drop_focus ();
static Gtk::Window* get_current_window () { return current_window; };
static void close_current_dialog ();
static bool close_current_dialog ();
static void keybindings_changed ();
static void save_keybindings ();
@@ -183,6 +183,8 @@ class LIBGTKMM2EXT_API Keyboard : public sigc::trackable, PBD::Stateful
static void save_keybindings (std::string const& path);
static std::string binding_filename_suffix;
static const int close_window_key;
static guint close_window_modifier;
int reset_bindings ();

View File

@@ -121,6 +121,9 @@ Keyboard* Keyboard::_the_keyboard = 0;
Gtk::Window* Keyboard::current_window = 0;
bool Keyboard::_some_magic_widget_has_focus = false;
const int Keyboard::close_window_key = GDK_w;
guint Keyboard::close_window_modifier = Keyboard::PrimaryModifier;
std::string Keyboard::user_keybindings_path;
bool Keyboard::can_save_keybindings = false;
bool Keyboard::bindings_changed_after_save_became_legal = false;
@@ -309,9 +312,10 @@ Keyboard::snooper (GtkWidget *widget, GdkEventKey *event)
*/
switch (event->keyval) {
case GDK_w:
close_current_dialog ();
ret = true;
case close_window_key:
if (close_current_dialog ()) {
ret = true;
}
break;
}
}
@@ -339,7 +343,7 @@ Keyboard::reset_relevant_modifier_key_mask ()
RelevantModifierKeysChanged(); /* EMIT SIGNAL */
}
void
bool
Keyboard::close_current_dialog ()
{
if (current_window) {
@@ -353,7 +357,11 @@ Keyboard::close_current_dialog ()
pre_dialog_active_window->present ();
pre_dialog_active_window = 0;
}
return true;
}
return false;
}
bool