-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Update WindowInfo.containerSize
on window resize to keep it correct when window is moved between displays
#1333
Conversation
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/scene/ComposeContainer.desktop.kt
Show resolved
Hide resolved
@@ -512,7 +512,10 @@ private fun rememberPopupMeasurePolicy( | |||
-platformInsets.top.roundToPx() | |||
) | |||
val positionInWindow = popupPositionProvider.calculatePosition( | |||
boundsWithoutInsets, sizeWithoutInsets, layoutDirection, contentSize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert unrelated change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not entirely unrelated, and it improves readability, and I don't want to waste time creating a separate PR for such a tiny change.
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/scene/ComposeContainer.desktop.kt
Outdated
Show resolved
Hide resolved
161fa84
to
400d90f
Compare
ComposeContainer
, register the window move/resize listener on the window, rather than on the layered pane.WindowInfo.containerSize
on window resize to keep it correct when window is moved between displays
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/scene/ComposeContainer.desktop.kt
Outdated
Show resolved
Hide resolved
compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/scene/ComposeContainer.desktop.kt
Show resolved
Hide resolved
… listener functions related to ComposeContainer.
400d90f
to
323be90
Compare
// When the window is moved to a display with a different density, componentResized is | ||
// called on the window, but not on `windowContainer`, so we need to update the size | ||
// here too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to have a test for this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't think of an easy way.
… when window is moved between displays (#1333)
ComposeContainter
currently registers the listener for window size and position on thewindowContainer
, which is aJLayeredPane
. It ends up not being called at all when the window is resized or moved. According to @MatkovIvan, however, this is intentional and merely poorly named (e.g.onChangeWindowPosition
is meant to be called when thewindowContainer
's position changes, not the window's).Because of this, when a window is moved to another screen with a different density, the size we store for it in
WindowInfo.containerSize
isn't updated. This, in turn, causes issues with popup positioning.This PR registers an additional size listener on the window, in order to update
WindowInfo.containerSize
when the window size changes. It also renames all the related listener functions.Fixes JetBrains/compose-multiplatform#4697
Possibly fixes additional issues where the window size was not being updated after moving it to a different screen.
Testing
Tested manually with this code:
To simulate a 2nd screen, I've used this app: https://github.com/Stengo/DeskPad and configured the 2nd screen to be of a very low resolution (such that the density is 1.0).
This could be tested by QA
Release Notes
Fixes - Desktop