Skip to content

WineFix: color picker fixes under Wine and Wayland - #64

Open
jfacemyer wants to merge 6 commits into
noahc3:devfrom
jfacemyer:winefix-color-picker-under-wine
Open

jfacemyer wants to merge 6 commits into
noahc3:devfrom
jfacemyer:winefix-color-picker-under-wine

Conversation

@jfacemyer

Copy link
Copy Markdown

The color picker under Wine, especially on Wayland. Six WineFix commits on dev, independent of #61 and #62. All of them have shipped in the AffinityOnLinux installer since early October.

  • The zoom preview was black on Wayland. The magnifier fix's "auto" mode checks WAYLAND_DISPLAY, which Wine 11.16 and later leave out of the Windows environment. It now also accepts WINE_HOST_XDG_SESSION_TYPE / XDG_SESSION_TYPE = wayland.
  • The preview showed selection handles over the picked color. The first capture was taken before the canvas had been redrawn without the overlay. It is retaken at 50, 150, 300 and 600 ms into the drag.
  • The magnifier stayed on top of other applications after switching away. The pick is ended as a canceled pick when Affinity is deactivated, and a picker-button drag (e.g. in the Colors panel) is ended the same way.
  • Two crashes that came with ending the pick on focus loss:
    • Application.Deactivated arrives inside the magnifier's timer tick, and ending the pick there destroyed the window mid-tick. The end is now deferred through the dispatcher, as WPF's Popup does.
    • A tick delivered after the window was gone threw a NullReferenceException. Such a timer is now stopped and the tick skipped.

Tested with Affinity 3.3 on Wine 11.19, KDE Plasma (Wayland).

The color picker magnifier fix defaults to "auto", which applies it when
WAYLAND_DISPLAY is set. Wine 11.16 and later leave WAYLAND_DISPLAY out of
the Windows environment (ntdll's is_ignored_env_var), so under current
Wine the fix was never applied and the zoom preview stayed black on
Wayland. The XDG session variables still come through, prefixed
WINE_HOST_; also accept WINE_HOST_XDG_SESSION_TYPE or XDG_SESSION_TYPE
set to "wayland".
ColourPickerMagnifier.StartDragging hides the tool overlay (selection
handles, outlines), and the first timer tick captures the canvas for the
zoom preview; that capture is kept for the whole drag. Under Wine the
canvas has usually not been redrawn without the overlay by then, so the
preview showed the handles while the picked color came from the document
under them.

Drop the capture 50, 150, 300 and 600 ms into the drag, so the next tick
takes it again from the redrawn canvas.
The color picker's magnifier is a topmost window. Under Wine, switching to
another application does not end the pick, so the magnifier stayed above
that application's windows. End it the way the tool does, by calling
UserInterfaceService.ShowColourPicker(false) as a canceled pick, when the
application is deactivated, and ignore requests to show it until the
application is active again: the tool still sees the mouse over the
canvas while Affinity is in the background.
A drag from a picker button, such as the one in the Colors panel, ends on
mouse up or on lost mouse capture. After switching to another application
the mouse comes up there, and under Wine the button keeps the capture, so
the pick was still running on return. End it through the magnifier's
OnFinishDragging(true), which makes the button release its capture as a
canceled pick.
…_ACTIVATEAPP

Application.Deactivated comes from WM_ACTIVATEAPP, a sent message, which
can arrive inside ColourPickerMagnifier's timer tick while its
SetWindowPos runs. Ending the pick there destroyed the magnifier window,
and the rest of timer_Tick then dereferenced it: a NullReferenceException
that took Affinity down. Defer the end with Dispatcher.BeginInvoke, as
WPF's Popup does for the same message, and check that the application is
still inactive and the same pick still running.
ColourPickerMagnifier.timer_Tick moves the magnifier window and then
reads it. A tick delivered after the pick has ended and the window is
gone throws a NullReferenceException, which takes Affinity down; this
happened after switching applications mid-pick. Stop such a timer and
skip the tick.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant