Commit Graph

120 Commits

Author SHA1 Message Date
Juuso Kaitila 604375b756 VST3: Fix broken resizing in Ardour
Adds timer_proc lambda for VST3 to check for size mismatches and trigger
a new resize to correct it through eventual consistency.

This is done to workaround an X11 sync issue where the plugin view would
end up smaller or larger than its wrapper window. In Ardour this could
result in the plugin becoming uninteractable.
2026-04-26 16:24:39 +02:00
Jakob Steltner 44d047e9e2 Work around wrong offset in plugin windows 2026-01-11 20:41:56 +01:00
Asahi Lina 2e1dcb2316 Handle absolute ConfigureNotify events for parent window
For VST2 in Ardour, it seems Ardour is doing its own WM/wrapper window
thing too. In this case, the plugin gets absolute ConfigureNotify events
that are already in the root coordinate space, so just use those
coordinates and ignore the host window.

Also fix the dimensions, which should always be those of the parent
window, not the host window. If the parent is the host window, still
track its geometry separately, and just don't add in the host window
dimensions in this case either.
2025-06-01 22:52:27 +02:00
Asahi Lina 6f65613292 VST3: Create the window with the plugin-returned initial size
Instead of creating the window as 128x128 and then resizing, create it
with the size requested by the plugin. Fixes Korg VST3 plugins.
2025-06-01 22:52:27 +02:00
Asahi Lina 9994043306 Use WM_WINDOW_ROLE instead of WM_STATE to detect the host window
Ardour brings up the plugin UI before the host window is visible, and it
is missing some properties. Using WM_WINDOW_ROLE instead of WM_STATE
makes it work.

For reference, these are the properties that are set on the window at
the time of plugin GUI instantiation:

_NET_WM_ICON(CARDINAL) =        Icon (16 x 16):
WM_WINDOW_ROLE(STRING) = "plugin_ui"
_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 6294918
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_UTILITY
_NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0x600d85
WM_CLIENT_LEADER(WINDOW): window id # 0x600001
_NET_WM_PID(CARDINAL) = 1604801
WM_LOCALE_NAME(STRING) = "en_US.UTF-8"
WM_CLIENT_MACHINE(STRING) = "homura"
WM_NORMAL_HINTS(WM_SIZE_HINTS):
                program specified size: 521 by 46
WM_PROTOCOLS(ATOM): protocols  WM_DELETE_WINDOW, WM_TAKE_FOCUS, _NET_WM_PING, _NET_WM_SYNC_REQUEST
WM_CLASS(STRING) = "ardour-8.12.0", "Ardour-8.12.0"
WM_ICON_NAME(STRING) = "Audio 1: Melodyne (by Celemony) [VST3]"
_NET_WM_ICON_NAME(UTF8_STRING) = "Audio 1: Melodyne (by Celemony) [VST3]"
WM_NAME(STRING) = "Audio 1: Melodyne (by Celemony) [VST3]"
_NET_WM_NAME(UTF8_STRING) = "Audio 1: Melodyne (by Celemony) [VST3]"
2025-06-01 22:51:47 +02:00
Robbert van der Helm 66840d4d16 Remove the editor_coordinate_hack option
I'm not sure if this would still be necessary with the new embedding
approach, but it definitely does cause more problems than it solves.
2025-06-01 22:47:53 +02:00
Robbert van der Helm 51e4d61004 Remove the editor_xembed option 2025-06-01 22:47:38 +02:00
Robbert van der Helm 983a19169b Don't include xcb_icccm.h
We just need this constant, so there's no real need to add the
additional dependency. There's also no real harm in adding it, but it
would result in additional work for every packager.
2025-06-01 22:47:13 +02:00
Rémi Bernon 02fb140b19 Remove now unnecessary fix_local_coordinates workaround. 2025-06-01 22:47:13 +02:00
Rémi Bernon 2c6c21409c Fix window wrapping by implementing a minimal ICCCM window manager. 2025-06-01 22:47:13 +02:00
Robbert van der Helm 49e696e42f Update the copyright headers
Happy new year!
2024-01-09 19:25:38 +01:00
Robbert van der Helm 9005474ded Spool fix_local_coordinates() call until release
This will cause the function to only be called on a `ConfigureNotify`
after all mouse buttons have been released. This prevents flickering
when dragging windows around.
2023-04-28 15:27:02 +02:00
Robbert van der Helm 1e66654c2e Update copyright headers for 2023
Happy new year!
2023-01-01 18:51:35 +01:00
Robbert van der Helm ea3680b8c7 Define yabridge Window class name in header
Apparently this is used in xdnd-proxy.cpp.
2022-11-14 23:31:37 +01:00
Robbert van der Helm 24e50a3afc Rename get_win32_handle() to win32_handle() 2022-10-09 14:23:29 +02:00
Robbert van der Helm 4df2b389a0 Work around resizing bug in Surge XT/CJE 2022-10-09 14:22:02 +02:00
Robbert van der Helm 1fec4c8860 Change the description in the GPL header 2022-04-16 20:37:10 +02:00
Robbert van der Helm d6260c1d6b Delay editor_force_xdnd until the reparent #160
This fixes the option not working correctly when REAPER reparents the
plugin's window to a new FX window.
2022-01-29 01:46:08 +01:00
Robbert van der Helm 4767b758b8 Delay showing editor the window
This fixes Waves V13 VST3 plugins crashing when opening the editor. They
will likely still crash later on anyways because they're kinda broken.
Amazing.
2022-01-09 00:41:14 +01:00
Robbert van der Helm 0b9a16cf40 Change the naming scheme for class field members
I'm not a fan of Hungarian notation, but C++ kind of needs it with its
implicit `this`. And of all the common options for this, I find
suffixing members with an underscore the least offensive one.
2022-01-01 21:07:17 +01:00
Robbert van der Helm e0ab24e645 Update copyright headers
Happy new year!
2022-01-01 18:32:10 +01:00
Robbert van der Helm ce8e4dccdf Move Win32 message limit constant 2021-11-30 03:28:05 +01:00
Robbert van der Helm 5613248cda Gate the new resizing behavior behind new option
This interferes with resizing plugins using resize handles, and since it
only helps with two buggy plugins this seems like the best solution
here.
2021-08-16 22:39:13 +02:00
Robbert van der Helm cc9226a3fc Remove editor_double_embed
It's no longer needed after the `fix_local_coordinates()` change from a
fa12c64866a8b79e862bc5db4c4b092a4b762689.
2021-08-16 21:21:57 +02:00
Robbert van der Helm 9ac597a6fd Make the resize function not-noexcept
Since technically the string allocations within the logging for
`fix_local_coordinates()` can throw.
2021-08-16 21:21:57 +02:00
Robbert van der Helm e430c5f015 Directly focus wine_window while holding Shift
This lets you type spaces in Bitwig, and it also allows you to interact
with the settings/license popup dialogs in Voxengo plugins in a normal
way.
2021-07-31 16:31:53 +02:00
Robbert van der Helm be6fc786ca Add a function for getting the active modifiers 2021-07-31 15:49:47 +02:00
Robbert van der Helm c98a9519fe Handle X11 events within the Win32 event loop
This unifies event handling and it allows X11 events to still be
processed even when the event loop is blocked.
2021-07-31 15:19:44 +02:00
Robbert van der Helm d053eab35a Filter LeaveNotify based on window under pointer
Instead of ignoring all `NonlinearVirtual` events. This lets us release
focus when instantly moving the mouse from a plugin GUI to something
else. This generates `NonlinearVirtual` event, and previously we ignored
those because that also happens when opening a dropdown menu in a TDR
plugin (which uses popup windows instead of actual dropdowns).
2021-07-27 18:05:47 +02:00
Robbert van der Helm e42448f758 Allow manual position for is_cursor_in_wine_window
We'll need this for the `LeaveNotify` because `GetCursorPos()` updates
only once every 100 ms, which means that it would still point to the old
window we're actually leaving.
2021-07-26 15:08:23 +02:00
Robbert van der Helm e1ed35bfd8 Don't respond to hit tests from the Win32 window
This will let us detect other, non-wrapper windows to the right and to
the bottom of a plugin GUI. Useful for drag-and-drop so we don't end up
overriding Wine's internal drag-and-drop mechanism.
2021-07-26 14:44:23 +02:00
Robbert van der Helm 85264a759d Move check for cursor within Wine window to editor
We'll reuse this for the LeaveNotify check instead to avoid having to
ignore all `NonVirtual` events.
2021-07-26 14:01:16 +02:00
Robbert van der Helm b21e9f29bb Mention new embedding structure in architecture.md 2021-07-22 14:25:56 +02:00
Robbert van der Helm 0ed75b5ce4 Don't fetch the root window early
Wine is weird. The whole reason why we're doing these weird things is
because Wine somehow tries to delete the window twice. If we don't call
`xcb_query_tree()` here (and get an error back), then we're back at the
error we tried to solve. Apparently this works, and given that noone
dares touching Wine's X11drv code I won't ask any further questions.
2021-07-21 20:39:16 +02:00
Robbert van der Helm 9002468229 Fetch the Wine and root window IDs early
There's no reason to wait until the last moment to fetch these.
2021-07-21 18:06:39 +02:00
Robbert van der Helm d41c05e90e Revert "Change editor window destruction order"
This reverts commit d3d21c65f4.

On second thought, Wine actually handles things better this way. We want
to avoid both hangs and the Wine window becoming visible, and this
achieves both of those things. We should just silence the warning.
2021-07-21 18:03:03 +02:00
Robbert van der Helm d3d21c65f4 Change editor window destruction order
The wrapper window can only be removed after we reparented the Wine
window back to the root.
2021-07-21 17:50:29 +02:00
Robbert van der Helm f6fb45fee3 Mention Ardour VST3 editor resizing
Ardour ignores the `IPlugView::resizeView()` and only listens to
`ConfigureNotify` events for growing its VST3 editorsZ, so now this
works.
2021-07-21 17:16:21 +02:00
Robbert van der Helm 418cd68a81 Resize the new wrapper window for VST2 plugins 2021-07-21 17:01:02 +02:00
Robbert van der Helm 42762d1abe 💥 Use another layer of editor embedding
We still need to make sure this window resizes properly, but this should
prevent the host from interacting with the full screen `ConfigureNotify`
events we keep sending to `wine_window`.
2021-07-21 17:01:02 +02:00
Robbert van der Helm a38e7c3588 Rename DeferredWindow to DeferredWin32Window 2021-07-21 14:26:34 +02:00
Robbert van der Helm 22be79aa0d Move X11 event tracing behind +editor debug flag 2021-07-20 03:15:39 +02:00
Robbert van der Helm 8fbc13fc25 Steal the window back when the WM reparents it
I've seen this happen once or twice. Earlier on (in #40) we could get
away with just reparenting the window another time. But here both
reparents succeed, and the issue still happens. But a reparent notify
for `parent_window` did appear on system affected by this issue, which
is very odd. Hopefully this will help.
2021-07-20 01:10:31 +02:00
Robbert van der Helm f43e9c2153 Only consider host windows with WM_STATE set
This is the same way (minus the mapping check part) that `xprop` and
`xwininfo` filter windows when clicking on them. REAPER's toplevel
window apparently doesn't process any keyboard input when the mouse
cursor is located outside of that window.
2021-07-17 21:05:27 +02:00
Robbert van der Helm b99f03cf64 Rename topmost_window to host_window
Since apparently to keep REAPER happy we shouldn't take the _very_
topmost window.
2021-07-17 19:11:29 +02:00
Robbert van der Helm f02341e77f Fix focus handling when reopening REAPER FX window
REAPER initializes the plugin's editor first before reparenting the
parent window to the FX window, so our `topmost_window` didn't actually
refer to the FX window.
2021-07-15 14:21:50 +02:00
Robbert van der Helm 764eb41da9 Remove fixme about Wine deleting windows twice
This should have been fixed as of yabridge 3.2.0 by adding doing a
reparent with a last second flush. Or at least, I haven't heard any
reports about this still being an issue.
2021-07-14 16:35:51 +02:00
Robbert van der Helm eac9f9433b Clean up X11 client message functions
clang-tidy would warn about all parameters being the same, which is
true, but that's kind of the point here.
2021-07-11 12:15:30 +02:00
Robbert van der Helm 998e222651 Fix definition clashes in unity build 2021-07-10 19:38:24 +02:00
Robbert van der Helm 091ab0f0df Spawn a thread to fake do our XDND polling
We cannot integrate this into our event loop like we planned, because
Wine a) grabs the mouse pointer so we cannot do that, and b) blocks the
GUI thread. So instead we will spawn our own thread and do polling based
XDND. When Wine's tracker window gets destroyed, we know that the left
mouse button has been released.
2021-07-10 19:28:40 +02:00