diff options
author | nick_m <mainsbridge@gmail.com> | 2015-04-02 02:41:49 +1100 |
---|---|---|
committer | nick_m <mainsbridge@gmail.com> | 2015-04-02 02:41:49 +1100 |
commit | 35f69656e859cdd00ce28e29083788a91d3fbd5f (patch) | |
tree | b53ca99b60eff69381ffc85a6011d56aea412535 /libs | |
parent | 9a4827374ca4e4c310d02adf65c727d92b56724c (diff) |
Window focus handling fixes.
Many windows were not getting key events.
Use magic focus infrastructure (built for widgets) to deliver key events
via window focus in/out.
Diffstat (limited to 'libs')
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/keyboard.h | 3 | ||||
-rw-r--r-- | libs/gtkmm2ext/keyboard.cc | 23 |
2 files changed, 26 insertions, 0 deletions
diff --git a/libs/gtkmm2ext/gtkmm2ext/keyboard.h b/libs/gtkmm2ext/gtkmm2ext/keyboard.h index d756c6199e..328638373f 100644 --- a/libs/gtkmm2ext/gtkmm2ext/keyboard.h +++ b/libs/gtkmm2ext/gtkmm2ext/keyboard.h @@ -106,6 +106,8 @@ class LIBGTKMM2EXT_API Keyboard : public sigc::trackable, PBD::Stateful bool leave_window (GdkEventCrossing *ev, Gtk::Window*); bool enter_window (GdkEventCrossing *ev, Gtk::Window*); + bool focus_in_window (GdkEventFocus *ev, Gtk::Window*); + bool focus_out_window (GdkEventFocus *ev, Gtk::Window*); static bool modifier_state_contains (guint state, ModifierMask); static bool modifier_state_equals (guint state, ModifierMask); @@ -146,6 +148,7 @@ class LIBGTKMM2EXT_API Keyboard : public sigc::trackable, PBD::Stateful static bool some_magic_widget_has_focus (); static void magic_widget_grab_focus (); static void magic_widget_drop_focus (); + static Gtk::Window* get_current_window () { return current_window; }; static void close_current_dialog (); diff --git a/libs/gtkmm2ext/keyboard.cc b/libs/gtkmm2ext/keyboard.cc index 48fcae8482..420d42209b 100644 --- a/libs/gtkmm2ext/keyboard.cc +++ b/libs/gtkmm2ext/keyboard.cc @@ -384,6 +384,29 @@ Keyboard::leave_window (GdkEventCrossing *ev, Gtk::Window* /*win*/) return false; } +bool +Keyboard::focus_in_window (GdkEventFocus *, Gtk::Window* win) +{ + current_window = win; + DEBUG_TRACE (DEBUG::Keyboard, string_compose ("Focusing in window, title = %1\n", win->get_title())); + return false; +} + +bool +Keyboard::focus_out_window (GdkEventFocus * ev, Gtk::Window* win) +{ + if (ev) { + state.clear (); + current_window = 0; + } else { + current_window = 0; + } + + DEBUG_TRACE (DEBUG::Keyboard, string_compose ("Foucusing out window, title = %1\n", win->get_title())); + + return false; +} + void Keyboard::set_edit_button (guint but) { |