On Thu, 17 Dec 2020 17:46:28 GMT, Frederic Thevenet <ftheve...@openjdk.org> 
wrote:

>> Good point. We would need some way to invalidate the cached values if the 
>> screen scale changes.
>> 
>>> We could possibly listen to `Window::renderScaleXProperty` and 
>>> `Window::renderScaleYProperty` and call `updateSnappedInsets` & 
>>> `requestLayout` when one changes?
>> 
>> A layout will happen anyway as the result of a Window moving to another 
>> screen, so really it's only the cached snapped insets that need to be 
>> recalculated. I don't know whether a listener is the best approach, since it 
>> would need to handle the case where the Window changes (either because the 
>> scene changed or the scene was added to a new window), which would present 
>> similar challenges to what we face with treeVisible.
>> 
>> Another possibility is for `updateSnappedInsets` to also cache the scaleX/Y 
>> at which the snapped insets were computed. The `snappedXXXXX` methods could 
>> check the current scale against the cached scale (a simple == test) and call 
>> `updateSnappedInsets` if the scale changes.
>
> I've opted for the cache and check for screen scale solution, as I agree it 
> presents less risks of leaked or missing listeners down the road.
> There's a slight unexpected drawback I've noticed, though, which is that the 
> repaint for the affected Region does not seem to occur right away on moving 
> the window to another screen, but only once the Region is interacted with 
> (e.g. hovering the mouse over it).

Your latest patch looks exactly like what I would expect. I need to do some 
multi-screen testing on Windows with different scale factors.

> ... the repaint for the affected Region does not seem to occur right away on 
> moving the window to another screen, but only once the Region is interacted 
> with (e.g. hovering the mouse over it).

This seems like a different (and preexisting) bug then. I think we're up to 
three follow-on issues if I haven't lost track:

1. Rendering a cached node doesn't match rendering it directly even when the 
transform is unchanged.
2. TextFlow: methods copied from Region have not picked up subsequent changes 
in those methods
3. Need to Render and layout scene out when scale changes (either when moving 
to a screen with a different scale or when the scale changes as the result of 
changing the setting of the current screen)

-------------

PR: https://git.openjdk.java.net/jfx/pull/308

Reply via email to