Skip to content

[Desktop] Fix changing WindowPlacement from Fullscreen to Maximized #1148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: jb-main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ class ComposeWindow @ExperimentalComposeUiApi constructor(
isFullscreen = true
}
WindowPlacement.Maximized -> {
isFullscreen = false
isMaximized = true
}
WindowPlacement.Floating -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,130 @@ class WindowStateTest {
assertThat(window.placement).isEqualTo(WindowPlacement.Floating)
}

@Test
fun `from floating to fullscreen to floating`() = runApplicationTest(
useDelay = isLinux || isMacOs,
delayMillis = 1000
) {
val state = WindowState(size = DpSize(200.dp, 200.dp))
lateinit var window: ComposeWindow

launchTestApplication {
Window(onCloseRequest = {}, state) {
window = this.window
}
}

awaitIdle()

// Enter fullscreen from floating
state.placement = WindowPlacement.Floating
awaitIdle()
assertThat(window.placement).isEqualTo(WindowPlacement.Floating)

state.placement = WindowPlacement.Fullscreen
awaitIdle()
assertThat(window.placement).isEqualTo(WindowPlacement.Fullscreen)

// Exit fullscreen to floating
state.placement = WindowPlacement.Floating
awaitIdle()
assertThat(window.placement).isEqualTo(WindowPlacement.Floating)
}

@Test
fun `from maximized to fullscreen to floating`() = runApplicationTest(
useDelay = isLinux || isMacOs,
delayMillis = 1000
) {
val state = WindowState(size = DpSize(200.dp, 200.dp))
lateinit var window: ComposeWindow

launchTestApplication {
Window(onCloseRequest = {}, state) {
window = this.window
}
}

awaitIdle()

// Enter fullscreen from maximized
state.placement = WindowPlacement.Maximized
awaitIdle()
assertThat(window.placement).isEqualTo(WindowPlacement.Maximized)

state.placement = WindowPlacement.Fullscreen
awaitIdle()
assertThat(window.placement).isEqualTo(WindowPlacement.Fullscreen)

// Exit fullscreen to floating
state.placement = WindowPlacement.Floating
awaitIdle()
assertThat(window.placement).isEqualTo(WindowPlacement.Floating)
}

@Test
fun `from maximized to fullscreen to maximized`() = runApplicationTest(
useDelay = isLinux || isMacOs,
delayMillis = 1000
) {
val state = WindowState(size = DpSize(200.dp, 200.dp))
lateinit var window: ComposeWindow

launchTestApplication {
Window(onCloseRequest = {}, state) {
window = this.window
}
}

awaitIdle()

// Enter fullscreen from maximized
state.placement = WindowPlacement.Maximized
awaitIdle()
assertThat(window.placement).isEqualTo(WindowPlacement.Maximized)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests fail on Linux in these lines:

expected: Maximized
but was : Floating


state.placement = WindowPlacement.Fullscreen
awaitIdle()
assertThat(window.placement).isEqualTo(WindowPlacement.Fullscreen)

// Exit fullscreen to maximized
state.placement = WindowPlacement.Maximized
awaitIdle()
assertThat(window.placement).isEqualTo(WindowPlacement.Maximized)
}

@Test
fun `from floating to fullscreen to maximized`() = runApplicationTest(
useDelay = isLinux || isMacOs,
delayMillis = 1000
) {
val state = WindowState(size = DpSize(200.dp, 200.dp))
lateinit var window: ComposeWindow

launchTestApplication {
Window(onCloseRequest = {}, state) {
window = this.window
}
}

awaitIdle()

// Enter fullscreen from floating
state.placement = WindowPlacement.Floating
awaitIdle()
assertThat(window.placement).isEqualTo(WindowPlacement.Floating)

state.placement = WindowPlacement.Fullscreen
awaitIdle()
assertThat(window.placement).isEqualTo(WindowPlacement.Fullscreen)

// Exit fullscreen to maximized
state.placement = WindowPlacement.Maximized
awaitIdle()
assertThat(window.placement).isEqualTo(WindowPlacement.Maximized)
}

// https://github.com/JetBrains/compose-multiplatform/issues/3003
@Test
fun `WindowState placement after showing fullscreen window`() = runApplicationTest(
Expand Down