Compare commits
23 Commits
signal-gro
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7d0e83ca2f | ||
|
|
b8650a2e1f | ||
|
|
19f275325d | ||
|
|
9a5a28db82 | ||
|
|
6c698c9c82 | ||
|
|
973956ed5e | ||
|
|
f05ae6686d | ||
|
|
3a47fef028 | ||
|
|
ccf0626795 | ||
|
|
9ba3bc6b0b | ||
|
|
99c6a39ac5 | ||
|
|
85d7bbe777 | ||
|
|
6f69252001 | ||
|
|
60bee26e29 | ||
|
|
7d4eab03b9 | ||
|
|
7070e59044 | ||
|
|
7f5745b2cf | ||
|
|
c7752bf20a | ||
|
|
8149100aac | ||
|
|
99bf71f0b9 | ||
|
|
2b882768d9 | ||
|
|
bb42e4d3ad | ||
|
|
c7effc8913 |
4
Makefile
4
Makefile
@@ -3,7 +3,7 @@ CHECKS := true
|
|||||||
|
|
||||||
.PHONY: *
|
.PHONY: *
|
||||||
|
|
||||||
build: lint tests
|
build: lint test
|
||||||
tsc -p ./src/main --outFile ./package/contents/code/main.js
|
tsc -p ./src/main --outFile ./package/contents/code/main.js
|
||||||
mkdir -p ./package/contents/config
|
mkdir -p ./package/contents/config
|
||||||
./run-ts.sh ./src/generators/config > ./package/contents/config/main.xml
|
./run-ts.sh ./src/generators/config > ./package/contents/config/main.xml
|
||||||
@@ -19,7 +19,7 @@ endif
|
|||||||
lint-fix: npm-install
|
lint-fix: npm-install
|
||||||
npx eslint ./src --fix
|
npx eslint ./src --fix
|
||||||
|
|
||||||
tests:
|
test:
|
||||||
ifeq (${CHECKS}, true)
|
ifeq (${CHECKS}, true)
|
||||||
./run-ts.sh ./src/tests
|
./run-ts.sh ./src/tests
|
||||||
endif
|
endif
|
||||||
|
|||||||
8
package-lock.json
generated
8
package-lock.json
generated
@@ -4,6 +4,7 @@
|
|||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
|
"name": "karousel",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^9.24.0",
|
"eslint": "^9.24.0",
|
||||||
"typescript-eslint": "^8.30.1"
|
"typescript-eslint": "^8.30.1"
|
||||||
@@ -999,10 +1000,11 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/js-yaml": {
|
"node_modules/js-yaml": {
|
||||||
"version": "4.1.0",
|
"version": "4.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz",
|
||||||
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
|
"integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"argparse": "^2.0.1"
|
"argparse": "^2.0.1"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="kcfg_cursorFollowsFocus">
|
<widget class="QCheckBox" name="kcfg_cursorFollowsFocus">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Cursor follows focus</string>
|
<string>Cursor follows focus (experimental)</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>When a window gains focus, move the cursor to it</string>
|
<string>When a window gains focus, move the cursor to it</string>
|
||||||
@@ -149,14 +149,14 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QRadioButton" name="kcfg_tiledKeepBelow">
|
<widget class="QRadioButton" name="kcfg_tiledKeepBelow">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Keep tiled windows below</string>
|
<string>Set "Keep Below" for tiled windows</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QRadioButton" name="kcfg_floatingKeepAbove">
|
<widget class="QRadioButton" name="kcfg_floatingKeepAbove">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Keep floating windows above</string>
|
<string>Set "Keep Above" for floating windows</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -458,6 +458,27 @@
|
|||||||
<string>Window Rules</string>
|
<string>Window Rules</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout">
|
<layout class="QVBoxLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_desktops">
|
||||||
|
<property name="text">
|
||||||
|
<string>Tiled desktops:</string>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="kcfg_tiledDesktops">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Regex string to match desktops by desktop name"</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPlainTextEdit" name="kcfg_windowRules">
|
<widget class="QPlainTextEdit" name="kcfg_windowRules">
|
||||||
<property name="tabChangesFocus">
|
<property name="tabChangesFocus">
|
||||||
|
|||||||
@@ -16,6 +16,16 @@ Item {
|
|||||||
qmlBase.karouselInstance.destroy();
|
qmlBase.karouselInstance.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Notification {
|
||||||
|
id: notificationInvalidTiledDesktops
|
||||||
|
componentName: "plasma_workspace"
|
||||||
|
eventId: "notification"
|
||||||
|
title: "Karousel"
|
||||||
|
text: "Your Tiled Desktops regex is malformed, please review your Karousel configuration"
|
||||||
|
flags: Notification.Persistent
|
||||||
|
urgency: Notification.HighUrgency
|
||||||
|
}
|
||||||
|
|
||||||
Notification {
|
Notification {
|
||||||
id: notificationInvalidWindowRules
|
id: notificationInvalidWindowRules
|
||||||
componentName: "plasma_workspace"
|
componentName: "plasma_workspace"
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"Name": "Peter Fajdiga"
|
"Name": "Peter Fajdiga"
|
||||||
}],
|
}],
|
||||||
"Id": "karousel",
|
"Id": "karousel",
|
||||||
"Version": "0.14",
|
"Version": "0.16",
|
||||||
"License": "GPLv3",
|
"License": "GPLv3",
|
||||||
"Website": "https://github.com/peterfajdiga/karousel",
|
"Website": "https://github.com/peterfajdiga/karousel",
|
||||||
"BugReportUrl": "https://github.com/peterfajdiga/karousel/issues"
|
"BugReportUrl": "https://github.com/peterfajdiga/karousel/issues"
|
||||||
|
|||||||
1
src/extern/global.d.ts
vendored
1
src/extern/global.d.ts
vendored
@@ -2,6 +2,7 @@ declare const Qt: Qt;
|
|||||||
declare const KWin: KWin;
|
declare const KWin: KWin;
|
||||||
declare const Workspace: Workspace;
|
declare const Workspace: Workspace;
|
||||||
declare const qmlBase: QmlObject;
|
declare const qmlBase: QmlObject;
|
||||||
|
declare const notificationInvalidTiledDesktops: Notification;
|
||||||
declare const notificationInvalidWindowRules: Notification;
|
declare const notificationInvalidWindowRules: Notification;
|
||||||
declare const notificationInvalidPresetWidths: Notification;
|
declare const notificationInvalidPresetWidths: Notification;
|
||||||
declare const moveCursorToFocus: DBusCall;
|
declare const moveCursorToFocus: DBusCall;
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ class ContextualResizer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const leftVisibleColumn = grid.getLeftmostVisibleColumn(visibleRange, true);
|
const leftVisibleColumn = grid.getLeftmostVisibleColumn(visibleRange);
|
||||||
const rightVisibleColumn = grid.getRightmostVisibleColumn(visibleRange, true);
|
const rightVisibleColumn = grid.getRightmostVisibleColumn(visibleRange);
|
||||||
if (leftVisibleColumn === null || rightVisibleColumn === null) {
|
if (leftVisibleColumn === null || rightVisibleColumn === null) {
|
||||||
console.assert(false); // should at least see self
|
console.assert(false); // should at least see self
|
||||||
return;
|
return;
|
||||||
@@ -50,8 +50,8 @@ class ContextualResizer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const leftVisibleColumn = grid.getLeftmostVisibleColumn(visibleRange, true);
|
const leftVisibleColumn = grid.getLeftmostVisibleColumn(visibleRange);
|
||||||
const rightVisibleColumn = grid.getRightmostVisibleColumn(visibleRange, true);
|
const rightVisibleColumn = grid.getRightmostVisibleColumn(visibleRange);
|
||||||
if (leftVisibleColumn === null || rightVisibleColumn === null) {
|
if (leftVisibleColumn === null || rightVisibleColumn === null) {
|
||||||
console.assert(false); // should at least see self
|
console.assert(false); // should at least see self
|
||||||
return;
|
return;
|
||||||
@@ -86,4 +86,22 @@ class ContextualResizer {
|
|||||||
column.setWidth(newWidth, true);
|
column.setWidth(newWidth, true);
|
||||||
desktop.scrollCenterVisible(column);
|
desktop.scrollCenterVisible(column);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public maximizeWidth(column: Column) {
|
||||||
|
const grid = column.grid;
|
||||||
|
const desktop = grid.desktop;
|
||||||
|
const presetWidths = this.presetWidths.getWidths(column.getMinWidth(), column.getMaxWidth());
|
||||||
|
const maxWidth = presetWidths[presetWidths.length-1];
|
||||||
|
column.setWidth(maxWidth, true);
|
||||||
|
desktop.scrollCenterVisible(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
public minimizeWidth(column: Column) {
|
||||||
|
const grid = column.grid;
|
||||||
|
const desktop = grid.desktop;
|
||||||
|
const presetWidths = this.presetWidths.getWidths(column.getMinWidth(), column.getMaxWidth());
|
||||||
|
const minWidth = presetWidths[0];
|
||||||
|
column.setWidth(minWidth, true);
|
||||||
|
desktop.scrollCenterVisible(column);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,4 +28,16 @@ class RawResizer {
|
|||||||
}
|
}
|
||||||
column.setWidth(newWidth, true);
|
column.setWidth(newWidth, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public maximizeWidth(column: Column) {
|
||||||
|
const presetWidths = this.presetWidths.getWidths(column.getMinWidth(), column.getMaxWidth());
|
||||||
|
const maxWidth = presetWidths[presetWidths.length-1];
|
||||||
|
column.setWidth(maxWidth, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public minimizeWidth(column: Column) {
|
||||||
|
const presetWidths = this.presetWidths.getWidths(column.getMinWidth(), column.getMaxWidth());
|
||||||
|
const minWidth = presetWidths[0];
|
||||||
|
column.setWidth(minWidth, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,4 +25,5 @@ interface Config {
|
|||||||
tiledKeepBelow: boolean;
|
tiledKeepBelow: boolean;
|
||||||
floatingKeepAbove: boolean;
|
floatingKeepAbove: boolean;
|
||||||
windowRules: string;
|
windowRules: string;
|
||||||
|
tiledDesktops: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,11 @@ const defaultWindowRules = `[
|
|||||||
"class": "(org\\\\.kde\\\\.)?yakuake",
|
"class": "(org\\\\.kde\\\\.)?yakuake",
|
||||||
"tile": false
|
"tile": false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"class": "wl-copy|wl-paste",
|
||||||
|
"caption": "wl-clipboard",
|
||||||
|
"tile": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"class": "steam",
|
"class": "steam",
|
||||||
"caption": "Steam Big Picture Mode",
|
"caption": "Steam Big Picture Mode",
|
||||||
@@ -189,4 +194,9 @@ const configDef = [
|
|||||||
type: "String",
|
type: "String",
|
||||||
default: defaultWindowRules,
|
default: defaultWindowRules,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "tiledDesktops",
|
||||||
|
type: "String",
|
||||||
|
default: ".*",
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
1
src/lib/extern/kwin.ts
vendored
1
src/lib/extern/kwin.ts
vendored
@@ -102,6 +102,7 @@ interface KwinDesktop {
|
|||||||
__brand: "KwinDesktop";
|
__brand: "KwinDesktop";
|
||||||
|
|
||||||
readonly id: string;
|
readonly id: string;
|
||||||
|
readonly name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ShortcutHandler extends QmlObject {
|
interface ShortcutHandler extends QmlObject {
|
||||||
|
|||||||
4
src/lib/extern/qt.ts
vendored
4
src/lib/extern/qt.ts
vendored
@@ -28,10 +28,6 @@ interface QmlRect {
|
|||||||
y: number;
|
y: number;
|
||||||
width: number;
|
width: number;
|
||||||
height: number;
|
height: number;
|
||||||
readonly top: number;
|
|
||||||
readonly bottom: number; // top + height
|
|
||||||
readonly left: number;
|
|
||||||
readonly right: number; // left + width
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface QmlSize {
|
interface QmlSize {
|
||||||
|
|||||||
@@ -62,7 +62,11 @@ class Actions {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public readonly focusStart = (cm: ClientManager, dm: DesktopManager) => {
|
public readonly focusStart = (cm: ClientManager, dm: DesktopManager) => {
|
||||||
const grid = dm.getCurrentDesktop().grid;
|
const desktop = dm.getCurrentDesktop();
|
||||||
|
if (desktop === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const grid = desktop.grid;
|
||||||
const firstColumn = grid.getFirstColumn();
|
const firstColumn = grid.getFirstColumn();
|
||||||
if (firstColumn === null) {
|
if (firstColumn === null) {
|
||||||
return;
|
return;
|
||||||
@@ -71,7 +75,11 @@ class Actions {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public readonly focusEnd = (cm: ClientManager, dm: DesktopManager) => {
|
public readonly focusEnd = (cm: ClientManager, dm: DesktopManager) => {
|
||||||
const grid = dm.getCurrentDesktop().grid;
|
const desktop = dm.getCurrentDesktop();
|
||||||
|
if (desktop === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const grid = desktop.grid;
|
||||||
const lastColumn = grid.getLastColumn();
|
const lastColumn = grid.getLastColumn();
|
||||||
if (lastColumn === null) {
|
if (lastColumn === null) {
|
||||||
return;
|
return;
|
||||||
@@ -184,6 +192,15 @@ class Actions {
|
|||||||
this.config.columnResizer.decreaseWidth(column);
|
this.config.columnResizer.decreaseWidth(column);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public readonly columnWidthMaximize = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
||||||
|
this.config.columnResizer.maximizeWidth(column);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
public readonly columnWidthMinimize = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
||||||
|
this.config.columnResizer.minimizeWidth(column);
|
||||||
|
};
|
||||||
|
|
||||||
public readonly cyclePresetWidths = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
public readonly cyclePresetWidths = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
||||||
const nextWidth = this.config.presetWidths.next(column.getWidth(), column.getMinWidth(), column.getMaxWidth());
|
const nextWidth = this.config.presetWidths.next(column.getWidth(), column.getMinWidth(), column.getMaxWidth());
|
||||||
column.setWidth(nextWidth, true);
|
column.setWidth(nextWidth, true);
|
||||||
@@ -196,8 +213,11 @@ class Actions {
|
|||||||
|
|
||||||
public readonly columnsWidthEqualize = (cm: ClientManager, dm: DesktopManager) => {
|
public readonly columnsWidthEqualize = (cm: ClientManager, dm: DesktopManager) => {
|
||||||
const desktop = dm.getCurrentDesktop();
|
const desktop = dm.getCurrentDesktop();
|
||||||
|
if (desktop === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const visibleRange = desktop.getCurrentVisibleRange();
|
const visibleRange = desktop.getCurrentVisibleRange();
|
||||||
const visibleColumns = Array.from(desktop.grid.getVisibleColumns(visibleRange, true));
|
const visibleColumns = Array.from(desktop.grid.getVisibleColumns(visibleRange));
|
||||||
|
|
||||||
const availableSpace = desktop.tilingArea.width;
|
const availableSpace = desktop.tilingArea.width;
|
||||||
const gapsWidth = desktop.grid.config.gapsInnerHorizontal * (visibleColumns.length-1);
|
const gapsWidth = desktop.grid.config.gapsInnerHorizontal * (visibleColumns.length-1);
|
||||||
@@ -219,7 +239,7 @@ class Actions {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentVisibleColumns = Array.from(grid.getVisibleColumns(visibleRange, true));
|
const currentVisibleColumns = Array.from(grid.getVisibleColumns(visibleRange));
|
||||||
console.assert(currentVisibleColumns.includes(focusedColumn), "should at least contain the focused column");
|
console.assert(currentVisibleColumns.includes(focusedColumn), "should at least contain the focused column");
|
||||||
|
|
||||||
const targetColumn = grid.getLeftColumn(currentVisibleColumns[0]);
|
const targetColumn = grid.getLeftColumn(currentVisibleColumns[0]);
|
||||||
@@ -246,7 +266,7 @@ class Actions {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentVisibleColumns = Array.from(grid.getVisibleColumns(visibleRange, true));
|
const currentVisibleColumns = Array.from(grid.getVisibleColumns(visibleRange));
|
||||||
console.assert(currentVisibleColumns.includes(focusedColumn), "should at least contain the focused column");
|
console.assert(currentVisibleColumns.includes(focusedColumn), "should at least contain the focused column");
|
||||||
|
|
||||||
const targetColumn = grid.getRightColumn(currentVisibleColumns[currentVisibleColumns.length-1]);
|
const targetColumn = grid.getRightColumn(currentVisibleColumns[currentVisibleColumns.length-1]);
|
||||||
@@ -297,11 +317,18 @@ class Actions {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private readonly gridScroll = (desktopManager: DesktopManager, amount: number) => {
|
private readonly gridScroll = (desktopManager: DesktopManager, amount: number) => {
|
||||||
desktopManager.getCurrentDesktop().adjustScroll(amount, false);
|
const desktop = desktopManager.getCurrentDesktop();
|
||||||
|
if (desktop !== undefined) {
|
||||||
|
desktop.adjustScroll(amount, false);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public readonly gridScrollStart = (cm: ClientManager, dm: DesktopManager) => {
|
public readonly gridScrollStart = (cm: ClientManager, dm: DesktopManager) => {
|
||||||
const grid = dm.getCurrentDesktop().grid;
|
const desktop = dm.getCurrentDesktop();
|
||||||
|
if (desktop === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const grid = desktop.grid;
|
||||||
const firstColumn = grid.getFirstColumn();
|
const firstColumn = grid.getFirstColumn();
|
||||||
if (firstColumn === null) {
|
if (firstColumn === null) {
|
||||||
return;
|
return;
|
||||||
@@ -310,7 +337,11 @@ class Actions {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public readonly gridScrollEnd = (cm: ClientManager, dm: DesktopManager) => {
|
public readonly gridScrollEnd = (cm: ClientManager, dm: DesktopManager) => {
|
||||||
const grid = dm.getCurrentDesktop().grid;
|
const desktop = dm.getCurrentDesktop();
|
||||||
|
if (desktop === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const grid = desktop.grid;
|
||||||
const lastColumn = grid.getLastColumn();
|
const lastColumn = grid.getLastColumn();
|
||||||
if (lastColumn === null) {
|
if (lastColumn === null) {
|
||||||
return;
|
return;
|
||||||
@@ -328,8 +359,12 @@ class Actions {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public readonly gridScrollLeftColumn = (cm: ClientManager, dm: DesktopManager) => {
|
public readonly gridScrollLeftColumn = (cm: ClientManager, dm: DesktopManager) => {
|
||||||
const grid = dm.getCurrentDesktop().grid;
|
const desktop = dm.getCurrentDesktop();
|
||||||
const column = grid.getLeftmostVisibleColumn(grid.desktop.getCurrentVisibleRange(), true);
|
if (desktop === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const grid = desktop.grid;
|
||||||
|
const column = grid.getLeftmostVisibleColumn(grid.desktop.getCurrentVisibleRange());
|
||||||
if (column === null) {
|
if (column === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -343,8 +378,12 @@ class Actions {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public readonly gridScrollRightColumn = (cm: ClientManager, dm: DesktopManager) => {
|
public readonly gridScrollRightColumn = (cm: ClientManager, dm: DesktopManager) => {
|
||||||
const grid = dm.getCurrentDesktop().grid;
|
const desktop = dm.getCurrentDesktop();
|
||||||
const column = grid.getRightmostVisibleColumn(grid.desktop.getCurrentVisibleRange(), true);
|
if (desktop === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const grid = desktop.grid;
|
||||||
|
const column = grid.getRightmostVisibleColumn(grid.desktop.getCurrentVisibleRange());
|
||||||
if (column === null) {
|
if (column === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -362,7 +401,11 @@ class Actions {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public readonly focus = (columnIndex: number, cm: ClientManager, dm: DesktopManager) => {
|
public readonly focus = (columnIndex: number, cm: ClientManager, dm: DesktopManager) => {
|
||||||
const grid = dm.getCurrentDesktop().grid;
|
const desktop = dm.getCurrentDesktop();
|
||||||
|
if (desktop === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const grid = desktop.grid;
|
||||||
const targetColumn = grid.getColumnAtIndex(columnIndex);
|
const targetColumn = grid.getColumnAtIndex(columnIndex);
|
||||||
if (targetColumn === null) {
|
if (targetColumn === null) {
|
||||||
return;
|
return;
|
||||||
@@ -396,7 +439,11 @@ class Actions {
|
|||||||
if (kwinDesktop === undefined) {
|
if (kwinDesktop === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const newGrid = dm.getDesktopInCurrentActivity(kwinDesktop).grid;
|
const newDesktop = dm.getDesktopInCurrentActivity(kwinDesktop);
|
||||||
|
if (newDesktop === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const newGrid = newDesktop.grid;
|
||||||
if (newGrid === null || newGrid === oldGrid) {
|
if (newGrid === null || newGrid === oldGrid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -408,7 +455,11 @@ class Actions {
|
|||||||
if (kwinDesktop === undefined) {
|
if (kwinDesktop === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const newGrid = dm.getDesktopInCurrentActivity(kwinDesktop).grid;
|
const newDesktop = dm.getDesktopInCurrentActivity(kwinDesktop);
|
||||||
|
if (newDesktop === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const newGrid = newDesktop.grid;
|
||||||
if (newGrid === null || newGrid === oldGrid) {
|
if (newGrid === null || newGrid === oldGrid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -422,12 +473,14 @@ namespace Actions {
|
|||||||
presetWidths: {
|
presetWidths: {
|
||||||
next: (currentWidth: number, minWidth: number, maxWidth: number) => number;
|
next: (currentWidth: number, minWidth: number, maxWidth: number) => number;
|
||||||
prev: (currentWidth: number, minWidth: number, maxWidth: number) => number
|
prev: (currentWidth: number, minWidth: number, maxWidth: number) => number
|
||||||
};
|
};
|
||||||
columnResizer: ColumnResizer;
|
columnResizer: ColumnResizer;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ColumnResizer {
|
export interface ColumnResizer {
|
||||||
increaseWidth(column: Column): void;
|
increaseWidth(column: Column): void;
|
||||||
decreaseWidth(column: Column): void;
|
decreaseWidth(column: Column): void;
|
||||||
|
maximizeWidth(column: Column): void;
|
||||||
|
minimizeWidth(column: Column): void;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,6 +146,16 @@ function getKeyBindings(world: World, actions: Actions): KeyBinding[] {
|
|||||||
defaultKeySequence: "Meta+Ctrl+-",
|
defaultKeySequence: "Meta+Ctrl+-",
|
||||||
action: () => world.doIfTiledFocused(actions.columnWidthDecrease),
|
action: () => world.doIfTiledFocused(actions.columnWidthDecrease),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "column-width-maximize",
|
||||||
|
description: "Increase column width to maximum",
|
||||||
|
action: () => world.doIfTiledFocused(actions.columnWidthMaximize),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "column-width-minimize",
|
||||||
|
description: "Decrease column width to minimum",
|
||||||
|
action: () => world.doIfTiledFocused(actions.columnWidthMinimize),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "cycle-preset-widths",
|
name: "cycle-preset-widths",
|
||||||
description: "Cycle through preset column widths",
|
description: "Cycle through preset column widths",
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class Column {
|
|||||||
public getMinWidth() {
|
public getMinWidth() {
|
||||||
let maxMinWidth = Column.minWidth;
|
let maxMinWidth = Column.minWidth;
|
||||||
for (const window of this.windows.iterator()) {
|
for (const window of this.windows.iterator()) {
|
||||||
const minWidth = window.client.kwinClient.minSize.width;
|
const minWidth = window.client.kwinClient.minSize.width.ceil();
|
||||||
if (minWidth > maxMinWidth) {
|
if (minWidth > maxMinWidth) {
|
||||||
maxMinWidth = minWidth;
|
maxMinWidth = minWidth;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,8 +141,20 @@ class Desktop {
|
|||||||
this.setScroll(this.gestureScrollXInitial + this.config.gestureScrollStep * amount, false);
|
this.setScroll(this.gestureScrollXInitial + this.config.gestureScrollStep * amount, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public gestureScrollFinish() {
|
public gestureScrollFinish(focusedWindow: Window|null) {
|
||||||
|
const scrolledRight = this.scrollX > this.gestureScrollXInitial!;
|
||||||
this.gestureScrollXInitial = null;
|
this.gestureScrollXInitial = null;
|
||||||
|
|
||||||
|
const visibleRange = this.getCurrentVisibleRange();
|
||||||
|
if (focusedWindow !== null && !Range.contains(visibleRange, focusedWindow.column)) {
|
||||||
|
// the focused window is no longer visible, find a new window to focus
|
||||||
|
const focusTargetColumn = scrolledRight ?
|
||||||
|
this.grid.getLeftmostVisibleColumn(visibleRange) :
|
||||||
|
this.grid.getRightmostVisibleColumn(visibleRange);
|
||||||
|
if (focusTargetColumn !== null) {
|
||||||
|
focusTargetColumn.getWindowToFocus().focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public arrange() {
|
public arrange() {
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ class Grid {
|
|||||||
this.width = x - this.config.gapsInnerHorizontal;
|
this.width = x - this.config.gapsInnerHorizontal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getLeftmostVisibleColumn(visibleRange: Range, fullyVisible: boolean) {
|
public getLeftmostVisibleColumn(visibleRange: Range) {
|
||||||
for (const column of this.columns.iterator()) {
|
for (const column of this.columns.iterator()) {
|
||||||
if (Range.contains(visibleRange, column)) {
|
if (Range.contains(visibleRange, column)) {
|
||||||
return column;
|
return column;
|
||||||
@@ -115,7 +115,7 @@ class Grid {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getRightmostVisibleColumn(visibleRange: Range, fullyVisible: boolean) {
|
public getRightmostVisibleColumn(visibleRange: Range) {
|
||||||
let last = null;
|
let last = null;
|
||||||
for (const column of this.columns.iterator()) {
|
for (const column of this.columns.iterator()) {
|
||||||
if (Range.contains(visibleRange, column)) {
|
if (Range.contains(visibleRange, column)) {
|
||||||
@@ -127,7 +127,7 @@ class Grid {
|
|||||||
return last;
|
return last;
|
||||||
}
|
}
|
||||||
|
|
||||||
public *getVisibleColumns(visibleRange: Range, fullyVisible: boolean) {
|
public *getVisibleColumns(visibleRange: Range) {
|
||||||
for (const column of this.columns.iterator()) {
|
for (const column of this.columns.iterator()) {
|
||||||
if (Range.contains(visibleRange, column)) {
|
if (Range.contains(visibleRange, column)) {
|
||||||
yield column;
|
yield column;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ class Window {
|
|||||||
|
|
||||||
constructor(client: ClientWrapper, column: Column) {
|
constructor(client: ClientWrapper, column: Column) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.height = client.kwinClient.frameGeometry.height;
|
this.height = client.kwinClient.frameGeometry.height.round();
|
||||||
|
|
||||||
let maximizedMode = this.client.getMaximizedMode();
|
let maximizedMode = this.client.getMaximizedMode();
|
||||||
if (maximizedMode === undefined) {
|
if (maximizedMode === undefined) {
|
||||||
@@ -123,7 +123,7 @@ class Window {
|
|||||||
|
|
||||||
public onFrameGeometryChanged() {
|
public onFrameGeometryChanged() {
|
||||||
const newGeometry = this.client.kwinClient.frameGeometry;
|
const newGeometry = this.client.kwinClient.frameGeometry;
|
||||||
this.column.setWidth(newGeometry.width, true);
|
this.column.setWidth(newGeometry.width.round(), true);
|
||||||
this.column.grid.desktop.onLayoutChanged();
|
this.column.grid.desktop.onLayoutChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
30
src/lib/rules/DesktopFilter.ts
Normal file
30
src/lib/rules/DesktopFilter.ts
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
class DesktopFilter {
|
||||||
|
private readonly desktopRegex: RegExp | null; // null means all desktops
|
||||||
|
|
||||||
|
constructor(desktopsConfig: string) {
|
||||||
|
this.desktopRegex = DesktopFilter.parseDesktopConfig(desktopsConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
public shouldWorkOnDesktop(kwinDesktop: KwinDesktop): boolean {
|
||||||
|
if (this.desktopRegex === null) {
|
||||||
|
return true; // Work on all desktops
|
||||||
|
}
|
||||||
|
return this.desktopRegex.test(kwinDesktop.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static parseDesktopConfig(config: string): RegExp | null {
|
||||||
|
const trimmed = config.trim();
|
||||||
|
|
||||||
|
if (trimmed.length === 0) {
|
||||||
|
return null; // Empty config means work on all desktops
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return new RegExp(`^${trimmed}$`);
|
||||||
|
} catch (e) {
|
||||||
|
notificationInvalidTiledDesktops.sendEvent();
|
||||||
|
log(`Invalid regex pattern in tiledDesktops config: ${trimmed}. Working on all desktops.`);
|
||||||
|
return null; // Invalid regex means work on all desktops as fallback
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,21 @@
|
|||||||
|
interface Number {
|
||||||
|
round(this: number): number;
|
||||||
|
floor(this: number): number;
|
||||||
|
ceil(this: number): number;
|
||||||
|
}
|
||||||
|
|
||||||
|
Number.prototype.round = function() {
|
||||||
|
return Math.round(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
Number.prototype.floor = function() {
|
||||||
|
return Math.floor(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
Number.prototype.ceil = function() {
|
||||||
|
return Math.ceil(this);
|
||||||
|
};
|
||||||
|
|
||||||
interface Function {
|
interface Function {
|
||||||
partial<H extends any[], T extends any[], R>(
|
partial<H extends any[], T extends any[], R>(
|
||||||
this: (...args: [...H, ...T]) => R,
|
this: (...args: [...H, ...T]) => R,
|
||||||
|
|||||||
@@ -24,9 +24,34 @@ function pointEquals(a: QmlPoint, b: QmlPoint) {
|
|||||||
a.y === b.y;
|
a.y === b.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
function rectContainsPoint(rect: QmlRect, point: QmlPoint) {
|
function rectRight(rect: QmlRect) {
|
||||||
return rect.left <= point.x &&
|
return rect.x + rect.width;
|
||||||
rect.right >= point.x &&
|
}
|
||||||
rect.top <= point.y &&
|
|
||||||
rect.bottom >= point.y;
|
function rectBottom(rect: QmlRect) {
|
||||||
|
return rect.y + rect.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
function rectContainsPoint(rect: QmlRect, point: QmlPoint) {
|
||||||
|
return rect.x <= point.x &&
|
||||||
|
rectRight(rect) >= point.x &&
|
||||||
|
rect.y <= point.y &&
|
||||||
|
rectBottom(rect) >= point.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
function roundQtRect(rect: QmlRect) {
|
||||||
|
return Qt.rect(
|
||||||
|
rect.x.round(),
|
||||||
|
rect.y.round(),
|
||||||
|
rect.width.round(),
|
||||||
|
rect.height.round(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function rectRightRound(rect: QmlRect) {
|
||||||
|
return rect.x.round() + rect.width.round();
|
||||||
|
}
|
||||||
|
|
||||||
|
function rectBottomRound(rect: QmlRect) {
|
||||||
|
return rect.y.round() + rect.height.round();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,16 +31,16 @@ class ClientManager {
|
|||||||
console.assert(!this.hasClient(kwinClient));
|
console.assert(!this.hasClient(kwinClient));
|
||||||
|
|
||||||
let constructState: (client: ClientWrapper) => ClientState.State;
|
let constructState: (client: ClientWrapper) => ClientState.State;
|
||||||
|
let desktop: Desktop | undefined;
|
||||||
if (kwinClient.dock) {
|
if (kwinClient.dock) {
|
||||||
constructState = () => new ClientState.Docked(this.world, kwinClient);
|
constructState = () => new ClientState.Docked(this.world, kwinClient);
|
||||||
} else if (
|
} else if (
|
||||||
Clients.canTileEver(kwinClient) &&
|
Clients.canTileEver(kwinClient) &&
|
||||||
this.windowRuleEnforcer.shouldTile(kwinClient)
|
this.windowRuleEnforcer.shouldTile(kwinClient) &&
|
||||||
|
(desktop = this.desktopManager.getDesktopForClient(kwinClient)) !== undefined
|
||||||
) {
|
) {
|
||||||
Clients.makeTileable(kwinClient);
|
Clients.makeTileable(kwinClient);
|
||||||
console.assert(Clients.canTileNow(kwinClient));
|
console.assert(Clients.canTileNow(kwinClient));
|
||||||
const desktop = this.desktopManager.getDesktopForClient(kwinClient);
|
|
||||||
console.assert(desktop !== undefined);
|
|
||||||
constructState = (client: ClientWrapper) => new ClientState.Tiled(this.world, client, desktop!.grid);
|
constructState = (client: ClientWrapper) => new ClientState.Tiled(this.world, client, desktop!.grid);
|
||||||
} else {
|
} else {
|
||||||
constructState = (client: ClientWrapper) => new ClientState.Floating(this.world, client, this.config, false);
|
constructState = (client: ClientWrapper) => new ClientState.Floating(this.world, client, this.config, false);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class ClientWrapper {
|
|||||||
}
|
}
|
||||||
this.signalManager = ClientWrapper.initSignalManager(this);
|
this.signalManager = ClientWrapper.initSignalManager(this);
|
||||||
this.rulesSignalManager = rulesSignalManager;
|
this.rulesSignalManager = rulesSignalManager;
|
||||||
this.preferredWidth = kwinClient.frameGeometry.width;
|
this.preferredWidth = kwinClient.frameGeometry.width.round();
|
||||||
this.manipulatingGeometry = new Doer();
|
this.manipulatingGeometry = new Doer();
|
||||||
this.lastPlacement = null;
|
this.lastPlacement = null;
|
||||||
this.stateManager = new ClientState.Manager(constructInitialState(this));
|
this.stateManager = new ClientState.Manager(constructInitialState(this));
|
||||||
@@ -49,10 +49,10 @@ class ClientWrapper {
|
|||||||
if (Clients.isOnOneOfVirtualDesktops(this.kwinClient, kwinDesktops)) {
|
if (Clients.isOnOneOfVirtualDesktops(this.kwinClient, kwinDesktops)) {
|
||||||
const frame = this.kwinClient.frameGeometry;
|
const frame = this.kwinClient.frameGeometry;
|
||||||
this.kwinClient.frameGeometry = Qt.rect(
|
this.kwinClient.frameGeometry = Qt.rect(
|
||||||
frame.x + dx,
|
frame.x.round() + dx,
|
||||||
frame.y + dy,
|
frame.y.round() + dy,
|
||||||
frame.width,
|
frame.width.round(),
|
||||||
frame.height,
|
frame.height.round(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,11 +142,11 @@ class ClientWrapper {
|
|||||||
if (!Clients.isOnVirtualDesktop(this.kwinClient, Workspace.currentDesktop)) {
|
if (!Clients.isOnVirtualDesktop(this.kwinClient, Workspace.currentDesktop)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const frame = this.kwinClient.frameGeometry;
|
const frame = roundQtRect(this.kwinClient.frameGeometry);
|
||||||
if (frame.left < screenSize.left) {
|
if (frame.x < screenSize.x) {
|
||||||
frame.x = screenSize.left;
|
frame.x = screenSize.x;
|
||||||
} else if (frame.right > screenSize.right) {
|
} else if (rectRight(frame) > rectRight(screenSize)) {
|
||||||
frame.x = screenSize.right - frame.width;
|
frame.x = rectRight(screenSize) - frame.width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ namespace Clients {
|
|||||||
|
|
||||||
export function isFullScreenGeometry(kwinClient: KwinClient) {
|
export function isFullScreenGeometry(kwinClient: KwinClient) {
|
||||||
const fullScreenArea = Workspace.clientArea(ClientAreaOption.FullScreenArea, kwinClient.output, getKwinDesktopApprox(kwinClient));
|
const fullScreenArea = Workspace.clientArea(ClientAreaOption.FullScreenArea, kwinClient.output, getKwinDesktopApprox(kwinClient));
|
||||||
return kwinClient.clientGeometry.width >= fullScreenArea.width &&
|
return kwinClient.clientGeometry.width.round() >= fullScreenArea.width &&
|
||||||
kwinClient.clientGeometry.height >= fullScreenArea.height;
|
kwinClient.clientGeometry.height.round() >= fullScreenArea.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isOnVirtualDesktop(kwinClient: KwinClient, kwinDesktop: KwinDesktop) {
|
export function isOnVirtualDesktop(kwinClient: KwinClient, kwinDesktop: KwinDesktop) {
|
||||||
|
|||||||
@@ -9,8 +9,7 @@ class DesktopManager {
|
|||||||
private readonly config: Desktop.Config,
|
private readonly config: Desktop.Config,
|
||||||
private readonly layoutConfig: LayoutConfig,
|
private readonly layoutConfig: LayoutConfig,
|
||||||
private readonly focusPasser: FocusPassing.Passer,
|
private readonly focusPasser: FocusPassing.Passer,
|
||||||
currentActivity: string,
|
private readonly desktopFilter: DesktopFilter,
|
||||||
currentDesktop: KwinDesktop,
|
|
||||||
) {
|
) {
|
||||||
this.pinManager = pinManager;
|
this.pinManager = pinManager;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
@@ -19,10 +18,12 @@ class DesktopManager {
|
|||||||
this.selectedScreen = Workspace.activeScreen;
|
this.selectedScreen = Workspace.activeScreen;
|
||||||
this.kwinActivities = new Set(Workspace.activities);
|
this.kwinActivities = new Set(Workspace.activities);
|
||||||
this.kwinDesktops = new Set(Workspace.desktops);
|
this.kwinDesktops = new Set(Workspace.desktops);
|
||||||
this.addDesktop(currentActivity, currentDesktop);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public getDesktop(activity: string, kwinDesktop: KwinDesktop) {
|
public getDesktop(activity: string, kwinDesktop: KwinDesktop) {
|
||||||
|
if (!this.desktopFilter.shouldWorkOnDesktop(kwinDesktop)) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
const desktopKey = DesktopManager.getDesktopKey(activity, kwinDesktop);
|
const desktopKey = DesktopManager.getDesktopKey(activity, kwinDesktop);
|
||||||
const desktop = this.desktops.get(desktopKey);
|
const desktop = this.desktops.get(desktopKey);
|
||||||
if (desktop !== undefined) {
|
if (desktop !== undefined) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class PinManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getAvailableSpace(kwinDesktop: KwinDesktop, screen: QmlRect) {
|
public getAvailableSpace(kwinDesktop: KwinDesktop, screen: QmlRect) {
|
||||||
const baseLot = new PinManager.Lot(screen.top, screen.bottom, screen.left, screen.right);
|
const baseLot = new PinManager.Lot(screen.y, rectBottom(screen), screen.x, rectRight(screen));
|
||||||
let lots = [baseLot];
|
let lots = [baseLot];
|
||||||
for (const client of this.pinnedClients) {
|
for (const client of this.pinnedClients) {
|
||||||
if (!Clients.isOnVirtualDesktop(client, kwinDesktop) || client.minimized) {
|
if (!Clients.isOnVirtualDesktop(client, kwinDesktop) || client.minimized) {
|
||||||
@@ -23,7 +23,7 @@ class PinManager {
|
|||||||
|
|
||||||
const newLots: PinManager.Lot[] = [];
|
const newLots: PinManager.Lot[] = [];
|
||||||
for (const lot of lots) {
|
for (const lot of lots) {
|
||||||
lot.split(newLots, client.frameGeometry);
|
lot.split(newLots, roundQtRect(client.frameGeometry));
|
||||||
}
|
}
|
||||||
lots = newLots;
|
lots = newLots;
|
||||||
}
|
}
|
||||||
@@ -60,23 +60,23 @@ namespace PinManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obstacle.top - this.top >= Lot.minHeight) {
|
if (obstacle.y - this.top >= Lot.minHeight) {
|
||||||
destLots.push(new Lot(this.top, obstacle.top, this.left, this.right));
|
destLots.push(new Lot(this.top, obstacle.y, this.left, this.right));
|
||||||
}
|
}
|
||||||
if (this.bottom - obstacle.bottom >= Lot.minHeight) {
|
if (this.bottom - rectBottom(obstacle) >= Lot.minHeight) {
|
||||||
destLots.push(new Lot(obstacle.bottom, this.bottom, this.left, this.right));
|
destLots.push(new Lot(rectBottom(obstacle), this.bottom, this.left, this.right));
|
||||||
}
|
}
|
||||||
if (obstacle.left - this.left >= Lot.minWidth) {
|
if (obstacle.x - this.left >= Lot.minWidth) {
|
||||||
destLots.push(new Lot(this.top, this.bottom, this.left, obstacle.left));
|
destLots.push(new Lot(this.top, this.bottom, this.left, obstacle.x));
|
||||||
}
|
}
|
||||||
if (this.right - obstacle.right >= Lot.minWidth) {
|
if (this.right - rectRight(obstacle) >= Lot.minWidth) {
|
||||||
destLots.push(new Lot(this.top, this.bottom, obstacle.right, this.right));
|
destLots.push(new Lot(this.top, this.bottom, rectRight(obstacle), this.right));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private contains(obstacle: QmlRect) {
|
private contains(obstacle: QmlRect) {
|
||||||
return obstacle.right > this.left && obstacle.left < this.right &&
|
return rectRight(obstacle) > this.left && obstacle.x < this.right &&
|
||||||
obstacle.bottom > this.top && obstacle.top < this.bottom;
|
rectBottom(obstacle) > this.top && obstacle.y < this.bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public area() {
|
public area() {
|
||||||
|
|||||||
@@ -70,8 +70,7 @@ class World {
|
|||||||
},
|
},
|
||||||
layoutConfig,
|
layoutConfig,
|
||||||
focusPasser,
|
focusPasser,
|
||||||
Workspace.currentActivity,
|
new DesktopFilter(config.tiledDesktops),
|
||||||
Workspace.currentDesktop,
|
|
||||||
);
|
);
|
||||||
this.clientManager = new ClientManager(config, this, this.desktopManager, this.pinManager);
|
this.clientManager = new ClientManager(config, this, this.desktopManager, this.pinManager);
|
||||||
this.addExistingClients();
|
this.addExistingClients();
|
||||||
@@ -98,13 +97,21 @@ class World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private update() {
|
private update() {
|
||||||
this.desktopManager.getCurrentDesktop().arrange();
|
const currentDesktop = this.desktopManager.getCurrentDesktop();
|
||||||
this.moveCursorToFocus();
|
if (currentDesktop !== undefined) {
|
||||||
|
currentDesktop.arrange();
|
||||||
|
this.moveCursorToFocus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private moveCursorToFocus() {
|
private moveCursorToFocus() {
|
||||||
if (this.cursorFollowsFocus && Workspace.activeWindow !== null) {
|
if (this.cursorFollowsFocus && Workspace.activeWindow !== null) {
|
||||||
const cursorAlreadyInFocus = rectContainsPoint(Workspace.activeWindow.frameGeometry, Workspace.cursorPos);
|
// Only move cursor for tiled windows
|
||||||
|
const tiledWindow = this.clientManager.findTiledWindow(Workspace.activeWindow);
|
||||||
|
if (tiledWindow === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const cursorAlreadyInFocus = rectContainsPoint(roundQtRect(Workspace.activeWindow.frameGeometry), Workspace.cursorPos);
|
||||||
if (cursorAlreadyInFocus) {
|
if (cursorAlreadyInFocus) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -141,11 +148,23 @@ class World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public gestureScroll(amount: number) {
|
public gestureScroll(amount: number) {
|
||||||
this.do((clientManager, desktopManager) => desktopManager.getCurrentDesktop().gestureScroll(amount));
|
this.do((clientManager, desktopManager) => {
|
||||||
|
const currentDesktop = desktopManager.getCurrentDesktop();
|
||||||
|
if (currentDesktop !== undefined) {
|
||||||
|
currentDesktop.gestureScroll(amount);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public gestureScrollFinish() {
|
public gestureScrollFinish() {
|
||||||
this.do((clientManager, desktopManager) => desktopManager.getCurrentDesktop().gestureScrollFinish());
|
this.do((clientManager, desktopManager) => {
|
||||||
|
const focusedWindow = Workspace.activeWindow === null ? null : clientManager.findTiledWindow(Workspace.activeWindow);
|
||||||
|
const currentDesktop = desktopManager.getCurrentDesktop();
|
||||||
|
if (currentDesktop !== undefined) {
|
||||||
|
console.assert(focusedWindow === null || focusedWindow.column.grid.desktop === currentDesktop);
|
||||||
|
currentDesktop.gestureScrollFinish(focusedWindow);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public destroy() {
|
public destroy() {
|
||||||
|
|||||||
@@ -30,10 +30,10 @@ namespace ClientState {
|
|||||||
const clientRect = client.kwinClient.frameGeometry;
|
const clientRect = client.kwinClient.frameGeometry;
|
||||||
const width = client.preferredWidth;
|
const width = client.preferredWidth;
|
||||||
client.place(
|
client.place(
|
||||||
clientRect.x,
|
clientRect.x.round(),
|
||||||
clientRect.y,
|
clientRect.y.round(),
|
||||||
width,
|
width,
|
||||||
Math.min(clientRect.height, Math.round(placementArea.height / 2)),
|
Math.min(clientRect.height.round(), Math.round(placementArea.height / 2)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -123,7 +123,12 @@ namespace ClientState {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const newGeometry = client.kwinClient.frameGeometry;
|
const newGeometry = roundQtRect(client.kwinClient.frameGeometry);
|
||||||
|
if (rectEquals(oldGeometry, newGeometry)) {
|
||||||
|
// no real changes, nothing to do
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const oldCenterX = oldGeometry.x + oldGeometry.width/2;
|
const oldCenterX = oldGeometry.x + oldGeometry.width/2;
|
||||||
const oldCenterY = oldGeometry.y + oldGeometry.height/2;
|
const oldCenterY = oldGeometry.y + oldGeometry.height/2;
|
||||||
const newCenterX = newGeometry.x + newGeometry.width/2;
|
const newCenterX = newGeometry.x + newGeometry.width/2;
|
||||||
@@ -142,7 +147,7 @@ namespace ClientState {
|
|||||||
window.column.onUserResizeWidth(
|
window.column.onUserResizeWidth(
|
||||||
resizeStartWidth,
|
resizeStartWidth,
|
||||||
newGeometry.width - resizeStartWidth,
|
newGeometry.width - resizeStartWidth,
|
||||||
newGeometry.left !== oldGeometry.left,
|
newGeometry.x !== oldGeometry.x,
|
||||||
resizeNeighbor,
|
resizeNeighbor,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -193,9 +198,9 @@ namespace ClientState {
|
|||||||
private static getResizeNeighborColumn(window: Window) {
|
private static getResizeNeighborColumn(window: Window) {
|
||||||
const kwinClient = window.client.kwinClient;
|
const kwinClient = window.client.kwinClient;
|
||||||
const column = window.column;
|
const column = window.column;
|
||||||
if (Workspace.cursorPos.x > kwinClient.clientGeometry.right) {
|
if (Workspace.cursorPos.x > rectRightRound(kwinClient.clientGeometry)) {
|
||||||
return column.grid.getRightColumn(column);
|
return column.grid.getRightColumn(column);
|
||||||
} else if (Workspace.cursorPos.x < kwinClient.clientGeometry.left) {
|
} else if (Workspace.cursorPos.x < kwinClient.clientGeometry.x.round()) {
|
||||||
return column.grid.getLeftColumn(column);
|
return column.grid.getLeftColumn(column);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
tests.register("Center focused", 1, () => {
|
tests.register("Center focused", 5, () => {
|
||||||
const config = getDefaultConfig();
|
const config = getDefaultConfig();
|
||||||
const { qtMock, workspaceMock, world } = init(config);
|
const { qtMock, workspaceMock, world } = init(config);
|
||||||
|
|
||||||
@@ -14,8 +14,8 @@ tests.register("Center focused", 1, () => {
|
|||||||
// center client2
|
// center client2
|
||||||
qtMock.fireShortcut("karousel-grid-scroll-focused");
|
qtMock.fireShortcut("karousel-grid-scroll-focused");
|
||||||
Assert.centered(config, tilingArea, client2);
|
Assert.centered(config, tilingArea, client2);
|
||||||
Assert.fullyVisible(client1.frameGeometry);
|
Assert.fullyVisible(client1.getActualFrameGeometry());
|
||||||
Assert.fullyVisible(client2.frameGeometry);
|
Assert.fullyVisible(client2.getActualFrameGeometry());
|
||||||
|
|
||||||
// undo center client2
|
// undo center client2
|
||||||
qtMock.fireShortcut("karousel-grid-scroll-focused");
|
qtMock.fireShortcut("karousel-grid-scroll-focused");
|
||||||
@@ -24,14 +24,14 @@ tests.register("Center focused", 1, () => {
|
|||||||
// center client2
|
// center client2
|
||||||
qtMock.fireShortcut("karousel-grid-scroll-focused");
|
qtMock.fireShortcut("karousel-grid-scroll-focused");
|
||||||
Assert.centered(config, tilingArea, client2);
|
Assert.centered(config, tilingArea, client2);
|
||||||
Assert.fullyVisible(client1.frameGeometry);
|
Assert.fullyVisible(client1.getActualFrameGeometry());
|
||||||
Assert.fullyVisible(client2.frameGeometry);
|
Assert.fullyVisible(client2.getActualFrameGeometry());
|
||||||
|
|
||||||
// focus client1 (no scrolling should occur)
|
// focus client1 (no scrolling should occur)
|
||||||
qtMock.fireShortcut("karousel-focus-left");
|
qtMock.fireShortcut("karousel-focus-left");
|
||||||
Assert.centered(config, tilingArea, client2, { message: "No scrolling should have occured" });
|
Assert.centered(config, tilingArea, client2, { message: "No scrolling should have occured" });
|
||||||
Assert.fullyVisible(client1.frameGeometry);
|
Assert.fullyVisible(client1.getActualFrameGeometry());
|
||||||
Assert.fullyVisible(client2.frameGeometry);
|
Assert.fullyVisible(client2.getActualFrameGeometry());
|
||||||
|
|
||||||
// center client1
|
// center client1
|
||||||
qtMock.fireShortcut("karousel-grid-scroll-focused");
|
qtMock.fireShortcut("karousel-grid-scroll-focused");
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
tests.register("columns squeeze side", 1, () => {
|
tests.register("columns squeeze side", 5, () => {
|
||||||
const baseTestCases = [
|
const baseTestCases = [
|
||||||
{ widths: [500, 500], blocked: [false, false], possible: true },
|
{ widths: [500, 500], blocked: [false, false], possible: true },
|
||||||
{ widths: [500, 768], blocked: [false, false], possible: true },
|
{ widths: [500, 768], blocked: [false, false], possible: true },
|
||||||
@@ -46,21 +46,21 @@ tests.register("columns squeeze side", 1, () => {
|
|||||||
Assert.columnsFillTilingArea(clients, assertOpt);
|
Assert.columnsFillTilingArea(clients, assertOpt);
|
||||||
for (let i = 0; i < clients.length; i++) {
|
for (let i = 0; i < clients.length; i++) {
|
||||||
if (testCase.blocked[i]) {
|
if (testCase.blocked[i]) {
|
||||||
Assert.equal(clients[i].frameGeometry.width, testCase.widths[i], assertOpt);
|
Assert.equal(clients[i].getActualFrameGeometry().width, testCase.widths[i], assertOpt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const frames = clients.map(client => client.frameGeometry);
|
const frames = clients.map(client => client.getActualFrameGeometry());
|
||||||
qtMock.fireShortcut(testCase.action);
|
qtMock.fireShortcut(testCase.action);
|
||||||
const newFrames = clients.map(client => client.frameGeometry);
|
const newFrames = clients.map(client => client.getActualFrameGeometry());
|
||||||
for (let i = 0; i < clients.length; i++) {
|
for (let i = 0; i < clients.length; i++) {
|
||||||
Assert.equalRects(frames[i], newFrames[i], assertOpt);
|
Assert.equalRects(frames[i], newFrames[i], assertOpt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
tests.register("columns squeeze side (just scroll)", 1, () => {
|
tests.register("columns squeeze side (just scroll)", 5, () => {
|
||||||
const baseTestCases = [
|
const baseTestCases = [
|
||||||
{ focus: 0, startVisible: [true, true, false], endVisible: [true, true, false] },
|
{ focus: 0, startVisible: [true, true, false], endVisible: [true, true, false] },
|
||||||
{ focus: 1, startVisible: [false, true, true], endVisible: [true, true, false] },
|
{ focus: 1, startVisible: [false, true, true], endVisible: [true, true, false] },
|
||||||
@@ -91,12 +91,12 @@ tests.register("columns squeeze side (just scroll)", 1, () => {
|
|||||||
const config = getDefaultConfig();
|
const config = getDefaultConfig();
|
||||||
const { qtMock, workspaceMock, world } = init(config);
|
const { qtMock, workspaceMock, world } = init(config);
|
||||||
|
|
||||||
function assertVisible(clients: KwinClient[], visible: boolean[]) {
|
function assertVisible(clients: MockKwinClient[], visible: boolean[]) {
|
||||||
for (let i = 0; i < clients.length; i++) {
|
for (let i = 0; i < clients.length; i++) {
|
||||||
if (visible[i]) {
|
if (visible[i]) {
|
||||||
Assert.fullyVisible(clients[i].frameGeometry, { message: assertMsg, skip: 1 });
|
Assert.fullyVisible(clients[i].getActualFrameGeometry(), { message: assertMsg, skip: 1 });
|
||||||
} else {
|
} else {
|
||||||
Assert.notFullyVisible(clients[i].frameGeometry, { message: assertMsg, skip: 1 });
|
Assert.notFullyVisible(clients[i].getActualFrameGeometry(), { message: assertMsg, skip: 1 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -114,9 +114,9 @@ tests.register("columns squeeze side (just scroll)", 1, () => {
|
|||||||
qtMock.fireShortcut(testCase.action);
|
qtMock.fireShortcut(testCase.action);
|
||||||
assertVisible(clients, testCase.endVisible);
|
assertVisible(clients, testCase.endVisible);
|
||||||
|
|
||||||
const frames = clients.map(client => client.frameGeometry);
|
const frames = clients.map(client => client.getActualFrameGeometry());
|
||||||
qtMock.fireShortcut(testCase.action);
|
qtMock.fireShortcut(testCase.action);
|
||||||
const newFrames = clients.map(client => client.frameGeometry);
|
const newFrames = clients.map(client => client.getActualFrameGeometry());
|
||||||
for (let i = 0; i < clients.length; i++) {
|
for (let i = 0; i < clients.length; i++) {
|
||||||
Assert.equalRects(frames[i], newFrames[i], { message: assertMsg });
|
Assert.equalRects(frames[i], newFrames[i], { message: assertMsg });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,32 +5,78 @@ tests.register("Drag tiled window, untile", 10, () => {
|
|||||||
|
|
||||||
const [client1, client2] = workspaceMock.createClients(2);
|
const [client1, client2] = workspaceMock.createClients(2);
|
||||||
const initialCursorPos = new MockQmlPoint(380, 20);
|
const initialCursorPos = new MockQmlPoint(380, 20);
|
||||||
Assert.assert(rectContainsPoint(client1.frameGeometry, initialCursorPos), { message: "invalid test setup" });
|
Assert.assert(rectContainsPoint(client1.getActualFrameGeometry(), initialCursorPos), { message: "invalid test setup" });
|
||||||
workspaceMock.cursorPos = initialCursorPos.clone();
|
workspaceMock.cursorPos = initialCursorPos.clone();
|
||||||
|
|
||||||
runOneOf(
|
runOneOf(
|
||||||
() => { Workspace.activeWindow = client1; },
|
() => { Workspace.activeWindow = client1; },
|
||||||
() => { qtMock.fireShortcut("karousel-focus-1"); },
|
() => { qtMock.fireShortcut("karousel-focus-1"); },
|
||||||
);
|
);
|
||||||
Assert.assert(rectContainsPoint(client1.frameGeometry, Workspace.cursorPos));
|
Assert.assert(rectContainsPoint(client1.getActualFrameGeometry(), Workspace.cursorPos));
|
||||||
Assert.assert(!rectContainsPoint(client2.frameGeometry, Workspace.cursorPos));
|
Assert.assert(!rectContainsPoint(client2.getActualFrameGeometry(), Workspace.cursorPos));
|
||||||
Assert.assert(pointEquals(Workspace.cursorPos, initialCursorPos), { message: "Cursor should not have been moved because it was already within the focused client" });
|
Assert.assert(pointEquals(Workspace.cursorPos, initialCursorPos), { message: "Cursor should not have been moved because it was already within the focused client" });
|
||||||
|
|
||||||
runOneOf(
|
runOneOf(
|
||||||
() => { Workspace.activeWindow = client2; },
|
() => { Workspace.activeWindow = client2; },
|
||||||
() => { qtMock.fireShortcut("karousel-focus-2"); },
|
() => { qtMock.fireShortcut("karousel-focus-2"); },
|
||||||
);
|
);
|
||||||
Assert.assert(!rectContainsPoint(client1.frameGeometry, Workspace.cursorPos));
|
Assert.assert(!rectContainsPoint(client1.getActualFrameGeometry(), Workspace.cursorPos));
|
||||||
Assert.assert(rectContainsPoint(client2.frameGeometry, Workspace.cursorPos));
|
Assert.assert(rectContainsPoint(client2.getActualFrameGeometry(), Workspace.cursorPos));
|
||||||
|
|
||||||
runOneOf(
|
runOneOf(
|
||||||
() => { Workspace.activeWindow = client1; },
|
() => { Workspace.activeWindow = client1; },
|
||||||
() => { qtMock.fireShortcut("karousel-focus-1"); },
|
() => { qtMock.fireShortcut("karousel-focus-1"); },
|
||||||
);
|
);
|
||||||
Assert.assert(rectContainsPoint(client1.frameGeometry, Workspace.cursorPos));
|
Assert.assert(rectContainsPoint(client1.getActualFrameGeometry(), Workspace.cursorPos));
|
||||||
Assert.assert(!rectContainsPoint(client2.frameGeometry, Workspace.cursorPos));
|
Assert.assert(!rectContainsPoint(client2.getActualFrameGeometry(), Workspace.cursorPos));
|
||||||
const lastCursorPos = workspaceMock.cursorPos.clone();
|
const lastCursorPos = workspaceMock.cursorPos.clone();
|
||||||
|
|
||||||
Workspace.activeWindow = null;
|
Workspace.activeWindow = null;
|
||||||
Assert.assert(pointEquals(Workspace.cursorPos, lastCursorPos), { message: "Cursor should not have been moved" });
|
Assert.assert(pointEquals(Workspace.cursorPos, lastCursorPos), { message: "Cursor should not have been moved" });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tests.register("Cursor follows focus only on matched desktops", 1, () => {
|
||||||
|
// Test that cursor follow focus only works for windows on matched desktops (tiled windows)
|
||||||
|
const config = getDefaultConfig();
|
||||||
|
config.cursorFollowsFocus = true;
|
||||||
|
config.tiledDesktops = "^Desktop 1$"; // Only work on Desktop 1
|
||||||
|
const { workspaceMock, world } = init(config);
|
||||||
|
|
||||||
|
// Create a client on Desktop 1 (matched desktop) - should be tiled
|
||||||
|
const client1 = new MockKwinClient();
|
||||||
|
client1.desktops = [workspaceMock.desktops[0]]; // Desktop 1
|
||||||
|
workspaceMock.createWindows(client1);
|
||||||
|
|
||||||
|
// Create a client on Desktop 2 (non-matched desktop) - should be floating
|
||||||
|
const client2 = new MockKwinClient();
|
||||||
|
client2.desktops = [workspaceMock.desktops[1]]; // Desktop 2
|
||||||
|
workspaceMock.createWindows(client2);
|
||||||
|
|
||||||
|
// Set initial cursor position outside both windows
|
||||||
|
const initialCursorPos = new MockQmlPoint(10, 10);
|
||||||
|
workspaceMock.cursorPos = initialCursorPos.clone();
|
||||||
|
|
||||||
|
// Test 1: Focus client1 on matched desktop (Desktop 1) - cursor should move
|
||||||
|
workspaceMock.currentDesktop = workspaceMock.desktops[0]; // Switch to Desktop 1
|
||||||
|
Workspace.activeWindow = client1;
|
||||||
|
world.do(() => {});
|
||||||
|
Assert.assert(rectContainsPoint(client1.getActualFrameGeometry(), Workspace.cursorPos),
|
||||||
|
{ message: "Cursor should have moved to tiled window on matched desktop" });
|
||||||
|
|
||||||
|
// Test 2: Switch to non-matched desktop (Desktop 2) and focus client2 - cursor should NOT move
|
||||||
|
workspaceMock.cursorPos = initialCursorPos.clone();
|
||||||
|
workspaceMock.currentDesktop = workspaceMock.desktops[1]; // Switch to Desktop 2
|
||||||
|
Workspace.activeWindow = client2;
|
||||||
|
world.do(() => {});
|
||||||
|
Assert.assert(pointEquals(Workspace.cursorPos, initialCursorPos),
|
||||||
|
{ message: "Cursor should NOT move on non-matched desktop" });
|
||||||
|
|
||||||
|
// Test 3: Even if we focus client1 (tiled) while on Desktop 2, cursor should NOT move
|
||||||
|
// because the current desktop is not matched
|
||||||
|
workspaceMock.cursorPos = initialCursorPos.clone();
|
||||||
|
workspaceMock.currentDesktop = workspaceMock.desktops[1]; // Stay on Desktop 2
|
||||||
|
Workspace.activeWindow = client1;
|
||||||
|
world.do(() => {});
|
||||||
|
Assert.assert(pointEquals(Workspace.cursorPos, initialCursorPos),
|
||||||
|
{ message: "Cursor should NOT move even for tiled window when current desktop is not matched" });
|
||||||
|
});
|
||||||
|
|||||||
73
src/tests/flows/desktopFiltering.ts
Normal file
73
src/tests/flows/desktopFiltering.ts
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
tests.register("Desktop filtering", 1, () => {
|
||||||
|
// Test 1: Default config should work on all desktops
|
||||||
|
const config1 = getDefaultConfig();
|
||||||
|
const { workspaceMock: wm1, world: world1 } = init(config1);
|
||||||
|
|
||||||
|
const client1 = new MockKwinClient();
|
||||||
|
client1.desktops = [wm1.desktops[0]];
|
||||||
|
wm1.createWindows(client1);
|
||||||
|
|
||||||
|
world1.do((clientManager) => {
|
||||||
|
Assert.tiledClient(clientManager, client1, { message: "Client should be tiled on desktop1 with default config (*)" });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
tests.register("Desktop filtering - specific desktop", 1, () => {
|
||||||
|
// Test 2: Specific desktop name - should work only on matching desktop
|
||||||
|
const config2 = getDefaultConfig();
|
||||||
|
config2.tiledDesktops = "^Desktop 1$";
|
||||||
|
const { workspaceMock: wm2, world: world2 } = init(config2);
|
||||||
|
|
||||||
|
const client1 = new MockKwinClient();
|
||||||
|
client1.desktops = [wm2.desktops[0]]; // Desktop 1
|
||||||
|
wm2.createWindows(client1);
|
||||||
|
world2.do((clientManager) => {
|
||||||
|
Assert.tiledClient(clientManager, client1, { message: "Client should be tiled on Desktop 1" });
|
||||||
|
});
|
||||||
|
|
||||||
|
wm2.removeWindow(client1);
|
||||||
|
|
||||||
|
const client2 = new MockKwinClient();
|
||||||
|
client2.desktops = [wm2.desktops[1]]; // Desktop 2
|
||||||
|
wm2.createWindows(client2);
|
||||||
|
world2.do((clientManager) => {
|
||||||
|
Assert.notTiledClient(clientManager, client2, { message: "Client should NOT be tiled on Desktop 2" });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
tests.register("Desktop filtering - multiple desktops", 1, () => {
|
||||||
|
// Test 3: Multiple desktop names using regex alternation
|
||||||
|
const config3 = getDefaultConfig();
|
||||||
|
config3.tiledDesktops = "^Desktop [12]$";
|
||||||
|
const { workspaceMock: wm3, world: world3 } = init(config3);
|
||||||
|
|
||||||
|
const client1 = new MockKwinClient();
|
||||||
|
client1.desktops = [wm3.desktops[0]]; // Desktop 1
|
||||||
|
wm3.createWindows(client1);
|
||||||
|
world3.do((clientManager) => {
|
||||||
|
Assert.tiledClient(clientManager, client1, { message: "Client should be tiled on Desktop 1" });
|
||||||
|
});
|
||||||
|
|
||||||
|
wm3.removeWindow(client1);
|
||||||
|
|
||||||
|
const client2 = new MockKwinClient();
|
||||||
|
client2.desktops = [wm3.desktops[1]]; // Desktop 2
|
||||||
|
wm3.createWindows(client2);
|
||||||
|
world3.do((clientManager) => {
|
||||||
|
Assert.tiledClient(clientManager, client2, { message: "Client should be tiled on Desktop 2" });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
tests.register("Desktop filtering - windows on multiple desktops", 1, () => {
|
||||||
|
// Test 4: Windows on multiple desktops should not be tiled (fallback to floating)
|
||||||
|
const config4 = getDefaultConfig();
|
||||||
|
config4.tiledDesktops = ".*";
|
||||||
|
const { workspaceMock: wm4, world: world4 } = init(config4);
|
||||||
|
|
||||||
|
const client1 = new MockKwinClient();
|
||||||
|
client1.desktops = [wm4.desktops[0], wm4.desktops[1]]; // Multiple desktops
|
||||||
|
wm4.createWindows(client1);
|
||||||
|
world4.do((clientManager) => {
|
||||||
|
Assert.notTiledClient(clientManager, client1, { message: "Client on multiple desktops should not be tiled" });
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -8,31 +8,31 @@ tests.register("External resize", 1, () => {
|
|||||||
|
|
||||||
function getTiledFrame(width: number) {
|
function getTiledFrame(width: number) {
|
||||||
return new MockQmlRect(
|
return new MockQmlRect(
|
||||||
tilingArea.left + Math.round((tilingArea.width - width) / 2),
|
tilingArea.x + Math.round((tilingArea.width - width) / 2),
|
||||||
tilingArea.top,
|
tilingArea.y,
|
||||||
width,
|
width,
|
||||||
tilingArea.height,
|
tilingArea.height,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const [client] = workspaceMock.createClientsWithFrames(getClientDesiredFrame(100));
|
const [client] = workspaceMock.createClientsWithFrames(getClientDesiredFrame(100));
|
||||||
Assert.equalRects(client.frameGeometry, getTiledFrame(100), { message: "We should tile the window, respecting its desired width" });
|
Assert.equalRects(client.getActualFrameGeometry(), getTiledFrame(100), { message: "We should tile the window, respecting its desired width" });
|
||||||
|
|
||||||
function testExternalResizing() {
|
function testExternalResizing() {
|
||||||
client.frameGeometry = getClientDesiredFrame(110);
|
client.frameGeometry = getClientDesiredFrame(110);
|
||||||
Assert.equalRects(client.frameGeometry, getTiledFrame(110), { message: "We should re-arrange the window, respecting its new desired width" });
|
Assert.equalRects(client.getActualFrameGeometry(), getTiledFrame(110), { message: "We should re-arrange the window, respecting its new desired width" });
|
||||||
|
|
||||||
client.frameGeometry = getClientDesiredFrame(120);
|
client.frameGeometry = getClientDesiredFrame(120);
|
||||||
Assert.equalRects(client.frameGeometry, getTiledFrame(120), { message: "We should re-arrange the window, respecting its new desired width" });
|
Assert.equalRects(client.getActualFrameGeometry(), getTiledFrame(120), { message: "We should re-arrange the window, respecting its new desired width" });
|
||||||
|
|
||||||
client.frameGeometry = getClientDesiredFrame(130);
|
client.frameGeometry = getClientDesiredFrame(130);
|
||||||
Assert.equalRects(client.frameGeometry, getTiledFrame(130), { message: "We should re-arrange the window, respecting its new desired width" });
|
Assert.equalRects(client.getActualFrameGeometry(), getTiledFrame(130), { message: "We should re-arrange the window, respecting its new desired width" });
|
||||||
|
|
||||||
client.frameGeometry = getClientDesiredFrame(140);
|
client.frameGeometry = getClientDesiredFrame(140);
|
||||||
Assert.equalRects(client.frameGeometry, getTiledFrame(140), { message: "We should re-arrange the window, respecting its new desired width" });
|
Assert.equalRects(client.getActualFrameGeometry(), getTiledFrame(140), { message: "We should re-arrange the window, respecting its new desired width" });
|
||||||
|
|
||||||
client.frameGeometry = getClientDesiredFrame(200);
|
client.frameGeometry = getClientDesiredFrame(200);
|
||||||
Assert.equalRects(client.frameGeometry, getClientDesiredFrame(200), { message: "We should give up and let the client have its desired frame" });
|
Assert.equalRects(client.getActualFrameGeometry(), getClientDesiredFrame(200), { message: "We should give up and let the client have its desired frame" });
|
||||||
}
|
}
|
||||||
|
|
||||||
timeControl(addTime => {
|
timeControl(addTime => {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ tests.register("Focus and move windows", 1, () => {
|
|||||||
});
|
});
|
||||||
Assert.assert(workspaceMock.activeWindow === client3);
|
Assert.assert(workspaceMock.activeWindow === client3);
|
||||||
|
|
||||||
function testLayout(shortcutName: string, grid: KwinClient[][]) {
|
function testLayout(shortcutName: string, grid: MockKwinClient[][]) {
|
||||||
qtMock.fireShortcut(shortcutName);
|
qtMock.fireShortcut(shortcutName);
|
||||||
Assert.grid(config, tilingArea, 100, grid, true, [], { skip: 1 });
|
Assert.grid(config, tilingArea, 100, grid, true, [], { skip: 1 });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ tests.register("LazyScroller", 20, () => {
|
|||||||
|
|
||||||
const [client3] = workspaceMock.createClientsWithWidths(300);
|
const [client3] = workspaceMock.createClientsWithWidths(300);
|
||||||
Assert.grid(config, tilingArea, 300, [[client1], [client2], [client3]], false);
|
Assert.grid(config, tilingArea, 300, [[client1], [client2], [client3]], false);
|
||||||
Assert.equal(client3.frameGeometry.right, tilingArea.right);
|
Assert.equal(rectRight(client3.getActualFrameGeometry()), rectRight(tilingArea));
|
||||||
|
|
||||||
runOneOf(
|
runOneOf(
|
||||||
() => { workspaceMock.activeWindow = client2; },
|
() => { workspaceMock.activeWindow = client2; },
|
||||||
@@ -21,7 +21,7 @@ tests.register("LazyScroller", 20, () => {
|
|||||||
() => { qtMock.fireShortcut("karousel-focus-left"); },
|
() => { qtMock.fireShortcut("karousel-focus-left"); },
|
||||||
);
|
);
|
||||||
Assert.grid(config, tilingArea, 300, [[client1], [client2], [client3]], false);
|
Assert.grid(config, tilingArea, 300, [[client1], [client2], [client3]], false);
|
||||||
Assert.equal(client3.frameGeometry.right, tilingArea.right);
|
Assert.equal(rectRight(client3.getActualFrameGeometry()), rectRight(tilingArea));
|
||||||
|
|
||||||
runOneOf(
|
runOneOf(
|
||||||
() => { workspaceMock.activeWindow = client1; },
|
() => { workspaceMock.activeWindow = client1; },
|
||||||
@@ -31,7 +31,7 @@ tests.register("LazyScroller", 20, () => {
|
|||||||
);
|
);
|
||||||
workspaceMock.activeWindow = client1;
|
workspaceMock.activeWindow = client1;
|
||||||
Assert.grid(config, tilingArea, 300, [[client1], [client2], [client3]], false);
|
Assert.grid(config, tilingArea, 300, [[client1], [client2], [client3]], false);
|
||||||
Assert.equal(client1.frameGeometry.left, tilingArea.left);
|
Assert.equal(client1.getActualFrameGeometry().x, tilingArea.x);
|
||||||
|
|
||||||
qtMock.fireShortcut("karousel-grid-scroll-focused");
|
qtMock.fireShortcut("karousel-grid-scroll-focused");
|
||||||
Assert.grid(config, tilingArea, 300, [[client1], [client2], [client3]], false);
|
Assert.grid(config, tilingArea, 300, [[client1], [client2], [client3]], false);
|
||||||
@@ -43,5 +43,5 @@ tests.register("LazyScroller", 20, () => {
|
|||||||
() => { qtMock.fireShortcut("karousel-focus-right"); },
|
() => { qtMock.fireShortcut("karousel-focus-right"); },
|
||||||
);
|
);
|
||||||
Assert.grid(config, tilingArea, 300, [[client1], [client2], [client3]], false);
|
Assert.grid(config, tilingArea, 300, [[client1], [client2], [client3]], false);
|
||||||
Assert.equal(client1.frameGeometry.left, tilingArea.left);
|
Assert.equal(client1.getActualFrameGeometry().x, tilingArea.x);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,43 +14,43 @@
|
|||||||
Assert.assert(clientManager.hasClient(kwinClient));
|
Assert.assert(clientManager.hasClient(kwinClient));
|
||||||
});
|
});
|
||||||
|
|
||||||
const columnLeftX = tilingArea.left + tilingArea.width/2 - 300/2;
|
const columnLeftX = tilingArea.x + tilingArea.width/2 - 300/2;
|
||||||
const columnTopY = tilingArea.top;
|
const columnTopY = tilingArea.y;
|
||||||
const columnHeight = tilingArea.height;
|
const columnHeight = tilingArea.height;
|
||||||
Assert.assert(!kwinClient.fullScreen);
|
Assert.assert(!kwinClient.fullScreen);
|
||||||
Assert.equal(kwinClient.keepBelow, shouldKeepBelow(true));
|
Assert.equal(kwinClient.keepBelow, shouldKeepBelow(true));
|
||||||
Assert.equal(kwinClient.keepAbove, shouldKeepAbove(true));
|
Assert.equal(kwinClient.keepAbove, shouldKeepAbove(true));
|
||||||
Assert.rect(kwinClient.frameGeometry, columnLeftX, columnTopY, 300, columnHeight);
|
Assert.rect(kwinClient.getActualFrameGeometry(), columnLeftX, columnTopY, 300, columnHeight);
|
||||||
|
|
||||||
kwinClient.fullScreen = true;
|
kwinClient.fullScreen = true;
|
||||||
Assert.assert(kwinClient.fullScreen);
|
Assert.assert(kwinClient.fullScreen);
|
||||||
Assert.equal(kwinClient.keepBelow, shouldKeepBelow(false));
|
Assert.equal(kwinClient.keepBelow, shouldKeepBelow(false));
|
||||||
Assert.equal(kwinClient.keepAbove, shouldKeepAbove(false));
|
Assert.equal(kwinClient.keepAbove, shouldKeepAbove(false));
|
||||||
Assert.equalRects(kwinClient.frameGeometry, screen);
|
Assert.equalRects(kwinClient.getActualFrameGeometry(), screen);
|
||||||
|
|
||||||
kwinClient.fullScreen = false;
|
kwinClient.fullScreen = false;
|
||||||
Assert.assert(!kwinClient.fullScreen);
|
Assert.assert(!kwinClient.fullScreen);
|
||||||
Assert.equal(kwinClient.keepBelow, shouldKeepBelow(true));
|
Assert.equal(kwinClient.keepBelow, shouldKeepBelow(true));
|
||||||
Assert.equal(kwinClient.keepAbove, shouldKeepAbove(true));
|
Assert.equal(kwinClient.keepAbove, shouldKeepAbove(true));
|
||||||
Assert.rect(kwinClient.frameGeometry, columnLeftX, columnTopY, 300, columnHeight);
|
Assert.rect(kwinClient.getActualFrameGeometry(), columnLeftX, columnTopY, 300, columnHeight);
|
||||||
|
|
||||||
kwinClient.setMaximize(true, true);
|
kwinClient.setMaximize(true, true);
|
||||||
Assert.assert(!kwinClient.fullScreen);
|
Assert.assert(!kwinClient.fullScreen);
|
||||||
Assert.equal(kwinClient.keepBelow, shouldKeepBelow(false));
|
Assert.equal(kwinClient.keepBelow, shouldKeepBelow(false));
|
||||||
Assert.equal(kwinClient.keepAbove, shouldKeepAbove(false));
|
Assert.equal(kwinClient.keepAbove, shouldKeepAbove(false));
|
||||||
Assert.equalRects(kwinClient.frameGeometry, screen);
|
Assert.equalRects(kwinClient.getActualFrameGeometry(), screen);
|
||||||
|
|
||||||
kwinClient.setMaximize(true, false);
|
kwinClient.setMaximize(true, false);
|
||||||
Assert.assert(!kwinClient.fullScreen);
|
Assert.assert(!kwinClient.fullScreen);
|
||||||
Assert.equal(kwinClient.keepBelow, shouldKeepBelow(false));
|
Assert.equal(kwinClient.keepBelow, shouldKeepBelow(false));
|
||||||
Assert.equal(kwinClient.keepAbove, shouldKeepAbove(false));
|
Assert.equal(kwinClient.keepAbove, shouldKeepAbove(false));
|
||||||
Assert.rect(kwinClient.frameGeometry, columnLeftX, 0, 300, screen.height);
|
Assert.rect(kwinClient.getActualFrameGeometry(), columnLeftX, 0, 300, screen.height);
|
||||||
|
|
||||||
kwinClient.setMaximize(false, false);
|
kwinClient.setMaximize(false, false);
|
||||||
Assert.assert(!kwinClient.fullScreen);
|
Assert.assert(!kwinClient.fullScreen);
|
||||||
Assert.equal(kwinClient.keepBelow, shouldKeepBelow(true));
|
Assert.equal(kwinClient.keepBelow, shouldKeepBelow(true));
|
||||||
Assert.equal(kwinClient.keepAbove, shouldKeepAbove(true));
|
Assert.equal(kwinClient.keepAbove, shouldKeepAbove(true));
|
||||||
Assert.rect(kwinClient.frameGeometry, columnLeftX, columnTopY, 300, columnHeight);
|
Assert.rect(kwinClient.getActualFrameGeometry(), columnLeftX, columnTopY, 300, columnHeight);
|
||||||
});
|
});
|
||||||
|
|
||||||
tests.register("Maximize with transient " + suffix, 100, () => {
|
tests.register("Maximize with transient " + suffix, 100, () => {
|
||||||
@@ -71,7 +71,7 @@
|
|||||||
);
|
);
|
||||||
Assert.equal(parent.keepBelow, shouldKeepBelow(false));
|
Assert.equal(parent.keepBelow, shouldKeepBelow(false));
|
||||||
Assert.equal(parent.keepAbove, shouldKeepAbove(false));
|
Assert.equal(parent.keepAbove, shouldKeepAbove(false));
|
||||||
Assert.equalRects(parent.frameGeometry, screen);
|
Assert.equalRects(parent.getActualFrameGeometry(), screen);
|
||||||
|
|
||||||
workspaceMock.createWindows(child);
|
workspaceMock.createWindows(child);
|
||||||
world.do((clientManager, desktopManager) => {
|
world.do((clientManager, desktopManager) => {
|
||||||
@@ -80,14 +80,14 @@
|
|||||||
Assert.assert(!child.fullScreen);
|
Assert.assert(!child.fullScreen);
|
||||||
Assert.equal(child.keepBelow, shouldKeepBelow(false));
|
Assert.equal(child.keepBelow, shouldKeepBelow(false));
|
||||||
Assert.equal(child.keepAbove, shouldKeepAbove(false));
|
Assert.equal(child.keepAbove, shouldKeepAbove(false));
|
||||||
Assert.rect(child.frameGeometry, 14, 24, 50, 50);
|
Assert.rect(child.getActualFrameGeometry(), 14, 24, 50, 50);
|
||||||
Assert.equal(parent.keepBelow, shouldKeepBelow(false));
|
Assert.equal(parent.keepBelow, shouldKeepBelow(false));
|
||||||
Assert.equal(parent.keepAbove, shouldKeepAbove(false));
|
Assert.equal(parent.keepAbove, shouldKeepAbove(false));
|
||||||
Assert.equalRects(parent.frameGeometry, screen);
|
Assert.equalRects(parent.getActualFrameGeometry(), screen);
|
||||||
});
|
});
|
||||||
|
|
||||||
{
|
{
|
||||||
function assertWindowed(config: Config, clients: KwinClient[]) {
|
function assertWindowed(config: Config, clients: MockKwinClient[]) {
|
||||||
Assert.assert(!clients[0].fullScreen);
|
Assert.assert(!clients[0].fullScreen);
|
||||||
Assert.equal(clients[0].keepBelow, shouldKeepBelow(true));
|
Assert.equal(clients[0].keepBelow, shouldKeepBelow(true));
|
||||||
Assert.equal(clients[0].keepAbove, shouldKeepAbove(true));
|
Assert.equal(clients[0].keepAbove, shouldKeepAbove(true));
|
||||||
@@ -100,7 +100,7 @@
|
|||||||
Assert.grid(config, tilingArea, [300, 400], [[clients[0]], [clients[1], clients[2]]], true);
|
Assert.grid(config, tilingArea, [300, 400], [[clients[0]], [clients[1], clients[2]]], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function assertFullScreenOrMaximized(clients: KwinClient[]) {
|
function assertFullScreenOrMaximized(clients: MockKwinClient[]) {
|
||||||
Assert.assert(!clients[0].fullScreen);
|
Assert.assert(!clients[0].fullScreen);
|
||||||
Assert.equal(clients[0].keepBelow, shouldKeepBelow(true));
|
Assert.equal(clients[0].keepBelow, shouldKeepBelow(true));
|
||||||
Assert.equal(clients[0].keepAbove, shouldKeepAbove(true));
|
Assert.equal(clients[0].keepAbove, shouldKeepAbove(true));
|
||||||
@@ -109,7 +109,7 @@
|
|||||||
Assert.equal(clients[1].keepAbove, shouldKeepAbove(true));
|
Assert.equal(clients[1].keepAbove, shouldKeepAbove(true));
|
||||||
Assert.equal(clients[2].keepBelow, shouldKeepBelow(false));
|
Assert.equal(clients[2].keepBelow, shouldKeepBelow(false));
|
||||||
Assert.equal(clients[2].keepAbove, shouldKeepAbove(false));
|
Assert.equal(clients[2].keepAbove, shouldKeepAbove(false));
|
||||||
Assert.equalRects(clients[2].frameGeometry, screen);
|
Assert.equalRects(clients[2].getActualFrameGeometry(), screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
tests.register("Re-maximize disabled " + suffix, 100, () => {
|
tests.register("Re-maximize disabled " + suffix, 100, () => {
|
||||||
@@ -232,7 +232,7 @@
|
|||||||
Assert.assert(fullScreenClient.fullScreen);
|
Assert.assert(fullScreenClient.fullScreen);
|
||||||
Assert.equal(fullScreenClient.keepBelow, shouldKeepBelow(false));
|
Assert.equal(fullScreenClient.keepBelow, shouldKeepBelow(false));
|
||||||
Assert.equal(fullScreenClient.keepAbove, shouldKeepAbove(false));
|
Assert.equal(fullScreenClient.keepAbove, shouldKeepAbove(false));
|
||||||
Assert.equalRects(fullScreenClient.frameGeometry, screen);
|
Assert.equalRects(fullScreenClient.getActualFrameGeometry(), screen);
|
||||||
Assert.equal(Workspace.activeWindow, fullScreenClient);
|
Assert.equal(Workspace.activeWindow, fullScreenClient);
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -245,7 +245,7 @@
|
|||||||
Assert.assert(fullScreenClient.fullScreen);
|
Assert.assert(fullScreenClient.fullScreen);
|
||||||
Assert.equal(fullScreenClient.keepBelow, shouldKeepBelow(false));
|
Assert.equal(fullScreenClient.keepBelow, shouldKeepBelow(false));
|
||||||
Assert.equal(fullScreenClient.keepAbove, shouldKeepAbove(false));
|
Assert.equal(fullScreenClient.keepAbove, shouldKeepAbove(false));
|
||||||
Assert.equalRects(fullScreenClient.frameGeometry, screen);
|
Assert.equalRects(fullScreenClient.getActualFrameGeometry(), screen);
|
||||||
Assert.equal(Workspace.activeWindow, fullScreenClient, opts);
|
Assert.equal(Workspace.activeWindow, fullScreenClient, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,7 +259,7 @@
|
|||||||
Assert.assert(fullScreenClient.fullScreen);
|
Assert.assert(fullScreenClient.fullScreen);
|
||||||
Assert.equal(fullScreenClient.keepBelow, shouldKeepBelow(false));
|
Assert.equal(fullScreenClient.keepBelow, shouldKeepBelow(false));
|
||||||
Assert.equal(fullScreenClient.keepAbove, shouldKeepAbove(false));
|
Assert.equal(fullScreenClient.keepAbove, shouldKeepAbove(false));
|
||||||
Assert.equalRects(fullScreenClient.frameGeometry, screen);
|
Assert.equalRects(fullScreenClient.getActualFrameGeometry(), screen);
|
||||||
Assert.equal(Workspace.activeWindow, windowedClient);
|
Assert.equal(Workspace.activeWindow, windowedClient);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -288,7 +288,7 @@
|
|||||||
Assert.assert(fullScreenClient.fullScreen);
|
Assert.assert(fullScreenClient.fullScreen);
|
||||||
Assert.equal(fullScreenClient.keepBelow, shouldKeepBelow(false));
|
Assert.equal(fullScreenClient.keepBelow, shouldKeepBelow(false));
|
||||||
Assert.equal(fullScreenClient.keepAbove, shouldKeepAbove(false));
|
Assert.equal(fullScreenClient.keepAbove, shouldKeepAbove(false));
|
||||||
Assert.equalRects(fullScreenClient.frameGeometry, screen);
|
Assert.equalRects(fullScreenClient.getActualFrameGeometry(), screen);
|
||||||
Assert.equal(Workspace.activeWindow, fullScreenClient);
|
Assert.equal(Workspace.activeWindow, fullScreenClient);
|
||||||
|
|
||||||
let expectedColumn2Width = 0;
|
let expectedColumn2Width = 0;
|
||||||
|
|||||||
@@ -22,26 +22,26 @@ tests.register("Pin", 20, () => {
|
|||||||
Assert.grid(config, tilingArea, 100, [ [pinned], [tiled1], [tiled2] ], true);
|
Assert.grid(config, tilingArea, 100, [ [pinned], [tiled1], [tiled2] ], true);
|
||||||
|
|
||||||
pinned.pin(screenHalfLeft);
|
pinned.pin(screenHalfLeft);
|
||||||
Assert.equalRects(pinned.frameGeometry, screenHalfLeft);
|
Assert.equalRects(pinned.getActualFrameGeometry(), screenHalfLeft);
|
||||||
Assert.grid(config, tilingAreaHalfRight, 100, [ [tiled1], [tiled2] ], true);
|
Assert.grid(config, tilingAreaHalfRight, 100, [ [tiled1], [tiled2] ], true);
|
||||||
|
|
||||||
pinned.pin(screenHalfRight);
|
pinned.pin(screenHalfRight);
|
||||||
Assert.equalRects(pinned.frameGeometry, screenHalfRight);
|
Assert.equalRects(pinned.getActualFrameGeometry(), screenHalfRight);
|
||||||
Assert.grid(config, tilingAreaHalfLeft, 100, [ [tiled1], [tiled2] ], true);
|
Assert.grid(config, tilingAreaHalfLeft, 100, [ [tiled1], [tiled2] ], true);
|
||||||
|
|
||||||
pinned.unpin();
|
pinned.unpin();
|
||||||
Assert.equalRects(pinned.frameGeometry, screenHalfRight);
|
Assert.equalRects(pinned.getActualFrameGeometry(), screenHalfRight);
|
||||||
Assert.grid(config, tilingArea, 100, [ [tiled1], [tiled2] ], true);
|
Assert.grid(config, tilingArea, 100, [ [tiled1], [tiled2] ], true);
|
||||||
|
|
||||||
pinned.pin(screenHalfRight);
|
pinned.pin(screenHalfRight);
|
||||||
Assert.equalRects(pinned.frameGeometry, screenHalfRight);
|
Assert.equalRects(pinned.getActualFrameGeometry(), screenHalfRight);
|
||||||
Assert.grid(config, tilingAreaHalfLeft, 100, [ [tiled1], [tiled2] ], true);
|
Assert.grid(config, tilingAreaHalfLeft, 100, [ [tiled1], [tiled2] ], true);
|
||||||
|
|
||||||
pinned.minimized = true;
|
pinned.minimized = true;
|
||||||
Assert.grid(config, tilingArea, 100, [ [tiled1], [tiled2] ], true);
|
Assert.grid(config, tilingArea, 100, [ [tiled1], [tiled2] ], true);
|
||||||
|
|
||||||
pinned.minimized = false;
|
pinned.minimized = false;
|
||||||
Assert.equalRects(pinned.frameGeometry, screenHalfRight);
|
Assert.equalRects(pinned.getActualFrameGeometry(), screenHalfRight);
|
||||||
Assert.grid(config, tilingAreaHalfLeft, 100, [ [tiled1], [tiled2] ], true);
|
Assert.grid(config, tilingAreaHalfLeft, 100, [ [tiled1], [tiled2] ], true);
|
||||||
|
|
||||||
workspaceMock.activeWindow = pinned;
|
workspaceMock.activeWindow = pinned;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
tests.register("Preset Widths default", 1, () => {
|
tests.register("Preset Widths default", 5, () => {
|
||||||
const config = getDefaultConfig();
|
const config = getDefaultConfig();
|
||||||
const { qtMock, workspaceMock, world } = init(config);
|
const { qtMock, workspaceMock, world } = init(config);
|
||||||
|
|
||||||
@@ -7,33 +7,48 @@ tests.register("Preset Widths default", 1, () => {
|
|||||||
|
|
||||||
function getRect(columnWidth: number) {
|
function getRect(columnWidth: number) {
|
||||||
return new MockQmlRect(
|
return new MockQmlRect(
|
||||||
tilingArea.left + (tilingArea.width - columnWidth) / 2,
|
tilingArea.x + (tilingArea.width - columnWidth) / 2,
|
||||||
tilingArea.top,
|
tilingArea.y,
|
||||||
columnWidth,
|
columnWidth,
|
||||||
tilingArea.height,
|
tilingArea.height,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const [kwinClient] = workspaceMock.createClientsWithWidths(300);
|
const [kwinClient] = workspaceMock.createClientsWithWidths(300);
|
||||||
Assert.equalRects(kwinClient.frameGeometry, getRect(300));
|
Assert.equalRects(kwinClient.getActualFrameGeometry(), getRect(300));
|
||||||
|
|
||||||
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
runOneOf(
|
||||||
Assert.equalRects(kwinClient.frameGeometry, getRect(halfWidth));
|
() => qtMock.fireShortcut("karousel-cycle-preset-widths"),
|
||||||
|
() => qtMock.fireShortcut("karousel-column-width-increase"),
|
||||||
|
);
|
||||||
|
Assert.equalRects(kwinClient.getActualFrameGeometry(), getRect(halfWidth));
|
||||||
|
|
||||||
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
runOneOf(
|
||||||
Assert.equalRects(kwinClient.frameGeometry, getRect(maxWidth));
|
() => qtMock.fireShortcut("karousel-cycle-preset-widths"),
|
||||||
|
() => qtMock.fireShortcut("karousel-column-width-increase"),
|
||||||
|
);
|
||||||
|
Assert.equalRects(kwinClient.getActualFrameGeometry(), getRect(maxWidth));
|
||||||
|
|
||||||
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
runOneOf(
|
||||||
Assert.equalRects(kwinClient.frameGeometry, getRect(halfWidth));
|
() => qtMock.fireShortcut("karousel-cycle-preset-widths"),
|
||||||
|
() => qtMock.fireShortcut("karousel-column-width-decrease"),
|
||||||
|
);
|
||||||
|
Assert.equalRects(kwinClient.getActualFrameGeometry(), getRect(halfWidth));
|
||||||
|
|
||||||
qtMock.fireShortcut("karousel-cycle-preset-widths-reverse");
|
runOneOf(
|
||||||
Assert.equalRects(kwinClient.frameGeometry, getRect(maxWidth));
|
() => qtMock.fireShortcut("karousel-cycle-preset-widths"),
|
||||||
|
() => qtMock.fireShortcut("karousel-column-width-increase"),
|
||||||
|
);
|
||||||
|
Assert.equalRects(kwinClient.getActualFrameGeometry(), getRect(maxWidth));
|
||||||
|
|
||||||
qtMock.fireShortcut("karousel-cycle-preset-widths-reverse");
|
runOneOf(
|
||||||
Assert.equalRects(kwinClient.frameGeometry, getRect(halfWidth));
|
() => qtMock.fireShortcut("karousel-cycle-preset-widths"),
|
||||||
|
() => qtMock.fireShortcut("karousel-column-width-decrease"),
|
||||||
|
);
|
||||||
|
Assert.equalRects(kwinClient.getActualFrameGeometry(), getRect(halfWidth));
|
||||||
});
|
});
|
||||||
|
|
||||||
tests.register("Preset Widths custom", 1, () => {
|
tests.register("Preset Widths custom", 5, () => {
|
||||||
const config = getDefaultConfig();
|
const config = getDefaultConfig();
|
||||||
config.presetWidths = "500px, 250px, 100px, 50%";
|
config.presetWidths = "500px, 250px, 100px, 50%";
|
||||||
const { qtMock, workspaceMock, world } = init(config);
|
const { qtMock, workspaceMock, world } = init(config);
|
||||||
@@ -43,39 +58,122 @@ tests.register("Preset Widths custom", 1, () => {
|
|||||||
|
|
||||||
function getRect(columnWidth: number) {
|
function getRect(columnWidth: number) {
|
||||||
return new MockQmlRect(
|
return new MockQmlRect(
|
||||||
tilingArea.left + (tilingArea.width - columnWidth) / 2,
|
tilingArea.x + (tilingArea.width - columnWidth) / 2,
|
||||||
tilingArea.top,
|
tilingArea.y,
|
||||||
columnWidth,
|
columnWidth,
|
||||||
tilingArea.height,
|
tilingArea.height,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const [kwinClient] = workspaceMock.createClientsWithWidths(200);
|
const [kwinClient] = workspaceMock.createClientsWithWidths(200);
|
||||||
Assert.equalRects(kwinClient.frameGeometry, getRect(200));
|
Assert.equalRects(kwinClient.getActualFrameGeometry(), getRect(200));
|
||||||
|
|
||||||
|
runOneOf(
|
||||||
|
() => qtMock.fireShortcut("karousel-cycle-preset-widths"),
|
||||||
|
() => qtMock.fireShortcut("karousel-column-width-increase"),
|
||||||
|
);
|
||||||
|
Assert.equalRects(kwinClient.getActualFrameGeometry(), getRect(250));
|
||||||
|
|
||||||
|
runOneOf(
|
||||||
|
() => qtMock.fireShortcut("karousel-cycle-preset-widths"),
|
||||||
|
() => qtMock.fireShortcut("karousel-column-width-increase"),
|
||||||
|
);
|
||||||
|
Assert.equalRects(kwinClient.getActualFrameGeometry(), getRect(halfWidth));
|
||||||
|
|
||||||
|
runOneOf(
|
||||||
|
() => qtMock.fireShortcut("karousel-cycle-preset-widths"),
|
||||||
|
() => qtMock.fireShortcut("karousel-column-width-increase"),
|
||||||
|
);
|
||||||
|
Assert.equalRects(kwinClient.getActualFrameGeometry(), getRect(500));
|
||||||
|
|
||||||
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
||||||
Assert.equalRects(kwinClient.frameGeometry, getRect(250));
|
Assert.equalRects(kwinClient.getActualFrameGeometry(), getRect(100));
|
||||||
|
|
||||||
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
runOneOf(
|
||||||
Assert.equalRects(kwinClient.frameGeometry, getRect(halfWidth));
|
() => qtMock.fireShortcut("karousel-cycle-preset-widths"),
|
||||||
|
() => qtMock.fireShortcut("karousel-column-width-increase"),
|
||||||
|
);
|
||||||
|
Assert.equalRects(kwinClient.getActualFrameGeometry(), getRect(250));
|
||||||
|
|
||||||
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
runOneOf(
|
||||||
Assert.equalRects(kwinClient.frameGeometry, getRect(500));
|
() => qtMock.fireShortcut("karousel-cycle-preset-widths-reverse"),
|
||||||
|
() => qtMock.fireShortcut("karousel-column-width-decrease"),
|
||||||
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
);
|
||||||
Assert.equalRects(kwinClient.frameGeometry, getRect(100));
|
Assert.equalRects(kwinClient.getActualFrameGeometry(), getRect(100));
|
||||||
|
|
||||||
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
|
||||||
Assert.equalRects(kwinClient.frameGeometry, getRect(250));
|
|
||||||
|
|
||||||
qtMock.fireShortcut("karousel-cycle-preset-widths-reverse");
|
qtMock.fireShortcut("karousel-cycle-preset-widths-reverse");
|
||||||
Assert.equalRects(kwinClient.frameGeometry, getRect(100));
|
Assert.equalRects(kwinClient.getActualFrameGeometry(), getRect(500));
|
||||||
|
|
||||||
|
runOneOf(
|
||||||
|
() => qtMock.fireShortcut("karousel-cycle-preset-widths-reverse"),
|
||||||
|
() => qtMock.fireShortcut("karousel-column-width-decrease"),
|
||||||
|
);
|
||||||
|
Assert.equalRects(kwinClient.getActualFrameGeometry(), getRect(halfWidth));
|
||||||
|
});
|
||||||
|
|
||||||
|
tests.register("Preset Widths custom percentages", 5, () => {
|
||||||
|
const config = getDefaultConfig();
|
||||||
|
config.presetWidths = "25%, 50%, 75%, 100%";
|
||||||
|
const { qtMock, workspaceMock, world } = init(config);
|
||||||
|
|
||||||
|
const width100 = tilingArea.width;
|
||||||
|
const width75 = width100*0.75 - config.gapsInnerHorizontal*0.25;
|
||||||
|
const width50 = width100*0.50 - config.gapsInnerHorizontal*0.50;
|
||||||
|
const width25 = width100*0.25 - config.gapsInnerHorizontal*0.75;
|
||||||
|
|
||||||
|
function getRect(columnWidth: number) {
|
||||||
|
return new MockQmlRect(
|
||||||
|
tilingArea.x + (tilingArea.width - columnWidth) / 2,
|
||||||
|
tilingArea.y,
|
||||||
|
columnWidth,
|
||||||
|
tilingArea.height,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const [kwinClient] = workspaceMock.createClientsWithWidths(200);
|
||||||
|
Assert.equalRects(kwinClient.getActualFrameGeometry(), getRect(200));
|
||||||
|
|
||||||
|
runOneOf(
|
||||||
|
() => qtMock.fireShortcut("karousel-cycle-preset-widths"),
|
||||||
|
() => qtMock.fireShortcut("karousel-column-width-increase"),
|
||||||
|
);
|
||||||
|
Assert.equalRects(kwinClient.getActualFrameGeometry(), getRect(width50));
|
||||||
|
|
||||||
|
runOneOf(
|
||||||
|
() => qtMock.fireShortcut("karousel-cycle-preset-widths"),
|
||||||
|
() => qtMock.fireShortcut("karousel-column-width-increase"),
|
||||||
|
);
|
||||||
|
Assert.equalRects(kwinClient.getActualFrameGeometry(), getRect(width75));
|
||||||
|
|
||||||
|
runOneOf(
|
||||||
|
() => qtMock.fireShortcut("karousel-cycle-preset-widths"),
|
||||||
|
() => qtMock.fireShortcut("karousel-column-width-increase"),
|
||||||
|
);
|
||||||
|
Assert.equalRects(kwinClient.getActualFrameGeometry(), getRect(width100));
|
||||||
|
|
||||||
|
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
||||||
|
Assert.equalRects(kwinClient.getActualFrameGeometry(), getRect(width25));
|
||||||
|
|
||||||
qtMock.fireShortcut("karousel-cycle-preset-widths-reverse");
|
qtMock.fireShortcut("karousel-cycle-preset-widths-reverse");
|
||||||
Assert.equalRects(kwinClient.frameGeometry, getRect(500));
|
Assert.equalRects(kwinClient.getActualFrameGeometry(), getRect(width100));
|
||||||
|
|
||||||
qtMock.fireShortcut("karousel-cycle-preset-widths-reverse");
|
runOneOf(
|
||||||
Assert.equalRects(kwinClient.frameGeometry, getRect(halfWidth));
|
() => qtMock.fireShortcut("karousel-cycle-preset-widths-reverse"),
|
||||||
|
() => qtMock.fireShortcut("karousel-column-width-decrease"),
|
||||||
|
);
|
||||||
|
Assert.equalRects(kwinClient.getActualFrameGeometry(), getRect(width75));
|
||||||
|
|
||||||
|
runOneOf(
|
||||||
|
() => qtMock.fireShortcut("karousel-cycle-preset-widths-reverse"),
|
||||||
|
() => qtMock.fireShortcut("karousel-column-width-decrease"),
|
||||||
|
);
|
||||||
|
Assert.equalRects(kwinClient.getActualFrameGeometry(), getRect(width50));
|
||||||
|
|
||||||
|
runOneOf(
|
||||||
|
() => qtMock.fireShortcut("karousel-cycle-preset-widths-reverse"),
|
||||||
|
() => qtMock.fireShortcut("karousel-column-width-decrease"),
|
||||||
|
);
|
||||||
|
Assert.equalRects(kwinClient.getActualFrameGeometry(), getRect(width25));
|
||||||
});
|
});
|
||||||
|
|
||||||
tests.register("Preset Widths fill screen uniform", 1, () => {
|
tests.register("Preset Widths fill screen uniform", 1, () => {
|
||||||
@@ -96,12 +194,12 @@ tests.register("Preset Widths fill screen uniform", 1, () => {
|
|||||||
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
qtMock.fireShortcut("karousel-cycle-preset-widths");
|
||||||
}
|
}
|
||||||
|
|
||||||
const left = tilingArea.left;
|
const left = tilingArea.x;
|
||||||
const right = tilingArea.right;
|
const right = rectRight(tilingArea);
|
||||||
const maxLeftoverPx = nColumns - 1;
|
const maxLeftoverPx = nColumns - 1;
|
||||||
const eps = Math.ceil(maxLeftoverPx / 2);
|
const eps = Math.ceil(maxLeftoverPx / 2);
|
||||||
Assert.between(firstClient!.frameGeometry.left, left, left+eps, { message: `nColumns: ${nColumns}` });
|
Assert.between(firstClient!.getActualFrameGeometry().x, left, left+eps, { message: `nColumns: ${nColumns}` });
|
||||||
Assert.between(lastClient!.frameGeometry.right, right-eps, right, { message: `nColumns: ${nColumns}` });
|
Assert.between(rectRight(lastClient!.getActualFrameGeometry()), right-eps, right, { message: `nColumns: ${nColumns}` });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -123,12 +221,12 @@ tests.register("Preset Widths fill screen non-uniform", 1, () => {
|
|||||||
const halfWidth = maxWidth/2 - config.gapsInnerHorizontal/2;
|
const halfWidth = maxWidth/2 - config.gapsInnerHorizontal/2;
|
||||||
const quarterWidth = halfWidth/2 - config.gapsInnerHorizontal/2;
|
const quarterWidth = halfWidth/2 - config.gapsInnerHorizontal/2;
|
||||||
const height = tilingArea.height;
|
const height = tilingArea.height;
|
||||||
const left1 = tilingArea.left;
|
const left1 = tilingArea.x;
|
||||||
const left2 = left1 + config.gapsInnerHorizontal + quarterWidth;
|
const left2 = left1 + config.gapsInnerHorizontal + quarterWidth;
|
||||||
const left3 = left2 + config.gapsInnerHorizontal + quarterWidth;
|
const left3 = left2 + config.gapsInnerHorizontal + quarterWidth;
|
||||||
|
|
||||||
Assert.rect(clientThin1.frameGeometry, left1, tilingArea.top, quarterWidth, height);
|
Assert.rect(clientThin1.getActualFrameGeometry(), left1, tilingArea.y, quarterWidth, height);
|
||||||
Assert.rect(clientThin2.frameGeometry, left2, tilingArea.top, quarterWidth, height);
|
Assert.rect(clientThin2.getActualFrameGeometry(), left2, tilingArea.y, quarterWidth, height);
|
||||||
Assert.rect(clientWide.frameGeometry, left3, tilingArea.top, halfWidth, height);
|
Assert.rect(clientWide.getActualFrameGeometry(), left3, tilingArea.y, halfWidth, height);
|
||||||
Assert.equal(clientWide.frameGeometry.right, tilingArea.right);
|
Assert.equal(rectRight(clientWide.getActualFrameGeometry()), rectRight(tilingArea));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ tests.register("User resize", 10, () => {
|
|||||||
let clientLeft: MockKwinClient, clientRightTop: MockKwinClient, clientRightBottom: MockKwinClient;
|
let clientLeft: MockKwinClient, clientRightTop: MockKwinClient, clientRightBottom: MockKwinClient;
|
||||||
function assertSizes(leftWidth: number, rightWidth: number, topHeight: number, bottomHeight: number) {
|
function assertSizes(leftWidth: number, rightWidth: number, topHeight: number, bottomHeight: number) {
|
||||||
const { left, right } = getGridBounds(clientLeft, clientRightTop);
|
const { left, right } = getGridBounds(clientLeft, clientRightTop);
|
||||||
Assert.rect(clientLeft.frameGeometry, left, tilingArea.top, leftWidth, tilingArea.height);
|
Assert.rect(clientLeft.getActualFrameGeometry(), left, tilingArea.y, leftWidth, tilingArea.height);
|
||||||
Assert.rect(clientRightTop.frameGeometry, left+leftWidth+gapH, tilingArea.top, rightWidth, topHeight);
|
Assert.rect(clientRightTop.getActualFrameGeometry(), left+leftWidth+gapH, tilingArea.y, rightWidth, topHeight);
|
||||||
Assert.rect(clientRightBottom.frameGeometry, left+leftWidth+gapH, tilingArea.top+topHeight+gapV, rightWidth, bottomHeight);
|
Assert.rect(clientRightBottom.getActualFrameGeometry(), left+leftWidth+gapH, tilingArea.y+topHeight+gapV, rightWidth, bottomHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -89,9 +89,9 @@ tests.register("User resize", 10, () => {
|
|||||||
|
|
||||||
function assertSizes(leftWidth: number, rightWidth: number, topHeight: number, bottomHeight: number) {
|
function assertSizes(leftWidth: number, rightWidth: number, topHeight: number, bottomHeight: number) {
|
||||||
const { left, right } = getGridBounds(clientLeftTop, clientRight);
|
const { left, right } = getGridBounds(clientLeftTop, clientRight);
|
||||||
Assert.rect(clientLeftTop.frameGeometry, left, tilingArea.top, leftWidth, topHeight);
|
Assert.rect(clientLeftTop.getActualFrameGeometry(), left, tilingArea.y, leftWidth, topHeight);
|
||||||
Assert.rect(clientLeftBottom.frameGeometry, left, tilingArea.top+topHeight+gapV, leftWidth, bottomHeight);
|
Assert.rect(clientLeftBottom.getActualFrameGeometry(), left, tilingArea.y+topHeight+gapV, leftWidth, bottomHeight);
|
||||||
Assert.rect(clientRight.frameGeometry, left+leftWidth+gapH, tilingArea.top, rightWidth, tilingArea.height);
|
Assert.rect(clientRight.getActualFrameGeometry(), left+leftWidth+gapH, tilingArea.y, rightWidth, tilingArea.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
workspaceMock.activeWindow = clientLeftBottom;
|
workspaceMock.activeWindow = clientLeftBottom;
|
||||||
|
|||||||
41
src/tests/units/rules/DesktopFilter.ts
Normal file
41
src/tests/units/rules/DesktopFilter.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
tests.register("DesktopFilter", 1, () => {
|
||||||
|
const desktop1 = { __brand: "KwinDesktop" as const, id: "1", name: "Desktop 1" };
|
||||||
|
const desktop2 = { __brand: "KwinDesktop" as const, id: "2", name: "Work" };
|
||||||
|
const desktop3 = { __brand: "KwinDesktop" as const, id: "3", name: "Desktop 2" };
|
||||||
|
|
||||||
|
// Test 1: Empty config means all desktops
|
||||||
|
let filter = new DesktopFilter("");
|
||||||
|
Assert.assert(filter.shouldWorkOnDesktop(desktop1), { message: "Empty config should work on desktop1" });
|
||||||
|
Assert.assert(filter.shouldWorkOnDesktop(desktop2), { message: "Empty config should work on desktop2" });
|
||||||
|
|
||||||
|
// Test 2: Whitespace only means all desktops
|
||||||
|
filter = new DesktopFilter(" \n \n ");
|
||||||
|
Assert.assert(filter.shouldWorkOnDesktop(desktop1), { message: "Whitespace only should work on desktop1" });
|
||||||
|
Assert.assert(filter.shouldWorkOnDesktop(desktop2), { message: "Whitespace only should work on desktop2" });
|
||||||
|
|
||||||
|
// Test 3: Match all regex pattern
|
||||||
|
filter = new DesktopFilter(".*");
|
||||||
|
Assert.assert(filter.shouldWorkOnDesktop(desktop1), { message: "Regex '.*' should work on desktop1" });
|
||||||
|
Assert.assert(filter.shouldWorkOnDesktop(desktop2), { message: "Regex '.*' should work on desktop2" });
|
||||||
|
|
||||||
|
// Test 4: Partial match without anchors
|
||||||
|
filter = new DesktopFilter("Work");
|
||||||
|
Assert.assert(!filter.shouldWorkOnDesktop(desktop1), { message: "Should not work on desktop1" });
|
||||||
|
Assert.assert(filter.shouldWorkOnDesktop(desktop2), { message: "Should work on desktop2 containing 'Work'" });
|
||||||
|
|
||||||
|
// Test 5: Regex alternation for multiple desktops
|
||||||
|
filter = new DesktopFilter("Desktop 1|Work");
|
||||||
|
Assert.assert(filter.shouldWorkOnDesktop(desktop1), { message: "Should work on desktop1" });
|
||||||
|
Assert.assert(filter.shouldWorkOnDesktop(desktop2), { message: "Should work on desktop2" });
|
||||||
|
Assert.assert(!filter.shouldWorkOnDesktop(desktop3), { message: "Should not work on desktop3" });
|
||||||
|
|
||||||
|
// Test 6: Regex pattern with character class
|
||||||
|
filter = new DesktopFilter("Desktop [12]");
|
||||||
|
Assert.assert(filter.shouldWorkOnDesktop(desktop1), { message: "Should work on desktop1" });
|
||||||
|
Assert.assert(!filter.shouldWorkOnDesktop(desktop2), { message: "Should not work on desktop2" });
|
||||||
|
Assert.assert(filter.shouldWorkOnDesktop(desktop3), { message: "Should work on desktop3" });
|
||||||
|
|
||||||
|
// Test 7: Case-sensitive matching
|
||||||
|
filter = new DesktopFilter("work");
|
||||||
|
Assert.assert(!filter.shouldWorkOnDesktop(desktop2), { message: "Should not work on desktop2 (case mismatch)" });
|
||||||
|
});
|
||||||
@@ -127,7 +127,7 @@ namespace Assert {
|
|||||||
config: Config,
|
config: Config,
|
||||||
tilingArea: QmlRect,
|
tilingArea: QmlRect,
|
||||||
columnWidths: number[] | number,
|
columnWidths: number[] | number,
|
||||||
grid: KwinClient[][],
|
grid: MockKwinClient[][],
|
||||||
centered: boolean,
|
centered: boolean,
|
||||||
stackedColumns: number[] = [],
|
stackedColumns: number[] = [],
|
||||||
{ message, skip=0 }: Options = {},
|
{ message, skip=0 }: Options = {},
|
||||||
@@ -161,7 +161,7 @@ namespace Assert {
|
|||||||
const gridWidth = getGridWidth();
|
const gridWidth = getGridWidth();
|
||||||
const startX = centered ?
|
const startX = centered ?
|
||||||
tilingArea.x + (tilingArea.width - gridWidth) / 2 :
|
tilingArea.x + (tilingArea.width - gridWidth) / 2 :
|
||||||
grid[0][0].frameGeometry.x;
|
grid[0][0].getActualFrameGeometry().x;
|
||||||
|
|
||||||
function getColumnX(column: number) {
|
function getColumnX(column: number) {
|
||||||
if (columnWidths instanceof Array) {
|
if (columnWidths instanceof Array) {
|
||||||
@@ -205,7 +205,7 @@ namespace Assert {
|
|||||||
for (let iWindow = 0; iWindow < nWindows; iWindow++) {
|
for (let iWindow = 0; iWindow < nWindows; iWindow++) {
|
||||||
const window = column[iWindow];
|
const window = column[iWindow];
|
||||||
equalRects(
|
equalRects(
|
||||||
window.frameGeometry,
|
window.getActualFrameGeometry(),
|
||||||
getRect(iColumn, iWindow, nColumns, nWindows),
|
getRect(iColumn, iWindow, nColumns, nWindows),
|
||||||
{ message: appendMessage(`column ${iColumn}, window ${iWindow}`, message), skip: skip+1 },
|
{ message: appendMessage(`column ${iColumn}, window ${iWindow}`, message), skip: skip+1 },
|
||||||
);
|
);
|
||||||
@@ -216,13 +216,13 @@ namespace Assert {
|
|||||||
export function centered(
|
export function centered(
|
||||||
config: Config,
|
config: Config,
|
||||||
tilingArea: QmlRect,
|
tilingArea: QmlRect,
|
||||||
client:KwinClient,
|
client:MockKwinClient,
|
||||||
{ message, skip=0 }: Options = {},
|
{ message, skip=0 }: Options = {},
|
||||||
) {
|
) {
|
||||||
grid(
|
grid(
|
||||||
config,
|
config,
|
||||||
tilingArea,
|
tilingArea,
|
||||||
client.frameGeometry.width,
|
client.getActualFrameGeometry().width,
|
||||||
[[client]],
|
[[client]],
|
||||||
true,
|
true,
|
||||||
[],
|
[],
|
||||||
@@ -235,7 +235,7 @@ namespace Assert {
|
|||||||
{ message, skip=0 }: Options = {},
|
{ message, skip=0 }: Options = {},
|
||||||
) {
|
) {
|
||||||
assert(
|
assert(
|
||||||
rect.left >= tilingArea.left && rect.right <= tilingArea.right,
|
rect.x >= tilingArea.x && rectRight(rect) <= rectRight(tilingArea),
|
||||||
{
|
{
|
||||||
message: appendMessage(`Rect ${rect} not fully visible`, message),
|
message: appendMessage(`Rect ${rect} not fully visible`, message),
|
||||||
skip: skip + 1,
|
skip: skip + 1,
|
||||||
@@ -248,7 +248,7 @@ namespace Assert {
|
|||||||
{ message, skip=0 }: Options = {},
|
{ message, skip=0 }: Options = {},
|
||||||
) {
|
) {
|
||||||
assert(
|
assert(
|
||||||
rect.left < tilingArea.left || rect.right > tilingArea.right,
|
rect.x < tilingArea.x || rectRight(rect) > rectRight(tilingArea),
|
||||||
{
|
{
|
||||||
message: appendMessage(`Rect ${rect} is fully visible, but shouldn't be`, message),
|
message: appendMessage(`Rect ${rect} is fully visible, but shouldn't be`, message),
|
||||||
skip: skip + 1,
|
skip: skip + 1,
|
||||||
@@ -257,18 +257,18 @@ namespace Assert {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function columnsFillTilingArea(
|
export function columnsFillTilingArea(
|
||||||
columns: KwinClient[],
|
columns: MockKwinClient[],
|
||||||
{ message, skip=0 }: Options = {},
|
{ message, skip=0 }: Options = {},
|
||||||
) {
|
) {
|
||||||
const options = { message: message, skip: skip+1 };
|
const options = { message: message, skip: skip+1 };
|
||||||
let x = tilingArea.left;
|
let x = tilingArea.x;
|
||||||
for (const column of columns) {
|
for (const column of columns) {
|
||||||
const width = column.frameGeometry.width;
|
const width = column.getActualFrameGeometry().width;
|
||||||
fullyVisible(column.frameGeometry, options);
|
fullyVisible(column.getActualFrameGeometry(), options);
|
||||||
rect(column.frameGeometry, x, tilingArea.top, width, tilingArea.height, options);
|
rect(column.getActualFrameGeometry(), x, tilingArea.y, width, tilingArea.height, options);
|
||||||
x += width + gapH;
|
x += width + gapH;
|
||||||
}
|
}
|
||||||
equal(columns[columns.length-1].frameGeometry.right, tilingArea.right, options);
|
equal(rectRight(columns[columns.length-1].getActualFrameGeometry()), rectRight(tilingArea), options);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function tiledClient(
|
export function tiledClient(
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ let Qt: Qt;
|
|||||||
let KWin: KWin;
|
let KWin: KWin;
|
||||||
let Workspace: Workspace;
|
let Workspace: Workspace;
|
||||||
let qmlBase: QmlObject;
|
let qmlBase: QmlObject;
|
||||||
|
let notificationInvalidTiledDesktops: Notification;
|
||||||
let notificationInvalidWindowRules: Notification;
|
let notificationInvalidWindowRules: Notification;
|
||||||
let notificationInvalidPresetWidths: Notification;
|
let notificationInvalidPresetWidths: Notification;
|
||||||
let moveCursorToFocus: DBusCall;
|
let moveCursorToFocus: DBusCall;
|
||||||
@@ -33,7 +34,7 @@ function init(config: Config) {
|
|||||||
__brand: "QmlObject",
|
__brand: "QmlObject",
|
||||||
call: () => {
|
call: () => {
|
||||||
Assert.assert(Workspace.activeWindow !== null, { message: "moveCursorToFocus should never be called if there's no focused window" });
|
Assert.assert(Workspace.activeWindow !== null, { message: "moveCursorToFocus should never be called if there's no focused window" });
|
||||||
const frame = Workspace.activeWindow!.frameGeometry;
|
const frame = (Workspace.activeWindow! as MockKwinClient).getActualFrameGeometry();
|
||||||
workspaceMock.cursorPos.x = Math.floor(frame.x + frame.width/2);
|
workspaceMock.cursorPos.x = Math.floor(frame.x + frame.width/2);
|
||||||
workspaceMock.cursorPos.y = Math.floor(frame.y + frame.height/2);
|
workspaceMock.cursorPos.y = Math.floor(frame.y + frame.height/2);
|
||||||
},
|
},
|
||||||
@@ -43,9 +44,9 @@ function init(config: Config) {
|
|||||||
return { qtMock, workspaceMock, world };
|
return { qtMock, workspaceMock, world };
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGridBounds(clientLeft: KwinClient, clientRight: KwinClient) {
|
function getGridBounds(clientLeft: MockKwinClient, clientRight: MockKwinClient) {
|
||||||
const columnsWidth = clientRight.frameGeometry.right - clientLeft.frameGeometry.left;
|
const columnsWidth = rectRight(clientRight.getActualFrameGeometry()) - clientLeft.getActualFrameGeometry().x;
|
||||||
const left = tilingArea.left + Math.floor((tilingArea.width - columnsWidth) / 2);
|
const left = tilingArea.x + Math.floor((tilingArea.width - columnsWidth) / 2);
|
||||||
const right = left + columnsWidth;
|
const right = left + columnsWidth;
|
||||||
return { left, right };
|
return { left, right };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class MockKwinClient {
|
|||||||
private static readonly borderThickness = 10;
|
private static readonly borderThickness = 10;
|
||||||
|
|
||||||
public caption = "App";
|
public caption = "App";
|
||||||
public minSize: Readonly<QmlSize> = new MockQmlSize(0, 0);
|
public minSize: Readonly<QmlSize> = new MockQmlSize(randomJitter(), randomJitter());
|
||||||
public readonly transient: boolean;
|
public readonly transient: boolean;
|
||||||
public move = false;
|
public move = false;
|
||||||
public resize = false;
|
public resize = false;
|
||||||
@@ -52,6 +52,7 @@ class MockKwinClient {
|
|||||||
this.windowedFrameGeometry = _frameGeometry.clone();
|
this.windowedFrameGeometry = _frameGeometry.clone();
|
||||||
this.transient = transientFor !== null;
|
this.transient = transientFor !== null;
|
||||||
this._desktops = [Workspace.currentDesktop];
|
this._desktops = [Workspace.currentDesktop];
|
||||||
|
this.activities = [Workspace.currentActivity];
|
||||||
}
|
}
|
||||||
|
|
||||||
setMaximize(vertically: boolean, horizontally: boolean) {
|
setMaximize(vertically: boolean, horizontally: boolean) {
|
||||||
@@ -159,10 +160,22 @@ class MockKwinClient {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public get frameGeometry() {
|
// for assertions
|
||||||
|
public getActualFrameGeometry() {
|
||||||
return this._frameGeometry;
|
return this._frameGeometry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// for Karousel
|
||||||
|
public get frameGeometry() {
|
||||||
|
return new MockQmlRect(
|
||||||
|
this._frameGeometry.x + randomJitter(),
|
||||||
|
this._frameGeometry.y + randomJitter(),
|
||||||
|
this._frameGeometry.width + randomJitter(),
|
||||||
|
this._frameGeometry.height + randomJitter(),
|
||||||
|
this.frameGeometryChanged.fire.bind(this.frameGeometryChanged),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public set frameGeometry(frameGeometry: MockQmlRect) {
|
public set frameGeometry(frameGeometry: MockQmlRect) {
|
||||||
const oldFrameGeometry = this._frameGeometry;
|
const oldFrameGeometry = this._frameGeometry;
|
||||||
this._frameGeometry = new MockQmlRect(
|
this._frameGeometry = new MockQmlRect(
|
||||||
|
|||||||
@@ -49,22 +49,6 @@ class MockQmlRect {
|
|||||||
this.onChanged(oldRect);
|
this.onChanged(oldRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
public get top() {
|
|
||||||
return this.y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public get bottom() {
|
|
||||||
return this.y + this.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
public get left() {
|
|
||||||
return this.x;
|
|
||||||
}
|
|
||||||
|
|
||||||
public get right() {
|
|
||||||
return this.x + this.width;
|
|
||||||
}
|
|
||||||
|
|
||||||
public set(target: QmlRect) {
|
public set(target: QmlRect) {
|
||||||
const oldRect = this.clone();
|
const oldRect = this.clone();
|
||||||
this._x = target.x;
|
this._x = target.x;
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ class MockWorkspace {
|
|||||||
|
|
||||||
public activities = ["test-activity"];
|
public activities = ["test-activity"];
|
||||||
public desktops: KwinDesktop[] = [
|
public desktops: KwinDesktop[] = [
|
||||||
{ __brand: "KwinDesktop", id: "desktop1" },
|
{ __brand: "KwinDesktop", id: "desktop1", name: "Desktop 1" },
|
||||||
{ __brand: "KwinDesktop", id: "desktop2" },
|
{ __brand: "KwinDesktop", id: "desktop2", name: "Desktop 2" },
|
||||||
];
|
];
|
||||||
public currentActivity = this.activities[0];
|
public currentActivity = this.activities[0];
|
||||||
public activeScreen: Output = { __brand: "Output" };
|
public activeScreen: Output = { __brand: "Output" };
|
||||||
@@ -75,7 +75,7 @@ class MockWorkspace {
|
|||||||
frame.y += delta.y;
|
frame.y += delta.y;
|
||||||
}
|
}
|
||||||
runOneOf(
|
runOneOf(
|
||||||
() => window.frameGeometry.set(frame),
|
() => window.getActualFrameGeometry().set(frame),
|
||||||
() => window.frameGeometry = frame,
|
() => window.frameGeometry = frame,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -88,8 +88,8 @@ class MockWorkspace {
|
|||||||
const frame = window.getFrameGeometryCopy();
|
const frame = window.getFrameGeometryCopy();
|
||||||
if (edgeResize) {
|
if (edgeResize) {
|
||||||
this.cursorPos = new MockQmlPoint(
|
this.cursorPos = new MockQmlPoint(
|
||||||
leftEdge ? frame.left : frame.right,
|
leftEdge ? frame.x : rectRight(frame),
|
||||||
topEdge ? frame.top : frame.bottom,
|
topEdge ? frame.y : rectBottom(frame),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
this.cursorPos = new MockQmlPoint(
|
this.cursorPos = new MockQmlPoint(
|
||||||
@@ -114,7 +114,7 @@ class MockWorkspace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
runOneOf(
|
runOneOf(
|
||||||
() => window.frameGeometry.set(frame),
|
() => window.getActualFrameGeometry().set(frame),
|
||||||
() => window.frameGeometry = frame,
|
() => window.frameGeometry = frame,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,14 @@ function runReorderDebug(order: number[], ...fs: (() => void)[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function randomJitter() {
|
||||||
|
if (Math.random() < 0.25) {
|
||||||
|
return (Math.random() - 0.5) * 0.5;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function randomInt(n: number) {
|
function randomInt(n: number) {
|
||||||
return Math.floor(Math.random() * n);
|
return Math.floor(Math.random() * n);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user