Mostly fix editor GUIs drifting in negative coords

I think some rounding in Wine is causing this issue, but then again
we're not supposed to send these ConfigureNotify events to the window
directly anyways.
This commit is contained in:
Robbert van der Helm
2020-12-26 16:30:25 +01:00
parent 47177ed889
commit db2cc5800a
3 changed files with 48 additions and 4 deletions
+5
View File
@@ -45,6 +45,11 @@ TODO: Add an updates screenshot with some fancy VST3-only plugins to the readme
and 5.8 required a change, but that change now breaks builds using Wine 6.0
and up, so this change has been reverted.
### Fixed
- Mostly fixed editor GUIs drifting off to the top or the left when dragging the
window off screen in those directions.
### yabridgectl
- Updated for the changes in yabridge 3.0. Yabridgectl now allows you to set up
+32 -4
View File
@@ -376,16 +376,44 @@ void Editor::fix_local_coordinates() const {
translated_event.response_type = XCB_CONFIGURE_NOTIFY;
translated_event.event = wine_window;
translated_event.window = wine_window;
// This should be set to the same sizes the window was created on. Since
// we're not using `SetWindowPos` to resize the Window, Wine can get a bit
// confused when we suddenly report a different client area size. Without
// this certain plugins (such as those by Valhalla DSP) would break.
// This should be set to the same sizes the window was created on. Wine can
// get a bit confused when we suddenly report a different client area size.
// Without this certain plugins (such as those by Valhalla DSP) would break.
translated_event.width = client_area.width;
translated_event.height = client_area.height;
translated_event.x = translated_coordinates->dst_x;
translated_event.y = translated_coordinates->dst_y;
free(translated_coordinates);
// When the window gets dragged off to the left or top corner of the screen
// a lot of plugin's GUIs start to drift off in the wrong direction when we
// send these negative coordinates in a ConfigureNotify event. To somewhat
// work around this, we'll move the Wine window to offset these changes.
// Since this could in theory cause other weird behaviour, we'll only undo
// these changes (by moving the window back to `(0, 0)`) once.
int correction_x = 0;
int correction_y = 0;
if (translated_event.x < 0) {
correction_x = -translated_event.x;
}
if (translated_event.y < 0) {
correction_y = -translated_event.y;
}
if (correction_x != 0 || correction_y != 0) {
SetWindowPos(
get_win32_handle(), nullptr, correction_x, correction_y, 0, 0,
SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_NOZORDER);
has_negative_coordinate_correction = true;
} else if (has_negative_coordinate_correction.compare_exchange_strong(
const_cast<bool&>(static_cast<const bool&>(true)), false)) {
// Undo this only once, since who knows what side effects this might
// cause
SetWindowPos(
get_win32_handle(), nullptr, 0, 0, 0, 0,
SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_NOZORDER);
}
xcb_send_event(
x11_connection.get(), false, wine_window,
XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY,
+11
View File
@@ -250,6 +250,17 @@ class Editor {
*/
const xcb_window_t topmost_window;
/**
* In `fix_local_coordinates()` we send a ConfigureNotify event to the Wine
* window with its screen coordinates. Because you're not supposed to do
* that directly, we're getting some strange behaviour on some plugins when
* the window gets dragged off screen to the left or the top. We perform a
* small workaround to mostly correct this issue. This flag indicates
* whether we have done this in the last call to `fix_local_coordinates()`,
* since we only only need to undo the changes made there once.
*/
mutable std::atomic_bool has_negative_coordinate_correction = false;
/**
* The atom corresponding to `_NET_ACTIVE_WINDOW`.
*/