Commit Graph

140 Commits

Author SHA1 Message Date
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
Robbert van der Helm 2fd453e747 Repeat the window mapped check for Ardour
This is probably a better idea than trying to be efficient. If we get
two events in a row, then it can be that the map status has changed
between the two events.
2021-05-02 18:33:05 +02:00
Robbert van der Helm fd29c7d825 Skip X11 events when the window is not mapped
This fixes potential assertion failures in Ardour when Ardour unmaps
editor windows.
2021-05-01 23:22:59 +02:00
Robbert van der Helm 5a68b8b39d Flush the reparent from 0c7dbe8
This should add a root reparent to prevent that X11 error, but it should
still prevent flickering by doing it just before closing the window.
2021-04-27 03:43:45 +02:00
Robbert van der Helm 0c7dbe8a4a Reparent to the root window before deferring close
We did this before implementing the deferred close in yabridge 3.0.0. It
didn't seem necessary anymore so we got rid of it, but without this
closing an iZotope Rx plugin's editor in Renoise was guaranteed to
trigger an X11 error and crash Renoise. Doing this reparent doesn't seem
to cause any slowdown but it does at least fix the specific combination
of iZotope Rx and Renoise.
2021-04-26 18:47:58 +02:00
Robbert van der Helm f6cf1a7dd2 Use explicit narrowing for SetWindowLongPtr() 2021-04-26 18:32:50 +02:00
Robbert van der Helm 5278c2e2ea Print all errors on the Wine side to STDERR
This one was using STDOUT for some reason
2021-04-12 14:19:31 +02:00
Robbert van der Helm 27370ab54b Remove debug prints 2021-01-30 23:11:25 +01:00
Robbert van der Helm b5dd806b2d Cache VST3 parameter information
This is in some cases needed to get decent performance in REAPER, as
REAPER seems to query this information (which cannot change without the
plugin requesting a restart) four times per second.
2021-01-30 22:24:05 +01:00
Robbert van der Helm 68bf2029b3 Fix type of X11 event mask 2021-01-30 16:38:08 +01:00
Robbert van der Helm fb7531d74b Greatly clean up the input focus grabbing
In commit 9788f21e0e we changed the input
focus grabbing to only grab focus once per event cycle, because
otherwise Bitwig would fight over who was getting focus. This is a bit
hacky, and with this approach you could in theory still have an
unnecessary focus grab 60 times per second (i.e. the default event
polling rate). Now we instead check the current focus target, and only
request focus when it's actually necessary.
2021-01-30 15:40:24 +01:00
Robbert van der Helm 2ca1d5b8ca Greatly increase reliability of deferred closing
It's pretty hard to find a solution that checks all of the boxes. I want
something that:

- Closes instantly when you close the editor, and in REAPER you should
  be able to instantly switch between docked and floating modes
- Where there should not be a delay in user interaction when quickly
  reopening the editor (or doing that switching thing in REAPER since that's
  the same thing)
- Where the window manager should not try to reparent the window during
  the losing process as that can cause some jarring flickering
- And, of course, there should be no weird Wine X11Drv crashes

And it should do all of that in Bitwig, REAPER, Carla, Ardour and
Renoise. Apparently it's quite the task to find an approach that checks
all the boxes there.
2021-01-21 16:47:35 +01:00