diff --git a/core/audio/plugin_host/vst2/vst2_plugin_host.cpp b/core/audio/plugin_host/vst2/vst2_plugin_host.cpp index 3ac94ca..836dfa3 100644 --- a/core/audio/plugin_host/vst2/vst2_plugin_host.cpp +++ b/core/audio/plugin_host/vst2/vst2_plugin_host.cpp @@ -2,6 +2,7 @@ #include "audio/device/audio_device_manager.h" #include "audio/mixer/channel_interface.h" +#include "window/window_manager.h" std::map<std::string, std::weak_ptr<dynamic_library>> vst2_library_map; VstTimeInfo vst2_plugin_host::vst_time_info{}; @@ -63,7 +64,7 @@ VstIntPtr vst_master_callback(AEffect* effect, VstInt32 opcode, VstInt32 index, case audioMasterSizeWindow: { // 设置插件窗口大小 - // g_window_manager.resize_plugin_host_window((plugin_host*)effect->user, index, value); + g_window_manager.resize_plugin_window((plugin_host*)effect->user, index, value); return 1; } case audioMasterGetTime: diff --git a/core/window/window_manager.cpp b/core/window/window_manager.cpp index c2d203a..bb86579 100644 --- a/core/window/window_manager.cpp +++ b/core/window/window_manager.cpp @@ -40,6 +40,8 @@ void* window_manager::create_plugin_window(plugin_host* host) { if (width == 0 || height == 0) return nullptr; auto w = create_window(width, height, host->name.c_str()); + // 设置窗口不可调整大小 + glfwSetWindowAttrib(w.get(), GLFW_RESIZABLE, GLFW_FALSE); host_info info; host_info& window_info = host_infos_[host]; window_info.window = w; @@ -96,3 +98,14 @@ void window_manager::on_host_window_close(GLFWwindow* window) { f->second.window.reset(); } } + +void window_manager::resize_plugin_window(plugin_host *host, int width, int height) { + const auto& find = host_infos_.find(host); + if (find == host_infos_.end()) { + return; + } + auto window = find->second.window; + if (!window) + return; + glfwSetWindowSize(window.get(), width, height); +} diff --git a/core/window/window_manager.h b/core/window/window_manager.h index 07b1d73..a470152 100644 --- a/core/window/window_manager.h +++ b/core/window/window_manager.h @@ -15,6 +15,7 @@ public: std::shared_ptr<GLFWwindow> create_window(int width, int height, const char* title); void* create_plugin_window(plugin_host* host); void destroy_plugin_window(plugin_host* host); + void resize_plugin_window(plugin_host* host, int width, int height); const char* get_name() override { return "window_manager"; } void update(); private: