29 Commits

Author SHA1 Message Date
Peter Fajdiga
21eacd7ba4 Makefile: package: rename package dir to karousel 2024-10-27 14:44:35 +01:00
Peter Fajdiga
5004417285 bump package to 0.7.2 2024-10-27 13:51:52 +01:00
Peter Fajdiga
a110aee7ce ClientWrapper: implement workaround for Qt5 JS bug 2024-09-10 23:33:56 +02:00
Peter Fajdiga
817ea64171 DesktopManager: fix getDesktopForClient 2024-08-30 12:14:40 +02:00
Peter Fajdiga
af930a9b2f Tiled: check if user is resizing any window in the grid 2024-03-18 19:28:58 +01:00
Peter Fajdiga
489a1447e7 ClientWrapper: create a workaround for the problem with stuck off-screen windows on Wayland 2024-03-18 19:28:58 +01:00
Peter Fajdiga
b984f025ec Column: avoid setting preferredWidth of a window when another window's height in the same column is being resized by the user 2024-03-10 21:29:47 +01:00
Peter Fajdiga
4e1204f1bd DesktopManager: refactor getDesktopForClient 2024-03-10 21:02:24 +01:00
Peter Fajdiga
bbcf51783d World: fix grammar in comment 2024-03-10 15:44:17 +01:00
Peter Fajdiga
019da3766e kwin.d.ts: use unknown for Tile 2024-03-10 15:44:17 +01:00
Peter Fajdiga
1535c994b8 use === everywhere 2024-03-10 15:44:16 +01:00
Peter Fajdiga
296d0deca9 remove void keyword in QSignal params 2024-03-09 21:55:15 +01:00
Peter Fajdiga
17e7d5b46e kwin.d.ts: remove unneeded QSignal params 2024-03-09 21:50:27 +01:00
Peter Fajdiga
840a50d14d move ClientAreaOption to kwin.d.ts 2024-03-09 21:44:23 +01:00
Peter Fajdiga
4f99c4dd45 Actions: remove superfluous return values 2024-03-09 19:53:10 +01:00
Peter Fajdiga
030eddaf34 Floating: add missing ; 2024-03-09 19:34:54 +01:00
Peter Fajdiga
7246a7660e kwin.d.ts: remove superfluous comments 2024-03-09 19:19:39 +01:00
Peter Fajdiga
687256d1dd src/config: unjsonify 2024-03-09 19:19:38 +01:00
Peter Fajdiga
12bb7506cc src/keyBindings: unjsonify 2024-03-09 19:19:13 +01:00
Peter Fajdiga
1808ee0025 mark all signal properties as readonly 2024-03-09 19:07:12 +01:00
Peter Fajdiga
3021f61933 metadata.json: change description 2024-03-01 15:54:06 +01:00
Peter Fajdiga
e908138478 fix bug where resizing used manualScrollStep setting instead of manualResizeStep setting 2024-02-22 20:24:12 +01:00
Peter Fajdiga
99ad115370 rename scrollers 2024-02-18 22:11:34 +01:00
Peter Fajdiga
c5a4238f5f move scroller src files to src/behavior/scroller 2024-02-18 22:07:28 +01:00
Peter Fajdiga
0670d9c265 separate clampScrollX logic into different Clamper implementations 2024-02-18 22:06:14 +01:00
Peter Fajdiga
845874b0d0 separate increaseColumnWidth and columnWidthDecrease logic into different ColumnResizer implementations 2024-02-18 22:06:13 +01:00
Peter Fajdiga
a422a077f6 Makefile: add prerequisites to package target 2024-02-18 21:28:17 +01:00
Peter Fajdiga
2fe1be99cb Desktop.scrollCenterVisible: stop prioritizing visible columns (this is now done by ColumnRange.addNeighbors) 2024-02-18 20:21:34 +01:00
Peter Fajdiga
1a449c238d ColumnRange: prioritize nearer columns 2024-02-18 20:15:58 +01:00
30 changed files with 460 additions and 426 deletions

View File

@@ -16,8 +16,8 @@ install: build config
uninstall:
kpackagetool5 --type=KWin/Script -r ./package
package:
tar -czf ./karousel_${subst .,_,${VERSION}}.tar.gz ./package
package: build config
tar -czf ./karousel_${subst .,_,${VERSION}}.tar.gz ./package --transform s/package/karousel/
logs:
journalctl -t kwin_x11 -g '^qml:|^file://.*karousel' -f

View File

@@ -21,7 +21,7 @@ function formatComment(comment: string | undefined) {
function printCols(...columns: (string[] | string)[]) {
const nCols = columns.length;
if (nCols == 0) {
if (nCols === 0) {
return;
}
@@ -30,7 +30,7 @@ function printCols(...columns: (string[] | string)[]) {
).map(
(column: string[] | string) => column.length
));
if (nRows == Infinity) {
if (nRows === Infinity) {
// we only have single string columns
nRows = 1;
}

View File

@@ -1,7 +1,7 @@
{
"KPlugin": {
"Name": "Karousel",
"Description": "Manual columnar tiling extension for KWin",
"Description": "Scrollable tiling extension for KWin",
"Icon": "preferences-system-windows",
"Authors": [{
"Email": "peter.fajdiga@gmail.com",
@@ -9,7 +9,7 @@
}],
"Id": "karousel",
"ServiceTypes": ["KWin/Script"],
"Version": "0.7.1",
"Version": "0.7.2",
"License": "GPLv3",
"Website": "https://github.com/peterfajdiga/karousel",
"BugReportUrl": "https://github.com/peterfajdiga/karousel/issues"

View File

@@ -166,89 +166,13 @@ namespace Actions {
columnWidthIncrease: () => {
world.doIfTiledFocused(false, (clientManager, desktopManager, window, column, grid) => {
const desktop = grid.desktop;
const visibleRange = desktop.getCurrentVisibleRange();
if(!column.isVisible(visibleRange, true) || column.getWidth() >= column.getMaxWidth()) {
return;
}
let leftVisibleColumn = grid.getLeftmostVisibleColumn(visibleRange, true);
let rightVisibleColumn = grid.getRightmostVisibleColumn(visibleRange, true);
if (leftVisibleColumn === null || rightVisibleColumn === null) {
console.assert(false); // should at least see self
return;
}
const leftSpace = leftVisibleColumn.getLeft() - visibleRange.getLeft();
const rightSpace = visibleRange.getRight() - rightVisibleColumn.getRight();
const newWidth = findNextStep(
[
visibleRange.getWidth(),
column.getWidth() + config.manualResizeStep,
column.getWidth() + leftSpace + rightSpace,
column.getWidth() + leftSpace + rightSpace + leftVisibleColumn.getWidth() + grid.config.gapsInnerHorizontal,
column.getWidth() + leftSpace + rightSpace + rightVisibleColumn.getWidth() + grid.config.gapsInnerHorizontal,
],
width => width - column.getWidth(),
)
if (newWidth === undefined) {
return;
}
column.setWidth(newWidth, true);
desktop.scrollCenterVisible(column, false);
desktop.onLayoutChanged();
desktop.autoAdjustScroll();
config.columnResizer.increaseWidth(column, config.manualResizeStep);
});
},
columnWidthDecrease: () => {
world.doIfTiledFocused(false, (clientManager, desktopManager, window, column, grid) => {
const desktop = grid.desktop;
const visibleRange = desktop.getCurrentVisibleRange();
if(!column.isVisible(visibleRange, true) || column.getWidth() <= column.getMinWidth()) {
return;
}
const leftVisibleColumn = grid.getLeftmostVisibleColumn(visibleRange, true);
const rightVisibleColumn = grid.getRightmostVisibleColumn(visibleRange, true);
if (leftVisibleColumn === null || rightVisibleColumn === null) {
console.assert(false); // should at least see self
return;
}
let leftOffScreenColumn = grid.getPrevColumn(leftVisibleColumn);
if (leftOffScreenColumn === column) {
leftOffScreenColumn = null;
}
let rightOffScreenColumn = grid.getNextColumn(rightVisibleColumn);
if (rightOffScreenColumn === column) {
rightOffScreenColumn = null;
}
const visibleColumnsWidth = rightVisibleColumn.getRight() - leftVisibleColumn.getLeft();
const unusedWidth = visibleRange.getWidth() - visibleColumnsWidth;
const leftOffScreen = leftOffScreenColumn === null ? 0 : leftOffScreenColumn.getWidth() + grid.config.gapsInnerHorizontal - unusedWidth;
const rightOffScreen = rightOffScreenColumn === null ? 0 : rightOffScreenColumn.getWidth() + grid.config.gapsInnerHorizontal - unusedWidth;
const newWidth = findNextStep(
[
visibleRange.getWidth(),
column.getWidth() - config.manualResizeStep,
column.getWidth() - leftOffScreen,
column.getWidth() - rightOffScreen,
],
width => column.getWidth() - width,
)
if (newWidth === undefined) {
return;
}
column.setWidth(newWidth, true);
desktop.scrollCenterVisible(column, true);
desktop.onLayoutChanged();
desktop.autoAdjustScroll();
config.columnResizer.decreaseWidth(column, config.manualResizeStep);
});
},
@@ -337,7 +261,7 @@ namespace Actions {
const grid = desktopManager.getCurrentDesktop().grid;
const targetColumn = grid.getColumnAtIndex(columnIndex);
if (targetColumn === null) {
return null;
return;
}
targetColumn.focus();
});
@@ -347,7 +271,7 @@ namespace Actions {
world.doIfTiledFocused(true, (clientManager, desktopManager, window, column, grid) => {
const targetColumn = grid.getColumnAtIndex(columnIndex);
if (targetColumn === null) {
return null;
return;
}
window.moveToColumn(targetColumn);
grid.desktop.autoAdjustScroll();
@@ -358,7 +282,7 @@ namespace Actions {
world.doIfTiledFocused(true, (clientManager, desktopManager, window, column, grid) => {
const targetColumn = grid.getColumnAtIndex(columnIndex);
if (targetColumn === null || targetColumn === column) {
return null;
return;
}
if (targetColumn.isAfter(column)) {
column.moveAfter(targetColumn);
@@ -399,21 +323,14 @@ namespace Actions {
});
}
function findNextStep(steps: number[], evaluate: (step: number) => number) {
let bestScore = Infinity;
let bestStep = undefined;
for (const step of steps) {
const score = evaluate(step);
if (score > 0 && score < bestScore) {
bestScore = score;
bestStep = step;
}
}
return bestStep;
}
export type Config = {
manualScrollStep: number,
manualResizeStep: number,
columnResizer: ColumnResizer,
};
export type ColumnResizer = {
increaseWidth(column: Column, step: number): void,
decreaseWidth(column: Column, step: number): void,
}
}

View File

@@ -1,10 +0,0 @@
enum ClientAreaOption {
PlacementArea,
MovementArea,
MaximizeArea,
MaximizeFullArea,
FullScreenArea,
WorkArea,
FullArea,
ScreenArea,
}

View File

@@ -0,0 +1,96 @@
class ContextualResizer {
public increaseWidth(column: Column, step: number) {
const grid = column.grid;
const desktop = grid.desktop;
const visibleRange = desktop.getCurrentVisibleRange();
if(!column.isVisible(visibleRange, true) || column.getWidth() >= column.getMaxWidth()) {
return;
}
let leftVisibleColumn = grid.getLeftmostVisibleColumn(visibleRange, true);
let rightVisibleColumn = grid.getRightmostVisibleColumn(visibleRange, true);
if (leftVisibleColumn === null || rightVisibleColumn === null) {
console.assert(false); // should at least see self
return;
}
const leftSpace = leftVisibleColumn.getLeft() - visibleRange.getLeft();
const rightSpace = visibleRange.getRight() - rightVisibleColumn.getRight();
const newWidth = ContextualResizer.findNextStep(
[
visibleRange.getWidth(),
column.getWidth() + step,
column.getWidth() + leftSpace + rightSpace,
column.getWidth() + leftSpace + rightSpace + leftVisibleColumn.getWidth() + grid.config.gapsInnerHorizontal,
column.getWidth() + leftSpace + rightSpace + rightVisibleColumn.getWidth() + grid.config.gapsInnerHorizontal,
],
width => width - column.getWidth(),
)
if (newWidth === undefined) {
return;
}
column.setWidth(newWidth, true);
desktop.scrollCenterVisible(column);
}
public decreaseWidth(column: Column, step: number) {
const grid = column.grid;
const desktop = grid.desktop;
const visibleRange = desktop.getCurrentVisibleRange();
if(!column.isVisible(visibleRange, true) || column.getWidth() <= column.getMinWidth()) {
return;
}
const leftVisibleColumn = grid.getLeftmostVisibleColumn(visibleRange, true);
const rightVisibleColumn = grid.getRightmostVisibleColumn(visibleRange, true);
if (leftVisibleColumn === null || rightVisibleColumn === null) {
console.assert(false); // should at least see self
return;
}
let leftOffScreenColumn = grid.getPrevColumn(leftVisibleColumn);
if (leftOffScreenColumn === column) {
leftOffScreenColumn = null;
}
let rightOffScreenColumn = grid.getNextColumn(rightVisibleColumn);
if (rightOffScreenColumn === column) {
rightOffScreenColumn = null;
}
const visibleColumnsWidth = rightVisibleColumn.getRight() - leftVisibleColumn.getLeft();
const unusedWidth = visibleRange.getWidth() - visibleColumnsWidth;
const leftOffScreen = leftOffScreenColumn === null ? 0 : leftOffScreenColumn.getWidth() + grid.config.gapsInnerHorizontal - unusedWidth;
const rightOffScreen = rightOffScreenColumn === null ? 0 : rightOffScreenColumn.getWidth() + grid.config.gapsInnerHorizontal - unusedWidth;
const newWidth = ContextualResizer.findNextStep(
[
visibleRange.getWidth(),
column.getWidth() - step,
column.getWidth() - leftOffScreen,
column.getWidth() - rightOffScreen,
],
width => column.getWidth() - width,
)
if (newWidth === undefined) {
return;
}
column.setWidth(newWidth, true);
desktop.scrollCenterVisible(column);
}
private static findNextStep(steps: number[], evaluate: (step: number) => number) {
let bestScore = Infinity;
let bestStep = undefined;
for (const step of steps) {
const score = evaluate(step);
if (score > 0 && score < bestScore) {
bestScore = score;
bestStep = step;
}
}
return bestStep;
}
}

View File

@@ -0,0 +1,9 @@
class RawResizer {
public increaseWidth(column: Column, step: number) {
column.adjustWidth(step, true);
}
public decreaseWidth(column: Column, step: number) {
column.adjustWidth(-step, true);
}
}

View File

@@ -1,13 +1,5 @@
class ScrollerCentered {
public scrollToColumn(desktop: Desktop, column: Column) {
desktop.scrollCenterRange(column);
}
class CenterClamper {
public clampScrollX(desktop: Desktop, x: number) {
return ScrollerCentered.clampScrollX(desktop, x);
}
public static clampScrollX(desktop: Desktop, x: number) {
const firstColumn = desktop.grid.getFirstColumn();
if (firstColumn === null) {
return 0;

View File

@@ -1,8 +1,4 @@
class ScrollerLazy {
public scrollToColumn(desktop: Desktop, column: Column) {
desktop.scrollIntoView(column);
}
class EdgeClamper {
public clampScrollX(desktop: Desktop, x: number) {
let minScroll = 0;
let maxScroll = desktop.grid.getWidth() - desktop.tilingArea.width;

View File

@@ -0,0 +1,5 @@
class CenteredScroller {
public scrollToColumn(desktop: Desktop, column: Column) {
desktop.scrollCenterRange(column);
}
}

View File

@@ -0,0 +1,5 @@
class GroupedScroller {
public scrollToColumn(desktop: Desktop, column: Column) {
desktop.scrollCenterVisible(column);
}
}

View File

@@ -0,0 +1,5 @@
class LazyScroller {
public scrollToColumn(desktop: Desktop, column: Column) {
desktop.scrollIntoView(column);
}
}

View File

@@ -72,103 +72,103 @@ const defaultWindowRules = `[
const configDef = [
{
"name": "gapsOuterTop",
"type": "UInt",
"default": 18
name: "gapsOuterTop",
type: "UInt",
default: 18,
},
{
"name": "gapsOuterBottom",
"type": "UInt",
"default": 18
name: "gapsOuterBottom",
type: "UInt",
default: 18,
},
{
"name": "gapsOuterLeft",
"type": "UInt",
"default": 18
name: "gapsOuterLeft",
type: "UInt",
default: 18,
},
{
"name": "gapsOuterRight",
"type": "UInt",
"default": 18
name: "gapsOuterRight",
type: "UInt",
default: 18,
},
{
"name": "gapsInnerHorizontal",
"type": "UInt",
"default": 18
name: "gapsInnerHorizontal",
type: "UInt",
default: 18,
},
{
"name": "gapsInnerVertical",
"type": "UInt",
"default": 18
name: "gapsInnerVertical",
type: "UInt",
default: 18,
},
{
"name": "manualScrollStep",
"type": "UInt",
"default": 200
name: "manualScrollStep",
type: "UInt",
default: 200,
},
{
"name": "manualResizeStep",
"type": "UInt",
"default": 600
name: "manualResizeStep",
type: "UInt",
default: 600,
},
{
"name": "offScreenOpacity",
"type": "UInt",
"default": 100
name: "offScreenOpacity",
type: "UInt",
default: 100,
},
{
"name": "untileOnDrag",
"type": "Bool",
"default": true
name: "untileOnDrag",
type: "Bool",
default: true,
},
{
"name": "stackColumnsByDefault",
"type": "Bool",
"default": false
name: "stackColumnsByDefault",
type: "Bool",
default: false,
},
{
"name": "resizeNeighborColumn",
"type": "Bool",
"default": false
name: "resizeNeighborColumn",
type: "Bool",
default: false,
},
{
"name": "reMaximize",
"type": "Bool",
"default": false
name: "reMaximize",
type: "Bool",
default: false,
},
{
"name": "skipSwitcher",
"type": "Bool",
"default": false
name: "skipSwitcher",
type: "Bool",
default: false,
},
{
"name": "scrollingLazy",
"type": "Bool",
"default": true
name: "scrollingLazy",
type: "Bool",
default: true,
},
{
"name": "scrollingCentered",
"type": "Bool",
"default": false
name: "scrollingCentered",
type: "Bool",
default: false,
},
{
"name": "scrollingGrouped",
"type": "Bool",
"default": false
name: "scrollingGrouped",
type: "Bool",
default: false,
},
{
"name": "tiledKeepBelow",
"type": "Bool",
"default": true
name: "tiledKeepBelow",
type: "Bool",
default: true,
},
{
"name": "floatingKeepAbove",
"type": "Bool",
"default": false
name: "floatingKeepAbove",
type: "Bool",
default: false,
},
{
"name": "windowRules",
"type": "String",
"default": defaultWindowRules
name: "windowRules",
type: "String",
default: defaultWindowRules,
}
];

62
src/extern/kwin.d.ts vendored
View File

@@ -1,39 +1,44 @@
declare const KWin: {
// Functions
readConfig(key: string, defaultValue: any): any;
registerShortcut(name: string, description: string, keySequence: string, callback: () => void): void;
};
declare const workspace: {
// Read-write Properties
readonly desktops: number;
readonly currentDesktop: number;
readonly currentActivity: string;
// Read-write Properties
activeClient: KwinClient;
// Signals
currentDesktopChanged: QSignal<[oldDesktopNumber: number]>
clientAdded: QSignal<[KwinClient]>;
clientRemoved: QSignal<[KwinClient]>;
clientMinimized: QSignal<[KwinClient]>;
clientUnminimized: QSignal<[KwinClient]>;
clientMaximizeSet: QSignal<[KwinClient, horizontally: boolean, vertically: boolean]>;
clientActivated: QSignal<[KwinClient]>;
numberDesktopsChanged: QSignal<[oldNumberOfVirtualDesktops: number]>;
currentActivityChanged: QSignal<[newActivity: string]>;
virtualScreenSizeChanged: QSignal<[void]>;
readonly currentDesktopChanged: QSignal<[]>
readonly clientAdded: QSignal<[KwinClient]>;
readonly clientRemoved: QSignal<[KwinClient]>;
readonly clientMinimized: QSignal<[KwinClient]>;
readonly clientUnminimized: QSignal<[KwinClient]>;
readonly clientMaximizeSet: QSignal<[KwinClient, horizontally: boolean, vertically: boolean]>;
readonly clientActivated: QSignal<[KwinClient]>;
readonly numberDesktopsChanged: QSignal<[]>;
readonly currentActivityChanged: QSignal<[]>;
readonly virtualScreenSizeChanged: QSignal<[]>;
// Functions
clientArea(option: ClientAreaOption, screenNumber: number, desktopNumber: number);
clientList(): KwinClient[];
};
type Tile = any;
const enum ClientAreaOption {
PlacementArea,
MovementArea,
MaximizeArea,
MaximizeFullArea,
FullScreenArea,
WorkArea,
FullArea,
ScreenArea,
}
type Tile = unknown;
interface KwinClient {
// Read-only Properties
readonly shadeable: boolean;
readonly caption: string;
readonly minSize: QmlSize;
@@ -47,9 +52,8 @@ interface KwinClient {
readonly dock: boolean;
readonly normalWindow: boolean;
readonly managed: boolean;
opacity: number;
// Read-write Properties
opacity: number;
fullScreen: boolean;
activities: string[]; // empty array means all activities
skipSwitcher: boolean;
@@ -61,17 +65,15 @@ interface KwinClient {
desktop: number; // -1 means all desktops
tile: Tile;
// Signals
fullScreenChanged: QSignal<[void]>;
desktopChanged: QSignal<[void]>;
activitiesChanged: QSignal<[KwinClient]>;
captionChanged: QSignal<[void]>;
tileChanged: QSignal<[Tile]>;
moveResizedChanged: QSignal<[void]>;
moveResizeCursorChanged: QSignal<[void]>;
clientStartUserMovedResized: QSignal<[void]>;
frameGeometryChanged: QSignal<[KwinClient, oldGeometry: QmlRect]>;
readonly fullScreenChanged: QSignal<[]>;
readonly desktopChanged: QSignal<[]>;
readonly activitiesChanged: QSignal<[]>;
readonly captionChanged: QSignal<[]>;
readonly tileChanged: QSignal<[]>;
readonly moveResizedChanged: QSignal<[]>;
readonly moveResizeCursorChanged: QSignal<[]>;
readonly clientStartUserMovedResized: QSignal<[]>;
readonly frameGeometryChanged: QSignal<[KwinClient, oldGeometry: QmlRect]>;
// Functions
setMaximize(vertically: boolean, horizontally: boolean): void;
}

2
src/extern/qt.d.ts vendored
View File

@@ -36,7 +36,7 @@ type QSignal<T extends unknown[]> = {
type QmlTimer = {
interval: number;
triggered: QSignal<[void]>;
readonly triggered: QSignal<[]>;
restart(): void;
destroy(): void;
};

View File

@@ -1,218 +1,218 @@
const keyBindings: KeyBinding[] = [
{
"name": "window-toggle-floating",
"description": "Toggle floating",
"defaultKeySequence": "Meta+Space",
"action": "windowToggleFloating",
name: "window-toggle-floating",
description: "Toggle floating",
defaultKeySequence: "Meta+Space",
action: "windowToggleFloating",
},
{
"name": "focus-left",
"description": "Move focus left",
"defaultKeySequence": "Meta+A",
"action": "focusLeft",
name: "focus-left",
description: "Move focus left",
defaultKeySequence: "Meta+A",
action: "focusLeft",
},
{
"name": "focus-right",
"description": "Move focus right",
"comment": "Clashes with default KDE shortcuts, may require manual remapping",
"defaultKeySequence": "Meta+D",
"action": "focusRight",
name: "focus-right",
description: "Move focus right",
comment: "Clashes with default KDE shortcuts, may require manual remapping",
defaultKeySequence: "Meta+D",
action: "focusRight",
},
{
"name": "focus-up",
"description": "Move focus up",
"comment": "Clashes with default KDE shortcuts, may require manual remapping",
"defaultKeySequence": "Meta+W",
"action": "focusUp",
name: "focus-up",
description: "Move focus up",
comment: "Clashes with default KDE shortcuts, may require manual remapping",
defaultKeySequence: "Meta+W",
action: "focusUp",
},
{
"name": "focus-down",
"description": "Move focus down",
"comment": "Clashes with default KDE shortcuts, may require manual remapping",
"defaultKeySequence": "Meta+S",
"action": "focusDown",
name: "focus-down",
description: "Move focus down",
comment: "Clashes with default KDE shortcuts, may require manual remapping",
defaultKeySequence: "Meta+S",
action: "focusDown",
},
{
"name": "focus-start",
"description": "Move focus to start",
"defaultKeySequence": "Meta+Home",
"action": "focusStart",
name: "focus-start",
description: "Move focus to start",
defaultKeySequence: "Meta+Home",
action: "focusStart",
},
{
"name": "focus-end",
"description": "Move focus to end",
"defaultKeySequence": "Meta+End",
"action": "focusEnd",
name: "focus-end",
description: "Move focus to end",
defaultKeySequence: "Meta+End",
action: "focusEnd",
},
{
"name": "window-move-left",
"description": "Move window left",
"comment": "Moves window out of and into columns",
"defaultKeySequence": "Meta+Shift+A",
"action": "windowMoveLeft",
name: "window-move-left",
description: "Move window left",
comment: "Moves window out of and into columns",
defaultKeySequence: "Meta+Shift+A",
action: "windowMoveLeft",
},
{
"name": "window-move-right",
"description": "Move window right",
"comment": "Moves window out of and into columns",
"defaultKeySequence": "Meta+Shift+D",
"action": "windowMoveRight",
name: "window-move-right",
description: "Move window right",
comment: "Moves window out of and into columns",
defaultKeySequence: "Meta+Shift+D",
action: "windowMoveRight",
},
{
"name": "window-move-up",
"description": "Move window up",
"defaultKeySequence": "Meta+Shift+W",
"action": "windowMoveUp",
name: "window-move-up",
description: "Move window up",
defaultKeySequence: "Meta+Shift+W",
action: "windowMoveUp",
},
{
"name": "window-move-down",
"description": "Move window down",
"defaultKeySequence": "Meta+Shift+S",
"action": "windowMoveDown",
name: "window-move-down",
description: "Move window down",
defaultKeySequence: "Meta+Shift+S",
action: "windowMoveDown",
},
{
"name": "window-move-start",
"description": "Move window to start",
"defaultKeySequence": "Meta+Shift+Home",
"action": "windowMoveStart",
name: "window-move-start",
description: "Move window to start",
defaultKeySequence: "Meta+Shift+Home",
action: "windowMoveStart",
},
{
"name": "window-move-end",
"description": "Move window to end",
"defaultKeySequence": "Meta+Shift+End",
"action": "windowMoveEnd",
name: "window-move-end",
description: "Move window to end",
defaultKeySequence: "Meta+Shift+End",
action: "windowMoveEnd",
},
{
"name": "column-toggle-stacked",
"description": "Toggle stacked layout for focused column",
"comment": "One window in the column visible, others shaded; not supported on Wayland",
"defaultKeySequence": "Meta+X",
"action": "columnToggleStacked",
name: "column-toggle-stacked",
description: "Toggle stacked layout for focused column",
comment: "One window in the column visible, others shaded; not supported on Wayland",
defaultKeySequence: "Meta+X",
action: "columnToggleStacked",
},
{
"name": "column-move-left",
"description": "Move column left",
"defaultKeySequence": "Meta+Ctrl+Shift+A",
"action": "columnMoveLeft",
name: "column-move-left",
description: "Move column left",
defaultKeySequence: "Meta+Ctrl+Shift+A",
action: "columnMoveLeft",
},
{
"name": "column-move-right",
"description": "Move column right",
"defaultKeySequence": "Meta+Ctrl+Shift+D",
"action": "columnMoveRight",
name: "column-move-right",
description: "Move column right",
defaultKeySequence: "Meta+Ctrl+Shift+D",
action: "columnMoveRight",
},
{
"name": "column-move-start",
"description": "Move column to start",
"defaultKeySequence": "Meta+Ctrl+Shift+Home",
"action": "columnMoveStart",
name: "column-move-start",
description: "Move column to start",
defaultKeySequence: "Meta+Ctrl+Shift+Home",
action: "columnMoveStart",
},
{
"name": "column-move-end",
"description": "Move column to end",
"defaultKeySequence": "Meta+Ctrl+Shift+End",
"action": "columnMoveEnd",
name: "column-move-end",
description: "Move column to end",
defaultKeySequence: "Meta+Ctrl+Shift+End",
action: "columnMoveEnd",
},
{
"name": "column-width-increase",
"description": "Increase column width",
"defaultKeySequence": "Meta+Ctrl++",
"action": "columnWidthIncrease",
name: "column-width-increase",
description: "Increase column width",
defaultKeySequence: "Meta+Ctrl++",
action: "columnWidthIncrease",
},
{
"name": "column-width-decrease",
"description": "Decrease column width",
"defaultKeySequence": "Meta+Ctrl+-",
"action": "columnWidthDecrease",
name: "column-width-decrease",
description: "Decrease column width",
defaultKeySequence: "Meta+Ctrl+-",
action: "columnWidthDecrease",
},
{
"name": "columns-width-equalize",
"description": "Equalize widths of visible columns",
"defaultKeySequence": "Meta+Ctrl+X",
"action": "columnsWidthEqualize",
name: "columns-width-equalize",
description: "Equalize widths of visible columns",
defaultKeySequence: "Meta+Ctrl+X",
action: "columnsWidthEqualize",
},
{
"name": "grid-scroll-focused",
"description": "Center focused window",
"comment": "Scrolls so that the focused window is centered in the screen",
"defaultKeySequence": "Meta+Alt+Return",
"action": "gridScrollFocused",
name: "grid-scroll-focused",
description: "Center focused window",
comment: "Scrolls so that the focused window is centered in the screen",
defaultKeySequence: "Meta+Alt+Return",
action: "gridScrollFocused",
},
{
"name": "grid-scroll-left-column",
"description": "Scroll one column to the left",
"defaultKeySequence": "Meta+Alt+A",
"action": "gridScrollLeftColumn",
name: "grid-scroll-left-column",
description: "Scroll one column to the left",
defaultKeySequence: "Meta+Alt+A",
action: "gridScrollLeftColumn",
},
{
"name": "grid-scroll-right-column",
"description": "Scroll one column to the right",
"defaultKeySequence": "Meta+Alt+D",
"action": "gridScrollRightColumn",
name: "grid-scroll-right-column",
description: "Scroll one column to the right",
defaultKeySequence: "Meta+Alt+D",
action: "gridScrollRightColumn",
},
{
"name": "grid-scroll-left",
"description": "Scroll left",
"defaultKeySequence": "Meta+Alt+PgUp",
"action": "gridScrollLeft",
name: "grid-scroll-left",
description: "Scroll left",
defaultKeySequence: "Meta+Alt+PgUp",
action: "gridScrollLeft",
},
{
"name": "grid-scroll-right",
"description": "Scroll right",
"defaultKeySequence": "Meta+Alt+PgDown",
"action": "gridScrollRight",
name: "grid-scroll-right",
description: "Scroll right",
defaultKeySequence: "Meta+Alt+PgDown",
action: "gridScrollRight",
},
{
"name": "grid-scroll-start",
"description": "Scroll to start",
"defaultKeySequence": "Meta+Alt+Home",
"action": "gridScrollStart",
name: "grid-scroll-start",
description: "Scroll to start",
defaultKeySequence: "Meta+Alt+Home",
action: "gridScrollStart",
},
{
"name": "grid-scroll-end",
"description": "Scroll to end",
"defaultKeySequence": "Meta+Alt+End",
"action": "gridScrollEnd",
name: "grid-scroll-end",
description: "Scroll to end",
defaultKeySequence: "Meta+Alt+End",
action: "gridScrollEnd",
},
];
const numKeyBindings: NumKeyBinding[] = [
{
"name": "focus-",
"description": "Move focus to column ",
"comment": "Clashes with default KDE shortcuts, may require manual remapping",
"defaultModifiers": "Meta",
"fKeys": false,
"action": "focusColumn",
name: "focus-",
description: "Move focus to column ",
comment: "Clashes with default KDE shortcuts, may require manual remapping",
defaultModifiers: "Meta",
fKeys: false,
action: "focusColumn",
},
{
"name": "window-move-to-column-",
"description": "Move window to column ",
"comment": "Requires manual remapping according to your keyboard layout, e.g. Meta+Shift+1 -> Meta+!",
"defaultModifiers": "Meta+Shift",
"fKeys": false,
"action": "windowMoveToColumn",
name: "window-move-to-column-",
description: "Move window to column ",
comment: "Requires manual remapping according to your keyboard layout, e.g. Meta+Shift+1 -> Meta+!",
defaultModifiers: "Meta+Shift",
fKeys: false,
action: "windowMoveToColumn",
},
{
"name": "column-move-to-column-",
"description": "Move column to position ",
"comment": "Requires manual remapping according to your keyboard layout, e.g. Meta+Ctrl+Shift+1 -> Meta+Ctrl+!",
"defaultModifiers": "Meta+Ctrl+Shift",
"fKeys": false,
"action": "columnMoveToColumn",
name: "column-move-to-column-",
description: "Move column to position ",
comment: "Requires manual remapping according to your keyboard layout, e.g. Meta+Ctrl+Shift+1 -> Meta+Ctrl+!",
defaultModifiers: "Meta+Ctrl+Shift",
fKeys: false,
action: "columnMoveToColumn",
},
{
"name": "column-move-to-desktop-",
"description": "Move column to desktop ",
"defaultModifiers": "Meta+Ctrl+Shift",
"fKeys": true,
"action": "columnMoveToDesktop",
name: "column-move-to-desktop-",
description: "Move column to desktop ",
defaultModifiers: "Meta+Ctrl+Shift",
fKeys: true,
action: "columnMoveToDesktop",
},
{
"name": "tail-move-to-desktop-",
"description": "Move this and all following columns to desktop ",
"defaultModifiers": "Meta+Ctrl+Shift+Alt",
"fKeys": true,
"action": "tailMoveToDesktop",
name: "tail-move-to-desktop-",
description: "Move this and all following columns to desktop ",
defaultModifiers: "Meta+Ctrl+Shift+Alt",
fKeys: true,
action: "tailMoveToDesktop",
},
];

View File

@@ -53,7 +53,12 @@ function registerNumKeyBindings(name: string, description: string, modifiers: st
}
function registerKeyBindings(world: World, config: Config) {
const actions = Actions.init(world, config);
const actions = Actions.init(world, {
manualScrollStep: config.manualScrollStep,
manualResizeStep: config.manualResizeStep,
columnResizer: config.scrollingCentered ? new RawResizer() : new ContextualResizer(),
});
for (const binding of keyBindings) {
registerKeyBinding(binding.name, binding.description, binding.defaultKeySequence, actions[binding.action]);
}

View File

@@ -92,16 +92,17 @@ class Column {
public setWidth(width: number, setPreferred: boolean) {
width = clamp(width, this.getMinWidth(), this.getMaxWidth());
const oldWidth = this.width;
if (width === this.width) {
return;
}
this.width = width;
if (setPreferred) {
for (const window of this.windows.iterator()) {
window.client.preferredWidth = width;
}
}
if (width !== oldWidth) {
this.grid.onColumnWidthChanged(this, oldWidth, width);
}
this.grid.onColumnWidthChanged(this);
}
public adjustWidth(widthDelta: number, setPreferred: boolean) {

View File

@@ -78,13 +78,10 @@ class Desktop {
this.adjustScroll(Math.round(windowCenter - screenCenter), false);
}
public scrollCenterVisible(focusedColumn: Column, prioritiseVisible: boolean) {
public scrollCenterVisible(focusedColumn: Column) {
const columnRange = new Desktop.ColumnRange(focusedColumn);
const visibleRange = this.getCurrentVisibleRange();
if (prioritiseVisible) {
columnRange.addNeighbors(visibleRange, this.grid.config.gapsInnerHorizontal, column => column.isVisible(visibleRange, true));
}
columnRange.addNeighbors(visibleRange, this.grid.config.gapsInnerHorizontal, () => true);
columnRange.addNeighbors(visibleRange, this.grid.config.gapsInnerHorizontal);
this.scrollCenterRange(columnRange);
}
@@ -112,7 +109,7 @@ class Desktop {
}
private clampScrollX(x: number) {
return this.config.scroller.clampScrollX(this, x);
return this.config.clamper.clampScrollX(this, x);
}
public setScroll(x: number, force: boolean) {
@@ -195,6 +192,7 @@ namespace Desktop {
marginLeft: number,
marginRight: number,
scroller: Desktop.Scroller,
clamper: Desktop.Clamper,
};
export type Range = {
@@ -242,17 +240,15 @@ namespace Desktop {
this.width = initialColumn.getWidth();
}
public addNeighbors(visibleRange: Desktop.Range, gap: number, condition: (column: Column) => boolean) {
public addNeighbors(visibleRange: Desktop.Range, gap: number) {
const grid = this.left.grid;
const columnRange = this;
function canFit(column: Column) {
return columnRange.width + gap + column.getWidth() <= visibleRange.getWidth()
return columnRange.width + gap + column.getWidth() <= visibleRange.getWidth();
}
function isUsable(column: Column|null) {
return column !== null &&
canFit(column) &&
condition(column)
return column !== null && canFit(column);
}
let leftColumn = grid.getPrevColumn(this.left);
@@ -267,10 +263,11 @@ namespace Desktop {
}
checkColumns();
const visibleCenter = visibleRange.getLeft() + visibleRange.getWidth() / 2;
while (leftColumn !== null || rightColumn !== null) {
const leftWidth = leftColumn === null ? -Infinity : leftColumn.getWidth();
const rightWidth = rightColumn === null ? -Infinity : rightColumn.getWidth();
if (leftWidth > rightWidth) {
const leftToCenter = leftColumn === null ? Infinity : Math.abs(leftColumn.getLeft() - visibleCenter);
const rightToCenter = rightColumn === null ? Infinity : Math.abs(rightColumn.getRight() - visibleCenter);
if (leftToCenter < rightToCenter) {
this.addLeft(leftColumn!, gap);
leftColumn = grid.getPrevColumn(leftColumn!);
} else {
@@ -306,6 +303,9 @@ namespace Desktop {
export type Scroller = {
scrollToColumn(desktop: Desktop, column: Column): void;
}
export type Clamper = {
clampScrollX(desktop: Desktop, x: number): number;
}
}

View File

@@ -43,6 +43,10 @@ class Grid {
return this.width;
}
public isUserResizing() {
return this.userResize;
}
public getPrevColumn(column: Column) {
return this.columns.getPrev(column);
}
@@ -185,7 +189,7 @@ class Grid {
this.desktop.autoAdjustScroll();
}
public onColumnWidthChanged(column: Column, oldWidth: number, width: number) {
public onColumnWidthChanged(column: Column) {
const nextColumn = this.columns.getNext(column);
this.columnsSetX(nextColumn);
this.desktop.onLayoutChanged();

View File

@@ -1,9 +0,0 @@
class ScrollerGrouped {
public scrollToColumn(desktop: Desktop, column: Column) {
desktop.scrollCenterVisible(column, true);
}
public clampScrollX(desktop: Desktop, x: number) {
return ScrollerCentered.clampScrollX(desktop, x);
}
}

View File

@@ -31,8 +31,9 @@ class WindowRuleEnforcer {
manager.connect(kwinClient.captionChanged, () => {
const shouldTile = enforcer.shouldTile(kwinClient);
world.do((clientManager, desktopManager) => {
if (shouldTile) {
clientManager.tileClient(kwinClient);
const desktop = desktopManager.getDesktopForClient(kwinClient);
if (shouldTile && desktop !== undefined) {
clientManager.tileClient(kwinClient, desktop.grid);
} else {
clientManager.untileClient(kwinClient);
}
@@ -71,11 +72,11 @@ class WindowRuleEnforcer {
}
private static joinRegexes(regexes: string[]) {
if (regexes.length == 0) {
if (regexes.length === 0) {
return new RegExp("");
}
if (regexes.length == 1) {
if (regexes.length === 1) {
return new RegExp("^" + regexes[0] + "$");
}

View File

@@ -60,7 +60,7 @@ function initWorkspaceSignalHandlers(world: World) {
world.do(() => {}); // re-arrange desktop
});
manager.connect(workspace.numberDesktopsChanged, (oldNumberOfVirtualDesktops: number) => {
manager.connect(workspace.numberDesktopsChanged, () => {
world.updateDesktops();
});

View File

@@ -27,13 +27,13 @@ class ClientManager {
public addClient(kwinClient: KwinClient) {
console.assert(!this.hasClient(kwinClient));
const desktop = this.desktopManager.getDesktopForClient(kwinClient);
let constructState: (client: ClientWrapper) => ClientState.State;
if (kwinClient.dock) {
constructState = () => new ClientState.Docked(this.world, kwinClient);
} else if (this.windowRuleEnforcer.shouldTile(kwinClient)) {
const grid = this.desktopManager.getDesktopForClient(kwinClient).grid;
constructState = (client: ClientWrapper) => new ClientState.Tiled(this.world, client, grid);
} else if (this.windowRuleEnforcer.shouldTile(kwinClient) && desktop !== undefined) {
constructState = (client: ClientWrapper) => new ClientState.Tiled(this.world, client, desktop.grid);
} else {
constructState = (client: ClientWrapper) => new ClientState.Floating(this.world, client, this.config, false);
}
@@ -86,12 +86,16 @@ class ClientManager {
return;
}
if (client.stateManager.getState() instanceof ClientState.TiledMinimized) {
const grid = this.desktopManager.getDesktopForClient(kwinClient).grid;
client.stateManager.setState(() => new ClientState.Tiled(this.world, client, grid), false);
const desktop = this.desktopManager.getDesktopForClient(kwinClient);
if (desktop !== undefined) {
client.stateManager.setState(() => new ClientState.Tiled(this.world, client, desktop.grid), false);
} else {
client.stateManager.setState(() => new ClientState.Floating(this.world, client, this.config, false), false);
}
}
}
public tileClient(kwinClient: KwinClient) {
public tileClient(kwinClient: KwinClient, grid: Grid) {
const client = this.clientMap.get(kwinClient);
if (client === undefined) {
return;
@@ -99,7 +103,6 @@ class ClientManager {
if (client.stateManager.getState() instanceof ClientState.Tiled) {
return;
}
const grid = this.desktopManager.getDesktopForClient(kwinClient).grid;
client.stateManager.setState(() => new ClientState.Tiled(this.world, client, grid), false);
}
@@ -147,8 +150,11 @@ class ClientManager {
const clientState = client.stateManager.getState();
if ((clientState instanceof ClientState.Floating || clientState instanceof ClientState.Pinned) && Clients.canTileEver(kwinClient)) {
Clients.makeTileable(kwinClient);
const grid = this.desktopManager.getDesktopForClient(kwinClient).grid;
client.stateManager.setState(() => new ClientState.Tiled(this.world, client, grid), false);
const desktop = this.desktopManager.getDesktopForClient(kwinClient);
if (desktop === undefined) {
return;
}
client.stateManager.setState(() => new ClientState.Tiled(this.world, client, desktop.grid), false);
} else if (clientState instanceof ClientState.Tiled) {
client.stateManager.setState(() => new ClientState.Floating(this.world, client, this.config, true), false);
}

View File

@@ -33,8 +33,15 @@ class ClientWrapper {
// window is being manually resized, prevent fighting with the user
return;
}
this.lastPlacement = Qt.rect(x, y, width, height);
this.kwinClient.frameGeometry = this.lastPlacement;
const clientWrapper = this; // workaround for bug in Qt5's JS engine
clientWrapper.lastPlacement = Qt.rect(x, y, width, height);
clientWrapper.kwinClient.frameGeometry = clientWrapper.lastPlacement;
if (clientWrapper.kwinClient.frameGeometry !== clientWrapper.lastPlacement) {
// frameGeometry assignment failed. This sometimes happens on Wayland
// when a window is off-screen, effectively making it stuck there.
clientWrapper.kwinClient.frameGeometry.x = x; // This makes it unstuck.
clientWrapper.kwinClient.frameGeometry = clientWrapper.lastPlacement;
}
});
}

View File

@@ -39,7 +39,9 @@ class DesktopManager {
}
public getDesktopForClient(kwinClient: KwinClient) {
console.assert(kwinClient.activities.length === 1 && kwinClient.desktop > 0);
if (kwinClient.activities.length !== 1 || kwinClient.desktop <= 0) {
return undefined;
}
return this.getDesktop(kwinClient.activities[0], kwinClient.desktop);
}

View File

@@ -11,7 +11,7 @@ class World {
this.workspaceSignalManager = initWorkspaceSignalHandlers(this);
this.screenResizedDelayer = new Delayer(1000, () => {
// this delay ensures that docks get taken into account by `workspace.clientArea`
// this delay ensures that docks are taken into account by `workspace.clientArea`
const desktopManager = this.desktopManager; // workaround for bug in Qt5's JS engine
for (const desktop of desktopManager.desktops()) {
desktop.onLayoutChanged();
@@ -40,10 +40,11 @@ class World {
marginBottom: config.gapsOuterBottom,
marginLeft: config.gapsOuterLeft,
marginRight: config.gapsOuterRight,
scroller: config.scrollingLazy ? new ScrollerLazy() :
config.scrollingCentered ? new ScrollerCentered() :
config.scrollingGrouped ? new ScrollerGrouped() :
scroller: config.scrollingLazy ? new LazyScroller() :
config.scrollingCentered ? new CenteredScroller() :
config.scrollingGrouped ? new GroupedScroller() :
console.assert(false),
clamper: config.scrollingLazy ? new EdgeClamper() : new CenterClamper(),
},
layoutConfig,
workspace.currentActivity,

View File

@@ -54,7 +54,7 @@ namespace ClientState {
clientManager.pinClient(kwinClient);
});
}
})
});
return manager;
}

View File

@@ -68,7 +68,7 @@ namespace ClientState {
oldDesktopNumber = kwinClient.desktop;
});
manager.connect(kwinClient.activitiesChanged, (kwinClient: KwinClient) => {
manager.connect(kwinClient.activitiesChanged, () => {
const desktops = kwinClient.desktop === -1 ? [] : [kwinClient.desktop];
const changedActivities = oldActivities.length === 0 || kwinClient.activities.length === 0 ?
[] :

View File

@@ -33,23 +33,25 @@ namespace ClientState {
manager.connect(kwinClient.desktopChanged, () => {
world.do((clientManager, desktopManager) => {
if (kwinClient.desktop === -1) {
const desktop = desktopManager.getDesktopForClient(kwinClient);
if (desktop === undefined) {
// windows on all desktops are not supported
clientManager.untileClient(kwinClient);
return;
}
Tiled.moveWindowToCorrectGrid(desktopManager, window);
Tiled.moveWindowToGrid(window, desktop.grid);
});
});
manager.connect(kwinClient.activitiesChanged, () => {
world.do((clientManager, desktopManager) => {
if (kwinClient.activities.length !== 1) {
const desktop = desktopManager.getDesktopForClient(kwinClient);
if (desktop === undefined) {
// windows on multiple activities are not supported
clientManager.untileClient(kwinClient);
return;
}
Tiled.moveWindowToCorrectGrid(desktopManager, window);
Tiled.moveWindowToGrid(window, desktop.grid);
});
})
@@ -106,6 +108,7 @@ namespace ClientState {
if (kwinClient.resize) {
world.do(() => window.onUserResize(oldGeometry, !cursorChangedAfterResizeStart));
} else if (
!window.column.grid.isUserResizing() &&
!client.isManipulatingGeometry(newGeometry) &&
!Clients.isMaximizedGeometry(kwinClient) &&
!Clients.isFullScreenGeometry(kwinClient) // not using `kwinClient.fullScreen` because it may not be set yet at this point
@@ -130,17 +133,13 @@ namespace ClientState {
return manager;
}
private static moveWindowToCorrectGrid(desktopManager: DesktopManager, window: Window) {
const kwinClient = window.client.kwinClient;
const oldGrid = window.column.grid;
const newGrid = desktopManager.getDesktopForClient(kwinClient).grid;
if (oldGrid === newGrid) {
// window already on the correct grid
private static moveWindowToGrid(window: Window, grid: Grid) {
if (grid === window.column.grid) {
// window already on the given grid
return;
}
const newColumn = new Column(newGrid, newGrid.getLastFocusedColumn() ?? newGrid.getLastColumn());
const newColumn = new Column(grid, grid.getLastFocusedColumn() ?? grid.getLastColumn());
window.moveToColumn(newColumn);
}