+void
+PluginUIWindow::set_parent (Gtk::Window* win)
+{
+ parent = win;
+}
+
+void
+PluginUIWindow::on_map ()
+{
+ Window::on_map ();
+ set_keep_above (true);
+}
+
+bool
+PluginUIWindow::on_enter_notify_event (GdkEventCrossing *ev)
+{
+ Keyboard::the_keyboard().enter_window (ev, this);
+ return false;
+}
+
+bool
+PluginUIWindow::on_leave_notify_event (GdkEventCrossing *ev)
+{
+ Keyboard::the_keyboard().leave_window (ev, this);
+ return false;
+}
+
+bool
+PluginUIWindow::on_focus_in_event (GdkEventFocus *ev)
+{
+ Window::on_focus_in_event (ev);
+ //Keyboard::the_keyboard().magic_widget_grab_focus ();
+ return false;
+}
+
+bool
+PluginUIWindow::on_focus_out_event (GdkEventFocus *ev)
+{
+ Window::on_focus_out_event (ev);
+ //Keyboard::the_keyboard().magic_widget_drop_focus ();
+ return false;
+}
+
+void
+PluginUIWindow::on_show ()
+{
+ if (_pluginui) {
+ _pluginui->update_presets ();
+ }
+
+ Window::on_show ();
+
+ if (parent) {
+ // set_transient_for (*parent);
+ }
+}
+
+void
+PluginUIWindow::on_hide ()
+{
+ Window::on_hide ();
+}
+
+bool
+PluginUIWindow::create_vst_editor(boost::shared_ptr<PluginInsert> insert)
+{
+#ifndef VST_SUPPORT
+ return false;
+#else
+
+ boost::shared_ptr<VSTPlugin> vp;
+
+ if ((vp = boost::dynamic_pointer_cast<VSTPlugin> (insert->plugin())) == 0) {
+ error << _("unknown type of editor-supplying plugin (note: no VST support in this version of ardour)")
+ << endmsg;
+ throw failed_constructor ();
+ } else {
+ VSTPluginUI* vpu = new VSTPluginUI (insert, vp);
+
+ _pluginui = vpu;
+ add (*vpu);
+ vpu->package (*this);
+ }
+
+ non_gtk_gui = true;
+ return true;
+#endif
+}
+
+bool
+PluginUIWindow::create_audiounit_editor (boost::shared_ptr<PluginInsert> insert)
+{
+#if !defined(HAVE_AUDIOUNITS) || !defined(GTKOSX)
+ return false;
+#else
+ VBox* box;
+ _pluginui = create_au_gui (insert, &box);
+ add (*box);
+ non_gtk_gui = true;
+
+ extern sigc::signal<void,bool> ApplicationActivationChanged;
+ ApplicationActivationChanged.connect (mem_fun (*this, &PluginUIWindow::app_activated));
+
+ return true;
+#endif
+}
+
+void
+PluginUIWindow::app_activated (bool yn)
+{
+#if defined (HAVE_AUDIOUNITS) && defined(GTKOSX)
+ cerr << "APP activated ? " << yn << endl;
+ 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)
+{
+#ifndef HAVE_LV2
+ return false;
+#else
+
+ 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);
+ }
+
+ non_gtk_gui = false;
+ return true;
+#endif
+}
+