2 Copyright (C) 2004 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <ardour/insert.h>
24 #include <ardour/vst_plugin.h>
26 #include "plugin_ui.h"
31 using namespace ARDOUR;
34 VSTPluginUI::VSTPluginUI (PluginInsert& pi, VSTPlugin& vp)
38 fst_run_editor (vst.fst());
40 preset_box.pack_end (bypass_button, false, false, 10);
41 preset_box.pack_end (save_button, false, false);
42 preset_box.pack_end (combo, false, false);
44 bypass_button.set_active (!insert.active());
46 pack_start (preset_box, false, false);
47 pack_start (socket, true, true);
50 VSTPluginUI::~VSTPluginUI ()
52 // nothing to do here - plugin destructor destroys the GUI
56 VSTPluginUI::get_preferred_height ()
58 return vst.fst()->height;
62 VSTPluginUI::package (Gtk::Window& win)
64 /* for GTK+2, remove this: you cannot add to a realized socket */
68 /* forward configure events to plugin window */
70 win.signal_configure_event().connect (bind (mem_fun (*this, &VSTPluginUI::configure_handler), &socket));
72 /* XXX in GTK2, use add_id() instead of steal, although add_id()
73 assumes that the window's owner understands the XEmbed protocol.
76 socket.add_id (fst_get_XID (vst.fst()));
82 VSTPluginUI::configure_handler (GdkEventConfigure* ev, Gtk::Socket *socket)
88 if (socket->gobj() == NULL) {
92 event.xconfigure.type = ConfigureNotify;
93 event.xconfigure.event = GDK_WINDOW_XWINDOW (socket->get_window()->gobj());
94 event.xconfigure.window = GDK_WINDOW_XWINDOW (socket->get_window()->gobj());
96 /* The ICCCM says that synthetic events should have root relative
97 * coordinates. We still aren't really ICCCM compliant, since
98 * we don't send events when the real toplevel is moved.
100 gdk_error_trap_push ();
101 gdk_window_get_origin (socket->get_window()->gobj(), &x, &y);
102 gdk_error_trap_pop ();
104 event.xconfigure.x = x;
105 event.xconfigure.y = y;
106 event.xconfigure.width = GTK_WIDGET(socket)->allocation.width;
107 event.xconfigure.height = GTK_WIDGET(socket)->allocation.height;
109 event.xconfigure.border_width = 0;
110 event.xconfigure.above = None;
111 event.xconfigure.override_redirect = False;
113 gdk_error_trap_push ();
114 XSendEvent (GDK_WINDOW_XDISPLAY (socket->get_window()->gobj()),
115 GDK_WINDOW_XWINDOW (socket->get_window()->gobj()),
116 False, StructureNotifyMask, &event);
117 // gdk_display_sync (GDK_WINDOW_XDISPLAY (socket->plug_window));
118 gdk_error_trap_pop ();