From 4e019c46173b06ce6565ef44a29c6267f27ca0d7 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 25 Jun 2012 21:44:53 +0000 Subject: [PATCH] re-enable Carbon plugin GUI support; fix misplacement of Carbon plugin GUI windows because of differences between Carbon/Cocoa/GTK coordinate spaces git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@12932 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/au_pluginui.h | 2 ++ gtk2_ardour/au_pluginui.mm | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/gtk2_ardour/au_pluginui.h b/gtk2_ardour/au_pluginui.h index 384203db0d..048f086511 100644 --- a/gtk2_ardour/au_pluginui.h +++ b/gtk2_ardour/au_pluginui.h @@ -4,6 +4,8 @@ #include #include +#define WITH_CARBON + #ifdef WITH_CARBON #include #include diff --git a/gtk2_ardour/au_pluginui.mm b/gtk2_ardour/au_pluginui.mm index 81c065ef74..075164ec06 100644 --- a/gtk2_ardour/au_pluginui.mm +++ b/gtk2_ardour/au_pluginui.mm @@ -527,7 +527,7 @@ AUPluginUI::get_nswindow () void AUPluginUI::activate () { -#ifdef WITN_CARBON +#ifdef WITH_CARBON ActivateWindow (carbon_window, TRUE); #endif // [cocoa_parent makeKeyAndOrderFront:nil]; @@ -546,7 +546,7 @@ AUPluginUI::parent_carbon_window () { #ifdef WITH_CARBON NSWindow* win = get_nswindow (); - int x, y; + Rect windowStructureBoundsRect; if (!win) { return -1; @@ -558,8 +558,12 @@ AUPluginUI::parent_carbon_window () error << _("AUPluginUI: no top level window!") << endmsg; return -1; } - - toplevel->get_window()->get_root_origin (x, y); + + /* figure out where the cocoa parent window is in carbon-coordinate space, which + differs from both cocoa-coordinate space and GTK-coordinate space + */ + + GetWindowBounds((WindowRef) [win windowRef], kWindowStructureRgn, &windowStructureBoundsRect); /* compute how tall the title bar is, because we have to offset the position of the carbon window by that much. @@ -572,7 +576,11 @@ AUPluginUI::parent_carbon_window () int packing_extra = 6; // this is the total vertical packing in our top level window - MoveWindow (carbon_window, x, y + titlebar_height + top_box.get_height() + packing_extra, false); + /* move into position, based on parent window position */ + MoveWindow (carbon_window, + windowStructureBoundsRect.left, + windowStructureBoundsRect.top + titlebar_height + top_box.get_height() + packing_extra, + false); ShowWindow (carbon_window); // create the cocoa window for the carbon one and make it visible