diff --git a/src/lib/behavior/PresetWidths.ts b/src/lib/behavior/PresetWidths.ts index 53487f1..847106c 100644 --- a/src/lib/behavior/PresetWidths.ts +++ b/src/lib/behavior/PresetWidths.ts @@ -7,7 +7,7 @@ class PresetWidths { public get(minWidth: number, maxWidth: number) { const widths = this.presets.map(f => clamp(f(maxWidth), minWidth, maxWidth)); - widths.sort((a, b) => b - a); + widths.sort((a, b) => a - b); return uniq(widths); } diff --git a/src/lib/keyBindings/Actions.ts b/src/lib/keyBindings/Actions.ts index 893ef2a..e0a41de 100644 --- a/src/lib/keyBindings/Actions.ts +++ b/src/lib/keyBindings/Actions.ts @@ -190,7 +190,7 @@ class Actions { } const widths = this.config.presetWidths.get(column.getMinWidth(), column.getMaxWidth()); const currentWidth = column.getWidth(); - const nextIndex = widths.findIndex(width => width < currentWidth); + const nextIndex = widths.findIndex(width => width > currentWidth); const nextWidth = nextIndex >= 0 ? widths[nextIndex] : widths[0]; column.setWidth(nextWidth, true); } diff --git a/src/tests/flows/presetWidths.ts b/src/tests/flows/presetWidths.ts index d225e21..ef2c0d4 100644 --- a/src/tests/flows/presetWidths.ts +++ b/src/tests/flows/presetWidths.ts @@ -25,14 +25,14 @@ tests.register("Preset Widths default", 1, () => { workspaceMock.createWindow(kwinClient); Assert.equalRects(kwinClient.frameGeometry, getRect(300)); - qtMock.fireShortcut("karousel-cycle-preset-widths"); - Assert.equalRects(kwinClient.frameGeometry, getRect(maxWidth)); - qtMock.fireShortcut("karousel-cycle-preset-widths"); Assert.equalRects(kwinClient.frameGeometry, getRect(halfWidth)); qtMock.fireShortcut("karousel-cycle-preset-widths"); Assert.equalRects(kwinClient.frameGeometry, getRect(maxWidth)); + + qtMock.fireShortcut("karousel-cycle-preset-widths"); + Assert.equalRects(kwinClient.frameGeometry, getRect(halfWidth)); }); tests.register("Preset Widths custom", 1, () => { @@ -48,7 +48,7 @@ tests.register("Preset Widths custom", 1, () => { 1, "app1", "Application 1", - new MockQmlRect(10, 20, 300, 200), + new MockQmlRect(10, 20, 200, 200), ); function getRect(columnWidth: number) { @@ -61,19 +61,19 @@ tests.register("Preset Widths custom", 1, () => { } workspaceMock.createWindow(kwinClient); - Assert.equalRects(kwinClient.frameGeometry, getRect(300)); + Assert.equalRects(kwinClient.frameGeometry, getRect(200)); qtMock.fireShortcut("karousel-cycle-preset-widths"); Assert.equalRects(kwinClient.frameGeometry, getRect(250)); qtMock.fireShortcut("karousel-cycle-preset-widths"); - Assert.equalRects(kwinClient.frameGeometry, getRect(100)); + Assert.equalRects(kwinClient.frameGeometry, getRect(halfWidth)); qtMock.fireShortcut("karousel-cycle-preset-widths"); Assert.equalRects(kwinClient.frameGeometry, getRect(500)); qtMock.fireShortcut("karousel-cycle-preset-widths"); - Assert.equalRects(kwinClient.frameGeometry, getRect(halfWidth)); + Assert.equalRects(kwinClient.frameGeometry, getRect(100)); qtMock.fireShortcut("karousel-cycle-preset-widths"); Assert.equalRects(kwinClient.frameGeometry, getRect(250)); @@ -123,7 +123,7 @@ tests.register("Preset Widths fill screen non-uniform", 1, () => { 1, "app1", "Application 1", - new MockQmlRect(10, 20, 300, 200), + new MockQmlRect(10, 20, 100, 200), ); workspaceMock.createWindow(clientThin1); qtMock.fireShortcut("karousel-cycle-preset-widths"); @@ -132,7 +132,7 @@ tests.register("Preset Widths fill screen non-uniform", 1, () => { 2, "app2", "Application 2", - new MockQmlRect(10, 20, 300, 200), + new MockQmlRect(10, 20, 100, 200), ); workspaceMock.createWindow(clientThin2); qtMock.fireShortcut("karousel-cycle-preset-widths"); @@ -141,7 +141,7 @@ tests.register("Preset Widths fill screen non-uniform", 1, () => { 10, "app10", "Application 10", - new MockQmlRect(10, 20, 410, 200), + new MockQmlRect(10, 20, 300, 200), ); workspaceMock.createWindow(clientWide); qtMock.fireShortcut("karousel-cycle-preset-widths"); diff --git a/src/tests/units/behavior/PresetWidths.ts b/src/tests/units/behavior/PresetWidths.ts index 70c0cc7..9d4f96e 100644 --- a/src/tests/units/behavior/PresetWidths.ts +++ b/src/tests/units/behavior/PresetWidths.ts @@ -4,12 +4,12 @@ tests.register("PresetWidths", 1, () => { const spacing = 10; const testCases = [ - { str: "100%, 50%", result: [800, 395] }, - { str: "105%, 50%", result: [800, 395] }, - { str: "100px,50 px", result: [100, 50] }, - { str: "900px,25 px", result: [800, 50] }, - { str: " 100px, 25 % , 0.1 ", result: [192, 100, 71] }, - { str: "100px, 25%, 0.1, 100px", result: [192, 100, 71] }, + { str: "100%, 50%", result: [395, 800] }, + { str: "105%, 50%", result: [395, 800] }, + { str: "100px,50 px", result: [50, 100] }, + { str: "900px,25 px", result: [50, 800] }, + { str: " 100px, 25 % , 0.1 ", result: [71, 100, 192] }, + { str: "100px, 25%, 0.1, 100px", result: [71, 100, 192] }, { str: "100px, -25 % , 0.1 ", error: true }, { str: "100px, 25 % , -0.1 ", error: true }, { str: "100px, 25 % , 0.1p", error: true },