Skip to content

window: Fix potential freeze during resize

Philipp Sieweck requested to merge psi/kwin:fix-move-resize into master

The loop in Window::handleInteractiveMoveResize "bruteforces" the value for nextMoveResizeGeom. In some cases, however, the loop never terminates.

I observed this behavior on Wayland with a multi-monitor setup. While developing an application, KWin freezes as soon as I resize the application's very small window at its lower left corner.

Screenshot of the application: image

The loop in Window::handleInteractiveMoveResize "bruteforces" the value for nextMoveResizeGeom such that the area of nextMoveResizeGeom contains at least requiredPixels. In each loop iteration, one or more attributes (left, right, top, bottom) of nextMoveResizeGeom are selected to be moved +/-1.0 towards the value of currentMoveResizeGeom. The loop terminates if either the area of nextMoveResizeGeom is large enough or nextMoveResizeGeom == currentMoveResizeGeom.

The problem is that the variables compared and adjusted here are floating point variables, and their difference may not be a whole number. Using +/-1.0 adjustments can make the loop oscillate indefinitely around the target value.

This commit ensures loop termination by using qFuzzyCompare to compare floating point values and correctly handles the cases where adjustments smaller than 1.0 are needed to reach the target value.

Edited by Philipp Sieweck

Merge request reports