better system for managing kbd focus after cmd-w closing a dialog.

Key, Button and Focus In events in the editor+mixer windows cause the respective window to be noted
as the window to which focus should return after a dialog is closed with cmd/ctrl-w
This commit is contained in:
Paul Davis 2016-02-22 14:03:55 -05:00
parent 60c4b30b7e
commit 86d27a736c
4 changed files with 36 additions and 9 deletions

View File

@ -87,6 +87,7 @@ ARDOUR_UI::create_editor ()
editor->Realized.connect (sigc::mem_fun (*this, &ARDOUR_UI::editor_realized));
editor->signal_window_state_event().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::main_window_state_event_handler), true));
editor->signal_event().connect (sigc::bind (sigc::ptr_fun (&Keyboard::catch_user_event_for_pre_dialog_focus), editor));
return 0;
}

View File

@ -23,6 +23,8 @@
is to cut down on the nasty compile times for these classes.
*/
#include "gtkmm2ext/keyboard.h"
#include "actions.h"
#include "ardour_ui.h"
#include "mixer_ui.h"
@ -46,6 +48,7 @@ ARDOUR_UI::create_mixer ()
}
mixer->signal_window_state_event().connect (sigc::bind (sigc::mem_fun (*this, &ARDOUR_UI::main_window_state_event_handler), false));
mixer->signal_event().connect (sigc::bind (sigc::ptr_fun (&Gtkmm2ext::Keyboard::catch_user_event_for_pre_dialog_focus), mixer));
return 0;
}

View File

@ -166,6 +166,8 @@ class LIBGTKMM2EXT_API Keyboard : public sigc::trackable, PBD::Stateful
static std::string current_binding_name () { return _current_binding_name; }
static std::map<std::string,std::string> binding_files;
static bool catch_user_event_for_pre_dialog_focus (GdkEvent* ev, Gtk::Window* w);
int reset_bindings ();
struct AccelKeyLess {
@ -211,6 +213,7 @@ class LIBGTKMM2EXT_API Keyboard : public sigc::trackable, PBD::Stateful
static void set_modifier (uint32_t newval, uint32_t& variable);
static bool _some_magic_widget_has_focus;
static Gtk::Window* pre_dialog_active_window;
};
} /* namespace */

View File

@ -111,9 +111,9 @@ bool Keyboard::bindings_changed_after_save_became_legal = false;
map<string,string> Keyboard::binding_files;
string Keyboard::_current_binding_name;
map<AccelKey,pair<string,string>,Keyboard::AccelKeyLess> Keyboard::release_keys;
Gtk::Window* Keyboard::pre_dialog_active_window = 0;
/* set this to initially contain the modifiers we care about, then track changes in ::set_edit_modifier() etc. */
GdkModifierType Keyboard::RelevantModifierKeyMask;
void
@ -432,17 +432,37 @@ Keyboard::close_current_dialog ()
if (current_window) {
current_window->hide ();
current_window = 0;
#ifdef __APPLE__
/* Since Apple users has a basically unconfigurable window
manager, and since users there cannot use
focus-follows-mouse, we force focus back to some application
"main window" after closing a dialog via Primary-w.
*/
GrabFocus ();
#endif
if (pre_dialog_active_window) {
pre_dialog_active_window->present ();
pre_dialog_active_window = 0;
}
}
}
bool
Keyboard::catch_user_event_for_pre_dialog_focus (GdkEvent* ev, Gtk::Window* w)
{
switch (ev->type) {
case GDK_BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
pre_dialog_active_window = w;
break;
case GDK_FOCUS_CHANGE:
if (ev->focus_change.in) {
pre_dialog_active_window = w;
}
break;
default:
break;
}
return false;
}
bool
Keyboard::key_is_down (uint32_t keyval)
{