From b5e58a8db11c64e3a42696270540bd39b626b07d Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Mon, 4 Mar 2024 12:26:50 -0500 Subject: [PATCH] kwin/convergentwindows: Fix race condition causing windows to be maximized too large See https://invent.kde.org/teams/plasma-mobile/issues/-/issues/256 We have a race condition between maximizing and disabling window decorations on a window (the calls aren't blocking). Workaround this by having the window already be in maximized size before we disable window decorations. --- .../convergentwindows/contents/ui/main.qml | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/kwin/scripts/convergentwindows/contents/ui/main.qml b/kwin/scripts/convergentwindows/contents/ui/main.qml index 40ed9abd..ff00a391 100644 --- a/kwin/scripts/convergentwindows/contents/ui/main.qml +++ b/kwin/scripts/convergentwindows/contents/ui/main.qml @@ -10,11 +10,23 @@ Loader { id: root function run(window) { - if (!ShellSettings.Settings.convergenceModeEnabled) { - window.noBorder = true; - window.setMaximize(true, true); - } else { + if (ShellSettings.Settings.convergenceModeEnabled) { window.noBorder = false; + } else { + const output = window.output; + const desktop = window.desktops[0]; // assume it's the first desktop that the window is on + const maximizeRect = KWinComponents.Workspace.clientArea(KWinComponents.Workspace.MaximizeArea, output, desktop); + + // set the window to the maximized size and position instantly, avoiding race condition + // between maximizing and window decorations being turned off (changing window height) + // see: https://invent.kde.org/teams/plasma-mobile/issues/-/issues/256 + window.frameGeometry = maximizeRect; + + // turn off window decorations + window.noBorder = true; + + // run maximize after to ensure the state is maximized + window.setMaximize(true, true); } }