diff options
-rw-r--r-- | gtk2_ardour/ardour_ui_ed.cc | 1 | ||||
-rw-r--r-- | gtk2_ardour/ardour_ui_mixer.cc | 3 | ||||
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/keyboard.h | 3 | ||||
-rw-r--r-- | libs/gtkmm2ext/keyboard.cc | 38 |
4 files changed, 36 insertions, 9 deletions
diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index 06995f75d7..8329ea35d2 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -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; } diff --git a/gtk2_ardour/ardour_ui_mixer.cc b/gtk2_ardour/ardour_ui_mixer.cc index 56ecc057f0..f5a8bc2713 100644 --- a/gtk2_ardour/ardour_ui_mixer.cc +++ b/gtk2_ardour/ardour_ui_mixer.cc @@ -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; } diff --git a/libs/gtkmm2ext/gtkmm2ext/keyboard.h b/libs/gtkmm2ext/gtkmm2ext/keyboard.h index 4319c9a4f6..5b4e6c50c6 100644 --- a/libs/gtkmm2ext/gtkmm2ext/keyboard.h +++ b/libs/gtkmm2ext/gtkmm2ext/keyboard.h @@ -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 */ diff --git a/libs/gtkmm2ext/keyboard.cc b/libs/gtkmm2ext/keyboard.cc index c1a279cce6..7217544ea6 100644 --- a/libs/gtkmm2ext/keyboard.cc +++ b/libs/gtkmm2ext/keyboard.cc @@ -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,18 +432,38 @@ 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) { return find (state.begin(), state.end(), keyval) != state.end(); |