Audacity 3.2.0
SocketWindow.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file SocketWindow.cpp
6
7 @author Vitaly Sverchinsky
8
9 @brief Part of Audacity VST3 module
10
11**********************************************************************/
12
13#include "SocketWindow.h"
14
15#include <gdk/gdk.h>
16#include <gtk/gtk.h>
17#include <gdk/gdkx.h>
18
19#ifdef __WXGTK3__
20#include <gtk/gtkx.h>
21#endif
22
23#include "RunLoop.h"
24#include "PlugFrame.h"
25
26using namespace internal::x11;
27
28void SocketWindow::OnMap(GtkWidget* widget, gpointer data)
29{
30 using namespace Steinberg;
31
32 auto self = reinterpret_cast<SocketWindow*>(data);
33
34 static auto runLoop = [&]() {
35 auto display = GDK_WINDOW_XDISPLAY(gtk_widget_get_window(widget));
36 return owned(safenew RunLoop(display));
37 }();
38
39 auto frame = owned(safenew PlugFrame(runLoop.get(), self->GetParent()));
40 if(self->mPlugView->setFrame(frame) == Steinberg::kResultOk)
41 {
42 self->mPlugView->attached(
43 (void*)gtk_socket_get_id(GTK_SOCKET(widget)),
44 Steinberg::kPlatformTypeX11EmbedWindowID
45 );
46 ViewRect initialSize;
47 if(self->mPlugView->getSize(&initialSize) == kResultOk)
48 frame->init(self->mPlugView.get(), &initialSize);
49 }
50}
51
52SocketWindow::SocketWindow(wxWindow* parent, wxWindowID winid, Steinberg::IPlugView* plugView)
53 : wxNativeWindow(parent, winid, gtk_socket_new()), mPlugView(plugView)
54{
55#ifdef __WXGTK3__
56 g_signal_connect(G_OBJECT(GetHandle()), "map", G_CALLBACK(&SocketWindow::OnMap), this);
57#else
58 gtk_signal_connect(GTK_OBJECT(GetHandle()), "map", G_CALLBACK(&SocketWindow::OnMap), this);
59#endif
60}
#define safenew
Definition: MemoryX.h:9
Wrapper for GtkSocket object, which provides X window mapping via XEmbed protocol.
Definition: SocketWindow.h:34
static void OnMap(GtkWidget *widget, gpointer data)
SocketWindow(wxWindow *parent, wxWindowID winid, Steinberg::IPlugView *plugView)