+#endif
+}
+
+void
+#ifdef GTKOSX
+PluginUIWindow::app_activated (bool yn)
+#else
+PluginUIWindow::app_activated (bool)
+#endif
+{
+#ifdef GTKOSX
+ if (_pluginui) {
+ if (yn) {
+ if (was_visible) {
+ _pluginui->activate ();
+ present ();
+ was_visible = true;
+ }
+ } else {
+ was_visible = is_visible();
+ hide ();
+ _pluginui->deactivate ();
+ }
+ }
+#endif
+}
+
+bool
+PluginUIWindow::create_lv2_editor(boost::shared_ptr<PluginInsert> insert)
+{
+#if defined(HAVE_SLV2) || defined(HAVE_SUIL)
+ boost::shared_ptr<LV2Plugin> vp;
+
+ if ((vp = boost::dynamic_pointer_cast<LV2Plugin> (insert->plugin())) == 0) {
+ error << _("create_lv2_editor called on non-LV2 plugin") << endmsg;
+ throw failed_constructor ();
+ } else {
+ LV2PluginUI* lpu = new LV2PluginUI (insert, vp);
+ _pluginui = lpu;
+ add (*lpu);
+ lpu->package (*this);
+ }
+
+ return true;
+#else
+ return false;
+#endif
+}
+
+void
+PluginUIWindow::keyboard_focused (bool yn)
+{
+ _keyboard_focused = yn;
+}
+
+bool
+PluginUIWindow::on_key_press_event (GdkEventKey* event)
+{
+ if (_keyboard_focused) {
+ if (_pluginui) {
+ if (_pluginui->non_gtk_gui()) {
+ _pluginui->forward_key_event (event);
+ } else {
+ return relay_key_press (event, this);
+ }
+ }
+ return true;
+ } else {
+ /* for us to be getting key press events, there really
+ MUST be a _pluginui, but just to be safe, check ...
+ */
+
+ if (_pluginui) {
+ if (_pluginui->non_gtk_gui()) {
+ /* pass editor window as the window for the event
+ to be handled in, not this one, because there are
+ no widgets in this window that we want to have
+ key focus.
+ */
+ return relay_key_press (event, &PublicEditor::instance());
+ } else {
+ return relay_key_press (event, this);
+ }
+ } else {
+ return false;
+ }
+ }
+}
+
+bool
+PluginUIWindow::on_key_release_event (GdkEventKey *event)
+{
+ if (_keyboard_focused) {
+ if (_pluginui) {
+ if (_pluginui->non_gtk_gui()) {
+ _pluginui->forward_key_event (event);
+ }
+ return true;
+ }
+ return false;
+ } else {
+ return true;
+ }