diff --git a/core/application/window_manager.cpp b/core/application/window_manager.cpp index 9a9713d..29f2fc7 100644 --- a/core/application/window_manager.cpp +++ b/core/application/window_manager.cpp @@ -24,7 +24,9 @@ void window_manager::tick() { glfwPollEvents(); if (should_close()) { destroy_all_plugin_host_window(); + return; } + update_host_window(); } void window_manager::destroy_all_plugin_host_window() { @@ -88,3 +90,17 @@ void window_manager::idle_thread_func() { std::this_thread::yield(); } } + +void window_manager::update_host_window() { + std::vector host_editor_to_close; + for (const auto& [host, window]: host_window_map_) { + if (glfwWindowShouldClose(window)) { + host->close_editor(); + glfwDestroyWindow(window); + host_editor_to_close.push_back(host); + } + } + for (auto host: host_editor_to_close) { + host_window_map_.erase(host); + } +} diff --git a/core/application/window_manager.h b/core/application/window_manager.h index ab7cf41..96fefd8 100644 --- a/core/application/window_manager.h +++ b/core/application/window_manager.h @@ -34,6 +34,8 @@ private: std::atomic_bool idle_thread_running_; #pragma endregion + void update_host_window(); + GLFWwindow* main_window_; std::map host_window_map_; };