summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2015-02-21 03:16:04 +0100
committerRobin Gareus <robin@gareus.org>2015-02-21 03:16:04 +0100
commita0eeb808850f9b39bd1b5526d70634a75a0a9701 (patch)
treeb37b1991302cc69bda8487e385a4aa3418009391 /gtk2_ardour
parent642e4950b915a2317bd51e3ec7c270909229c353 (diff)
fix embedded plugin UI keyboard handling
When the GUI is opened the first time all is fine, focus is on the embedded widget. However once a user presses one of the preset buttons (Add, Save,...) there is no possibility to return focus to the embedded widget. Ardour always 'sees' it as focus=GtkButton and passes the event to the editor.
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/au_pluginui.h1
-rw-r--r--gtk2_ardour/au_pluginui.mm7
-rw-r--r--gtk2_ardour/lv2_plugin_ui.cc11
-rw-r--r--gtk2_ardour/lv2_plugin_ui.h1
-rw-r--r--gtk2_ardour/plugin_ui.cc2
-rw-r--r--gtk2_ardour/plugin_ui.h3
6 files changed, 24 insertions, 1 deletions
diff --git a/gtk2_ardour/au_pluginui.h b/gtk2_ardour/au_pluginui.h
index 424d81e901..71c81dfde3 100644
--- a/gtk2_ardour/au_pluginui.h
+++ b/gtk2_ardour/au_pluginui.h
@@ -76,6 +76,7 @@ class AUPluginUI : public PlugUIBase, public Gtk::VBox
void lower_box_realized ();
void cocoa_view_resized ();
void on_realize ();
+ void grab_focus();
void forward_key_event (GdkEventKey*);
bool on_window_show (const std::string& /*title*/);
diff --git a/gtk2_ardour/au_pluginui.mm b/gtk2_ardour/au_pluginui.mm
index 9040d28a6f..76b94781d5 100644
--- a/gtk2_ardour/au_pluginui.mm
+++ b/gtk2_ardour/au_pluginui.mm
@@ -678,6 +678,13 @@ AUPluginUI::parent_cocoa_window ()
}
void
+AUPluginUI::grab_focus()
+{
+ if (au_view) {
+ [au_view becomeFirstResponder];
+ }
+}
+void
AUPluginUI::forward_key_event (GdkEventKey* ev)
{
NSEvent* nsevent = gdk_quartz_event_get_nsevent ((GdkEvent*)ev);
diff --git a/gtk2_ardour/lv2_plugin_ui.cc b/gtk2_ardour/lv2_plugin_ui.cc
index 3a64a830d1..8e57eeed60 100644
--- a/gtk2_ardour/lv2_plugin_ui.cc
+++ b/gtk2_ardour/lv2_plugin_ui.cc
@@ -341,6 +341,8 @@ LV2PluginUI::lv2ui_instantiate(const std::string& title)
container->add(*Gtk::manage(Glib::wrap(c_widget)));
}
container->show_all();
+ gtk_widget_set_can_focus(c_widget, true);
+ gtk_widget_grab_focus(c_widget);
} else {
_external_ui_ptr = (struct lv2_external_ui*)GET_WIDGET(_inst);
}
@@ -369,6 +371,15 @@ LV2PluginUI::lv2ui_instantiate(const std::string& title)
}
void
+LV2PluginUI::grab_focus()
+{
+ if (_inst && !_lv2->is_external_ui()) {
+ GtkWidget* c_widget = (GtkWidget*)GET_WIDGET(_inst);
+ gtk_widget_grab_focus(c_widget);
+ }
+}
+
+void
LV2PluginUI::lv2ui_free()
{
stop_updating (0);
diff --git a/gtk2_ardour/lv2_plugin_ui.h b/gtk2_ardour/lv2_plugin_ui.h
index a39386a7e0..6a8acf9cf5 100644
--- a/gtk2_ardour/lv2_plugin_ui.h
+++ b/gtk2_ardour/lv2_plugin_ui.h
@@ -60,6 +60,7 @@ class LV2PluginUI : public PlugUIBase, public Gtk::VBox
bool stop_updating(GdkEventAny*);
int package (Gtk::Window&);
+ void grab_focus ();
private:
diff --git a/gtk2_ardour/plugin_ui.cc b/gtk2_ardour/plugin_ui.cc
index 717fd6d44b..b4e8e0001e 100644
--- a/gtk2_ardour/plugin_ui.cc
+++ b/gtk2_ardour/plugin_ui.cc
@@ -353,6 +353,7 @@ PluginUIWindow::on_key_press_event (GdkEventKey* event)
{
if (_keyboard_focused) {
if (_pluginui) {
+ _pluginui->grab_focus();
if (_pluginui->non_gtk_gui()) {
_pluginui->forward_key_event (event);
} else {
@@ -366,6 +367,7 @@ PluginUIWindow::on_key_press_event (GdkEventKey* event)
*/
if (_pluginui) {
+ _pluginui->grab_focus();
if (_pluginui->non_gtk_gui()) {
/* pass editor window as the window for the event
to be handled in, not this one, because there are
diff --git a/gtk2_ardour/plugin_ui.h b/gtk2_ardour/plugin_ui.h
index 14bfbe3eca..58dc6ce2a3 100644
--- a/gtk2_ardour/plugin_ui.h
+++ b/gtk2_ardour/plugin_ui.h
@@ -103,7 +103,8 @@ class PlugUIBase : public virtual sigc::trackable, public PBD::ScopedConnectionL
virtual void on_window_hide() {}
virtual void forward_key_event (GdkEventKey*) {}
- virtual bool non_gtk_gui() const { return false; }
+ virtual void grab_focus () {}
+ virtual bool non_gtk_gui() const { return false; }
sigc::signal<void,bool> KeyboardFocused;