Resize the window together with ConfigureNotify

This way we need less hacks and things can't get out of sync.
This commit is contained in:
Robbert van der Helm
2020-04-12 19:15:28 +02:00
parent e1cc342bd0
commit 3850e39777
3 changed files with 6 additions and 33 deletions
+6 -12
View File
@@ -48,18 +48,6 @@ HWND Editor::open(AEffect* effect) {
return win32_handle->get();
}
bool Editor::resize(const VstRect& new_size) {
if (!win32_handle.has_value()) {
return false;
}
SetWindowPos(win32_handle->get(), HWND_TOP, new_size.left, new_size.top,
new_size.right - new_size.left, new_size.bottom - new_size.top,
0);
return true;
}
void Editor::close() {
// RAII will destroy the window and tiemrs for us
win32_handle = std::nullopt;
@@ -128,6 +116,7 @@ void Editor::handle_events() {
// Handle X11 events
// TODO: Check if we should forward other events mostly to prevent
// unnecessary GUI processing in the background
// TODO: Check whether drag and drop works out of the box
xcb_generic_event_t* generic_event;
while ((generic_event = xcb_poll_for_event(x11_connection.get())) !=
nullptr) {
@@ -140,6 +129,11 @@ void Editor::handle_events() {
break;
}
// The client area of the Win32 window doesn't expand
// automatically
SetWindowPos(win32_handle->get(), HWND_TOP, 0, 0,
event.width, event.height, 0);
// We're purposely not using XEmbed. This has the
// consequence that wine still thinks that any X and Y
// coordinates are relative to the x11 window root instead
-10
View File
@@ -57,16 +57,6 @@ class Editor {
void close();
/**
* Resize the window to match the given size, if open.
*
* @param new_size The rectangle with the plugin's current position.
*
* @return Whether the resizing was succesful. Will return false if the
* editor isn't open.
*/
bool resize(const VstRect& new_size);
/**
* Embed the (open) window into a parent window.
*
-11
View File
@@ -298,17 +298,6 @@ class HostCallbackDataConverter : DefaultDataConverter {
case audioMasterGetTime:
return WantsVstTimeInfo{};
break;
case audioMasterSizeWindow:
// Plugins use this opcode to indicate that their editor should
// be resized, so we'll have to update the Wine window
// accordingly
// TODO: Can we just do this when handling XCB_CONFIGURE_NOTIFY
// instead?
editor.resize(VstRect{0, 0, static_cast<short>(value),
static_cast<short>(index)});
return DefaultDataConverter::read(opcode, index, value, data);
break;
case audioMasterIOChanged:
// This is a helpful event that indicates that the VST plugin's
// `AEffect` struct has changed. Writing these results back is