From dd0a45d2e4a37805b5addcd2110664b7995cfdc5 Mon Sep 17 00:00:00 2001 From: Jin Liu Date: Tue, 20 Jan 2026 13:13:24 +0800 Subject: [PATCH] Fix "Decrease column width" requires two keypresses through certain preset width in fractional scaling Kwin might adjust the logical window width to a fractional number, so it lands at integer physical pixels. (E.g. from 939 to 939.2 at 2.5x scaling, so we would again try to decrease width from 939.2 to 939, with no visible effect). Fixed by requiring new width to be at lease 1px different from the current one. BUG: #151 --- src/lib/behavior/columnResizer/ContextualResizer.ts | 6 ++++-- src/lib/behavior/columnResizer/RawResizer.ts | 8 ++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/lib/behavior/columnResizer/ContextualResizer.ts b/src/lib/behavior/columnResizer/ContextualResizer.ts index ce4ea016..5c6ae192 100644 --- a/src/lib/behavior/columnResizer/ContextualResizer.ts +++ b/src/lib/behavior/columnResizer/ContextualResizer.ts @@ -3,6 +3,8 @@ class ContextualResizer { private readonly presetWidths: { getWidths: (minWidth: number, maxWidth: number) => number[] }, ) {} + private readonly DELTA = 1; + public increaseWidth(column: Column) { const grid = column.grid; const desktop = grid.desktop; @@ -30,7 +32,7 @@ class ContextualResizer { column.getWidth() + leftSpace + rightSpace + rightVisibleColumn.getWidth() + grid.config.gapsInnerHorizontal, ...this.presetWidths.getWidths(minWidth, maxWidth), ], - width => width - column.getWidth(), + width => width - column.getWidth() - this.DELTA, ); if (newWidth === undefined) { return; @@ -77,7 +79,7 @@ class ContextualResizer { column.getWidth() - rightOffScreen, ...this.presetWidths.getWidths(minWidth, maxWidth), ], - width => column.getWidth() - width, + width => column.getWidth() - width - this.DELTA, ); if (newWidth === undefined) { return; diff --git a/src/lib/behavior/columnResizer/RawResizer.ts b/src/lib/behavior/columnResizer/RawResizer.ts index 2e02df20..67e96aaa 100644 --- a/src/lib/behavior/columnResizer/RawResizer.ts +++ b/src/lib/behavior/columnResizer/RawResizer.ts @@ -3,16 +3,19 @@ class RawResizer { private readonly presetWidths: { getWidths: (minWidth: number, maxWidth: number) => number[] }, ) {} + private readonly DELTA = 1; + public increaseWidth(column: Column) { const newWidth = findMinPositive( [ ...this.presetWidths.getWidths(column.getMinWidth(), column.getMaxWidth()), ], - width => width - column.getWidth(), + width => width - column.getWidth() - this.DELTA, ); if (newWidth === undefined) { return; } + column.setWidth(newWidth, true); } @@ -21,11 +24,12 @@ class RawResizer { [ ...this.presetWidths.getWidths(column.getMinWidth(), column.getMaxWidth()), ], - width => column.getWidth() - width, + width => column.getWidth() - width - this.DELTA, ); if (newWidth === undefined) { return; } + column.setWidth(newWidth, true); } }