diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2016-02-22 14:03:55 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2016-02-22 14:03:55 -0500 |
commit | 86d27a736c8e654dd2c03cfa12511ebd3e40128b (patch) | |
tree | 85ed725adde8fd5ef763cfd3b8562d9daa9eb3b9 /libs/gtkmm2ext/keyboard.cc | |
parent | 60c4b30b7ed37ae7fff54112982e6118c0ffab77 (diff) |
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
Diffstat (limited to 'libs/gtkmm2ext/keyboard.cc')
-rw-r--r-- | libs/gtkmm2ext/keyboard.cc | 38 |
1 files changed, 29 insertions, 9 deletions
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(); |