diff --git a/README.md b/README.md index 34298e2c..ace7cf41 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,7 @@ Yet Another way to use Windows VST2 plugins in Linux VST hosts. There are a few things that should be done before releasing this, including: - Fix implementation bugs: - - Fix hiding and showing of editor windows, closing a window with alt+f4 - freezes the editor, + - Closing editor windows is slow, this can be improved, - Polish GUIs even further. There are some todos left in `src/wine-host/editor.{h,cpp}`. - There are likely some minor issues left. diff --git a/src/wine-host/editor.cpp b/src/wine-host/editor.cpp index d6312b69..e676bb32 100644 --- a/src/wine-host/editor.cpp +++ b/src/wine-host/editor.cpp @@ -30,18 +30,25 @@ xcb_window_t get_x11_handle(HWND win32_handle); ATOM register_window_class(std::string window_class_name); +WindowClass::WindowClass(std::string name) + : atom(register_window_class(name)) {} + +WindowClass::~WindowClass() { + UnregisterClass(reinterpret_cast(atom), GetModuleHandle(nullptr)); +} + Editor::Editor(const std::string& window_class_name, AEffect* effect, std::mutex& effect_mutex, const size_t parent_window_handle) - : window_class(register_window_class(window_class_name)), + : window_class(window_class_name), // Create a window without any decoratiosn for easy embedding. The // combination of `WS_EX_TOOLWINDOW` and `WS_POPUP` causes the window to // be drawn without any decorations (making resizes behave as you'd // expect) and also causes mouse coordinates to be relative to the window // itself. win32_handle(CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_ACCEPTFILES, - reinterpret_cast(window_class), + reinterpret_cast(window_class.atom), "yabridge plugin", WS_POPUP, CW_USEDEFAULT, diff --git a/src/wine-host/editor.h b/src/wine-host/editor.h index 9a2400d1..6006bfdb 100644 --- a/src/wine-host/editor.h +++ b/src/wine-host/editor.h @@ -17,6 +17,21 @@ #include #include +/** + * A basic RAII wrapper around the Win32 window class system, for use in the + * Editor class below. + */ +class WindowClass { + public: + WindowClass(std::string name); + ~WindowClass(); + + /** + * The Win32 window class registered for the windows window. + */ + const ATOM atom; +}; + /** * A wrapper around the win32 windowing API to create and destroy editor * windows. We can embed this window into the window provided by the host, and a @@ -74,7 +89,7 @@ class Editor { /** * The Win32 window class registered for the windows window. */ - ATOM window_class; + WindowClass window_class; public: /**