[Desktop] Fix changing WindowPlacement from Fullscreen to Maximized
Proposed Changes
When the WindowPlacement is set to Maximized, I changed the isFullscreen value to false to make sure that we exit fullscreen.
It's fixing the issue in mac, I still didn't try it on windows to make sure that it's not causing any issues.
Testing
Test: Describe how you tested your changes. Note that this line (with Test:) is required, your PR will not build without it!
I wasn't able to test this change since isFullscreen is private.
Issues Fixed
Fixes: https://github.com/JetBrains/compose-multiplatform/issues/4380
Google CLA
You need to sign the Google Contributor’s License Agreement at https://cla.developers.google.com/. This is needed since we synchronise most of the code with Google’s AOSP repository. Signing this agreement allows us to synchronise code from your Pull Requests as well.
This fixes the issue, but it looks like it causes a different issue.
Now if you set window placement to floating -> fullscreen -> maximized, the placement is going to be changed to floating instead of maximized. It looks like the isFullscreen = false is going to return the window to the latest state before opening fullscreen.
I will add this condition to the test.
Any ideas how to fix this edge case?
I was able to use this workaround, the first set placement to Maximized will exit the fullscreen, then I wait for the full screen to be exited and then I set the placement to Maximized again.
scope.launch {
window.placement = WindowPlacement.Maximized
while (window.placement == WindowPlacement.Fullscreen) {
withFrameMillis { }
}
window.placement = WindowPlacement.Maximized
}
So for this to work correctly, we need to add a check when the window is fullscreen and you change the placement to Maximized exit the fullscreen first and wait for it to be exited successfully then maximize the window.
Using something like this can fix the issue, but I'm not sure if you are ok with using runBlocking here. We need to wait for fullscreen to exit before changing the isMaximized value.
There's also another possible solution by relying on the listeners in Window.desktop.kt and correct the isMaximized value after exiting fullscreen.