+bool
+AUPluginUI::lower_box_visibility_notify (GdkEventVisibility* ev)
+{
+#ifdef WITH_CARBON
+ if (carbon_window && ev->state != GDK_VISIBILITY_UNOBSCURED) {
+ ShowWindow (carbon_window);
+ ActivateWindow (carbon_window, TRUE);
+ return true;
+ }
+#endif
+ return false;
+}
+
+void
+AUPluginUI::update_view_size ()
+{
+ if (!mapped || alo_width == 0 || alo_height == 0) {
+ return;
+ }
+ gint xx, yy;
+ gtk_widget_translate_coordinates(
+ GTK_WIDGET(low_box.gobj()),
+ GTK_WIDGET(low_box.get_parent()->gobj()),
+ 8, 6, &xx, &yy);
+
+ [[NSNotificationCenter defaultCenter] removeObserver:_notify
+ name:NSViewFrameDidChangeNotification
+ object:au_view];
+
+ if (!resizable) {
+ xx += (alo_width - req_width) * .5;
+ [au_view setFrame:NSMakeRect(xx, yy, req_width, req_height)];
+ } else {
+ /* this mitigates issues with plugins that resize themselves
+ * depending on visible options (e.g AUSampler)
+ * since the OSX y-axis points upwards, the plugin adjusts its
+ * own y-offset if the view expands to the bottom to accomodate
+ * subviews inside the main view.
+ */
+ [au_view setAutoresizesSubviews:0];
+ [au_view setFrame:NSMakeRect(xx, yy, alo_width, alo_height)];
+ [au_view setAutoresizesSubviews:1];
+ [au_view setNeedsDisplay:1];
+ }
+
+ last_au_frame = [au_view frame];
+
+ [[NSNotificationCenter defaultCenter]
+ addObserver:_notify
+ selector:@selector(auViewResized:) name:NSViewFrameDidChangeNotification
+ object:au_view];
+}
+
+void
+AUPluginUI::lower_box_map ()
+{
+ mapped = true;
+ [au_view setHidden:0];
+ update_view_size ();
+}
+
+void
+AUPluginUI::lower_box_unmap ()
+{
+ mapped = false;
+ [au_view setHidden:1];
+}
+
+void
+AUPluginUI::lower_box_size_request (GtkRequisition* requisition)
+{
+ requisition->width = req_width;
+ requisition->height = req_height;
+}
+
+void
+AUPluginUI::lower_box_size_allocate (Gtk::Allocation& allocation)
+{
+ alo_width = allocation.get_width ();
+ alo_height = allocation.get_height ();
+ update_view_size ();
+}
+
+gboolean
+AUPluginUI::lower_box_expose (GdkEventExpose* event)
+{
+#if 0 // AU view magically redraws by itself
+ [au_view drawRect:NSMakeRect(event->area.x,
+ event->area.y,
+ event->area.width,
+ event->area.height)];
+#endif
+ /* hack to keep ardour responsive
+ * some UIs (e.g Addictive Drums) completely hog the CPU
+ */
+ ARDOUR::GUIIdle();
+
+ return true;
+}
+