Commit Graph

201 Commits

Author SHA1 Message Date
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
Robbert van der Helm 8b870a51b0 Remove unnecessary XDND proxy call
This was left over from the original implementation, before we had this
smart pointer-singleton hybrid thing. There's already a handle stored
inside of `Editor`.
2021-07-14 16:41:24 +02:00
Robbert van der Helm 2671511dc0 Handle ConvertSelection for XDND 2021-07-11 14:05:09 +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 82f7a8f799 Check property type instead of format
All of these fields should be zero, but this sounds like the better way
to test this.
2021-07-10 22:24:06 +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
Robbert van der Helm 42ce69943a Fix typo in X11 error message 2021-07-10 18:22:54 +02:00
Robbert van der Helm ddac793e82 Add a function for fetching X11 atoms by name 2021-07-10 17:22:04 +02:00
Robbert van der Helm d908db5476 Add an X11 event handling function to the proxy 2021-07-10 16:19:23 +02:00
Robbert van der Helm b47a6e034b Rename init_proxy -> get_handle 2021-07-10 15:16:20 +02:00
Robbert van der Helm 2ba2cf1ab7 Free the drag-and-drop proxy after closing editors
Apparently X11 connections are a scarce resource, so it seems like a
good idea to not hang on to them for too long. Now this is sort of a
hybrid between COM-style memory management and a singleton.
2021-07-10 00:15:38 +02:00
Robbert van der Helm fc61658ada Add the start for a Wine->X11 DnD wrapper 2021-07-09 18:48:11 +02:00
Robbert van der Helm b72b6f8273 Change const static to static const
To match the order used everywhere else.
2021-07-08 18:18:29 +02:00
Robbert van der Helm e0b06c84ce Avoid manual memory management in the editor
Letting `std::unique_ptr<T>` do the thinking for us makes a lot more
sense. We only need manual memory management for the error because we
need to pass a pointer to that pointer to xcb, but at least we have the
macro there so it still stays nice and readable.
2021-07-01 19:51:45 +02:00
Robbert van der Helm c067cd1b40 Prevent cursors from being unintentionally hidden
Some interaction between JUCE and Wine would cause these cursors to be
hidden and then never shown again. This is of course more of a temporary
workaround until the issue gets solved within Wine.
2021-06-28 18:13:43 +02:00
Robbert van der Helm 8cffd0761b Move the THROW_X11_ERROR macro up 2021-06-28 17:16:43 +02:00
Robbert van der Helm 7ac4ee713c Only query XEmbed properties when using Xembed
This is mostly just to make this long constructor more readable.
2021-06-28 16:15:07 +02:00
Robbert van der Helm efeb8d7348 Rearrange editor functions 2021-06-15 11:00:22 +02:00
Robbert van der Helm fe7f6eff96 Make the last commit appear a little less drastic 2021-06-05 11:41:22 +02:00
Robbert van der Helm 974951e966 Translate mouse coordinates from Wine window
Instead of the parent Window. Tracktion Waveform does some weird things
with its VST2 editor embedding, so with the old approach this would
cause mouse clicks to be offset 27 pixels vertically and one pixel
horizontally.
2021-06-05 11:32:24 +02:00
Robbert van der Helm a9643577fd Also add noexcept qualifications on the Wine side
See the last few commits.
2021-05-14 18:27:19 +02:00
Robbert van der Helm 49750575bc Fix xcb assertion failures in Ardour for good
Hopefully. Checking mapped state apparently wasn't enough to prevent
spurious assertion failures on `is_child_window_or_same()`. Now we'll
just use exceptions instead of assertions so we catch them and ignore
them.
2021-05-02 20:40:59 +02:00