X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Flxvst_plugin_ui.cc;h=f5265cffa8d0f45a212b44416f99145de209e1e1;hb=29b80725559c8fd60ae51bf33270963e647d0c1c;hp=e3335d4990775b5ff3cd72bd6e5bd18fbadf4053;hpb=316973d7c7bc99bfef6367d42009883d0de2abbd;p=ardour.git diff --git a/gtk2_ardour/lxvst_plugin_ui.cc b/gtk2_ardour/lxvst_plugin_ui.cc index e3335d4990..f5265cffa8 100644 --- a/gtk2_ardour/lxvst_plugin_ui.cc +++ b/gtk2_ardour/lxvst_plugin_ui.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2004 Paul Davis + Copyright (C) 2004 Paul Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,7 +20,7 @@ #include "ardour/lxvst_plugin.h" #include "ardour/linux_vst_support.h" #include "lxvst_plugin_ui.h" -#include "ardour_ui.h" +#include "timers.h" #include #define LXVST_H_FIDDLE 40 @@ -38,8 +38,8 @@ LXVSTPluginUI::LXVSTPluginUI (boost::shared_ptr pi, boost::shared_ LXVSTPluginUI::~LXVSTPluginUI () { - _screen_update_connection.disconnect(); - + _screen_update_connection.disconnect(); + // plugin destructor destroys the custom GUI, via the vstfx engine, // and then our PluginUIWindow does the rest } @@ -49,7 +49,7 @@ bool LXVSTPluginUI::start_updating (GdkEventAny*) { _screen_update_connection.disconnect(); - _screen_update_connection = ARDOUR_UI::instance()->RapidScreenUpdate.connect (mem_fun(*this, &LXVSTPluginUI::resize_callback)); + _screen_update_connection = Timers::rapid_connect (mem_fun(*this, &LXVSTPluginUI::resize_callback)); return false; } @@ -67,35 +67,38 @@ LXVSTPluginUI::resize_callback () /* We could maybe use this to resize the plugin GTK parent window if required */ - + if (!_vst->state()->want_resize) { return; } int new_height = _vst->state()->height; int new_width = _vst->state()->width; - + void* gtk_parent_window = _vst->state()->extra_data; - + if (gtk_parent_window) { + _socket.set_size_request( + new_width + _vst->state()->hoffset, + new_height + _vst->state()->voffset); + ((Gtk::Window*) gtk_parent_window)->resize (new_width, new_height + LXVST_H_FIDDLE); } - _vst->state()->want_resize = 0; } int LXVSTPluginUI::get_preferred_height () -{ +{ /* XXX: FIXME */ - + /* We have to return the required height of the plugin UI window + a fiddle factor because we can't know how big the preset menu bar is until the window is realised and we can't realise it until we have told it how big we would like it to be which we can't do until it is realised etc */ - // May not be 40 for all screen res etc + // May not be 40 for all screen res etc return VSTPluginUI::get_preferred_height () + LXVST_H_FIDDLE; } @@ -103,9 +106,9 @@ int LXVSTPluginUI::package (Gtk::Window& win) { VSTPluginUI::package (win); - + /* Map the UI start and stop updating events to 'Map' events on the Window */ - + win.signal_map_event().connect (mem_fun (*this, &LXVSTPluginUI::start_updating)); win.signal_unmap_event().connect (mem_fun (*this, &LXVSTPluginUI::stop_updating)); @@ -129,31 +132,31 @@ LXVSTPluginUI::get_XID () created and we get bad Window errors when trying to embed it in the GTK UI */ - + pthread_mutex_lock (&(_vst->state()->lock)); - + /* The Window may be scheduled for creation - but not actually created by the gui_event_loop yet - + but not actually created by the gui_event_loop yet - spin here until it has been activated. Possible deadlock if the window never gets activated but should not be called here if the window doesn't exist or will never exist */ - + while (!(_vst->state()->been_activated)) { Glib::usleep (1000); } - + int const id = _vst->state()->xid; - + pthread_mutex_unlock (&(_vst->state()->lock)); - - /* Finally it might be safe to return the ID - + + /* Finally it might be safe to return the ID - problems will arise if we return either a zero ID and GTK tries to socket it or if we return an ID which hasn't yet become real to the server */ - + return id; } @@ -162,11 +165,11 @@ static Display *the_gtk_display; static error_handler_t vstfx_error_handler; static error_handler_t gtk_error_handler; -static int +static int gtk_xerror_handler (Display*, XErrorEvent*) { std::cerr << "** ERROR ** LXVSTPluginUI : Trapped an X Window System Error" << std::endl; - + return 0; }