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.
This commit is contained in:
Devin Lin 2024-03-04 12:26:50 -05:00
parent 8b9015e4fb
commit b5e58a8db1

View file

@ -10,11 +10,23 @@ Loader {
id: root id: root
function run(window) { function run(window) {
if (!ShellSettings.Settings.convergenceModeEnabled) { if (ShellSettings.Settings.convergenceModeEnabled) {
window.noBorder = true;
window.setMaximize(true, true);
} else {
window.noBorder = false; 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);
} }
} }