Commit Graph

173 Commits

Author SHA1 Message Date
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 d46f7882bd Reposition to (0, 0) while fixing coordinates
The goal is to have the window be at (0, 0), while Wine's X11 event
layer thinks it is at the actual screen coordinates. This is needed to
prevent drawing issues with buggy plugins that rely on absolute screen
coordinates to draw their GUI.
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 bf59e5e8ce Also grab keyboard focus on parent window focus
This allows you to directly focus plugin GUIs that are open in the
background in REAPER.
2021-07-31 16:14:02 +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 186a6c01a2 Filter Win32 windows for XDND by class name
Instead of ignoring all windows that have an associated X11 window. That
would otherwise treat standalone applications like yabridge GUI
wrappers.
2021-07-26 14:29:06 +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 0523a06ed7 Move the win32 window class name to a constant 2021-07-26 13:51:40 +02:00
Robbert van der Helm d522e57a8a Add active window to enter/leave/focus tracing 2021-07-26 12:43:32 +02:00
Robbert van der Helm 890c534573 Trace input focus grabbing 2021-07-26 12:38:17 +02:00
Robbert van der Helm 4d2ee96167 Remove old TODO about +editor debug level 2021-07-23 15:22:45 +02:00
Robbert van der Helm 8108e08dbf Keep the old time stamp and sequence number
On second thought this seems like a good idea.
2021-07-22 16:31:03 +02:00
Robbert van der Helm 3c8f3b0b41 Forward synthetic keyboard events to Wine window
This is needed for Bitwig Studio. See the comments.
2021-07-22 16:05:22 +02:00
Robbert van der Helm c4c23b9574 Unify enter/focus event tracing 2021-07-22 16:04:39 +02:00
Robbert van der Helm 9aae3665a2 Fix reparent error logging 2021-07-22 15:45:56 +02:00
Robbert van der Helm 1e47390edc Also listen for ConfigureNotify on the wrapper
This is needed for Tracktion Waveform because they shift our wrapper
window a bit downwards. Otherwise opening the window while your mouse
cursor is already inside of it would trip up Wine's coordinates.
2021-07-21 22:54:21 +02:00
Robbert van der Helm 99304d19b8 Listen to the correct window for focus and enter
This now all got shifted one window by the introduction of the wrapper
window.
2021-07-21 22:53:04 +02:00
Robbert van der Helm 68c47064a0 Check the window in focus/enter events 2021-07-21 22:29:16 +02:00
Robbert van der Helm cb1c1858e0 Translate coordinates from the wrapper window
We moved this from `parent_window` to `wine_window` in
974951e966 to account for Waveform adding
an offset in their windows, so now that we have `wrapper_window` we
should be translating from there instead.
2021-07-21 22:18:58 +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 e1e5a1588c Unmap wine_window before reparenting back to root 2021-07-21 17:53:27 +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 e223c98b0d Remove XEmbed testing todo
Still seems to work 'fine' (as in, not really).
2021-07-21 17:01:02 +02:00
Robbert van der Helm e95f381fa0 Remove unnecessary unreparent check
Or at least, hopefully this is not needed.
2021-07-21 17:01:02 +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 68d4a6610e Don't reparent when the parent gets reparented
Some hosts, like Carla 2.3.1, will resize their windows to match the
reparented window's client area. This messes with our ConfigureNotify
setup.
2021-07-21 13:20:39 +02:00
Robbert van der Helm 1ee1229e47 Only show reparent message with editor tracing 2021-07-21 13:20:05 +02:00
Robbert van der Helm acfceaa93f Reuse the reparenting tracing in XEmbed 2021-07-20 23:13:23 +02:00
Robbert van der Helm a749faa17f Don't trace the start of every X11 event
We'll already print the event anyways.
2021-07-20 23:08:44 +02:00
Robbert van der Helm ca6fc3a453 Fix typo in log message 2021-07-20 23:06:59 +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 db8eb5b678 Add a todo about the editor debug level 2021-07-20 01:31:24 +02:00
Robbert van der Helm f2ffb68b55 Attempt to fix rare multiple displays issue
(cherry picked from 1950206159fbc830718803fa152b636b2a914a95)

Under certain DEs/WMs, the window might not render at all when using
multiple displays and the primary display is set to the rightmost
display.

This seems like a reasonably candidate for fixing this.

https://github.com/robbert-vdh/yabridge/issues/89
https://github.com/robbert-vdh/yabridge/issues/104
2021-07-20 01:10:31 +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 0f75461379 Check the windows IDs when handling X11 events
This seems like a good idea now that we're listening to more and more
events.
2021-07-20 01:00:03 +02:00
Robbert van der Helm 906ead26fd Perform some more diagnostics when reparent fails 2021-07-20 00:43:57 +02:00
Robbert van der Helm ca883da5b2 Add tracing for the various X11 events 2021-07-19 12:59:16 +02:00
Robbert van der Helm a02dcbdb5a Fix an...interesting spelling correction
I might have accidentally hit `z=` at some point.
2021-07-18 19:48:16 +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