fixes for AU plugin GUIs, including the "hidden GUI shows up when app becomes active/focus again" bug

git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@3241 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2008-04-09 21:05:58 +00:00
parent 5a484d8f36
commit edab5bb523
5 changed files with 67 additions and 54 deletions

View file

@ -3359,6 +3359,11 @@ ARDOUR_UI::TransportControllable::set_id (const string& str)
void
ARDOUR_UI::setup_profile ()
{
cerr << "GDK screen dimensions: "
<< gdk_screen_width() << " x "
<< gdk_screen_height()
<< endl;
if (gdk_screen_width() < 1200) {
Profile->set_small_screen ();
}

View file

@ -39,9 +39,9 @@ class AUPluginUI : public PlugUIBase, public Gtk::VBox
bool start_updating(GdkEventAny*);
bool stop_updating(GdkEventAny*);
virtual void activate ();
virtual void deactivate ();
void activate ();
void deactivate ();
void lower_box_realized ();
void on_realize ();
void on_show ();
@ -56,7 +56,7 @@ class AUPluginUI : public PlugUIBase, public Gtk::VBox
boost::shared_ptr<ARDOUR::AUPlugin> au;
int prefheight;
int prefwidth;
Gtk::HBox top_box;
Gtk::EventBox low_box;
Gtk::VBox vpacker;
@ -80,6 +80,7 @@ class AUPluginUI : public PlugUIBase, public Gtk::VBox
WindowRef carbon_window;
EventHandlerRef carbon_event_handler;
bool _activating_from_app;
NSView* packView;
bool test_cocoa_view_support ();
bool test_carbon_view_support ();

View file

@ -83,6 +83,7 @@ AUPluginUI::AUPluginUI (boost::shared_ptr<PluginInsert> insert)
cocoa_parent = 0;
cocoa_window = 0;
au_view = 0;
packView = 0;
/* prefer cocoa, fall back to cocoa, but use carbon if its there */
@ -108,6 +109,9 @@ AUPluginUI::~AUPluginUI ()
DisposeWindow (carbon_window);
}
if (packView && packView != au_view) {
[packView release];
}
}
bool
@ -260,6 +264,49 @@ AUPluginUI::create_cocoa_view ()
[(AUGenericView *)au_view setShowsExpertParameters:YES];
}
NSRect packFrame;
// Get the size of the new AU View's frame
packFrame = [au_view frame];
packFrame.origin.x = 0;
packFrame.origin.y = 0;
if (packFrame.size.width > 500 || packFrame.size.height > 500) {
/* its too big - use a scrollview */
NSRect frameRect = [[cocoa_window contentView] frame];
scroll_view = [[[NSScrollView alloc] initWithFrame:frameRect] autorelease];
[scroll_view setDrawsBackground:NO];
[scroll_view setHasHorizontalScroller:YES];
[scroll_view setHasVerticalScroller:YES];
packFrame.size = [NSScrollView frameSizeForContentSize:packFrame.size
hasHorizontalScroller:[scroll_view hasHorizontalScroller]
hasVerticalScroller:[scroll_view hasVerticalScroller]
borderType:[scroll_view borderType]];
// Create a new frame with same origin as current
// frame but size equal to the size of the new view
NSRect newFrame;
newFrame.origin = [scroll_view frame].origin;
newFrame.size = packFrame.size;
// Set the new frame and document views on the scroll view
[scroll_view setFrame:newFrame];
[scroll_view setDocumentView:au_view];
packView = scroll_view;
} else {
packView = au_view;
}
prefwidth = packFrame.size.width;
prefheight = packFrame.size.height;
return 0;
}
@ -353,7 +400,7 @@ AUPluginUI::activate ()
void
AUPluginUI::deactivate ()
{
return;
return;
cerr << "APP DEactivated, for " << insert->name() << endl;
_activating_from_app = true;
ActivateWindow (carbon_window, FALSE);
@ -465,7 +512,6 @@ int
AUPluginUI::parent_cocoa_window ()
{
NSWindow* win = get_nswindow ();
NSView* packView = 0;
NSRect packFrame;
if (!win) {
@ -481,40 +527,6 @@ AUPluginUI::parent_cocoa_window ()
// Get the size of the new AU View's frame
packFrame = [au_view frame];
packFrame.origin.x = 0;
packFrame.origin.y = 0;
if (packFrame.size.width > 500 || packFrame.size.height > 500) {
/* its too big - use a scrollview */
NSRect frameRect = [[cocoa_window contentView] frame];
scroll_view = [[[NSScrollView alloc] initWithFrame:frameRect] autorelease];
[scroll_view setDrawsBackground:NO];
[scroll_view setHasHorizontalScroller:YES];
[scroll_view setHasVerticalScroller:YES];
packFrame.size = [NSScrollView frameSizeForContentSize:packFrame.size
hasHorizontalScroller:[scroll_view hasHorizontalScroller]
hasVerticalScroller:[scroll_view hasVerticalScroller]
borderType:[scroll_view borderType]];
// Create a new frame with same origin as current
// frame but size equal to the size of the new view
NSRect newFrame;
newFrame.origin = [scroll_view frame].origin;
newFrame.size = packFrame.size;
// Set the new frame and document views on the scroll view
[scroll_view setFrame:newFrame];
[scroll_view setDocumentView:au_view];
packView = scroll_view;
} else {
packView = au_view;
}
NSView* view = gdk_quartz_window_get_nsview (low_box.get_window()->gobj());
@ -559,17 +571,6 @@ AUPluginUI::on_hide ()
bool
AUPluginUI::on_map_event (GdkEventAny* ev)
{
cerr << "AU plugin map event\n";
if (carbon_window) {
// move top level GTK window to the correct level
// to keep the stack together and not be sliceable
NSWindow* win = get_nswindow ();
// [win setLevel:NSFloatingWindowLevel];
}
return false;
}

View file

@ -66,6 +66,7 @@ PluginUIWindow::PluginUIWindow (Gtk::Window* win, boost::shared_ptr<PluginInsert
{
bool have_gui = false;
non_gtk_gui = false;
was_visible = false;
if (insert->plugin()->has_editor()) {
switch (insert->type()) {
@ -156,7 +157,6 @@ PluginUIWindow::on_show ()
Window::on_show ();
if (parent) {
cerr << "plugin becomes transient for " << parent << endl;
// set_transient_for (*parent);
}
}
@ -218,9 +218,13 @@ PluginUIWindow::app_activated (bool yn)
cerr << "APP activated ? " << yn << endl;
if (_pluginui) {
if (yn) {
_pluginui->activate ();
present ();
if (was_visible) {
_pluginui->activate ();
present ();
was_visible = true;
}
} else {
was_visible = is_visible();
hide ();
_pluginui->deactivate ();
}

View file

@ -220,6 +220,8 @@ class PluginUIWindow : public Gtk::Window
Gtk::Window* parent;
Gtk::VBox vbox;
bool non_gtk_gui;
bool was_visible;
void app_activated (bool);
void plugin_going_away ();