Compare commits
361 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
47f4bbd9b6 | ||
|
|
2d4ad73d16 | ||
|
|
bb4e4f8ebd | ||
|
|
0742975334 | ||
|
|
64457429d0 | ||
|
|
02154f2f5e | ||
|
|
0a2bb4f65d | ||
|
|
6f207e59c4 | ||
|
|
4c987b6c5b | ||
|
|
bca0158df9 | ||
|
|
9feeb0f23e | ||
|
|
0241846ea5 | ||
|
|
3bf3f16f49 | ||
|
|
782a6db56d | ||
|
|
93b6850ffd | ||
|
|
5f0c637d1a | ||
|
|
8829d0b291 | ||
|
|
d37b4bc5d1 | ||
|
|
ead29e5e69 | ||
|
|
ff75d931f6 | ||
|
|
d00d514d30 | ||
|
|
3b919909dc | ||
|
|
0004b6f921 | ||
|
|
24265c56f9 | ||
|
|
dcbc0a474d | ||
|
|
88f170f5c1 | ||
|
|
78ab48ee09 | ||
|
|
b2d81796f8 | ||
|
|
7d27331ce5 | ||
|
|
55e1037a7b | ||
|
|
7820c7d00e | ||
|
|
3d8ca0bc14 | ||
|
|
eaf68b87f9 | ||
|
|
b2dfad6042 | ||
|
|
054808cb38 | ||
|
|
97059fa4f7 | ||
|
|
5e7959c7f4 | ||
|
|
a9c3aa7eae | ||
|
|
3aec148f16 | ||
|
|
c60cfeb521 | ||
|
|
0bbf82d84d | ||
|
|
44c5c43c25 | ||
|
|
98b2d8b882 | ||
|
|
4e78d27620 | ||
|
|
32700d1193 | ||
|
|
817351ec44 | ||
|
|
c2dd832e5c | ||
|
|
2f78f9afb1 | ||
|
|
2cc716f59e | ||
|
|
685323546a | ||
|
|
c8e40185dc | ||
|
|
0b0cb77e9e | ||
|
|
ce4f810372 | ||
|
|
3ccc6dd870 | ||
|
|
92e1c2ffd4 | ||
|
|
3a1c911974 | ||
|
|
e197c3200e | ||
|
|
4fea81423a | ||
|
|
b459ba6d4e | ||
|
|
a16e2edb1e | ||
|
|
fb1047c8ba | ||
|
|
66bc14287d | ||
|
|
86ab4a20f4 | ||
|
|
f467d5a523 | ||
|
|
082d4571d8 | ||
|
|
aa061e586e | ||
|
|
ff5121f1c4 | ||
|
|
984edbec90 | ||
|
|
ea27ce4a03 | ||
|
|
ae0a4e142a | ||
|
|
09b7b44e2c | ||
|
|
fb88300dbe | ||
|
|
9dafb92f47 | ||
|
|
92144e8e83 | ||
|
|
9b54dd543e | ||
|
|
5145b04cb7 | ||
|
|
4372e13869 | ||
|
|
7694bb1f8d | ||
|
|
3615952bd7 | ||
|
|
cba6ecbb3d | ||
|
|
db55af462b | ||
|
|
32f384df75 | ||
|
|
25ac6d4ce8 | ||
|
|
194f774519 | ||
|
|
430f731804 | ||
|
|
2cdf308a72 | ||
|
|
acf4c5c6ae | ||
|
|
703ed2eb40 | ||
|
|
ec5e7002dc | ||
|
|
fe92b1aa13 | ||
|
|
d812fa706f | ||
|
|
0bb9ae9e8d | ||
|
|
315ea6b560 | ||
|
|
a4236534fc | ||
|
|
e95378c0dd | ||
|
|
884dc9977d | ||
|
|
f3cf45e5f3 | ||
|
|
5e7f191e95 | ||
|
|
ec14d5295f | ||
|
|
116372c954 | ||
|
|
7290a0741d | ||
|
|
5bbd0da172 | ||
|
|
fb415042d8 | ||
|
|
ff5ba6b455 | ||
|
|
ef0e840812 | ||
|
|
b0cb9eaba0 | ||
|
|
0eb624d6ff | ||
|
|
6e53bbad2f | ||
|
|
218ab65d61 | ||
|
|
e91c9c825e | ||
|
|
c2931c9fbe | ||
|
|
1c61f22353 | ||
|
|
3ff7688e42 | ||
|
|
f5ca5e71c0 | ||
|
|
3f222f0ef8 | ||
|
|
9a08841bb8 | ||
|
|
2081b9997c | ||
|
|
93fe2a3cfd | ||
|
|
9cee3f2808 | ||
|
|
16618e6ad3 | ||
|
|
90c27bc58b | ||
|
|
79055dcdf3 | ||
|
|
1e328c7b57 | ||
|
|
2be6a04fc4 | ||
|
|
9b21a720be | ||
|
|
fcfed28a0a | ||
|
|
7dce802b70 | ||
|
|
94393393f5 | ||
|
|
1ba128af05 | ||
|
|
8094b64ce7 | ||
|
|
335418e84b | ||
|
|
c675fc63d1 | ||
|
|
9d81262b18 | ||
|
|
5d36f02631 | ||
|
|
977facbed7 | ||
|
|
278a2d9c7b | ||
|
|
8076635719 | ||
|
|
c8f0ed87a4 | ||
|
|
b3f581c386 | ||
|
|
279333dd1d | ||
|
|
dac1d488b7 | ||
|
|
df587fc37b | ||
|
|
987a4c852f | ||
|
|
ebff074a4c | ||
|
|
ef4c509e75 | ||
|
|
d0c1438724 | ||
|
|
d926be2e12 | ||
|
|
b18516646d | ||
|
|
b0405858c5 | ||
|
|
0cb3513532 | ||
|
|
0b2d876074 | ||
|
|
cb1b70d4f0 | ||
|
|
da6b983e4a | ||
|
|
6181057fa8 | ||
|
|
abc8671c6f | ||
|
|
36bf942266 | ||
|
|
d239ac24b3 | ||
|
|
79571146be | ||
|
|
7273196e0c | ||
|
|
212ade5ab6 | ||
|
|
239f8d95cb | ||
|
|
e430a20638 | ||
|
|
0beaebd874 | ||
|
|
6100090db3 | ||
|
|
8d07958962 | ||
|
|
80bafee5ed | ||
|
|
38e72a9504 | ||
|
|
d0c4cee63d | ||
|
|
494192179b | ||
|
|
0dcba7cbc0 | ||
|
|
8312364202 | ||
|
|
6d8dfad4e7 | ||
|
|
0d970a8bec | ||
|
|
12e8d71ef3 | ||
|
|
407b24df08 | ||
|
|
4ecced369a | ||
|
|
e3979d94f7 | ||
|
|
b6a5080d5d | ||
|
|
e974f0ebbd | ||
|
|
23e13436d8 | ||
|
|
aaef587c00 | ||
|
|
8f4c20138e | ||
|
|
a754da9b78 | ||
|
|
b94d3e2304 | ||
|
|
11e1458180 | ||
|
|
e7e68628dd | ||
|
|
edac1a679c | ||
|
|
f711248619 | ||
|
|
502f4bee26 | ||
|
|
35d2096811 | ||
|
|
f682c160db | ||
|
|
ef9cb01755 | ||
|
|
d51b9caec5 | ||
|
|
62bc96f205 | ||
|
|
35802eead7 | ||
|
|
ba886fe5f6 | ||
|
|
30e4e3e273 | ||
|
|
6bcb30b0bd | ||
|
|
747a90f5d7 | ||
|
|
da899171c4 | ||
|
|
109238e645 | ||
|
|
7d1ebcf126 | ||
|
|
07ce0cceb5 | ||
|
|
c7aaa66c5c | ||
|
|
5c77f4f276 | ||
|
|
80608e721f | ||
|
|
54b07ebe56 | ||
|
|
aeba236720 | ||
|
|
1984442ed3 | ||
|
|
2a4c5eac3b | ||
|
|
266beb85ae | ||
|
|
5877e466da | ||
|
|
9a60f94eda | ||
|
|
0f7092a5b6 | ||
|
|
0b3608a530 | ||
|
|
aaeac977e6 | ||
|
|
adc78f11bc | ||
|
|
f1206b18b1 | ||
|
|
c6066c354d | ||
|
|
914202f091 | ||
|
|
b85c86e7db | ||
|
|
fdb4b88333 | ||
|
|
4e3d924366 | ||
|
|
3d3e8cff17 | ||
|
|
a79229da75 | ||
|
|
53d04c1d33 | ||
|
|
a18ff61d9e | ||
|
|
99ffad9223 | ||
|
|
e776df509b | ||
|
|
63de2d4cae | ||
|
|
85d361f16f | ||
|
|
f3b75807be | ||
|
|
88bce26456 | ||
|
|
3a75ddab0f | ||
|
|
ee0aa93308 | ||
|
|
33ca138420 | ||
|
|
79f4aaeef8 | ||
|
|
0aca6e1146 | ||
|
|
28e54434aa | ||
|
|
ee14509228 | ||
|
|
1596edc43f | ||
|
|
b897ab5b9f | ||
|
|
5e6dad8459 | ||
|
|
beeba74442 | ||
|
|
3e14440180 | ||
|
|
36836ad258 | ||
|
|
bebc009cc6 | ||
|
|
a4ba8516dc | ||
|
|
675a70d907 | ||
|
|
3ba66f1c89 | ||
|
|
4556198b2e | ||
|
|
7b8de5955d | ||
|
|
68a687b7d4 | ||
|
|
20a3ece4b5 | ||
|
|
3cad8102ee | ||
|
|
7fd45eed8f | ||
|
|
7299341608 | ||
|
|
842ec1ac63 | ||
|
|
0523465b84 | ||
|
|
c7cfa261b9 | ||
|
|
56955e4df3 | ||
|
|
bb308cfbfb | ||
|
|
6c00245943 | ||
|
|
2efdbe5a7b | ||
|
|
092cbf3ff1 | ||
|
|
f9ae299ce8 | ||
|
|
695f5edf6a | ||
|
|
9b80b535a1 | ||
|
|
752df86db5 | ||
|
|
f05eefe19b | ||
|
|
f550285778 | ||
|
|
5247a6a0d3 | ||
|
|
2b114a63dc | ||
|
|
63e4015f3a | ||
|
|
02db31266b | ||
|
|
67d4d89700 | ||
|
|
755cf90b1a | ||
|
|
e6a01217a5 | ||
|
|
21d7bbd6c4 | ||
|
|
605215acdc | ||
|
|
4b6808dba1 | ||
|
|
f9749c6f56 | ||
|
|
9b40b2f777 | ||
|
|
33470b4d7b | ||
|
|
8947719621 | ||
|
|
4bf4f8e8a1 | ||
|
|
080de7cf97 | ||
|
|
c29902dc15 | ||
|
|
1736b0a398 | ||
|
|
a1c44647ca | ||
|
|
0ea75d6348 | ||
|
|
12901e45ce | ||
|
|
29b4ccd1dd | ||
|
|
7b547bc5b8 | ||
|
|
78a127111b | ||
|
|
333b7601b2 | ||
|
|
1927ae445d | ||
|
|
1f563dae01 | ||
|
|
6b82eedbfe | ||
|
|
b479735130 | ||
|
|
c8f022d66f | ||
|
|
7f71750a8e | ||
|
|
13ebf24732 | ||
|
|
ec6b3247b7 | ||
|
|
50681d3a07 | ||
|
|
af930a9b2f | ||
|
|
489a1447e7 | ||
|
|
b984f025ec | ||
|
|
4e1204f1bd | ||
|
|
bbcf51783d | ||
|
|
019da3766e | ||
|
|
1535c994b8 | ||
|
|
296d0deca9 | ||
|
|
17e7d5b46e | ||
|
|
840a50d14d | ||
|
|
4f99c4dd45 | ||
|
|
030eddaf34 | ||
|
|
7246a7660e | ||
|
|
687256d1dd | ||
|
|
12bb7506cc | ||
|
|
1808ee0025 | ||
|
|
3021f61933 | ||
|
|
e908138478 | ||
|
|
99ad115370 | ||
|
|
c5a4238f5f | ||
|
|
0670d9c265 | ||
|
|
845874b0d0 | ||
|
|
a422a077f6 | ||
|
|
2fe1be99cb | ||
|
|
1a449c238d | ||
|
|
9bda7d1a09 | ||
|
|
2ce72bcee8 | ||
|
|
ff3f6c5d6b | ||
|
|
3ab230b498 | ||
|
|
ba9f362a1c | ||
|
|
ad6c3f1cae | ||
|
|
ba4dd2a9c1 | ||
|
|
bb61853009 | ||
|
|
0cfd9b9e36 | ||
|
|
43c4f7ef9a | ||
|
|
9cb3f33ecb | ||
|
|
31b9e61ae3 | ||
|
|
668e6696ab | ||
|
|
e63959cfbf | ||
|
|
ef2650beb8 | ||
|
|
750c47c040 | ||
|
|
88ca0d02e1 | ||
|
|
aba786b754 | ||
|
|
47aa625c99 | ||
|
|
03c7cc6503 | ||
|
|
9e9ff2b74f | ||
|
|
5674624e6f | ||
|
|
44dd88ef7c | ||
|
|
f800d6ecf0 | ||
|
|
3477e17bb3 | ||
|
|
755c781646 | ||
|
|
926345ba31 | ||
|
|
a2295ede43 | ||
|
|
ca80a7ca28 | ||
|
|
64474b1677 | ||
|
|
eca63cbc16 |
19
.github/ISSUE_TEMPLATE/1-compatibility-issue.md
vendored
Normal file
19
.github/ISSUE_TEMPLATE/1-compatibility-issue.md
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
name: Compatibility issue
|
||||||
|
about: Report an issue with a specific application or window
|
||||||
|
title: "[Compatibility]"
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Karousel version:
|
||||||
|
Plasma version:
|
||||||
|
X11 / Wayland:
|
||||||
|
|
||||||
|
Window class:
|
||||||
|
Window caption (title):
|
||||||
|
Window type:
|
||||||
|
(Get this info [here](https://github.com/peterfajdiga/karousel/wiki/Getting-window-info))
|
||||||
|
|
||||||
|
Description:
|
||||||
14
.github/ISSUE_TEMPLATE/2-bug-report.md
vendored
Normal file
14
.github/ISSUE_TEMPLATE/2-bug-report.md
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
name: Generic bug report
|
||||||
|
about: Report a bug
|
||||||
|
title: "[Bug]"
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Karousel version:
|
||||||
|
Plasma version:
|
||||||
|
X11 / Wayland:
|
||||||
|
|
||||||
|
Description:
|
||||||
22
.github/ISSUE_TEMPLATE/3-feature_request.md
vendored
Normal file
22
.github/ISSUE_TEMPLATE/3-feature_request.md
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Request a feature
|
||||||
|
title: "[Feature]"
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Is your feature request related to a problem? Please describe.**
|
||||||
|
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||||
|
|
||||||
|
**Describe the solution you'd like**
|
||||||
|
A clear and concise description of what you want to happen.
|
||||||
|
|
||||||
|
**Describe alternatives you've considered**
|
||||||
|
A clear and concise description of any alternative solutions or features you've considered.
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context or screenshots about the feature request here.
|
||||||
|
|
||||||
|
These sections are just guidelines, feel free to remove them.
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,4 +1,5 @@
|
|||||||
/package/contents/code/main.js
|
/package/contents/code/main.js
|
||||||
/package/contents/config/main.xml
|
/package/contents/config/main.xml
|
||||||
/karousel.tar.gz
|
/karousel*.tar.gz
|
||||||
|
run-ts-tmp.js
|
||||||
/.idea
|
/.idea
|
||||||
|
|||||||
37
Makefile
37
Makefile
@@ -1,31 +1,32 @@
|
|||||||
|
VERSION = $(shell grep '"Version":' ./package/metadata.json | grep -o '[0-9\.]*')
|
||||||
|
TESTS := true
|
||||||
|
|
||||||
.PHONY: *
|
.PHONY: *
|
||||||
|
|
||||||
TSC_SCRIPT_FLAGS = --lib es2020 ./src/extern/qt.d.ts
|
build: tests
|
||||||
|
tsc -p ./src/main --outFile ./package/contents/code/main.js
|
||||||
config:
|
|
||||||
mkdir -p ./package/contents/config
|
mkdir -p ./package/contents/config
|
||||||
tsc ${TSC_SCRIPT_FLAGS} ./src/config/definition.ts ./generators/config/kcfg.ts --outFile /dev/stdout | node - > ./package/contents/config/main.xml
|
./run-ts.sh ./src/generators/config > ./package/contents/config/main.xml
|
||||||
|
|
||||||
build:
|
tests:
|
||||||
tsc --outFile ./package/contents/code/main.js
|
ifeq (${TESTS}, true)
|
||||||
|
./run-ts.sh ./src/tests
|
||||||
|
endif
|
||||||
|
|
||||||
install: build config
|
install: build
|
||||||
kpackagetool5 --type=KWin/Script -i ./package || kpackagetool5 --type=KWin/Script -u ./package
|
kpackagetool6 --type=KWin/Script --install=./package || kpackagetool6 --type=KWin/Script --upgrade=./package
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
kpackagetool5 --type=KWin/Script -r ./package
|
kpackagetool6 --type=KWin/Script --remove=karousel
|
||||||
|
|
||||||
package:
|
package: build
|
||||||
tar -czf ./karousel.tar.gz ./package
|
tar -czf ./karousel_${subst .,_,${VERSION}}.tar.gz ./package --transform s/package/karousel/
|
||||||
|
|
||||||
logs:
|
|
||||||
journalctl -t kwin_x11 -g '^qml:|^file://.*karousel' -f
|
|
||||||
|
|
||||||
docs-key-bindings-bbcode:
|
docs-key-bindings-bbcode:
|
||||||
@tsc ${TSC_SCRIPT_FLAGS} ./src/keyBindings/definition.ts ./generators/docs/keyBindings.ts ./generators/docs/keyBindingsBbcode.ts --outFile /dev/stdout | node -
|
@./run-ts.sh ./src/generators/docs/keyBindingsBbcode
|
||||||
|
|
||||||
docs-key-bindings-table:
|
docs-key-bindings-markdown:
|
||||||
@tsc ${TSC_SCRIPT_FLAGS} ./src/keyBindings/definition.ts ./generators/docs/keyBindings.ts ./generators/docs/keyBindingsTable.ts --outFile /dev/stdout | node -
|
@./run-ts.sh ./src/generators/docs/keyBindingsMarkdown
|
||||||
|
|
||||||
docs-key-bindings-fmt:
|
docs-key-bindings-fmt:
|
||||||
@tsc ${TSC_SCRIPT_FLAGS} ./src/keyBindings/definition.ts ./generators/docs/keyBindings.ts ./generators/docs/keyBindingsFmt.ts --outFile /dev/stdout | node -
|
@./run-ts.sh ./src/generators/docs/keyBindingsFmt
|
||||||
|
|||||||
33
README.md
33
README.md
@@ -1,24 +1,19 @@
|
|||||||
# Karousel
|
# Karousel
|
||||||
KWin tiling script with scrolling. Works especially well with ultrawide screens.
|
Scrollable tiling Kwin script. Works especially well with ultrawide screens.
|
||||||
Use with [this](https://github.com/peterfajdiga/kwin4_effect_geometry_change) for animations.
|
Use with [this](https://github.com/peterfajdiga/kwin4_effect_geometry_change) for animations.
|
||||||
|
|
||||||
https://github.com/peterfajdiga/karousel/assets/22796326/2ab62d18-09c7-45f9-8fda-e5e36b8d7a02
|
https://github.com/peterfajdiga/karousel/assets/22796326/2ab62d18-09c7-45f9-8fda-e5e36b8d7a02
|
||||||
|
|
||||||
Karousel works differently from most tiling window managers in that it does not maximize the width
|
A scrollable tiling window manager tiles windows, but it does not maximize their widths. Instead, it leaves the width of windows to the user's control.
|
||||||
of windows, as this can be undesirable with wider screens, where it results in excessively wide
|
Windows are automatically centered when possible. And when running out of width, windows can be scrolled through horizontally.
|
||||||
windows that require large return sweeps when reading their content.
|
|
||||||
Instead, it leaves the width of windows to the user's control. This additionally prevents
|
|
||||||
unprompted reflow of window content.
|
|
||||||
|
|
||||||
Windows are automatically centered when possible. And when running out of width, windows can be
|
Similar window managers include [PaperWM](https://github.com/paperwm/PaperWM),
|
||||||
scrolled through horizontally.
|
[Niri](https://github.com/YaLTeR/niri), and
|
||||||
|
|
||||||
Similar window managers include [PaperWM](https://github.com/paperwm/PaperWM) and
|
|
||||||
[Cardboard](https://gitlab.com/cardboardwm/cardboard).
|
[Cardboard](https://gitlab.com/cardboardwm/cardboard).
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
Karousel requires the following QML modules:
|
Karousel requires the following QML modules:
|
||||||
- QtQuick 2.15
|
- QtQuick 6.0
|
||||||
- org.kde.kwin 3.0
|
- org.kde.kwin 3.0
|
||||||
- org.kde.notification 1.0
|
- org.kde.notification 1.0
|
||||||
|
|
||||||
@@ -27,6 +22,13 @@ Karousel requires the following QML modules:
|
|||||||
- Doesn't support windows on all desktops
|
- Doesn't support windows on all desktops
|
||||||
- Doesn't support windows on multiple activities
|
- Doesn't support windows on multiple activities
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
First install the _org.kde.notification_ QML module (_qml-module-org-kde-notifications_ package on Ubuntu).
|
||||||
|
|
||||||
|
Then download the [latest release](https://github.com/peterfajdiga/karousel/releases/latest) and extract it into _~/.local/share/kwin/scripts/_.
|
||||||
|
|
||||||
|
Or clone the repo and run `make install` (requires node and tsc).
|
||||||
|
|
||||||
## Key bindings
|
## Key bindings
|
||||||
The key bindings can be configured in KDE System Settings among KWin's own keyboard shortcuts.
|
The key bindings can be configured in KDE System Settings among KWin's own keyboard shortcuts.
|
||||||
Here's the default ones:
|
Here's the default ones:
|
||||||
@@ -37,12 +39,16 @@ Here's the default ones:
|
|||||||
| Meta+D | Move focus right (Clashes with default KDE shortcuts, may require manual remapping) |
|
| Meta+D | Move focus right (Clashes with default KDE shortcuts, may require manual remapping) |
|
||||||
| Meta+W | Move focus up (Clashes with default KDE shortcuts, may require manual remapping) |
|
| Meta+W | Move focus up (Clashes with default KDE shortcuts, may require manual remapping) |
|
||||||
| Meta+S | Move focus down (Clashes with default KDE shortcuts, may require manual remapping) |
|
| Meta+S | Move focus down (Clashes with default KDE shortcuts, may require manual remapping) |
|
||||||
|
| (unassigned) | Move focus to the next window in grid |
|
||||||
|
| (unassigned) | Move focus to the previous window in grid |
|
||||||
| Meta+Home | Move focus to start |
|
| Meta+Home | Move focus to start |
|
||||||
| Meta+End | Move focus to end |
|
| Meta+End | Move focus to end |
|
||||||
| Meta+Shift+A | Move window left (Moves window out of and into columns) |
|
| Meta+Shift+A | Move window left (Moves window out of and into columns) |
|
||||||
| Meta+Shift+D | Move window right (Moves window out of and into columns) |
|
| Meta+Shift+D | Move window right (Moves window out of and into columns) |
|
||||||
| Meta+Shift+W | Move window up |
|
| Meta+Shift+W | Move window up |
|
||||||
| Meta+Shift+S | Move window down |
|
| Meta+Shift+S | Move window down |
|
||||||
|
| (unassigned) | Move window to the next position in grid |
|
||||||
|
| (unassigned) | Move window to the previous position in grid |
|
||||||
| Meta+Shift+Home | Move window to start |
|
| Meta+Shift+Home | Move window to start |
|
||||||
| Meta+Shift+End | Move window to end |
|
| Meta+Shift+End | Move window to end |
|
||||||
| Meta+X | Toggle stacked layout for focused column (One window in the column visible, others shaded; not supported on Wayland) |
|
| Meta+X | Toggle stacked layout for focused column (One window in the column visible, others shaded; not supported on Wayland) |
|
||||||
@@ -52,6 +58,10 @@ Here's the default ones:
|
|||||||
| Meta+Ctrl+Shift+End | Move column to end |
|
| Meta+Ctrl+Shift+End | Move column to end |
|
||||||
| Meta+Ctrl++ | Increase column width |
|
| Meta+Ctrl++ | Increase column width |
|
||||||
| Meta+Ctrl+- | Decrease column width |
|
| Meta+Ctrl+- | Decrease column width |
|
||||||
|
| Meta+R | Cycle through preset column widths |
|
||||||
|
| Meta+Ctrl+X | Equalize widths of visible columns |
|
||||||
|
| Meta+Ctrl+A | Squeeze left column onto the screen (Clashes with default KDE shortcuts, may require manual remapping) |
|
||||||
|
| Meta+Ctrl+D | Squeeze right column onto the screen |
|
||||||
| Meta+Alt+Return | Center focused window (Scrolls so that the focused window is centered in the screen) |
|
| Meta+Alt+Return | Center focused window (Scrolls so that the focused window is centered in the screen) |
|
||||||
| Meta+Alt+A | Scroll one column to the left |
|
| Meta+Alt+A | Scroll one column to the left |
|
||||||
| Meta+Alt+D | Scroll one column to the right |
|
| Meta+Alt+D | Scroll one column to the right |
|
||||||
@@ -59,6 +69,7 @@ Here's the default ones:
|
|||||||
| Meta+Alt+PgDown | Scroll right |
|
| Meta+Alt+PgDown | Scroll right |
|
||||||
| Meta+Alt+Home | Scroll to start |
|
| Meta+Alt+Home | Scroll to start |
|
||||||
| Meta+Alt+End | Scroll to end |
|
| Meta+Alt+End | Scroll to end |
|
||||||
|
| Meta+Ctrl+Return | Move Karousel grid to the current screen |
|
||||||
| Meta+[N] | Move focus to column N (Clashes with default KDE shortcuts, may require manual remapping) |
|
| Meta+[N] | Move focus to column N (Clashes with default KDE shortcuts, may require manual remapping) |
|
||||||
| Meta+Shift+[N] | Move window to column N (Requires manual remapping according to your keyboard layout, e.g. Meta+Shift+1 -> Meta+!) |
|
| Meta+Shift+[N] | Move window to column N (Requires manual remapping according to your keyboard layout, e.g. Meta+Shift+1 -> Meta+!) |
|
||||||
| Meta+Ctrl+Shift+[N] | Move column to position N (Requires manual remapping according to your keyboard layout, e.g. Meta+Ctrl+Shift+1 -> Meta+Ctrl+!) |
|
| Meta+Ctrl+Shift+[N] | Move column to position N (Requires manual remapping according to your keyboard layout, e.g. Meta+Ctrl+Shift+1 -> Meta+Ctrl+!) |
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
console.log(`[list]`);
|
|
||||||
|
|
||||||
for (const binding of keyBindings) {
|
|
||||||
console.log(` [*] ${binding.defaultKeySequence} — ${binding.description}${formatComment(binding.comment)}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const binding of numKeyBindings) {
|
|
||||||
const numPrefix = binding.fKeys ? "F" : "";
|
|
||||||
console.log(` [*] ${binding.defaultModifiers}+${numPrefix}[N] — ${binding.description}N${formatComment(binding.comment)}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(`[/list]`);
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
const colLeft = [
|
|
||||||
...keyBindings.map((binding: KeyBinding) => binding.defaultKeySequence),
|
|
||||||
...numKeyBindings.map((binding: NumKeyBinding) => {
|
|
||||||
const numPrefix = binding.fKeys ? "F" : "";
|
|
||||||
return `${binding.defaultModifiers}+${numPrefix}[N]`;
|
|
||||||
}),
|
|
||||||
];
|
|
||||||
|
|
||||||
const colRight = [
|
|
||||||
...keyBindings.map((binding: KeyBinding) => `${binding.description}${formatComment(binding.comment)}`),
|
|
||||||
...numKeyBindings.map((binding: NumKeyBinding) => `${binding.description}N${formatComment(binding.comment)}`),
|
|
||||||
];
|
|
||||||
|
|
||||||
printCols(colLeft, " ", colRight);
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
const colLeft = [
|
|
||||||
"Shortcut",
|
|
||||||
"---",
|
|
||||||
...keyBindings.map((binding: KeyBinding) => binding.defaultKeySequence),
|
|
||||||
...numKeyBindings.map((binding: NumKeyBinding) => {
|
|
||||||
const numPrefix = binding.fKeys ? "F" : "";
|
|
||||||
return `${binding.defaultModifiers}+${numPrefix}[N]`;
|
|
||||||
}),
|
|
||||||
];
|
|
||||||
|
|
||||||
const colRight = [
|
|
||||||
"Action",
|
|
||||||
"---",
|
|
||||||
...keyBindings.map((binding: KeyBinding) => `${binding.description}${formatComment(binding.comment)}`),
|
|
||||||
...numKeyBindings.map((binding: NumKeyBinding) => `${binding.description}N${formatComment(binding.comment)}`),
|
|
||||||
];
|
|
||||||
|
|
||||||
printCols("| ", colLeft, " | ", colRight, " |");
|
|
||||||
@@ -11,6 +11,143 @@
|
|||||||
<layout class="QVBoxLayout" name="layout_main">
|
<layout class="QVBoxLayout" name="layout_main">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="tabContainer">
|
<widget class="QTabWidget" name="tabContainer">
|
||||||
|
<widget class="QWidget" name="tab_behavior">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Behavior</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox">
|
||||||
|
<property name="flat">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="kcfg_untileOnDrag">
|
||||||
|
<property name="text">
|
||||||
|
<string>Un-tile windows by dragging them</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="kcfg_stackColumnsByDefault">
|
||||||
|
<property name="text">
|
||||||
|
<string>Stack columns by default</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>New columns start in stacked mode (one window in the column visible, others shaded). Not supported on Wayland.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="kcfg_resizeNeighborColumn">
|
||||||
|
<property name="text">
|
||||||
|
<string>Resize neighbor column on edge resize</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>When resizing a column by dragging its edge, also inversely resize the column on the other side of the edge</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="kcfg_reMaximize">
|
||||||
|
<property name="text">
|
||||||
|
<string>Re-maximize tiled windows</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Restore maximized and full-screen states of tiled windows on focus</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="kcfg_skipSwitcher">
|
||||||
|
<property name="text">
|
||||||
|
<string>Tiled windows skip switcher</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Scrolling mode</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="kcfg_scrollingLazy">
|
||||||
|
<property name="text">
|
||||||
|
<string>Only scroll as necessary</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="kcfg_scrollingCentered">
|
||||||
|
<property name="text">
|
||||||
|
<string>Center focused column</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="kcfg_scrollingGrouped">
|
||||||
|
<property name="text">
|
||||||
|
<string>Center visible columns</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Layering mode</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="kcfg_tiledKeepBelow">
|
||||||
|
<property name="text">
|
||||||
|
<string>Keep tiled windows below</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="kcfg_floatingKeepAbove">
|
||||||
|
<property name="text">
|
||||||
|
<string>Keep floating windows above</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QRadioButton" name="kcfg_noLayering">
|
||||||
|
<property name="text">
|
||||||
|
<string>No layering</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<spacer name="spacer_footer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
|
||||||
<widget class="QWidget" name="tab_parameters">
|
<widget class="QWidget" name="tab_parameters">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Parameters</string>
|
<string>Parameters</string>
|
||||||
@@ -143,14 +280,14 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item row="6" column="0">
|
<item row="6" column="0">
|
||||||
<widget class="QLabel" name="label_overscroll">
|
<widget class="QLabel" name="label_manualScrollStep">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Overscroll amount:</string>
|
<string>Manual scroll step size:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="1">
|
<item row="6" column="1">
|
||||||
<widget class="QSpinBox" name="kcfg_overscroll">
|
<widget class="QSpinBox" name="kcfg_manualScrollStep">
|
||||||
<property name="suffix">
|
<property name="suffix">
|
||||||
<string> px</string>
|
<string> px</string>
|
||||||
</property>
|
</property>
|
||||||
@@ -164,22 +301,19 @@
|
|||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item row="7" column="0">
|
<item row="7" column="0">
|
||||||
<widget class="QLabel" name="label_manualScrollStep">
|
<widget class="QLabel" name="label_presetWidths">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Manual scroll step size:</string>
|
<string>Preset widths:</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Widths used for cycling through widths</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="1">
|
<item row="7" column="1">
|
||||||
<widget class="QSpinBox" name="kcfg_manualScrollStep">
|
<widget class="QLineEdit" name="kcfg_presetWidths">
|
||||||
<property name="suffix">
|
<property name="toolTip">
|
||||||
<string> px</string>
|
<string>Comma-separated list of widths. Supported units: "px" and "%".</string>
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>999</number>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -207,136 +341,6 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
||||||
<widget class="QWidget" name="tab_behavior">
|
|
||||||
<attribute name="title">
|
|
||||||
<string>Behavior</string>
|
|
||||||
</attribute>
|
|
||||||
<layout class="QVBoxLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox">
|
|
||||||
<property name="flat">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="kcfg_untileOnDrag">
|
|
||||||
<property name="text">
|
|
||||||
<string>Un-tile windows by dragging them</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="kcfg_stackColumnsByDefault">
|
|
||||||
<property name="text">
|
|
||||||
<string>Stack columns by default</string>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>New columns start in stacked mode (one window in the column visible, others shaded). Not supported on Wayland.</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="kcfg_resizeNeighborColumn">
|
|
||||||
<property name="text">
|
|
||||||
<string>Resize neighbor column on edge resize</string>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>When resizing a column by dragging its edge, also inversely resize the column on the other side of the edge</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="kcfg_reMaximize">
|
|
||||||
<property name="text">
|
|
||||||
<string>Re-maximize tiled windows</string>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Restore maximized and full-screen states of tiled windows on focus</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="kcfg_skipSwitcher">
|
|
||||||
<property name="text">
|
|
||||||
<string>Tiled windows skip switcher</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox">
|
|
||||||
<property name="title">
|
|
||||||
<string>Scrolling mode</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QRadioButton" name="kcfg_scrollingLazy">
|
|
||||||
<property name="text">
|
|
||||||
<string>Only scroll as necessary</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QRadioButton" name="kcfg_scrollingCentered">
|
|
||||||
<property name="text">
|
|
||||||
<string>Center focused column</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QRadioButton" name="kcfg_scrollingGrouped">
|
|
||||||
<property name="text">
|
|
||||||
<string>Prevent needlessly obscuring columns</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox">
|
|
||||||
<property name="title">
|
|
||||||
<string>Layering mode</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QRadioButton" name="kcfg_tiledKeepBelow">
|
|
||||||
<property name="text">
|
|
||||||
<string>Keep tiled windows below</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QRadioButton" name="kcfg_floatingKeepAbove">
|
|
||||||
<property name="text">
|
|
||||||
<string>Keep floating windows above</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
|
|
||||||
<item>
|
|
||||||
<spacer name="spacer_footer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
|
|
||||||
<widget class="QWidget" name="tab_windowRules">
|
<widget class="QWidget" name="tab_windowRules">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Window Rules</string>
|
<string>Window Rules</string>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import QtQuick 2.15
|
import QtQuick 6.0
|
||||||
import org.kde.kwin 3.0
|
import org.kde.kwin 3.0
|
||||||
import org.kde.notification 1.0
|
import org.kde.notification 1.0
|
||||||
import "./main.js" as Karousel
|
import "../code/main.js" as Karousel
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: qmlBase
|
id: qmlBase
|
||||||
@@ -25,4 +25,14 @@ Item {
|
|||||||
flags: Notification.Persistent
|
flags: Notification.Persistent
|
||||||
urgency: Notification.HighUrgency
|
urgency: Notification.HighUrgency
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Notification {
|
||||||
|
id: notificationInvalidPresetWidths
|
||||||
|
componentName: "plasma_workspace"
|
||||||
|
eventId: "notification"
|
||||||
|
title: "Karousel"
|
||||||
|
text: "Your preset widths are malformed, please review your Karousel configuration"
|
||||||
|
flags: Notification.Persistent
|
||||||
|
urgency: Notification.HighUrgency
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,20 +1,21 @@
|
|||||||
{
|
{
|
||||||
|
"KPackageStructure": "KWin/Script",
|
||||||
"KPlugin": {
|
"KPlugin": {
|
||||||
"Name": "Karousel",
|
"Name": "Karousel",
|
||||||
"Description": "Manual columnar tiling extension for KWin",
|
"Description": "Scrollable tiling extension for KWin",
|
||||||
"Icon": "preferences-system-windows",
|
"Icon": "preferences-system-windows",
|
||||||
"Authors": [{
|
"Authors": [{
|
||||||
"Email": "peter.fajdiga@gmail.com",
|
"Email": "peter.fajdiga@gmail.com",
|
||||||
"Name": "Peter Fajdiga"
|
"Name": "Peter Fajdiga"
|
||||||
}],
|
}],
|
||||||
"Id": "karousel",
|
"Id": "karousel",
|
||||||
"ServiceTypes": ["KWin/Script"],
|
"Version": "0.11",
|
||||||
"Version": "0.6",
|
|
||||||
"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"
|
||||||
},
|
},
|
||||||
"X-Plasma-API": "declarativescript",
|
"X-Plasma-API": "declarativescript",
|
||||||
"X-Plasma-MainScript": "code/main.qml",
|
"X-Plasma-API-Minimum-Version": "6.0",
|
||||||
|
"X-Plasma-MainScript": "ui/main.qml",
|
||||||
"X-KDE-ConfigModule": "kwin/effects/configs/kcm_kwin4_genericscripted"
|
"X-KDE-ConfigModule": "kwin/effects/configs/kcm_kwin4_genericscripted"
|
||||||
}
|
}
|
||||||
|
|||||||
8
run-ts.sh
Executable file
8
run-ts.sh
Executable file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
JS_FILE='./run-ts-tmp.js'
|
||||||
|
|
||||||
|
tsc -p "$1" --outFile "$JS_FILE"
|
||||||
|
node "$JS_FILE"
|
||||||
329
src/Actions.ts
329
src/Actions.ts
@@ -1,329 +0,0 @@
|
|||||||
namespace Actions {
|
|
||||||
export function init(world: World, config: Config) {
|
|
||||||
return {
|
|
||||||
focusLeft: () => {
|
|
||||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
|
||||||
const prevColumn = grid.getPrevColumn(column);
|
|
||||||
if (prevColumn === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
prevColumn.focus();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
focusRight: () => {
|
|
||||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
|
||||||
const nextColumn = grid.getNextColumn(column);
|
|
||||||
if (nextColumn === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
nextColumn.focus();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
focusUp: () => {
|
|
||||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
|
||||||
const prevWindow = column.getPrevWindow(window);
|
|
||||||
if (prevWindow === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
prevWindow.focus();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
focusDown: () => {
|
|
||||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
|
||||||
const nextWindow = column.getNextWindow(window);
|
|
||||||
if (nextWindow === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
nextWindow.focus();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
focusStart: () => {
|
|
||||||
world.do((clientManager, desktopManager) => {
|
|
||||||
const grid = desktopManager.getCurrentDesktop().grid;
|
|
||||||
const firstColumn = grid.getFirstColumn();
|
|
||||||
if (firstColumn === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
firstColumn.focus();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
focusEnd: () => {
|
|
||||||
world.do((clientManager, desktopManager) => {
|
|
||||||
const grid = desktopManager.getCurrentDesktop().grid;
|
|
||||||
const lastColumn = grid.getLastColumn();
|
|
||||||
if (lastColumn === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
lastColumn.focus();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
windowMoveLeft: () => {
|
|
||||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
|
||||||
if (column.getWindowCount() === 1) {
|
|
||||||
// move from own column into existing column
|
|
||||||
const prevColumn = grid.getPrevColumn(column);
|
|
||||||
if (prevColumn === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
window.moveToColumn(prevColumn);
|
|
||||||
grid.desktop.autoAdjustScroll();
|
|
||||||
} else {
|
|
||||||
// move from shared column into own column
|
|
||||||
const newColumn = new Column(grid, grid.getPrevColumn(column));
|
|
||||||
window.moveToColumn(newColumn);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
windowMoveRight: () => {
|
|
||||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
|
||||||
if (column.getWindowCount() === 1) {
|
|
||||||
// move from own column into existing column
|
|
||||||
const nextColumn = grid.getNextColumn(column);
|
|
||||||
if (nextColumn === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
window.moveToColumn(nextColumn);
|
|
||||||
grid.desktop.autoAdjustScroll();
|
|
||||||
} else {
|
|
||||||
// move from shared column into own column
|
|
||||||
const newColumn = new Column(grid, column);
|
|
||||||
window.moveToColumn(newColumn);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
windowMoveUp: () => {
|
|
||||||
// TODO (optimization): only arrange moved windows
|
|
||||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
|
||||||
column.moveWindowUp(window);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
windowMoveDown: () => {
|
|
||||||
// TODO (optimization): only arrange moved windows
|
|
||||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
|
||||||
column.moveWindowDown(window);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
windowMoveStart: () => {
|
|
||||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
|
||||||
const newColumn = new Column(grid, null);
|
|
||||||
window.moveToColumn(newColumn);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
windowMoveEnd: () => {
|
|
||||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
|
||||||
const newColumn = new Column(grid, grid.getLastColumn());
|
|
||||||
window.moveToColumn(newColumn);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
windowToggleFloating: () => {
|
|
||||||
const kwinClient = workspace.activeClient;
|
|
||||||
world.do((clientManager, desktopManager) => {
|
|
||||||
clientManager.toggleFloatingClient(kwinClient);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
columnMoveLeft: () => {
|
|
||||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
|
||||||
grid.moveColumnLeft(column);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
columnMoveRight: () => {
|
|
||||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
|
||||||
grid.moveColumnRight(column);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
columnMoveStart: () => {
|
|
||||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
|
||||||
column.moveAfter(null);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
columnMoveEnd: () => {
|
|
||||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
|
||||||
column.moveAfter(grid.getLastColumn());
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
columnToggleStacked: () => {
|
|
||||||
world.doIfTiledFocused(false, (world, desktopManager, window, column, grid) => {
|
|
||||||
column.toggleStacked();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
columnWidthIncrease: () => {
|
|
||||||
world.doIfTiledFocused(false, (world, desktopManager, window, column, grid) => {
|
|
||||||
grid.increaseColumnWidth(column);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
columnWidthDecrease: () => {
|
|
||||||
world.doIfTiledFocused(false, (world, desktopManager, window, column, grid) => {
|
|
||||||
grid.decreaseColumnWidth(column);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
columnsWidthEqualize: () => {
|
|
||||||
world.do((clientManager, desktopManager) => {
|
|
||||||
desktopManager.getCurrentDesktop().equalizeVisibleColumnsWidths();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
gridScrollLeft: () => {
|
|
||||||
gridScroll(world, -config.manualScrollStep);
|
|
||||||
},
|
|
||||||
|
|
||||||
gridScrollRight: () => {
|
|
||||||
gridScroll(world, config.manualScrollStep);
|
|
||||||
},
|
|
||||||
|
|
||||||
gridScrollStart: () => {
|
|
||||||
world.do((clientManager, desktopManager) => {
|
|
||||||
const grid = desktopManager.getCurrentDesktop().grid;
|
|
||||||
const firstColumn = grid.getFirstColumn();
|
|
||||||
if (firstColumn === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
grid.desktop.scrollToColumn(firstColumn);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
gridScrollEnd: () => {
|
|
||||||
world.do((clientManager, desktopManager) => {
|
|
||||||
const grid = desktopManager.getCurrentDesktop().grid;
|
|
||||||
const lastColumn = grid.getLastColumn();
|
|
||||||
if (lastColumn === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
grid.desktop.scrollToColumn(lastColumn);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
gridScrollFocused: () => {
|
|
||||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
|
||||||
grid.desktop.scrollCenterRange(column);
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
gridScrollLeftColumn: () => {
|
|
||||||
world.do((clientManager, desktopManager) => {
|
|
||||||
const grid = desktopManager.getCurrentDesktop().grid;
|
|
||||||
const column = grid.getLeftmostVisibleColumn(grid.desktop.getCurrentVisibleRange(), true);
|
|
||||||
if (column === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const prevColumn = grid.getPrevColumn(column);
|
|
||||||
if (prevColumn === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
grid.desktop.scrollToColumn(prevColumn);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
gridScrollRightColumn: () => {
|
|
||||||
world.do((clientManager, desktopManager) => {
|
|
||||||
const grid = desktopManager.getCurrentDesktop().grid;
|
|
||||||
const column = grid.getRightmostVisibleColumn(grid.desktop.getCurrentVisibleRange(), true);
|
|
||||||
if (column === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const nextColumn = grid.getNextColumn(column);
|
|
||||||
if (nextColumn === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
grid.desktop.scrollToColumn(nextColumn);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function initNum(world: World) {
|
|
||||||
return {
|
|
||||||
focusColumn: (columnIndex: number) => {
|
|
||||||
world.do((clientManager, desktopManager) => {
|
|
||||||
const grid = desktopManager.getCurrentDesktop().grid;
|
|
||||||
const targetColumn = grid.getColumnAtIndex(columnIndex);
|
|
||||||
if (targetColumn === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
targetColumn.focus();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
windowMoveToColumn: (columnIndex: number) => {
|
|
||||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
|
||||||
const targetColumn = grid.getColumnAtIndex(columnIndex);
|
|
||||||
if (targetColumn === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
window.moveToColumn(targetColumn);
|
|
||||||
grid.desktop.autoAdjustScroll();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
columnMoveToColumn: (columnIndex: number) => {
|
|
||||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
|
||||||
const targetColumn = grid.getColumnAtIndex(columnIndex);
|
|
||||||
if (targetColumn === null || targetColumn === column) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (targetColumn.isAfter(column)) {
|
|
||||||
column.moveAfter(targetColumn);
|
|
||||||
} else {
|
|
||||||
column.moveAfter(grid.getPrevColumn(targetColumn));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
columnMoveToDesktop: (desktopIndex: number) => {
|
|
||||||
world.doIfTiledFocused(true, (clientManager, desktopManager, window, column, oldGrid) => {
|
|
||||||
const desktopNumber = desktopIndex + 1;
|
|
||||||
const newGrid = desktopManager.getDesktopInCurrentActivity(desktopNumber).grid;
|
|
||||||
if (newGrid === null || newGrid === oldGrid) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
column.moveToGrid(newGrid, newGrid.getLastColumn());
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
tailMoveToDesktop: (desktopIndex: number) => {
|
|
||||||
world.doIfTiledFocused(true, (clientManager, desktopManager, window, column, oldGrid) => {
|
|
||||||
const desktopNumber = desktopIndex + 1;
|
|
||||||
const newGrid = desktopManager.getDesktopInCurrentActivity(desktopNumber).grid;
|
|
||||||
if (newGrid === null || newGrid === oldGrid) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
oldGrid.evacuateTail(newGrid, column);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function gridScroll(world: World, amount: number) {
|
|
||||||
world.do((clientManager, desktopManager) => {
|
|
||||||
const grid = desktopManager.getCurrentDesktop().grid;
|
|
||||||
grid.desktop.adjustScroll(amount, false);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export type Config = {
|
|
||||||
manualScrollStep: number,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
enum ClientAreaOption {
|
|
||||||
PlacementArea,
|
|
||||||
MovementArea,
|
|
||||||
MaximizeArea,
|
|
||||||
MaximizeFullArea,
|
|
||||||
FullScreenArea,
|
|
||||||
WorkArea,
|
|
||||||
FullArea,
|
|
||||||
ScreenArea,
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
type Config = {
|
|
||||||
gapsOuterTop: number,
|
|
||||||
gapsOuterBottom: number,
|
|
||||||
gapsOuterLeft: number,
|
|
||||||
gapsOuterRight: number,
|
|
||||||
gapsInnerHorizontal: number,
|
|
||||||
gapsInnerVertical: number,
|
|
||||||
overscroll: number,
|
|
||||||
manualScrollStep: number,
|
|
||||||
offScreenOpacity: number,
|
|
||||||
untileOnDrag: boolean,
|
|
||||||
stackColumnsByDefault: boolean,
|
|
||||||
resizeNeighborColumn: boolean,
|
|
||||||
reMaximize: boolean,
|
|
||||||
skipSwitcher: boolean,
|
|
||||||
scrollingLazy: boolean,
|
|
||||||
scrollingCentered: boolean,
|
|
||||||
scrollingGrouped: boolean,
|
|
||||||
tiledKeepBelow: boolean,
|
|
||||||
floatingKeepAbove: boolean,
|
|
||||||
windowRules: string,
|
|
||||||
};
|
|
||||||
@@ -1,174 +0,0 @@
|
|||||||
const defaultWindowRules = `[
|
|
||||||
{
|
|
||||||
"class": "ksmserver-logout-greeter",
|
|
||||||
"tile": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"class": "kcalc",
|
|
||||||
"tile": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"class": "org.kde.kcalc",
|
|
||||||
"tile": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"class": "kfind",
|
|
||||||
"tile": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"class": "org.kde.kfind",
|
|
||||||
"tile": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"class": "kruler",
|
|
||||||
"tile": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"class": "org.kde.kruler",
|
|
||||||
"tile": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"class": "krunner",
|
|
||||||
"tile": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"class": "org.kde.krunner",
|
|
||||||
"tile": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"class": "yakuake",
|
|
||||||
"tile": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"class": "org.kde.yakuake",
|
|
||||||
"tile": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"class": "zoom",
|
|
||||||
"caption": "Zoom Cloud Meetings|zoom|zoom <2>",
|
|
||||||
"tile": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"class": "jetbrains-idea",
|
|
||||||
"caption": "splash",
|
|
||||||
"tile": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"class": "jetbrains-studio",
|
|
||||||
"caption": "splash",
|
|
||||||
"tile": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"class": "jetbrains-idea",
|
|
||||||
"caption": "Unstash Changes|Paths Affected by stash@.*",
|
|
||||||
"tile": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"class": "jetbrains-studio",
|
|
||||||
"caption": "Unstash Changes|Paths Affected by stash@.*",
|
|
||||||
"tile": true
|
|
||||||
}
|
|
||||||
]`;
|
|
||||||
|
|
||||||
const configDef = [
|
|
||||||
{
|
|
||||||
"name": "gapsOuterTop",
|
|
||||||
"type": "UInt",
|
|
||||||
"default": 18
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "gapsOuterBottom",
|
|
||||||
"type": "UInt",
|
|
||||||
"default": 18
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "gapsOuterLeft",
|
|
||||||
"type": "UInt",
|
|
||||||
"default": 18
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "gapsOuterRight",
|
|
||||||
"type": "UInt",
|
|
||||||
"default": 18
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "gapsInnerHorizontal",
|
|
||||||
"type": "UInt",
|
|
||||||
"default": 18
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "gapsInnerVertical",
|
|
||||||
"type": "UInt",
|
|
||||||
"default": 18
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "overscroll",
|
|
||||||
"type": "UInt",
|
|
||||||
"default": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "manualScrollStep",
|
|
||||||
"type": "UInt",
|
|
||||||
"default": 200
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "offScreenOpacity",
|
|
||||||
"type": "UInt",
|
|
||||||
"default": 100
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "untileOnDrag",
|
|
||||||
"type": "Bool",
|
|
||||||
"default": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "stackColumnsByDefault",
|
|
||||||
"type": "Bool",
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "resizeNeighborColumn",
|
|
||||||
"type": "Bool",
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "reMaximize",
|
|
||||||
"type": "Bool",
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "skipSwitcher",
|
|
||||||
"type": "Bool",
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "scrollingLazy",
|
|
||||||
"type": "Bool",
|
|
||||||
"default": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "scrollingCentered",
|
|
||||||
"type": "Bool",
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "scrollingGrouped",
|
|
||||||
"type": "Bool",
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "tiledKeepBelow",
|
|
||||||
"type": "Bool",
|
|
||||||
"default": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "floatingKeepAbove",
|
|
||||||
"type": "Bool",
|
|
||||||
"default": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "windowRules",
|
|
||||||
"type": "String",
|
|
||||||
"default": defaultWindowRules
|
|
||||||
}
|
|
||||||
];
|
|
||||||
8
src/extern/global.d.ts
vendored
8
src/extern/global.d.ts
vendored
@@ -1,6 +1,6 @@
|
|||||||
|
declare const Qt: Qt;
|
||||||
|
declare const KWin: KWin;
|
||||||
|
declare const Workspace: Workspace;
|
||||||
declare const qmlBase: QmlObject;
|
declare const qmlBase: QmlObject;
|
||||||
declare const notificationInvalidWindowRules: Notification;
|
declare const notificationInvalidWindowRules: Notification;
|
||||||
|
declare const notificationInvalidPresetWidths: Notification;
|
||||||
type Notification = {
|
|
||||||
sendEvent(): void;
|
|
||||||
};
|
|
||||||
|
|||||||
77
src/extern/kwin.d.ts
vendored
77
src/extern/kwin.d.ts
vendored
@@ -1,77 +0,0 @@
|
|||||||
declare const KWin: {
|
|
||||||
// Functions
|
|
||||||
readConfig(key: string, defaultValue: any): any;
|
|
||||||
registerShortcut(name: string, description: string, keySequence: string, callback: () => void): void;
|
|
||||||
};
|
|
||||||
|
|
||||||
declare const workspace: {
|
|
||||||
// Read-write Properties
|
|
||||||
readonly desktops: number;
|
|
||||||
readonly currentDesktop: number;
|
|
||||||
readonly currentActivity: string;
|
|
||||||
|
|
||||||
// Read-write Properties
|
|
||||||
activeClient: KwinClient;
|
|
||||||
|
|
||||||
// Signals
|
|
||||||
currentDesktopChanged: QSignal<[oldDesktopNumber: number]>
|
|
||||||
clientAdded: QSignal<[KwinClient]>;
|
|
||||||
clientRemoved: QSignal<[KwinClient]>;
|
|
||||||
clientMinimized: QSignal<[KwinClient]>;
|
|
||||||
clientUnminimized: QSignal<[KwinClient]>;
|
|
||||||
clientMaximizeSet: QSignal<[KwinClient, horizontally: boolean, vertically: boolean]>;
|
|
||||||
clientActivated: QSignal<[KwinClient]>;
|
|
||||||
numberDesktopsChanged: QSignal<[oldNumberOfVirtualDesktops: number]>;
|
|
||||||
currentActivityChanged: QSignal<[newActivity: string]>;
|
|
||||||
virtualScreenSizeChanged: QSignal<[void]>;
|
|
||||||
|
|
||||||
// Functions
|
|
||||||
clientArea(option: ClientAreaOption, screenNumber: number, desktopNumber: number);
|
|
||||||
clientList(): KwinClient[];
|
|
||||||
};
|
|
||||||
|
|
||||||
type Tile = any;
|
|
||||||
|
|
||||||
interface KwinClient {
|
|
||||||
// Read-only Properties
|
|
||||||
readonly shadeable: boolean;
|
|
||||||
readonly caption: string;
|
|
||||||
readonly minSize: QmlSize;
|
|
||||||
readonly transient: boolean;
|
|
||||||
readonly transientFor: KwinClient;
|
|
||||||
readonly move: boolean;
|
|
||||||
readonly resize: boolean;
|
|
||||||
readonly resizeable: boolean;
|
|
||||||
readonly screen: number;
|
|
||||||
readonly resourceClass: QByteArray;
|
|
||||||
readonly dock: boolean;
|
|
||||||
readonly normalWindow: boolean;
|
|
||||||
readonly managed: boolean;
|
|
||||||
opacity: number;
|
|
||||||
|
|
||||||
// Read-write Properties
|
|
||||||
fullScreen: boolean;
|
|
||||||
activities: string[]; // empty array means all activities
|
|
||||||
skipSwitcher: boolean;
|
|
||||||
keepAbove: boolean;
|
|
||||||
keepBelow: boolean;
|
|
||||||
shade: boolean;
|
|
||||||
minimized: boolean;
|
|
||||||
frameGeometry: QmlRect;
|
|
||||||
desktop: number; // -1 means all desktops
|
|
||||||
tile: Tile;
|
|
||||||
|
|
||||||
// Signals
|
|
||||||
fullScreenChanged: QSignal<[void]>;
|
|
||||||
desktopChanged: QSignal<[void]>;
|
|
||||||
activitiesChanged: QSignal<[KwinClient]>;
|
|
||||||
captionChanged: QSignal<[void]>;
|
|
||||||
tileChanged: QSignal<[Tile]>;
|
|
||||||
moveResizedChanged: QSignal<[void]>;
|
|
||||||
moveResizeCursorChanged: QSignal<[void]>;
|
|
||||||
clientStartUserMovedResized: QSignal<[void]>;
|
|
||||||
frameGeometryChanged: QSignal<[KwinClient, oldGeometry: QmlRect]>;
|
|
||||||
|
|
||||||
// Functions
|
|
||||||
setMaximize(vertically: boolean, horizontally: boolean): void;
|
|
||||||
}
|
|
||||||
41
src/extern/qt.d.ts
vendored
41
src/extern/qt.d.ts
vendored
@@ -1,41 +0,0 @@
|
|||||||
declare const console: {
|
|
||||||
log(...args: any[]);
|
|
||||||
assert(boolean);
|
|
||||||
};
|
|
||||||
|
|
||||||
declare const Qt: {
|
|
||||||
rect(x: number, y: number, width: number, height: number): QmlRect;
|
|
||||||
createQmlObject(qml: string, parent: QmlObject);
|
|
||||||
};
|
|
||||||
|
|
||||||
type QmlObject = unknown;
|
|
||||||
|
|
||||||
type QByteArray = string;
|
|
||||||
|
|
||||||
type QmlRect = {
|
|
||||||
x: number;
|
|
||||||
y: number;
|
|
||||||
width: number;
|
|
||||||
height: number;
|
|
||||||
top: number;
|
|
||||||
bottom: number; // top + height
|
|
||||||
left: number;
|
|
||||||
right: number; // left + width
|
|
||||||
};
|
|
||||||
|
|
||||||
type QmlSize = {
|
|
||||||
width: number;
|
|
||||||
height: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
type QSignal<T extends unknown[]> = {
|
|
||||||
connect(handler: (...args: [...T]) => void): void;
|
|
||||||
disconnect(handler: (...args: [...T]) => void): void;
|
|
||||||
};
|
|
||||||
|
|
||||||
type QmlTimer = {
|
|
||||||
interval: number;
|
|
||||||
triggered: QSignal<[void]>;
|
|
||||||
restart(): void;
|
|
||||||
destroy(): void;
|
|
||||||
};
|
|
||||||
@@ -5,9 +5,20 @@ console.log(`<?xml version="1.0" encoding="UTF-8"?>
|
|||||||
|
|
||||||
for (const entry of configDef) {
|
for (const entry of configDef) {
|
||||||
console.log(` <entry name="${entry.name}" type="${entry.type}">
|
console.log(` <entry name="${entry.name}" type="${entry.type}">
|
||||||
<default>${entry.default}</default>
|
<default>${escapeXml(entry.default)}</default>
|
||||||
</entry>`);
|
</entry>`);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(` </group>
|
console.log(` </group>
|
||||||
</kcfg>`);
|
</kcfg>`);
|
||||||
|
|
||||||
|
function escapeXml(input: any) {
|
||||||
|
if (typeof input === "string") {
|
||||||
|
return input
|
||||||
|
.replace(/&/g, '&')
|
||||||
|
.replace(/</g, '<')
|
||||||
|
.replace(/>/g, '>');
|
||||||
|
} else {
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
}
|
||||||
8
src/generators/config/tsconfig.json
Normal file
8
src/generators/config/tsconfig.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig.json",
|
||||||
|
"include": [
|
||||||
|
"../../extern/**/*",
|
||||||
|
"../../lib/**/*",
|
||||||
|
"./**/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,27 +1,16 @@
|
|||||||
type KeyBinding = {
|
type DocsKeyBinding = {
|
||||||
name: string;
|
|
||||||
description: string;
|
description: string;
|
||||||
comment?: string;
|
keySequence: string;
|
||||||
defaultKeySequence: string;
|
};
|
||||||
action: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
type NumKeyBinding = {
|
function formatDescription(item: {description: string, comment?: string}) {
|
||||||
name: string;
|
const suffix = item.comment === undefined ? "" : ` (${item.comment})`;
|
||||||
description: string;
|
return `${applyMacro(item.description, "N")}${suffix}`;
|
||||||
comment?: string;
|
|
||||||
defaultModifiers: string;
|
|
||||||
fKeys: boolean;
|
|
||||||
action: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
function formatComment(comment: string | undefined) {
|
|
||||||
return comment === undefined ? "" : ` (${comment})`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function printCols(...columns: (string[] | string)[]) {
|
function printCols(...columns: (string[] | string)[]) {
|
||||||
const nCols = columns.length;
|
const nCols = columns.length;
|
||||||
if (nCols == 0) {
|
if (nCols === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +19,7 @@ function printCols(...columns: (string[] | string)[]) {
|
|||||||
).map(
|
).map(
|
||||||
(column: string[] | string) => column.length
|
(column: string[] | string) => column.length
|
||||||
));
|
));
|
||||||
if (nRows == Infinity) {
|
if (nRows === Infinity) {
|
||||||
// we only have single string columns
|
// we only have single string columns
|
||||||
nRows = 1;
|
nRows = 1;
|
||||||
}
|
}
|
||||||
@@ -65,3 +54,15 @@ function printCols(...columns: (string[] | string)[]) {
|
|||||||
console.log(line);
|
console.log(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const empty: any = {};
|
||||||
|
const keyBindings: DocsKeyBinding[] = Array.prototype.concat(
|
||||||
|
getKeyBindings(empty, empty).map(binding => ({
|
||||||
|
description: formatDescription(binding),
|
||||||
|
keySequence: binding.defaultKeySequence || "(unassigned)",
|
||||||
|
})),
|
||||||
|
getNumKeyBindings(empty, empty).map(binding => ({
|
||||||
|
description: formatDescription(binding),
|
||||||
|
keySequence: `${binding.defaultModifiers}+${binding.fKeys ? "F" : ""}[N]`,
|
||||||
|
})),
|
||||||
|
);
|
||||||
7
src/generators/docs/keyBindingsBbcode/main.ts
Normal file
7
src/generators/docs/keyBindingsBbcode/main.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
console.log(`[list]`);
|
||||||
|
|
||||||
|
for (const binding of keyBindings) {
|
||||||
|
console.log(` [*] ${binding.keySequence} — ${binding.description}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`[/list]`);
|
||||||
9
src/generators/docs/keyBindingsBbcode/tsconfig.json
Normal file
9
src/generators/docs/keyBindingsBbcode/tsconfig.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../../tsconfig.json",
|
||||||
|
"include": [
|
||||||
|
"../../../extern/**/*",
|
||||||
|
"../../../lib/**/*",
|
||||||
|
"../keyBindings.ts",
|
||||||
|
"./**/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
9
src/generators/docs/keyBindingsFmt/main.ts
Normal file
9
src/generators/docs/keyBindingsFmt/main.ts
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
const colLeft = [
|
||||||
|
...keyBindings.map(binding => binding.keySequence),
|
||||||
|
];
|
||||||
|
|
||||||
|
const colRight = [
|
||||||
|
...keyBindings.map(binding => binding.description),
|
||||||
|
];
|
||||||
|
|
||||||
|
printCols(colLeft, " ", colRight);
|
||||||
9
src/generators/docs/keyBindingsFmt/tsconfig.json
Normal file
9
src/generators/docs/keyBindingsFmt/tsconfig.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../../tsconfig.json",
|
||||||
|
"include": [
|
||||||
|
"../../../extern/**/*",
|
||||||
|
"../../../lib/**/*",
|
||||||
|
"../keyBindings.ts",
|
||||||
|
"./**/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
13
src/generators/docs/keyBindingsMarkdown/main.ts
Normal file
13
src/generators/docs/keyBindingsMarkdown/main.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
const colLeft = [
|
||||||
|
"Shortcut",
|
||||||
|
"---",
|
||||||
|
...keyBindings.map(binding => binding.keySequence),
|
||||||
|
];
|
||||||
|
|
||||||
|
const colRight = [
|
||||||
|
"Action",
|
||||||
|
"---",
|
||||||
|
...keyBindings.map(binding => binding.description),
|
||||||
|
];
|
||||||
|
|
||||||
|
printCols("| ", colLeft, " | ", colRight, " |");
|
||||||
9
src/generators/docs/keyBindingsMarkdown/tsconfig.json
Normal file
9
src/generators/docs/keyBindingsMarkdown/tsconfig.json
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../../tsconfig.json",
|
||||||
|
"include": [
|
||||||
|
"../../../extern/**/*",
|
||||||
|
"../../../lib/**/*",
|
||||||
|
"../keyBindings.ts",
|
||||||
|
"./**/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,218 +0,0 @@
|
|||||||
const keyBindings: KeyBinding[] = [
|
|
||||||
{
|
|
||||||
"name": "window-toggle-floating",
|
|
||||||
"description": "Toggle floating",
|
|
||||||
"defaultKeySequence": "Meta+Space",
|
|
||||||
"action": "windowToggleFloating",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "focus-left",
|
|
||||||
"description": "Move focus left",
|
|
||||||
"defaultKeySequence": "Meta+A",
|
|
||||||
"action": "focusLeft",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "focus-right",
|
|
||||||
"description": "Move focus right",
|
|
||||||
"comment": "Clashes with default KDE shortcuts, may require manual remapping",
|
|
||||||
"defaultKeySequence": "Meta+D",
|
|
||||||
"action": "focusRight",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "focus-up",
|
|
||||||
"description": "Move focus up",
|
|
||||||
"comment": "Clashes with default KDE shortcuts, may require manual remapping",
|
|
||||||
"defaultKeySequence": "Meta+W",
|
|
||||||
"action": "focusUp",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "focus-down",
|
|
||||||
"description": "Move focus down",
|
|
||||||
"comment": "Clashes with default KDE shortcuts, may require manual remapping",
|
|
||||||
"defaultKeySequence": "Meta+S",
|
|
||||||
"action": "focusDown",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "focus-start",
|
|
||||||
"description": "Move focus to start",
|
|
||||||
"defaultKeySequence": "Meta+Home",
|
|
||||||
"action": "focusStart",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "focus-end",
|
|
||||||
"description": "Move focus to end",
|
|
||||||
"defaultKeySequence": "Meta+End",
|
|
||||||
"action": "focusEnd",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "window-move-left",
|
|
||||||
"description": "Move window left",
|
|
||||||
"comment": "Moves window out of and into columns",
|
|
||||||
"defaultKeySequence": "Meta+Shift+A",
|
|
||||||
"action": "windowMoveLeft",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "window-move-right",
|
|
||||||
"description": "Move window right",
|
|
||||||
"comment": "Moves window out of and into columns",
|
|
||||||
"defaultKeySequence": "Meta+Shift+D",
|
|
||||||
"action": "windowMoveRight",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "window-move-up",
|
|
||||||
"description": "Move window up",
|
|
||||||
"defaultKeySequence": "Meta+Shift+W",
|
|
||||||
"action": "windowMoveUp",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "window-move-down",
|
|
||||||
"description": "Move window down",
|
|
||||||
"defaultKeySequence": "Meta+Shift+S",
|
|
||||||
"action": "windowMoveDown",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "window-move-start",
|
|
||||||
"description": "Move window to start",
|
|
||||||
"defaultKeySequence": "Meta+Shift+Home",
|
|
||||||
"action": "windowMoveStart",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "window-move-end",
|
|
||||||
"description": "Move window to end",
|
|
||||||
"defaultKeySequence": "Meta+Shift+End",
|
|
||||||
"action": "windowMoveEnd",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "column-toggle-stacked",
|
|
||||||
"description": "Toggle stacked layout for focused column",
|
|
||||||
"comment": "One window in the column visible, others shaded; not supported on Wayland",
|
|
||||||
"defaultKeySequence": "Meta+X",
|
|
||||||
"action": "columnToggleStacked",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "column-move-left",
|
|
||||||
"description": "Move column left",
|
|
||||||
"defaultKeySequence": "Meta+Ctrl+Shift+A",
|
|
||||||
"action": "columnMoveLeft",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "column-move-right",
|
|
||||||
"description": "Move column right",
|
|
||||||
"defaultKeySequence": "Meta+Ctrl+Shift+D",
|
|
||||||
"action": "columnMoveRight",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "column-move-start",
|
|
||||||
"description": "Move column to start",
|
|
||||||
"defaultKeySequence": "Meta+Ctrl+Shift+Home",
|
|
||||||
"action": "columnMoveStart",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "column-move-end",
|
|
||||||
"description": "Move column to end",
|
|
||||||
"defaultKeySequence": "Meta+Ctrl+Shift+End",
|
|
||||||
"action": "columnMoveEnd",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "column-width-increase",
|
|
||||||
"description": "Increase column width",
|
|
||||||
"defaultKeySequence": "Meta+Ctrl++",
|
|
||||||
"action": "columnWidthIncrease",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "column-width-decrease",
|
|
||||||
"description": "Decrease column width",
|
|
||||||
"defaultKeySequence": "Meta+Ctrl+-",
|
|
||||||
"action": "columnWidthDecrease",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "columns-width-equalize",
|
|
||||||
"description": "Equalize widths of visible columns",
|
|
||||||
"defaultKeySequence": "Meta+Ctrl+X",
|
|
||||||
"action": "columnsWidthEqualize",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "grid-scroll-focused",
|
|
||||||
"description": "Center focused window",
|
|
||||||
"comment": "Scrolls so that the focused window is centered in the screen",
|
|
||||||
"defaultKeySequence": "Meta+Alt+Return",
|
|
||||||
"action": "gridScrollFocused",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "grid-scroll-left-column",
|
|
||||||
"description": "Scroll one column to the left",
|
|
||||||
"defaultKeySequence": "Meta+Alt+A",
|
|
||||||
"action": "gridScrollLeftColumn",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "grid-scroll-right-column",
|
|
||||||
"description": "Scroll one column to the right",
|
|
||||||
"defaultKeySequence": "Meta+Alt+D",
|
|
||||||
"action": "gridScrollRightColumn",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "grid-scroll-left",
|
|
||||||
"description": "Scroll left",
|
|
||||||
"defaultKeySequence": "Meta+Alt+PgUp",
|
|
||||||
"action": "gridScrollLeft",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "grid-scroll-right",
|
|
||||||
"description": "Scroll right",
|
|
||||||
"defaultKeySequence": "Meta+Alt+PgDown",
|
|
||||||
"action": "gridScrollRight",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "grid-scroll-start",
|
|
||||||
"description": "Scroll to start",
|
|
||||||
"defaultKeySequence": "Meta+Alt+Home",
|
|
||||||
"action": "gridScrollStart",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "grid-scroll-end",
|
|
||||||
"description": "Scroll to end",
|
|
||||||
"defaultKeySequence": "Meta+Alt+End",
|
|
||||||
"action": "gridScrollEnd",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const numKeyBindings: NumKeyBinding[] = [
|
|
||||||
{
|
|
||||||
"name": "focus-",
|
|
||||||
"description": "Move focus to column ",
|
|
||||||
"comment": "Clashes with default KDE shortcuts, may require manual remapping",
|
|
||||||
"defaultModifiers": "Meta",
|
|
||||||
"fKeys": false,
|
|
||||||
"action": "focusColumn",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "window-move-to-column-",
|
|
||||||
"description": "Move window to column ",
|
|
||||||
"comment": "Requires manual remapping according to your keyboard layout, e.g. Meta+Shift+1 -> Meta+!",
|
|
||||||
"defaultModifiers": "Meta+Shift",
|
|
||||||
"fKeys": false,
|
|
||||||
"action": "windowMoveToColumn",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "column-move-to-column-",
|
|
||||||
"description": "Move column to position ",
|
|
||||||
"comment": "Requires manual remapping according to your keyboard layout, e.g. Meta+Ctrl+Shift+1 -> Meta+Ctrl+!",
|
|
||||||
"defaultModifiers": "Meta+Ctrl+Shift",
|
|
||||||
"fKeys": false,
|
|
||||||
"action": "columnMoveToColumn",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "column-move-to-desktop-",
|
|
||||||
"description": "Move column to desktop ",
|
|
||||||
"defaultModifiers": "Meta+Ctrl+Shift",
|
|
||||||
"fKeys": true,
|
|
||||||
"action": "columnMoveToDesktop",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "tail-move-to-desktop-",
|
|
||||||
"description": "Move this and all following columns to desktop ",
|
|
||||||
"defaultModifiers": "Meta+Ctrl+Shift+Alt",
|
|
||||||
"fKeys": true,
|
|
||||||
"action": "tailMoveToDesktop",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
type KeyBinding = {
|
|
||||||
name: string;
|
|
||||||
description: string;
|
|
||||||
comment?: string;
|
|
||||||
defaultKeySequence: string;
|
|
||||||
action: keyof ReturnType<typeof Actions.init>;
|
|
||||||
};
|
|
||||||
|
|
||||||
type NumKeyBinding = {
|
|
||||||
name: string;
|
|
||||||
description: string;
|
|
||||||
comment?: string;
|
|
||||||
defaultModifiers: string;
|
|
||||||
fKeys: boolean;
|
|
||||||
action: keyof ReturnType<typeof Actions.initNum>;
|
|
||||||
};
|
|
||||||
|
|
||||||
function catchWrap(f: () => void) {
|
|
||||||
return () => {
|
|
||||||
try {
|
|
||||||
f();
|
|
||||||
} catch (error: any) {
|
|
||||||
log(error);
|
|
||||||
log(error.stack);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function registerKeyBinding(name: string, description: string, keySequence: string, callback: () => void) {
|
|
||||||
KWin.registerShortcut(
|
|
||||||
"karousel-" + name,
|
|
||||||
"Karousel: " + description,
|
|
||||||
keySequence,
|
|
||||||
catchWrap(callback),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function registerNumKeyBindings(name: string, description: string, modifiers: string, fKeys: boolean, callback: (i: number) => void) {
|
|
||||||
const numPrefix = fKeys ? "F" : "";
|
|
||||||
const n = fKeys ? 12 : 9;
|
|
||||||
for (let i = 0; i < 12; i++) {
|
|
||||||
const numKey = String(i + 1);
|
|
||||||
const keySequence = i < n ?
|
|
||||||
modifiers + "+" + numPrefix + numKey :
|
|
||||||
"";
|
|
||||||
registerKeyBinding(
|
|
||||||
name + numKey,
|
|
||||||
description + numKey,
|
|
||||||
keySequence,
|
|
||||||
() => callback(i),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function registerKeyBindings(world: World, config: Config) {
|
|
||||||
const actions = Actions.init(world, config);
|
|
||||||
for (const binding of keyBindings) {
|
|
||||||
registerKeyBinding(binding.name, binding.description, binding.defaultKeySequence, actions[binding.action]);
|
|
||||||
}
|
|
||||||
|
|
||||||
const numActions = Actions.initNum(world);
|
|
||||||
for (const binding of numKeyBindings) {
|
|
||||||
registerNumKeyBindings(binding.name, binding.description, binding.defaultModifiers, binding.fKeys, numActions[binding.action]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,232 +0,0 @@
|
|||||||
class Desktop {
|
|
||||||
public readonly grid: Grid;
|
|
||||||
public readonly desktopNumber: number;
|
|
||||||
private readonly pinManager: PinManager;
|
|
||||||
private readonly config: Desktop.Config;
|
|
||||||
private scrollX: number;
|
|
||||||
private dirty: boolean;
|
|
||||||
private dirtyScroll: boolean;
|
|
||||||
private dirtyPins: boolean;
|
|
||||||
public clientArea: QmlRect;
|
|
||||||
public tilingArea: QmlRect;
|
|
||||||
|
|
||||||
constructor(desktopNumber: number, pinManager: PinManager, config: Desktop.Config, layoutConfig: LayoutConfig) {
|
|
||||||
this.pinManager = pinManager;
|
|
||||||
this.config = config;
|
|
||||||
this.scrollX = 0;
|
|
||||||
this.dirty = true;
|
|
||||||
this.dirtyScroll = true;
|
|
||||||
this.dirtyPins = true;
|
|
||||||
this.desktopNumber = desktopNumber;
|
|
||||||
this.grid = new Grid(this, layoutConfig);
|
|
||||||
this.clientArea = Desktop.getClientArea(desktopNumber);
|
|
||||||
this.tilingArea = Desktop.getTilingArea(this.clientArea, desktopNumber, pinManager, config);
|
|
||||||
}
|
|
||||||
|
|
||||||
private updateArea() {
|
|
||||||
const newClientArea = Desktop.getClientArea(this.desktopNumber);
|
|
||||||
if (newClientArea === this.clientArea && !this.dirtyPins) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.clientArea = newClientArea;
|
|
||||||
this.tilingArea = Desktop.getTilingArea(newClientArea, this.desktopNumber, this.pinManager, this.config);
|
|
||||||
this.dirty = true;
|
|
||||||
this.dirtyScroll = true;
|
|
||||||
this.dirtyPins = false;
|
|
||||||
this.grid.onScreenSizeChanged();
|
|
||||||
this.autoAdjustScroll();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static getClientArea(desktopNumber: number) {
|
|
||||||
return workspace.clientArea(ClientAreaOption.PlacementArea, 0, desktopNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static getTilingArea(clientArea: QmlRect, desktopNumber: number, pinManager: PinManager, config: Desktop.Config) {
|
|
||||||
const availableSpace = pinManager.getAvailableSpace(desktopNumber, clientArea);
|
|
||||||
const top = availableSpace.top + config.marginTop;
|
|
||||||
const bottom = availableSpace.bottom - config.marginBottom;
|
|
||||||
const left = availableSpace.left + config.marginLeft;
|
|
||||||
const right = availableSpace.right - config.marginRight;
|
|
||||||
return Qt.rect(
|
|
||||||
left,
|
|
||||||
top,
|
|
||||||
right - left,
|
|
||||||
bottom - top,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// calculates a Range that scrolls the contained Range into view
|
|
||||||
public calculateVisibleRange(containedRange: Desktop.Range) {
|
|
||||||
const left = containedRange.getLeft();
|
|
||||||
const right = containedRange.getRight();
|
|
||||||
const initialVisibleRange = this.getCurrentVisibleRange();
|
|
||||||
|
|
||||||
let targetScrollX: number;
|
|
||||||
if (left < initialVisibleRange.getLeft()) {
|
|
||||||
targetScrollX = left;
|
|
||||||
} else if (right > initialVisibleRange.getRight()) {
|
|
||||||
targetScrollX = right - this.tilingArea.width;
|
|
||||||
} else {
|
|
||||||
return this.getVisibleRange(this.clampScrollX(this.scrollX));
|
|
||||||
}
|
|
||||||
|
|
||||||
const overscroll = this.getTargetOverscroll(targetScrollX, left < initialVisibleRange.getLeft());
|
|
||||||
return this.getVisibleRange(this.clampScrollX(targetScrollX + overscroll));
|
|
||||||
}
|
|
||||||
|
|
||||||
private getTargetOverscroll(targetScrollX: number, scrollLeft: boolean) {
|
|
||||||
if (this.config.overscroll === 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
const visibleColumnsWidth = this.grid.getVisibleColumnsWidth(this.getVisibleRange(targetScrollX), true);
|
|
||||||
const remainingSpace = this.tilingArea.width - visibleColumnsWidth;
|
|
||||||
const overscrollX = Math.min(this.config.overscroll, Math.round(remainingSpace / 2));
|
|
||||||
const direction = scrollLeft ? -1 : 1;
|
|
||||||
return overscrollX * direction;
|
|
||||||
}
|
|
||||||
|
|
||||||
public scrollToRange(range: Desktop.Range) {
|
|
||||||
this.setScroll(this.calculateVisibleRange(range).getLeft(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public scrollCenterRange(range: Desktop.Range) {
|
|
||||||
const windowCenter = range.getLeft() + range.getWidth() / 2;
|
|
||||||
const screenCenter = this.scrollX + this.tilingArea.width / 2;
|
|
||||||
this.adjustScroll(Math.round(windowCenter - screenCenter), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public autoAdjustScroll() {
|
|
||||||
const focusedColumn = this.grid.getLastFocusedColumn();
|
|
||||||
if (focusedColumn === null || focusedColumn.grid !== this.grid) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.scrollToColumn(focusedColumn);
|
|
||||||
}
|
|
||||||
|
|
||||||
public scrollToColumn(column: Column) {
|
|
||||||
if (this.dirtyScroll || !column.isVisible(this.getCurrentVisibleRange(), true)) {
|
|
||||||
this.config.scroller.scrollToColumn(this, column);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private getVisibleRange(scrollX: number) {
|
|
||||||
return new Desktop.RangeImpl(scrollX, this.tilingArea.width);
|
|
||||||
}
|
|
||||||
|
|
||||||
public getCurrentVisibleRange() {
|
|
||||||
return this.getVisibleRange(this.scrollX);
|
|
||||||
}
|
|
||||||
|
|
||||||
private clampScrollX(x: number) {
|
|
||||||
return this.config.scroller.clampScrollX(this, x);
|
|
||||||
}
|
|
||||||
|
|
||||||
public setScroll(x: number, force: boolean) {
|
|
||||||
const oldScrollX = this.scrollX;
|
|
||||||
this.scrollX = force ? x : this.clampScrollX(x);
|
|
||||||
if (this.scrollX !== oldScrollX) {
|
|
||||||
this.onLayoutChanged();
|
|
||||||
}
|
|
||||||
this.dirtyScroll = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public adjustScroll(dx: number, force: boolean) {
|
|
||||||
this.setScroll(this.scrollX + dx, force);
|
|
||||||
}
|
|
||||||
|
|
||||||
public equalizeVisibleColumnsWidths() {
|
|
||||||
const visibleRange = this.getCurrentVisibleRange();
|
|
||||||
const visibleColumns = Array.from(this.grid.getVisibleColumns(visibleRange, true));
|
|
||||||
|
|
||||||
let remainingWidth = this.tilingArea.width - (visibleColumns.length-1) * this.grid.config.gapsInnerHorizontal;
|
|
||||||
let remainingColumns = visibleColumns.length;
|
|
||||||
for (const column of visibleColumns) {
|
|
||||||
const columnWidth = Math.round(remainingWidth / remainingColumns);
|
|
||||||
column.setWidth(columnWidth, true);
|
|
||||||
remainingWidth -= columnWidth;
|
|
||||||
remainingColumns--;
|
|
||||||
}
|
|
||||||
|
|
||||||
const targetVisibleRange = Desktop.RangeImpl.fromRanges(
|
|
||||||
visibleColumns[0],
|
|
||||||
visibleColumns[visibleColumns.length - 1],
|
|
||||||
);
|
|
||||||
this.setScroll(this.calculateVisibleRange(targetVisibleRange).getLeft(), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public arrange() {
|
|
||||||
// TODO (optimization): only arrange visible windows
|
|
||||||
this.updateArea();
|
|
||||||
if (!this.dirty) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.grid.arrange(this.tilingArea.x - this.scrollX, this.getCurrentVisibleRange());
|
|
||||||
this.dirty = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public onLayoutChanged() {
|
|
||||||
this.dirty = true;
|
|
||||||
this.dirtyScroll = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public onPinsChanged() {
|
|
||||||
this.dirty = true;
|
|
||||||
this.dirtyScroll = true;
|
|
||||||
this.dirtyPins = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public destroy() {
|
|
||||||
this.grid.destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Desktop {
|
|
||||||
export type Config = {
|
|
||||||
marginTop: number,
|
|
||||||
marginBottom: number,
|
|
||||||
marginLeft: number,
|
|
||||||
marginRight: number,
|
|
||||||
overscroll: number,
|
|
||||||
scroller: Desktop.Scroller,
|
|
||||||
};
|
|
||||||
|
|
||||||
export type Range = {
|
|
||||||
getLeft(): number;
|
|
||||||
getRight(): number;
|
|
||||||
getWidth(): number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class RangeImpl {
|
|
||||||
private readonly x: number;
|
|
||||||
private readonly width: number;
|
|
||||||
|
|
||||||
constructor(x: number, width: number) {
|
|
||||||
this.x = x;
|
|
||||||
this.width = width;
|
|
||||||
}
|
|
||||||
|
|
||||||
public getLeft() {
|
|
||||||
return this.x;
|
|
||||||
}
|
|
||||||
|
|
||||||
public getRight() {
|
|
||||||
return this.x + this.width;
|
|
||||||
}
|
|
||||||
|
|
||||||
public getWidth() {
|
|
||||||
return this.width;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static fromRanges(leftRange: Range, rightRange: Range) {
|
|
||||||
const left = leftRange.getLeft();
|
|
||||||
const right = rightRange.getRight();
|
|
||||||
return new RangeImpl(left, right - left);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export type Scroller = {
|
|
||||||
scrollToColumn(desktop: Desktop, column: Column): void;
|
|
||||||
clampScrollX(desktop: Desktop, x: number): number;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,324 +0,0 @@
|
|||||||
import Range = Desktop.Range;
|
|
||||||
|
|
||||||
class Grid {
|
|
||||||
public readonly desktop: Desktop;
|
|
||||||
public readonly config: LayoutConfig;
|
|
||||||
private readonly columns: LinkedList<Column>;
|
|
||||||
private lastFocusedColumn: Column|null;
|
|
||||||
private width: number;
|
|
||||||
private userResize: boolean; // is any part of the grid being resized by the user
|
|
||||||
private readonly userResizeFinishedDelayer: Delayer;
|
|
||||||
|
|
||||||
constructor(desktop: Desktop, config: LayoutConfig) {
|
|
||||||
this.desktop = desktop;
|
|
||||||
this.config = config;
|
|
||||||
this.columns = new LinkedList();
|
|
||||||
this.lastFocusedColumn = null;
|
|
||||||
this.width = 0;
|
|
||||||
this.userResize = false;
|
|
||||||
this.userResizeFinishedDelayer = new Delayer(50, () => {
|
|
||||||
// this delay prevents windows' contents from freezing after resizing
|
|
||||||
this.desktop.onLayoutChanged();
|
|
||||||
this.desktop.autoAdjustScroll();
|
|
||||||
this.desktop.arrange();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public moveColumnLeft(column: Column) {
|
|
||||||
this.columns.moveBack(column);
|
|
||||||
this.columnsSetX(column);
|
|
||||||
this.desktop.onLayoutChanged();
|
|
||||||
this.desktop.autoAdjustScroll();
|
|
||||||
}
|
|
||||||
|
|
||||||
public moveColumnRight(column: Column) {
|
|
||||||
const nextColumn = this.columns.getNext(column);
|
|
||||||
if (nextColumn === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.moveColumnLeft(nextColumn);
|
|
||||||
}
|
|
||||||
|
|
||||||
public getWidth() {
|
|
||||||
return this.width;
|
|
||||||
}
|
|
||||||
|
|
||||||
public getPrevColumn(column: Column) {
|
|
||||||
return this.columns.getPrev(column);
|
|
||||||
}
|
|
||||||
|
|
||||||
public getNextColumn(column: Column) {
|
|
||||||
return this.columns.getNext(column);
|
|
||||||
}
|
|
||||||
|
|
||||||
public getFirstColumn() {
|
|
||||||
return this.columns.getFirst();
|
|
||||||
}
|
|
||||||
|
|
||||||
public getLastColumn() {
|
|
||||||
return this.columns.getLast();
|
|
||||||
}
|
|
||||||
|
|
||||||
public getColumnAtIndex(i: number) {
|
|
||||||
return this.columns.getItemAtIndex(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
public getLastFocusedColumn() {
|
|
||||||
if (this.lastFocusedColumn === null || this.lastFocusedColumn.grid !== this) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return this.lastFocusedColumn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public getLastFocusedWindow() {
|
|
||||||
const lastFocusedColumn = this.getLastFocusedColumn();
|
|
||||||
if (lastFocusedColumn === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return lastFocusedColumn.getFocusTaker();
|
|
||||||
}
|
|
||||||
|
|
||||||
private columnsSetX(firstMovedColumn: Column|null) {
|
|
||||||
const lastUnmovedColumn = firstMovedColumn === null ? this.columns.getLast() : this.columns.getPrev(firstMovedColumn);
|
|
||||||
let x = lastUnmovedColumn === null ? 0 : lastUnmovedColumn.getRight() + this.config.gapsInnerHorizontal;
|
|
||||||
if (firstMovedColumn !== null) {
|
|
||||||
for (const column of this.columns.iteratorFrom(firstMovedColumn)) {
|
|
||||||
column.gridX = x;
|
|
||||||
x += column.getWidth() + this.config.gapsInnerHorizontal;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.width = x - this.config.gapsInnerHorizontal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public getLeftmostVisibleColumn(visibleRange: Desktop.Range, fullyVisible: boolean) {
|
|
||||||
for (const column of this.columns.iterator()) {
|
|
||||||
if (column.isVisible(visibleRange, fullyVisible)) {
|
|
||||||
return column;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public getRightmostVisibleColumn(visibleRange: Desktop.Range, fullyVisible: boolean) {
|
|
||||||
let last = null;
|
|
||||||
for (const column of this.columns.iterator()) {
|
|
||||||
if (column.isVisible(visibleRange, fullyVisible)) {
|
|
||||||
last = column;
|
|
||||||
} else if (last !== null) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return last;
|
|
||||||
}
|
|
||||||
|
|
||||||
public *getVisibleColumns(visibleRange: Desktop.Range, fullyVisible: boolean) {
|
|
||||||
for (const column of this.columns.iterator()) {
|
|
||||||
if (column.isVisible(visibleRange, fullyVisible)) {
|
|
||||||
yield column;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public getVisibleColumnsWidth(visibleRange: Desktop.Range, fullyVisible: boolean) {
|
|
||||||
let width = 0;
|
|
||||||
let nVisible = 0;
|
|
||||||
for (const column of this.getVisibleColumns(visibleRange, fullyVisible)) {
|
|
||||||
width += column.getWidth();
|
|
||||||
nVisible++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nVisible > 0) {
|
|
||||||
width += (nVisible-1) * this.config.gapsInnerHorizontal;
|
|
||||||
}
|
|
||||||
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
|
|
||||||
public increaseColumnWidth(column: Column) {
|
|
||||||
const visibleRange = this.desktop.calculateVisibleRange(column);
|
|
||||||
if(!column.isVisible(visibleRange, true) || column.getWidth() >= column.getMaxWidth()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let leftVisibleColumn = this.getLeftmostVisibleColumn(visibleRange, true);
|
|
||||||
let rightVisibleColumn = this.getRightmostVisibleColumn(visibleRange, true);
|
|
||||||
if (leftVisibleColumn === null || rightVisibleColumn === null) {
|
|
||||||
console.assert(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const leftSpace = leftVisibleColumn.getLeft() - visibleRange.getLeft();
|
|
||||||
const rightSpace = visibleRange.getRight() - rightVisibleColumn.getRight();
|
|
||||||
if (leftSpace + rightSpace > 0) {
|
|
||||||
column.adjustWidth(leftSpace + rightSpace, true);
|
|
||||||
} else {
|
|
||||||
// left and right columns are touching the screen's edges
|
|
||||||
const leftSpace = leftVisibleColumn === column ? Infinity : leftVisibleColumn.getWidth() + this.config.gapsInnerHorizontal;
|
|
||||||
const rightSpace = rightVisibleColumn === column ? Infinity : rightVisibleColumn.getWidth() + this.config.gapsInnerHorizontal;
|
|
||||||
if (leftSpace < rightSpace) {
|
|
||||||
column.adjustWidth(leftSpace, true);
|
|
||||||
leftVisibleColumn = this.getNextColumn(leftVisibleColumn)!;
|
|
||||||
} else {
|
|
||||||
column.adjustWidth(rightSpace, true);
|
|
||||||
rightVisibleColumn = this.getPrevColumn(rightVisibleColumn)!;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.desktop.scrollCenterRange(Desktop.RangeImpl.fromRanges(leftVisibleColumn, rightVisibleColumn));
|
|
||||||
}
|
|
||||||
|
|
||||||
public decreaseColumnWidth(column: Column) {
|
|
||||||
const visibleRange = this.desktop.calculateVisibleRange(column);
|
|
||||||
if (!column.isVisible(visibleRange, true)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.width <= visibleRange.getWidth()) {
|
|
||||||
column.setWidth(Math.round(column.getWidth() / 2), true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const leftVisibleColumn = this.getLeftmostVisibleColumn(visibleRange, true);
|
|
||||||
const rightVisibleColumn = this.getRightmostVisibleColumn(visibleRange, true);
|
|
||||||
if (leftVisibleColumn === null || rightVisibleColumn === null) {
|
|
||||||
console.assert(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let leftOffScreenColumn = this.getPrevColumn(leftVisibleColumn);
|
|
||||||
if (leftOffScreenColumn === column) {
|
|
||||||
leftOffScreenColumn = null;
|
|
||||||
}
|
|
||||||
let rightOffScreenColumn = this.getNextColumn(rightVisibleColumn);
|
|
||||||
if (rightOffScreenColumn === column) {
|
|
||||||
rightOffScreenColumn = null;
|
|
||||||
}
|
|
||||||
if (leftOffScreenColumn === null && rightOffScreenColumn === null) {
|
|
||||||
console.assert(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const leftInvisibleWidth = leftOffScreenColumn === null ? Infinity : visibleRange.getLeft() - leftOffScreenColumn.getLeft();
|
|
||||||
const rightInvisibleWidth = rightOffScreenColumn === null ? Infinity : rightOffScreenColumn.getRight() - visibleRange.getRight();
|
|
||||||
|
|
||||||
const leftSpace = leftVisibleColumn.getLeft() - visibleRange.getLeft();
|
|
||||||
const rightSpace = visibleRange.getRight() - rightVisibleColumn.getRight();
|
|
||||||
|
|
||||||
if (leftInvisibleWidth < rightInvisibleWidth) {
|
|
||||||
const deltaWidth = rightSpace - leftInvisibleWidth;
|
|
||||||
column.adjustWidth(deltaWidth, true);
|
|
||||||
console.assert(leftOffScreenColumn !== null);
|
|
||||||
const newVisibleWidth = rightVisibleColumn.getRight() - leftOffScreenColumn!.getLeft();
|
|
||||||
const leftVisibleColumn = newVisibleWidth <= visibleRange.getWidth() ? leftOffScreenColumn! : this.getNextColumn(leftOffScreenColumn!)!;
|
|
||||||
this.desktop.scrollCenterRange(Desktop.RangeImpl.fromRanges(leftVisibleColumn, rightVisibleColumn));
|
|
||||||
} else {
|
|
||||||
const deltaWidth = leftSpace - rightInvisibleWidth;
|
|
||||||
column.adjustWidth(deltaWidth, true);
|
|
||||||
console.assert(rightOffScreenColumn !== null);
|
|
||||||
const newVisibleWidth = rightOffScreenColumn!.getRight() - leftVisibleColumn.getLeft();
|
|
||||||
const rightVisibleColumn = newVisibleWidth <= visibleRange.getWidth() ? rightOffScreenColumn! : this.getPrevColumn(rightOffScreenColumn!)!;
|
|
||||||
this.desktop.scrollCenterRange(Desktop.RangeImpl.fromRanges(leftVisibleColumn, rightVisibleColumn));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public arrange(x: number, visibleRange: Range) {
|
|
||||||
for (const column of this.columns.iterator()) {
|
|
||||||
column.arrange(x, visibleRange, this.userResize);
|
|
||||||
x += column.getWidth() + this.config.gapsInnerHorizontal;
|
|
||||||
}
|
|
||||||
|
|
||||||
const focusedWindow = this.getLastFocusedWindow();
|
|
||||||
if (focusedWindow !== null) {
|
|
||||||
focusedWindow.client.ensureTransientsVisible(this.desktop.clientArea);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public onColumnAdded(column: Column, prevColumn: Column|null) {
|
|
||||||
if (prevColumn === null) {
|
|
||||||
this.columns.insertStart(column);
|
|
||||||
} else {
|
|
||||||
this.columns.insertAfter(column, prevColumn);
|
|
||||||
}
|
|
||||||
this.columnsSetX(column);
|
|
||||||
this.desktop.onLayoutChanged();
|
|
||||||
this.desktop.autoAdjustScroll();
|
|
||||||
}
|
|
||||||
|
|
||||||
public onColumnRemoved(column: Column, passFocus: boolean) {
|
|
||||||
const isLastColumn = this.columns.length() === 1;
|
|
||||||
const nextColumn = this.getNextColumn(column);
|
|
||||||
const columnToFocus = isLastColumn ? null : this.getPrevColumn(column) ?? nextColumn;
|
|
||||||
if (column === this.lastFocusedColumn) {
|
|
||||||
this.lastFocusedColumn = columnToFocus;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.columns.remove(column);
|
|
||||||
this.columnsSetX(nextColumn);
|
|
||||||
|
|
||||||
this.desktop.onLayoutChanged();
|
|
||||||
if (passFocus && columnToFocus !== null) {
|
|
||||||
columnToFocus.focus();
|
|
||||||
} else {
|
|
||||||
this.desktop.autoAdjustScroll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public onColumnMoved(column: Column, prevColumn: Column|null) {
|
|
||||||
const movedLeft = prevColumn === null ? true : column.isAfter(prevColumn);
|
|
||||||
const firstMovedColumn = movedLeft ? column : this.getNextColumn(column);
|
|
||||||
this.columns.move(column, prevColumn);
|
|
||||||
this.columnsSetX(firstMovedColumn);
|
|
||||||
this.desktop.onLayoutChanged();
|
|
||||||
this.desktop.autoAdjustScroll();
|
|
||||||
}
|
|
||||||
|
|
||||||
public onColumnWidthChanged(column: Column, oldWidth: number, width: number) {
|
|
||||||
const nextColumn = this.columns.getNext(column);
|
|
||||||
this.columnsSetX(nextColumn);
|
|
||||||
if (!this.userResize) {
|
|
||||||
this.desktop.autoAdjustScroll();
|
|
||||||
}
|
|
||||||
this.desktop.onLayoutChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
public onColumnFocused(column: Column) {
|
|
||||||
const lastFocusedColumn = this.getLastFocusedColumn();
|
|
||||||
if (lastFocusedColumn !== null) {
|
|
||||||
lastFocusedColumn.restoreToTiled();
|
|
||||||
}
|
|
||||||
this.lastFocusedColumn = column;
|
|
||||||
this.desktop.scrollToColumn(column);
|
|
||||||
}
|
|
||||||
|
|
||||||
public onScreenSizeChanged() {
|
|
||||||
for (const column of this.columns.iterator()) {
|
|
||||||
column.updateWidth();
|
|
||||||
column.resizeWindows();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public onUserResizeStarted() {
|
|
||||||
this.userResize = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public onUserResizeFinished() {
|
|
||||||
this.userResize = false;
|
|
||||||
this.userResizeFinishedDelayer.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
public evacuateTail(targetGrid: Grid, startColumn: Column) {
|
|
||||||
for (const column of this.columns.iteratorFrom(startColumn)) {
|
|
||||||
column.moveToGrid(targetGrid, targetGrid.getLastColumn());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public evacuate(targetGrid: Grid) {
|
|
||||||
for (const column of this.columns.iterator()) {
|
|
||||||
column.moveToGrid(targetGrid, targetGrid.getLastColumn());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public destroy() {
|
|
||||||
this.userResizeFinishedDelayer.destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
type LayoutConfig = {
|
|
||||||
gapsInnerHorizontal: number,
|
|
||||||
gapsInnerVertical: number,
|
|
||||||
offScreenOpacity: number,
|
|
||||||
stackColumnsByDefault: boolean,
|
|
||||||
resizeNeighborColumn: boolean,
|
|
||||||
reMaximize: boolean,
|
|
||||||
skipSwitcher: boolean,
|
|
||||||
tiledKeepBelow: boolean,
|
|
||||||
maximizedKeepAbove: boolean,
|
|
||||||
};
|
|
||||||
@@ -1,87 +0,0 @@
|
|||||||
class ScrollerGrouped {
|
|
||||||
private readonly layoutConfig: LayoutConfig;
|
|
||||||
|
|
||||||
constructor(layoutConfig: LayoutConfig) {
|
|
||||||
this.layoutConfig = layoutConfig;
|
|
||||||
}
|
|
||||||
|
|
||||||
public scrollToColumn(desktop: Desktop, column: Column) {
|
|
||||||
const columnRange = new ScrollerGrouped.ColumnRange(column);
|
|
||||||
const visibleRange = desktop.getCurrentVisibleRange();
|
|
||||||
columnRange.addNeighbors(visibleRange, this.layoutConfig.gapsInnerHorizontal, true);
|
|
||||||
columnRange.addNeighbors(visibleRange, this.layoutConfig.gapsInnerHorizontal, false);
|
|
||||||
desktop.scrollCenterRange(columnRange);
|
|
||||||
}
|
|
||||||
|
|
||||||
public clampScrollX(desktop: Desktop, x: number) {
|
|
||||||
return ScrollerCentered.clampScrollX(desktop, x);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace ScrollerGrouped {
|
|
||||||
import Range = Desktop.Range;
|
|
||||||
|
|
||||||
export class ColumnRange {
|
|
||||||
private left: Column;
|
|
||||||
private right: Column;
|
|
||||||
private width: number;
|
|
||||||
|
|
||||||
constructor(initialColumn: Column) {
|
|
||||||
this.left = initialColumn;
|
|
||||||
this.right = initialColumn;
|
|
||||||
this.width = initialColumn.getWidth();
|
|
||||||
}
|
|
||||||
|
|
||||||
public addNeighbors(visibleRange: Range, gap: number, requireVisible: boolean) {
|
|
||||||
const grid = this.left.grid;
|
|
||||||
|
|
||||||
let leftColumn: Column|null = this.left;
|
|
||||||
while (true) {
|
|
||||||
leftColumn = grid.getPrevColumn(leftColumn);
|
|
||||||
if (
|
|
||||||
leftColumn === null ||
|
|
||||||
requireVisible && !leftColumn.isVisible(visibleRange, true) ||
|
|
||||||
this.width + gap + leftColumn.getWidth() > visibleRange.getWidth()
|
|
||||||
) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
this.addLeft(leftColumn, gap);
|
|
||||||
}
|
|
||||||
|
|
||||||
let rightColumn: Column|null = this.right;
|
|
||||||
while (true) {
|
|
||||||
rightColumn = grid.getNextColumn(rightColumn);
|
|
||||||
if (
|
|
||||||
rightColumn === null ||
|
|
||||||
requireVisible && !rightColumn.isVisible(visibleRange, true) ||
|
|
||||||
this.width + gap + rightColumn.getWidth() > visibleRange.getWidth()
|
|
||||||
) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
this.addRight(rightColumn, gap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public addLeft(column: Column, gap: number) {
|
|
||||||
this.left = column;
|
|
||||||
this.width += column.getWidth() + gap;
|
|
||||||
}
|
|
||||||
|
|
||||||
public addRight(column: Column, gap: number) {
|
|
||||||
this.right = column;
|
|
||||||
this.width += column.getWidth() + gap;
|
|
||||||
}
|
|
||||||
|
|
||||||
public getLeft() {
|
|
||||||
return this.left.getLeft();
|
|
||||||
}
|
|
||||||
|
|
||||||
public getRight() {
|
|
||||||
return this.right.getRight();
|
|
||||||
}
|
|
||||||
|
|
||||||
public getWidth() {
|
|
||||||
return this.width;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
62
src/lib/behavior/PresetWidths.ts
Normal file
62
src/lib/behavior/PresetWidths.ts
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
class PresetWidths {
|
||||||
|
private readonly presets: ((maxWidth: number) => number)[];
|
||||||
|
|
||||||
|
constructor(presetWidths: string, spacing: number) {
|
||||||
|
this.presets = PresetWidths.parsePresetWidths(presetWidths, spacing);
|
||||||
|
}
|
||||||
|
|
||||||
|
public next(currentWidth: number, minWidth: number, maxWidth: number) {
|
||||||
|
const widths = this.getWidths(minWidth, maxWidth);
|
||||||
|
const nextIndex = widths.findIndex(width => width > currentWidth);
|
||||||
|
return nextIndex >= 0 ? widths[nextIndex] : widths[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public prev(currentWidth: number, minWidth: number, maxWidth: number) {
|
||||||
|
const widths = this.getWidths(minWidth, maxWidth).reverse();
|
||||||
|
const nextIndex = widths.findIndex(width => width < currentWidth);
|
||||||
|
return nextIndex >= 0 ? widths[nextIndex] : widths[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public getWidths(minWidth: number, maxWidth: number) {
|
||||||
|
const widths = this.presets.map(f => clamp(f(maxWidth), minWidth, maxWidth));
|
||||||
|
widths.sort((a, b) => a - b);
|
||||||
|
return uniq(widths);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static parsePresetWidths(presetWidths: string, spacing: number): ((maxWidth: number) => number)[] {
|
||||||
|
function getRatioFunction(ratio: number) {
|
||||||
|
return (maxWidth: number) => Math.floor((maxWidth + spacing) * ratio - spacing);
|
||||||
|
}
|
||||||
|
|
||||||
|
return presetWidths.split(",").map((widthStr: string) => {
|
||||||
|
widthStr = widthStr.trim();
|
||||||
|
|
||||||
|
const widthPx = PresetWidths.parseNumberWithSuffix(widthStr, "px");
|
||||||
|
if (widthPx !== undefined) {
|
||||||
|
return () => widthPx;
|
||||||
|
}
|
||||||
|
|
||||||
|
const widthPct = PresetWidths.parseNumberWithSuffix(widthStr, "%");
|
||||||
|
if (widthPct !== undefined) {
|
||||||
|
return getRatioFunction(widthPct / 100.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return getRatioFunction(PresetWidths.parseNumberSafe(widthStr));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static parseNumberSafe(str: string) {
|
||||||
|
const num = Number(str);
|
||||||
|
if (isNaN(num) || num <= 0) {
|
||||||
|
throw new Error("Invalid number: " + str);
|
||||||
|
}
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static parseNumberWithSuffix(str: string, suffix: string) {
|
||||||
|
if (!str.endsWith(suffix)) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return PresetWidths.parseNumberSafe(str.substring(0, str.length-suffix.length).trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
89
src/lib/behavior/columnResizer/ContextualResizer.ts
Normal file
89
src/lib/behavior/columnResizer/ContextualResizer.ts
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
class ContextualResizer {
|
||||||
|
constructor(
|
||||||
|
private readonly presetWidths: { getWidths: (minWidth: number, maxWidth: number) => number[] },
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public increaseWidth(column: Column) {
|
||||||
|
const grid = column.grid;
|
||||||
|
const desktop = grid.desktop;
|
||||||
|
const visibleRange = desktop.getCurrentVisibleRange();
|
||||||
|
const minWidth = column.getMinWidth();
|
||||||
|
const maxWidth = column.getMaxWidth();
|
||||||
|
if(!Range.contains(visibleRange, column) || column.getWidth() >= maxWidth) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let leftVisibleColumn = grid.getLeftmostVisibleColumn(visibleRange, true);
|
||||||
|
let rightVisibleColumn = grid.getRightmostVisibleColumn(visibleRange, true);
|
||||||
|
if (leftVisibleColumn === null || rightVisibleColumn === null) {
|
||||||
|
console.assert(false); // should at least see self
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const leftSpace = leftVisibleColumn.getLeft() - visibleRange.getLeft();
|
||||||
|
const rightSpace = visibleRange.getRight() - rightVisibleColumn.getRight();
|
||||||
|
|
||||||
|
const newWidth = findMinPositive(
|
||||||
|
[
|
||||||
|
column.getWidth() + leftSpace + rightSpace,
|
||||||
|
column.getWidth() + leftSpace + rightSpace + leftVisibleColumn.getWidth() + grid.config.gapsInnerHorizontal,
|
||||||
|
column.getWidth() + leftSpace + rightSpace + rightVisibleColumn.getWidth() + grid.config.gapsInnerHorizontal,
|
||||||
|
...this.presetWidths.getWidths(minWidth, maxWidth),
|
||||||
|
],
|
||||||
|
width => width - column.getWidth(),
|
||||||
|
)
|
||||||
|
if (newWidth === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
column.setWidth(newWidth, true);
|
||||||
|
desktop.scrollCenterVisible(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
public decreaseWidth(column: Column) {
|
||||||
|
const grid = column.grid;
|
||||||
|
const desktop = grid.desktop;
|
||||||
|
const visibleRange = desktop.getCurrentVisibleRange();
|
||||||
|
const minWidth = column.getMinWidth();
|
||||||
|
const maxWidth = column.getMaxWidth();
|
||||||
|
if(!Range.contains(visibleRange, column) || column.getWidth() <= minWidth) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const leftVisibleColumn = grid.getLeftmostVisibleColumn(visibleRange, true);
|
||||||
|
const rightVisibleColumn = grid.getRightmostVisibleColumn(visibleRange, true);
|
||||||
|
if (leftVisibleColumn === null || rightVisibleColumn === null) {
|
||||||
|
console.assert(false); // should at least see self
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let leftOffScreenColumn = grid.getLeftColumn(leftVisibleColumn);
|
||||||
|
if (leftOffScreenColumn === column) {
|
||||||
|
leftOffScreenColumn = null;
|
||||||
|
}
|
||||||
|
let rightOffScreenColumn = grid.getRightColumn(rightVisibleColumn);
|
||||||
|
if (rightOffScreenColumn === column) {
|
||||||
|
rightOffScreenColumn = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const visibleColumnsWidth = rightVisibleColumn.getRight() - leftVisibleColumn.getLeft();
|
||||||
|
const unusedWidth = visibleRange.getWidth() - visibleColumnsWidth;
|
||||||
|
const leftOffScreen = leftOffScreenColumn === null ? 0 : leftOffScreenColumn.getWidth() + grid.config.gapsInnerHorizontal - unusedWidth;
|
||||||
|
const rightOffScreen = rightOffScreenColumn === null ? 0 : rightOffScreenColumn.getWidth() + grid.config.gapsInnerHorizontal - unusedWidth;
|
||||||
|
|
||||||
|
const newWidth = findMinPositive(
|
||||||
|
[
|
||||||
|
column.getWidth() - leftOffScreen,
|
||||||
|
column.getWidth() - rightOffScreen,
|
||||||
|
...this.presetWidths.getWidths(minWidth, maxWidth),
|
||||||
|
],
|
||||||
|
width => column.getWidth() - width,
|
||||||
|
)
|
||||||
|
if (newWidth === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
column.setWidth(newWidth, true);
|
||||||
|
desktop.scrollCenterVisible(column);
|
||||||
|
}
|
||||||
|
}
|
||||||
31
src/lib/behavior/columnResizer/RawResizer.ts
Normal file
31
src/lib/behavior/columnResizer/RawResizer.ts
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
class RawResizer {
|
||||||
|
constructor(
|
||||||
|
private readonly presetWidths: { getWidths: (minWidth: number, maxWidth: number) => number[] },
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public increaseWidth(column: Column) {
|
||||||
|
const newWidth = findMinPositive(
|
||||||
|
[
|
||||||
|
...this.presetWidths.getWidths(column.getMinWidth(), column.getMaxWidth()),
|
||||||
|
],
|
||||||
|
width => width - column.getWidth(),
|
||||||
|
);
|
||||||
|
if (newWidth === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
column.setWidth(newWidth, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public decreaseWidth(column: Column) {
|
||||||
|
const newWidth = findMinPositive(
|
||||||
|
[
|
||||||
|
...this.presetWidths.getWidths(column.getMinWidth(), column.getMaxWidth()),
|
||||||
|
],
|
||||||
|
width => column.getWidth() - width,
|
||||||
|
);
|
||||||
|
if (newWidth === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
column.setWidth(newWidth, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +1,5 @@
|
|||||||
class ScrollerCentered {
|
class CenterClamper {
|
||||||
public scrollToColumn(desktop: Desktop, column: Column) {
|
|
||||||
desktop.scrollCenterRange(column);
|
|
||||||
}
|
|
||||||
|
|
||||||
public clampScrollX(desktop: Desktop, x: number) {
|
public clampScrollX(desktop: Desktop, x: number) {
|
||||||
return ScrollerCentered.clampScrollX(desktop, x);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static clampScrollX(desktop: Desktop, x: number) {
|
|
||||||
const firstColumn = desktop.grid.getFirstColumn();
|
const firstColumn = desktop.grid.getFirstColumn();
|
||||||
if (firstColumn === null) {
|
if (firstColumn === null) {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1,8 +1,4 @@
|
|||||||
class ScrollerLazy {
|
class EdgeClamper {
|
||||||
public scrollToColumn(desktop: Desktop, column: Column) {
|
|
||||||
desktop.scrollToRange(column);
|
|
||||||
}
|
|
||||||
|
|
||||||
public clampScrollX(desktop: Desktop, x: number) {
|
public clampScrollX(desktop: Desktop, x: number) {
|
||||||
let minScroll = 0;
|
let minScroll = 0;
|
||||||
let maxScroll = desktop.grid.getWidth() - desktop.tilingArea.width;
|
let maxScroll = desktop.grid.getWidth() - desktop.tilingArea.width;
|
||||||
5
src/lib/behavior/scroller/CenteredScroller.ts
Normal file
5
src/lib/behavior/scroller/CenteredScroller.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
class CenteredScroller {
|
||||||
|
public scrollToColumn(desktop: Desktop, column: Column) {
|
||||||
|
desktop.scrollCenterRange(column);
|
||||||
|
}
|
||||||
|
}
|
||||||
5
src/lib/behavior/scroller/GroupedScroller.ts
Normal file
5
src/lib/behavior/scroller/GroupedScroller.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
class GroupedScroller {
|
||||||
|
public scrollToColumn(desktop: Desktop, column: Column) {
|
||||||
|
desktop.scrollCenterVisible(column);
|
||||||
|
}
|
||||||
|
}
|
||||||
5
src/lib/behavior/scroller/LazyScroller.ts
Normal file
5
src/lib/behavior/scroller/LazyScroller.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
class LazyScroller {
|
||||||
|
public scrollToColumn(desktop: Desktop, column: Column) {
|
||||||
|
desktop.scrollIntoView(column);
|
||||||
|
}
|
||||||
|
}
|
||||||
22
src/lib/config/config.ts
Normal file
22
src/lib/config/config.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
type Config = {
|
||||||
|
gapsOuterTop: number;
|
||||||
|
gapsOuterBottom: number;
|
||||||
|
gapsOuterLeft: number;
|
||||||
|
gapsOuterRight: number;
|
||||||
|
gapsInnerHorizontal: number;
|
||||||
|
gapsInnerVertical: number;
|
||||||
|
manualScrollStep: number;
|
||||||
|
presetWidths: string;
|
||||||
|
offScreenOpacity: number;
|
||||||
|
untileOnDrag: boolean;
|
||||||
|
stackColumnsByDefault: boolean;
|
||||||
|
resizeNeighborColumn: boolean;
|
||||||
|
reMaximize: boolean;
|
||||||
|
skipSwitcher: boolean;
|
||||||
|
scrollingLazy: boolean;
|
||||||
|
scrollingCentered: boolean;
|
||||||
|
scrollingGrouped: boolean;
|
||||||
|
tiledKeepBelow: boolean;
|
||||||
|
floatingKeepAbove: boolean;
|
||||||
|
windowRules: string;
|
||||||
|
};
|
||||||
158
src/lib/config/definition.ts
Normal file
158
src/lib/config/definition.ts
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
const defaultWindowRules = `[
|
||||||
|
{
|
||||||
|
"class": "(org\\\\.kde\\\\.)?plasmashell",
|
||||||
|
"tile": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"class": "(org\\\\.kde\\\\.)?kded6",
|
||||||
|
"tile": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"class": "(org\\\\.kde\\\\.)?kcalc",
|
||||||
|
"tile": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"class": "(org\\\\.kde\\\\.)?kfind",
|
||||||
|
"tile": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"class": "(org\\\\.kde\\\\.)?kruler",
|
||||||
|
"tile": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"class": "(org\\\\.kde\\\\.)?krunner",
|
||||||
|
"tile": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"class": "(org\\\\.kde\\\\.)?yakuake",
|
||||||
|
"tile": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"class": "steam",
|
||||||
|
"caption": "Steam Big Picture Mode",
|
||||||
|
"tile": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"class": "zoom",
|
||||||
|
"caption": "Zoom Cloud Meetings|zoom|zoom <2>",
|
||||||
|
"tile": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"class": "jetbrains-.*",
|
||||||
|
"caption": "splash",
|
||||||
|
"tile": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"class": "jetbrains-.*",
|
||||||
|
"caption": "Unstash Changes|Paths Affected by stash@.*",
|
||||||
|
"tile": true
|
||||||
|
}
|
||||||
|
]`;
|
||||||
|
|
||||||
|
const configDef = [
|
||||||
|
{
|
||||||
|
name: "gapsOuterTop",
|
||||||
|
type: "UInt",
|
||||||
|
default: 16,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "gapsOuterBottom",
|
||||||
|
type: "UInt",
|
||||||
|
default: 16,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "gapsOuterLeft",
|
||||||
|
type: "UInt",
|
||||||
|
default: 16,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "gapsOuterRight",
|
||||||
|
type: "UInt",
|
||||||
|
default: 16,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "gapsInnerHorizontal",
|
||||||
|
type: "UInt",
|
||||||
|
default: 8,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "gapsInnerVertical",
|
||||||
|
type: "UInt",
|
||||||
|
default: 8,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "manualScrollStep",
|
||||||
|
type: "UInt",
|
||||||
|
default: 200,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "presetWidths",
|
||||||
|
type: "String",
|
||||||
|
default: "50%, 100%",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "offScreenOpacity",
|
||||||
|
type: "UInt",
|
||||||
|
default: 100,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "untileOnDrag",
|
||||||
|
type: "Bool",
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "stackColumnsByDefault",
|
||||||
|
type: "Bool",
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "resizeNeighborColumn",
|
||||||
|
type: "Bool",
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "reMaximize",
|
||||||
|
type: "Bool",
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "skipSwitcher",
|
||||||
|
type: "Bool",
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "scrollingLazy",
|
||||||
|
type: "Bool",
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "scrollingCentered",
|
||||||
|
type: "Bool",
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "scrollingGrouped",
|
||||||
|
type: "Bool",
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "tiledKeepBelow",
|
||||||
|
type: "Bool",
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "floatingKeepAbove",
|
||||||
|
type: "Bool",
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "noLayering",
|
||||||
|
type: "Bool",
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "windowRules",
|
||||||
|
type: "String",
|
||||||
|
default: defaultWindowRules,
|
||||||
|
}
|
||||||
|
];
|
||||||
1
src/lib/extern/global.d.ts
vendored
Normal file
1
src/lib/extern/global.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
declare const console: Console;
|
||||||
112
src/lib/extern/kwin.ts
vendored
Normal file
112
src/lib/extern/kwin.ts
vendored
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
type KWin = {
|
||||||
|
__brand: "KWin";
|
||||||
|
|
||||||
|
readConfig(key: string, defaultValue: any): any;
|
||||||
|
};
|
||||||
|
|
||||||
|
type Workspace = {
|
||||||
|
__brand: "Workspace";
|
||||||
|
|
||||||
|
readonly activities: string[];
|
||||||
|
readonly desktops: KwinDesktop[];
|
||||||
|
readonly currentDesktop: KwinDesktop;
|
||||||
|
readonly currentActivity: string;
|
||||||
|
readonly activeScreen: Output;
|
||||||
|
readonly windows: KwinClient[];
|
||||||
|
readonly cursorPos: Readonly<QmlPoint>;
|
||||||
|
|
||||||
|
activeWindow: KwinClient|null;
|
||||||
|
|
||||||
|
readonly currentDesktopChanged: QSignal<[]>;
|
||||||
|
readonly windowAdded: QSignal<[KwinClient]>;
|
||||||
|
readonly windowRemoved: QSignal<[KwinClient]>;
|
||||||
|
readonly windowActivated: QSignal<[KwinClient|null]>;
|
||||||
|
readonly screensChanged: QSignal<[]>;
|
||||||
|
readonly activitiesChanged: QSignal<[]>;
|
||||||
|
readonly desktopsChanged: QSignal<[]>;
|
||||||
|
readonly currentActivityChanged: QSignal<[]>;
|
||||||
|
readonly virtualScreenSizeChanged: QSignal<[]>;
|
||||||
|
|
||||||
|
clientArea(option: ClientAreaOption, output: Output, kwinDesktop: KwinDesktop): QmlRect;
|
||||||
|
};
|
||||||
|
|
||||||
|
const enum ClientAreaOption {
|
||||||
|
PlacementArea,
|
||||||
|
MovementArea,
|
||||||
|
MaximizeArea,
|
||||||
|
MaximizeFullArea,
|
||||||
|
FullScreenArea,
|
||||||
|
WorkArea,
|
||||||
|
FullArea,
|
||||||
|
ScreenArea,
|
||||||
|
}
|
||||||
|
|
||||||
|
const enum MaximizedMode {
|
||||||
|
Unmaximized,
|
||||||
|
Vertically,
|
||||||
|
Horizontally,
|
||||||
|
Maximized,
|
||||||
|
}
|
||||||
|
|
||||||
|
type Tile = { __brand: "Tile" };
|
||||||
|
type Output = { __brand: "Output" };
|
||||||
|
|
||||||
|
type KwinClient = {
|
||||||
|
__brand: "KwinClient";
|
||||||
|
|
||||||
|
readonly shadeable: boolean;
|
||||||
|
readonly caption: string;
|
||||||
|
readonly minSize: Readonly<QmlSize>;
|
||||||
|
readonly transient: boolean;
|
||||||
|
readonly transientFor: KwinClient | null;
|
||||||
|
readonly clientGeometry: Readonly<QmlRect>;
|
||||||
|
readonly move: boolean;
|
||||||
|
readonly resize: boolean;
|
||||||
|
readonly moveable: boolean;
|
||||||
|
readonly resizeable: boolean;
|
||||||
|
readonly fullScreenable: boolean;
|
||||||
|
readonly maximizable: boolean;
|
||||||
|
readonly output: Output;
|
||||||
|
readonly resourceClass: string;
|
||||||
|
readonly dock: boolean;
|
||||||
|
readonly normalWindow: boolean;
|
||||||
|
readonly managed: boolean;
|
||||||
|
readonly popupWindow: boolean;
|
||||||
|
readonly pid: number;
|
||||||
|
|
||||||
|
fullScreen: boolean;
|
||||||
|
activities: string[]; // empty array means all activities
|
||||||
|
skipSwitcher: boolean;
|
||||||
|
keepAbove: boolean;
|
||||||
|
keepBelow: boolean;
|
||||||
|
shade: boolean;
|
||||||
|
minimized: boolean;
|
||||||
|
frameGeometry: QmlRect;
|
||||||
|
desktops: KwinDesktop[]; // empty array means all desktops
|
||||||
|
tile: Tile|null;
|
||||||
|
opacity: number;
|
||||||
|
|
||||||
|
readonly fullScreenChanged: QSignal<[]>;
|
||||||
|
readonly desktopsChanged: QSignal<[]>;
|
||||||
|
readonly activitiesChanged: QSignal<[]>;
|
||||||
|
readonly minimizedChanged: QSignal<[]>;
|
||||||
|
readonly maximizedAboutToChange: QSignal<[MaximizedMode]>;
|
||||||
|
readonly captionChanged: QSignal<[]>;
|
||||||
|
readonly tileChanged: QSignal<[]>;
|
||||||
|
readonly interactiveMoveResizeStarted: QSignal<[]>;
|
||||||
|
readonly interactiveMoveResizeFinished: QSignal<[]>;
|
||||||
|
readonly frameGeometryChanged: QSignal<[oldGeometry: QmlRect]>;
|
||||||
|
|
||||||
|
setMaximize(vertically: boolean, horizontally: boolean): void;
|
||||||
|
};
|
||||||
|
|
||||||
|
type KwinDesktop = {
|
||||||
|
__brand: "KwinDesktop";
|
||||||
|
|
||||||
|
readonly id: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type ShortcutHandler = QmlObject & {
|
||||||
|
readonly activated: QSignal<[]>;
|
||||||
|
destroy(): void;
|
||||||
|
};
|
||||||
3
src/lib/extern/notification.ts
vendored
Normal file
3
src/lib/extern/notification.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
type Notification = QmlObject & {
|
||||||
|
sendEvent(): void;
|
||||||
|
};
|
||||||
56
src/lib/extern/qt.ts
vendored
Normal file
56
src/lib/extern/qt.ts
vendored
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
type Console = {
|
||||||
|
__brand: "Console";
|
||||||
|
|
||||||
|
log(...args: any[]): void;
|
||||||
|
assert(assertion: boolean, message?: string): void;
|
||||||
|
};
|
||||||
|
|
||||||
|
type Qt = {
|
||||||
|
__brand: "Qt";
|
||||||
|
|
||||||
|
rect(x: number, y: number, width: number, height: number): QmlRect;
|
||||||
|
createQmlObject(qml: string, parent: QmlObject): QmlObject;
|
||||||
|
};
|
||||||
|
|
||||||
|
type QmlObject = { __brand: "QmlObject" };
|
||||||
|
|
||||||
|
type QmlPoint = {
|
||||||
|
__brand: "QmlPoint";
|
||||||
|
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
type QmlRect = {
|
||||||
|
__brand: "QmlRect";
|
||||||
|
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
width: number;
|
||||||
|
height: number;
|
||||||
|
readonly top: number;
|
||||||
|
readonly bottom: number; // top + height
|
||||||
|
readonly left: number;
|
||||||
|
readonly right: number; // left + width
|
||||||
|
};
|
||||||
|
|
||||||
|
type QmlSize = {
|
||||||
|
__brand: "QmlSize";
|
||||||
|
|
||||||
|
width: number;
|
||||||
|
height: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
type QSignal<T extends unknown[]> = {
|
||||||
|
__brand: "QSignal";
|
||||||
|
|
||||||
|
connect(handler: (...args: [...T]) => void): void;
|
||||||
|
disconnect(handler: (...args: [...T]) => void): void;
|
||||||
|
};
|
||||||
|
|
||||||
|
type QmlTimer = QmlObject & {
|
||||||
|
interval: number;
|
||||||
|
readonly triggered: QSignal<[]>;
|
||||||
|
restart(): void;
|
||||||
|
destroy(): void;
|
||||||
|
};
|
||||||
428
src/lib/keyBindings/Actions.ts
Normal file
428
src/lib/keyBindings/Actions.ts
Normal file
@@ -0,0 +1,428 @@
|
|||||||
|
class Actions {
|
||||||
|
constructor(
|
||||||
|
private readonly config: Actions.Config,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public readonly focusLeft = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
||||||
|
const leftColumn = grid.getLeftColumn(column);
|
||||||
|
if (leftColumn === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
leftColumn.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly focusRight = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
||||||
|
const rightColumn = grid.getRightColumn(column);
|
||||||
|
if (rightColumn === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
rightColumn.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly focusUp = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
||||||
|
const aboveWindow = column.getAboveWindow(window);
|
||||||
|
if (aboveWindow === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
aboveWindow.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly focusDown = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
||||||
|
const belowWindow = column.getBelowWindow(window);
|
||||||
|
if (belowWindow === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
belowWindow.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly focusNext = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
||||||
|
const belowWindow = column.getBelowWindow(window);
|
||||||
|
if (belowWindow !== null) {
|
||||||
|
belowWindow.focus();
|
||||||
|
} else {
|
||||||
|
const rightColumn = grid.getRightColumn(column);
|
||||||
|
if (rightColumn === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
rightColumn.getFirstWindow().focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly focusPrevious = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
||||||
|
const aboveWindow = column.getAboveWindow(window);
|
||||||
|
if (aboveWindow !== null) {
|
||||||
|
aboveWindow.focus();
|
||||||
|
} else {
|
||||||
|
const leftColumn = grid.getLeftColumn(column);
|
||||||
|
if (leftColumn === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
leftColumn.getLastWindow().focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly focusStart = (cm: ClientManager, dm: DesktopManager) => {
|
||||||
|
const grid = dm.getCurrentDesktop().grid;
|
||||||
|
const firstColumn = grid.getFirstColumn();
|
||||||
|
if (firstColumn === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
firstColumn.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly focusEnd = (cm: ClientManager, dm: DesktopManager) => {
|
||||||
|
const grid = dm.getCurrentDesktop().grid;
|
||||||
|
const lastColumn = grid.getLastColumn();
|
||||||
|
if (lastColumn === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lastColumn.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly windowMoveLeft = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
||||||
|
if (column.getWindowCount() === 1) {
|
||||||
|
// move from own column into existing column
|
||||||
|
const leftColumn = grid.getLeftColumn(column);
|
||||||
|
if (leftColumn === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
window.moveToColumn(leftColumn, true);
|
||||||
|
grid.desktop.autoAdjustScroll();
|
||||||
|
} else {
|
||||||
|
// move from shared column into own column
|
||||||
|
const newColumn = new Column(grid, grid.getLeftColumn(column));
|
||||||
|
window.moveToColumn(newColumn, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly windowMoveRight = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid, bottom: boolean = true) => {
|
||||||
|
if (column.getWindowCount() === 1) {
|
||||||
|
// move from own column into existing column
|
||||||
|
const rightColumn = grid.getRightColumn(column);
|
||||||
|
if (rightColumn === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
window.moveToColumn(rightColumn, bottom);
|
||||||
|
grid.desktop.autoAdjustScroll();
|
||||||
|
} else {
|
||||||
|
// move from shared column into own column
|
||||||
|
const newColumn = new Column(grid, column);
|
||||||
|
window.moveToColumn(newColumn, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO (optimization): only arrange moved windows
|
||||||
|
public readonly windowMoveUp = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
||||||
|
column.moveWindowUp(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO (optimization): only arrange moved windows
|
||||||
|
public readonly windowMoveDown = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
||||||
|
column.moveWindowDown(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly windowMoveNext = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
||||||
|
const canMoveDown = window !== column.getLastWindow();
|
||||||
|
if (canMoveDown) {
|
||||||
|
column.moveWindowDown(window);
|
||||||
|
} else {
|
||||||
|
this.windowMoveRight(cm, dm, window, column, grid, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly windowMovePrevious = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
||||||
|
const canMoveUp = window !== column.getFirstWindow();
|
||||||
|
if (canMoveUp) {
|
||||||
|
column.moveWindowUp(window);
|
||||||
|
} else {
|
||||||
|
this.windowMoveLeft(cm, dm, window, column, grid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly windowMoveStart = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
||||||
|
const newColumn = new Column(grid, null);
|
||||||
|
window.moveToColumn(newColumn, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly windowMoveEnd = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
||||||
|
const newColumn = new Column(grid, grid.getLastColumn());
|
||||||
|
window.moveToColumn(newColumn, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly windowToggleFloating = (cm: ClientManager, dm: DesktopManager) => {
|
||||||
|
if (Workspace.activeWindow === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cm.toggleFloatingClient(Workspace.activeWindow);
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly columnMoveLeft = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
||||||
|
grid.moveColumnLeft(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly columnMoveRight = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
||||||
|
grid.moveColumnRight(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly columnMoveStart = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
||||||
|
grid.moveColumn(column, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly columnMoveEnd = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
||||||
|
grid.moveColumn(column, grid.getLastColumn());
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly columnToggleStacked = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
||||||
|
column.toggleStacked();
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly columnWidthIncrease = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
||||||
|
this.config.columnResizer.increaseWidth(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly columnWidthDecrease = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
||||||
|
this.config.columnResizer.decreaseWidth(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
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());
|
||||||
|
column.setWidth(nextWidth, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly cyclePresetWidthsReverse = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
||||||
|
const nextWidth = this.config.presetWidths.prev(column.getWidth(), column.getMinWidth(), column.getMaxWidth());
|
||||||
|
column.setWidth(nextWidth, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly columnsWidthEqualize = (cm: ClientManager, dm: DesktopManager) => {
|
||||||
|
const desktop = dm.getCurrentDesktop();
|
||||||
|
const visibleRange = desktop.getCurrentVisibleRange();
|
||||||
|
const visibleColumns = Array.from(desktop.grid.getVisibleColumns(visibleRange, true));
|
||||||
|
|
||||||
|
const availableSpace = desktop.tilingArea.width;
|
||||||
|
const gapsWidth = desktop.grid.config.gapsInnerHorizontal * (visibleColumns.length-1);
|
||||||
|
const widths = fillSpace(
|
||||||
|
availableSpace - gapsWidth,
|
||||||
|
visibleColumns.map(column => ({ min: column.getMinWidth(), max: column.getMaxWidth() })),
|
||||||
|
);
|
||||||
|
visibleColumns.forEach((column, index) => column.setWidth(widths[index], true));
|
||||||
|
|
||||||
|
desktop.scrollCenterRange(Range.fromRanges(
|
||||||
|
visibleColumns[0],
|
||||||
|
visibleColumns[visibleColumns.length - 1],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly columnsSqueezeLeft = (cm: ClientManager, dm: DesktopManager, window: Window, focusedColumn: Column, grid: Grid) => {
|
||||||
|
const visibleRange = grid.desktop.getCurrentVisibleRange();
|
||||||
|
if (!Range.contains(visibleRange, focusedColumn)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const currentVisibleColumns = Array.from(grid.getVisibleColumns(visibleRange, true));
|
||||||
|
console.assert(currentVisibleColumns.includes(focusedColumn), "should at least contain the focused column");
|
||||||
|
|
||||||
|
const targetColumn = grid.getLeftColumn(currentVisibleColumns[0]);
|
||||||
|
if (targetColumn === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const wantedVisibleColumns = [targetColumn, ...currentVisibleColumns];
|
||||||
|
while (true) {
|
||||||
|
const success = this.squeezeColumns(wantedVisibleColumns);
|
||||||
|
if (success) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const removedColumn = wantedVisibleColumns.pop();
|
||||||
|
if (removedColumn === focusedColumn) {
|
||||||
|
break; // don't scroll past the currently focused column
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly columnsSqueezeRight = (cm: ClientManager, dm: DesktopManager, window: Window, focusedColumn: Column, grid: Grid) => {
|
||||||
|
const visibleRange = grid.desktop.getCurrentVisibleRange();
|
||||||
|
if (!Range.contains(visibleRange, focusedColumn)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const currentVisibleColumns = Array.from(grid.getVisibleColumns(visibleRange, true));
|
||||||
|
console.assert(currentVisibleColumns.includes(focusedColumn), "should at least contain the focused column");
|
||||||
|
|
||||||
|
const targetColumn = grid.getRightColumn(currentVisibleColumns[currentVisibleColumns.length-1]);
|
||||||
|
if (targetColumn === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const wantedVisibleColumns = [...currentVisibleColumns, targetColumn];
|
||||||
|
while (true) {
|
||||||
|
const success = this.squeezeColumns(wantedVisibleColumns);
|
||||||
|
if (success) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const removedColumn = wantedVisibleColumns.shift();
|
||||||
|
if (removedColumn === focusedColumn) {
|
||||||
|
break; // don't scroll past the currently focused column
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly squeezeColumns = (columns: Column[]) => {
|
||||||
|
const firstColumn = columns[0];
|
||||||
|
const lastColumn = columns[columns.length-1];
|
||||||
|
const grid = firstColumn.grid;
|
||||||
|
const desktop = grid.desktop;
|
||||||
|
|
||||||
|
const availableSpace = desktop.tilingArea.width;
|
||||||
|
const gapsWidth = grid.config.gapsInnerHorizontal * (columns.length-1);
|
||||||
|
const columnConstraints = columns.map(column => ({ min: column.getMinWidth(), max: column.getWidth() }));
|
||||||
|
const minTotalWidth = gapsWidth + columnConstraints.reduce((acc, constraint) => acc + constraint.min, 0);
|
||||||
|
if (minTotalWidth > availableSpace) {
|
||||||
|
// there's nothing we can do
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const widths = fillSpace(availableSpace - gapsWidth, columnConstraints);
|
||||||
|
columns.forEach((column, index) => column.setWidth(widths[index], true));
|
||||||
|
desktop.scrollCenterRange(Range.fromRanges(firstColumn, lastColumn));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly gridScrollLeft = (cm: ClientManager, dm: DesktopManager) => {
|
||||||
|
this.gridScroll(dm, -this.config.manualScrollStep);
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly gridScrollRight = (cm: ClientManager, dm: DesktopManager) => {
|
||||||
|
this.gridScroll(dm, this.config.manualScrollStep);
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly gridScroll = (desktopManager: DesktopManager, amount: number) => {
|
||||||
|
desktopManager.getCurrentDesktop().adjustScroll(amount, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly gridScrollStart = (cm: ClientManager, dm: DesktopManager) => {
|
||||||
|
const grid = dm.getCurrentDesktop().grid;
|
||||||
|
const firstColumn = grid.getFirstColumn();
|
||||||
|
if (firstColumn === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
grid.desktop.scrollToColumn(firstColumn);
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly gridScrollEnd = (cm: ClientManager, dm: DesktopManager) => {
|
||||||
|
const grid = dm.getCurrentDesktop().grid;
|
||||||
|
const lastColumn = grid.getLastColumn();
|
||||||
|
if (lastColumn === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
grid.desktop.scrollToColumn(lastColumn);
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly gridScrollFocused = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
||||||
|
grid.desktop.scrollCenterRange(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly gridScrollLeftColumn = (cm: ClientManager, dm: DesktopManager) => {
|
||||||
|
const grid = dm.getCurrentDesktop().grid;
|
||||||
|
const column = grid.getLeftmostVisibleColumn(grid.desktop.getCurrentVisibleRange(), true);
|
||||||
|
if (column === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const leftColumn = grid.getLeftColumn(column);
|
||||||
|
if (leftColumn === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
grid.desktop.scrollToColumn(leftColumn);
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly gridScrollRightColumn = (cm: ClientManager, dm: DesktopManager) => {
|
||||||
|
const grid = dm.getCurrentDesktop().grid;
|
||||||
|
const column = grid.getRightmostVisibleColumn(grid.desktop.getCurrentVisibleRange(), true);
|
||||||
|
if (column === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const rightColumn = grid.getRightColumn(column);
|
||||||
|
if (rightColumn === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
grid.desktop.scrollToColumn(rightColumn);
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly screenSwitch = (cm: ClientManager, dm: DesktopManager) => {
|
||||||
|
dm.selectScreen(Workspace.activeScreen);
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly focus = (columnIndex: number, cm: ClientManager, dm: DesktopManager) => {
|
||||||
|
const grid = dm.getCurrentDesktop().grid;
|
||||||
|
const targetColumn = grid.getColumnAtIndex(columnIndex);
|
||||||
|
if (targetColumn === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
targetColumn.focus();
|
||||||
|
};
|
||||||
|
|
||||||
|
public readonly windowMoveToColumn = (columnIndex: number, cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
||||||
|
const targetColumn = grid.getColumnAtIndex(columnIndex);
|
||||||
|
if (targetColumn === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
window.moveToColumn(targetColumn, true);
|
||||||
|
grid.desktop.autoAdjustScroll();
|
||||||
|
};
|
||||||
|
|
||||||
|
public readonly columnMoveToColumn = (columnIndex: number, cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
|
||||||
|
const targetColumn = grid.getColumnAtIndex(columnIndex);
|
||||||
|
if (targetColumn === null || targetColumn === column) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (targetColumn.isToTheRightOf(column)) {
|
||||||
|
grid.moveColumn(column, targetColumn);
|
||||||
|
} else {
|
||||||
|
grid.moveColumn(column, grid.getLeftColumn(targetColumn));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public readonly columnMoveToDesktop = (desktopIndex: number, cm: ClientManager, dm: DesktopManager, window: Window, column: Column, oldGrid: Grid) => {
|
||||||
|
const kwinDesktop = Workspace.desktops[desktopIndex];
|
||||||
|
if (kwinDesktop === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const newGrid = dm.getDesktopInCurrentActivity(kwinDesktop).grid;
|
||||||
|
if (newGrid === null || newGrid === oldGrid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
column.moveToGrid(newGrid, newGrid.getLastColumn());
|
||||||
|
};
|
||||||
|
|
||||||
|
public readonly tailMoveToDesktop = (desktopIndex: number, cm: ClientManager, dm: DesktopManager, window: Window, column: Column, oldGrid: Grid) => {
|
||||||
|
const kwinDesktop = Workspace.desktops[desktopIndex];
|
||||||
|
if (kwinDesktop === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const newGrid = dm.getDesktopInCurrentActivity(kwinDesktop).grid;
|
||||||
|
if (newGrid === null || newGrid === oldGrid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
oldGrid.evacuateTail(newGrid, column);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Actions {
|
||||||
|
export type Config = {
|
||||||
|
manualScrollStep: number;
|
||||||
|
presetWidths: {
|
||||||
|
next: (currentWidth: number, minWidth: number, maxWidth: number) => number;
|
||||||
|
prev: (currentWidth: number, minWidth: number, maxWidth: number) => number
|
||||||
|
};
|
||||||
|
columnResizer: ColumnResizer;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type ColumnResizer = {
|
||||||
|
increaseWidth(column: Column): void;
|
||||||
|
decreaseWidth(column: Column): void;
|
||||||
|
};
|
||||||
|
}
|
||||||
273
src/lib/keyBindings/definition.ts
Normal file
273
src/lib/keyBindings/definition.ts
Normal file
@@ -0,0 +1,273 @@
|
|||||||
|
function getKeyBindings(world: World, actions: Actions): KeyBinding[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
name: "window-toggle-floating",
|
||||||
|
description: "Toggle floating",
|
||||||
|
defaultKeySequence: "Meta+Space",
|
||||||
|
action: () => world.do(actions.windowToggleFloating),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "focus-left",
|
||||||
|
description: "Move focus left",
|
||||||
|
defaultKeySequence: "Meta+A",
|
||||||
|
action: () => world.doIfTiledFocused(actions.focusLeft),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "focus-right",
|
||||||
|
description: "Move focus right",
|
||||||
|
comment: "Clashes with default KDE shortcuts, may require manual remapping",
|
||||||
|
defaultKeySequence: "Meta+D",
|
||||||
|
action: () => world.doIfTiledFocused(actions.focusRight),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "focus-up",
|
||||||
|
description: "Move focus up",
|
||||||
|
comment: "Clashes with default KDE shortcuts, may require manual remapping",
|
||||||
|
defaultKeySequence: "Meta+W",
|
||||||
|
action: () => world.doIfTiledFocused(actions.focusUp),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "focus-down",
|
||||||
|
description: "Move focus down",
|
||||||
|
comment: "Clashes with default KDE shortcuts, may require manual remapping",
|
||||||
|
defaultKeySequence: "Meta+S",
|
||||||
|
action: () => world.doIfTiledFocused(actions.focusDown),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "focus-next",
|
||||||
|
description: "Move focus to the next window in grid",
|
||||||
|
action: () => world.doIfTiledFocused(actions.focusNext),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "focus-previous",
|
||||||
|
description: "Move focus to the previous window in grid",
|
||||||
|
action: () => world.doIfTiledFocused(actions.focusPrevious),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "focus-start",
|
||||||
|
description: "Move focus to start",
|
||||||
|
defaultKeySequence: "Meta+Home",
|
||||||
|
action: () => world.do(actions.focusStart),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "focus-end",
|
||||||
|
description: "Move focus to end",
|
||||||
|
defaultKeySequence: "Meta+End",
|
||||||
|
action: () => world.do(actions.focusEnd),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "window-move-left",
|
||||||
|
description: "Move window left",
|
||||||
|
comment: "Moves window out of and into columns",
|
||||||
|
defaultKeySequence: "Meta+Shift+A",
|
||||||
|
action: () => world.doIfTiledFocused(actions.windowMoveLeft),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "window-move-right",
|
||||||
|
description: "Move window right",
|
||||||
|
comment: "Moves window out of and into columns",
|
||||||
|
defaultKeySequence: "Meta+Shift+D",
|
||||||
|
action: () => world.doIfTiledFocused(actions.windowMoveRight),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "window-move-up",
|
||||||
|
description: "Move window up",
|
||||||
|
defaultKeySequence: "Meta+Shift+W",
|
||||||
|
action: () => world.doIfTiledFocused(actions.windowMoveUp),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "window-move-down",
|
||||||
|
description: "Move window down",
|
||||||
|
defaultKeySequence: "Meta+Shift+S",
|
||||||
|
action: () => world.doIfTiledFocused(actions.windowMoveDown),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "window-move-next",
|
||||||
|
description: "Move window to the next position in grid",
|
||||||
|
action: () => world.doIfTiledFocused(actions.windowMoveNext),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "window-move-previous",
|
||||||
|
description: "Move window to the previous position in grid",
|
||||||
|
action: () => world.doIfTiledFocused(actions.windowMovePrevious),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "window-move-start",
|
||||||
|
description: "Move window to start",
|
||||||
|
defaultKeySequence: "Meta+Shift+Home",
|
||||||
|
action: () => world.doIfTiledFocused(actions.windowMoveStart),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "window-move-end",
|
||||||
|
description: "Move window to end",
|
||||||
|
defaultKeySequence: "Meta+Shift+End",
|
||||||
|
action: () => world.doIfTiledFocused(actions.windowMoveEnd),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "column-toggle-stacked",
|
||||||
|
description: "Toggle stacked layout for focused column",
|
||||||
|
comment: "One window in the column visible, others shaded; not supported on Wayland",
|
||||||
|
defaultKeySequence: "Meta+X",
|
||||||
|
action: () => world.doIfTiledFocused(actions.columnToggleStacked),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "column-move-left",
|
||||||
|
description: "Move column left",
|
||||||
|
defaultKeySequence: "Meta+Ctrl+Shift+A",
|
||||||
|
action: () => world.doIfTiledFocused(actions.columnMoveLeft),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "column-move-right",
|
||||||
|
description: "Move column right",
|
||||||
|
defaultKeySequence: "Meta+Ctrl+Shift+D",
|
||||||
|
action: () => world.doIfTiledFocused(actions.columnMoveRight),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "column-move-start",
|
||||||
|
description: "Move column to start",
|
||||||
|
defaultKeySequence: "Meta+Ctrl+Shift+Home",
|
||||||
|
action: () => world.doIfTiledFocused(actions.columnMoveStart),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "column-move-end",
|
||||||
|
description: "Move column to end",
|
||||||
|
defaultKeySequence: "Meta+Ctrl+Shift+End",
|
||||||
|
action: () => world.doIfTiledFocused(actions.columnMoveEnd),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "column-width-increase",
|
||||||
|
description: "Increase column width",
|
||||||
|
defaultKeySequence: "Meta+Ctrl++",
|
||||||
|
action: () => world.doIfTiledFocused(actions.columnWidthIncrease),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "column-width-decrease",
|
||||||
|
description: "Decrease column width",
|
||||||
|
defaultKeySequence: "Meta+Ctrl+-",
|
||||||
|
action: () => world.doIfTiledFocused(actions.columnWidthDecrease),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "cycle-preset-widths",
|
||||||
|
description: "Cycle through preset column widths",
|
||||||
|
defaultKeySequence: "Meta+R",
|
||||||
|
action: () => world.doIfTiledFocused(actions.cyclePresetWidths),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "cycle-preset-widths-reverse",
|
||||||
|
description: "Cycle through preset column widths in reverse",
|
||||||
|
defaultKeySequence: "Meta+Shift+R",
|
||||||
|
action: () => world.doIfTiledFocused(actions.cyclePresetWidthsReverse),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "columns-width-equalize",
|
||||||
|
description: "Equalize widths of visible columns",
|
||||||
|
defaultKeySequence: "Meta+Ctrl+X",
|
||||||
|
action: () => world.do(actions.columnsWidthEqualize),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "columns-squeeze-left",
|
||||||
|
description: "Squeeze left column onto the screen",
|
||||||
|
comment: "Clashes with default KDE shortcuts, may require manual remapping",
|
||||||
|
defaultKeySequence: "Meta+Ctrl+A",
|
||||||
|
action: () => world.doIfTiledFocused(actions.columnsSqueezeLeft),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "columns-squeeze-right",
|
||||||
|
description: "Squeeze right column onto the screen",
|
||||||
|
defaultKeySequence: "Meta+Ctrl+D",
|
||||||
|
action: () => world.doIfTiledFocused(actions.columnsSqueezeRight),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "grid-scroll-focused",
|
||||||
|
description: "Center focused window",
|
||||||
|
comment: "Scrolls so that the focused window is centered in the screen",
|
||||||
|
defaultKeySequence: "Meta+Alt+Return",
|
||||||
|
action: () => world.doIfTiledFocused(actions.gridScrollFocused),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "grid-scroll-left-column",
|
||||||
|
description: "Scroll one column to the left",
|
||||||
|
defaultKeySequence: "Meta+Alt+A",
|
||||||
|
action: () => world.do(actions.gridScrollLeftColumn),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "grid-scroll-right-column",
|
||||||
|
description: "Scroll one column to the right",
|
||||||
|
defaultKeySequence: "Meta+Alt+D",
|
||||||
|
action: () => world.do(actions.gridScrollRightColumn),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "grid-scroll-left",
|
||||||
|
description: "Scroll left",
|
||||||
|
defaultKeySequence: "Meta+Alt+PgUp",
|
||||||
|
action: () => world.do(actions.gridScrollLeft),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "grid-scroll-right",
|
||||||
|
description: "Scroll right",
|
||||||
|
defaultKeySequence: "Meta+Alt+PgDown",
|
||||||
|
action: () => world.do(actions.gridScrollRight),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "grid-scroll-start",
|
||||||
|
description: "Scroll to start",
|
||||||
|
defaultKeySequence: "Meta+Alt+Home",
|
||||||
|
action: () => world.do(actions.gridScrollStart),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "grid-scroll-end",
|
||||||
|
description: "Scroll to end",
|
||||||
|
defaultKeySequence: "Meta+Alt+End",
|
||||||
|
action: () => world.do(actions.gridScrollEnd),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "screen-switch",
|
||||||
|
description: "Move Karousel grid to the current screen",
|
||||||
|
defaultKeySequence: "Meta+Ctrl+Return",
|
||||||
|
action: () => world.do(actions.screenSwitch),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getNumKeyBindings(world: World, actions: Actions): NumKeyBinding[] {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
name: "focus-{}",
|
||||||
|
description: "Move focus to column {}",
|
||||||
|
comment: "Clashes with default KDE shortcuts, may require manual remapping",
|
||||||
|
defaultModifiers: "Meta",
|
||||||
|
fKeys: false,
|
||||||
|
action: (i: number) => world.do(actions.focus.partial(i)),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "window-move-to-column-{}",
|
||||||
|
description: "Move window to column {}",
|
||||||
|
comment: "Requires manual remapping according to your keyboard layout, e.g. Meta+Shift+1 -> Meta+!",
|
||||||
|
defaultModifiers: "Meta+Shift",
|
||||||
|
fKeys: false,
|
||||||
|
action: (i: number) => world.doIfTiledFocused(actions.windowMoveToColumn.partial(i)),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "column-move-to-column-{}",
|
||||||
|
description: "Move column to position {}",
|
||||||
|
comment: "Requires manual remapping according to your keyboard layout, e.g. Meta+Ctrl+Shift+1 -> Meta+Ctrl+!",
|
||||||
|
defaultModifiers: "Meta+Ctrl+Shift",
|
||||||
|
fKeys: false,
|
||||||
|
action: (i: number) => world.doIfTiledFocused(actions.columnMoveToColumn.partial(i)),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "column-move-to-desktop-{}",
|
||||||
|
description: "Move column to desktop {}",
|
||||||
|
defaultModifiers: "Meta+Ctrl+Shift",
|
||||||
|
fKeys: true,
|
||||||
|
action: (i: number) => world.doIfTiledFocused(actions.columnMoveToDesktop.partial(i)),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "tail-move-to-desktop-{}",
|
||||||
|
description: "Move this and all following columns to desktop {}",
|
||||||
|
defaultModifiers: "Meta+Ctrl+Shift+Alt",
|
||||||
|
fKeys: true,
|
||||||
|
action: (i: number) => world.doIfTiledFocused(actions.tailMoveToDesktop.partial(i)),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
68
src/lib/keyBindings/loader.ts
Normal file
68
src/lib/keyBindings/loader.ts
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
type KeyBinding = {
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
comment?: string;
|
||||||
|
defaultKeySequence?: string;
|
||||||
|
action: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
type NumKeyBinding = {
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
comment?: string;
|
||||||
|
defaultModifiers: string;
|
||||||
|
fKeys: boolean;
|
||||||
|
action: (i: number) => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
function catchWrap(f: () => void) {
|
||||||
|
return () => {
|
||||||
|
try {
|
||||||
|
f();
|
||||||
|
} catch (error: any) {
|
||||||
|
log(error);
|
||||||
|
log(error.stack);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function registerKeyBinding(shortcutActions: ShortcutAction[], keyBinding: KeyBinding) {
|
||||||
|
shortcutActions.push(new ShortcutAction(
|
||||||
|
keyBinding,
|
||||||
|
catchWrap(keyBinding.action),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
function registerNumKeyBindings(shortcutActions: ShortcutAction[], numKeyBinding: NumKeyBinding) {
|
||||||
|
const numPrefix = numKeyBinding.fKeys ? "F" : "";
|
||||||
|
const n = numKeyBinding.fKeys ? 12 : 9;
|
||||||
|
for (let i = 0; i < 12; i++) {
|
||||||
|
const numKey = String(i + 1);
|
||||||
|
const keySequence = i < n ?
|
||||||
|
numKeyBinding.defaultModifiers + "+" + numPrefix + numKey :
|
||||||
|
"";
|
||||||
|
shortcutActions.push(new ShortcutAction(
|
||||||
|
{
|
||||||
|
name: applyMacro(numKeyBinding.name, numKey),
|
||||||
|
description: applyMacro(numKeyBinding.description, numKey),
|
||||||
|
defaultKeySequence: keySequence,
|
||||||
|
},
|
||||||
|
catchWrap(() => numKeyBinding.action(i)),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function registerKeyBindings(world: World, config: Actions.Config) {
|
||||||
|
const actions = new Actions(config);
|
||||||
|
const shortcutActions: ShortcutAction[] = [];
|
||||||
|
|
||||||
|
for (const keyBinding of getKeyBindings(world, actions)) {
|
||||||
|
registerKeyBinding(shortcutActions, keyBinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const numKeyBinding of getNumKeyBindings(world, actions)) {
|
||||||
|
registerNumKeyBindings(shortcutActions, numKeyBinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
return shortcutActions;
|
||||||
|
}
|
||||||
@@ -5,46 +5,39 @@ class Column {
|
|||||||
private readonly windows: LinkedList<Window>;
|
private readonly windows: LinkedList<Window>;
|
||||||
private stacked: boolean;
|
private stacked: boolean;
|
||||||
private focusTaker: Window|null;
|
private focusTaker: Window|null;
|
||||||
private static readonly minWidth = 10;
|
private static readonly minWidth = 40;
|
||||||
|
|
||||||
constructor(grid: Grid, prevColumn: Column|null) {
|
constructor(grid: Grid, leftColumn: Column|null) {
|
||||||
this.gridX = 0;
|
this.gridX = 0;
|
||||||
this.width = 0;
|
this.width = 0;
|
||||||
this.windows = new LinkedList();
|
this.windows = new LinkedList();
|
||||||
this.stacked = grid.config.stackColumnsByDefault;
|
this.stacked = grid.config.stackColumnsByDefault;
|
||||||
this.focusTaker = null;
|
this.focusTaker = null;
|
||||||
this.grid = grid;
|
this.grid = grid;
|
||||||
this.grid.onColumnAdded(this, prevColumn);
|
this.grid.onColumnAdded(this, leftColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
public moveToGrid(targetGrid: Grid, prevColumn: Column|null) {
|
public moveToGrid(targetGrid: Grid, leftColumn: Column|null) {
|
||||||
if (targetGrid === this.grid) {
|
if (targetGrid === this.grid) {
|
||||||
this.grid.onColumnMoved(this, prevColumn);
|
this.grid.moveColumn(this, leftColumn);
|
||||||
} else {
|
} else {
|
||||||
this.grid.onColumnRemoved(this, false);
|
this.grid.onColumnRemoved(this, this.isFocused());
|
||||||
this.grid = targetGrid;
|
this.grid = targetGrid;
|
||||||
targetGrid.onColumnAdded(this, prevColumn);
|
targetGrid.onColumnAdded(this, leftColumn);
|
||||||
for (const window of this.windows.iterator()) {
|
for (const window of this.windows.iterator()) {
|
||||||
window.client.kwinClient.desktop = targetGrid.desktop.desktopNumber;
|
window.client.kwinClient.desktops = [targetGrid.desktop.kwinDesktop];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public moveAfter(prevColumn: Column|null) {
|
public isToTheLeftOf(other: Column) {
|
||||||
if (prevColumn === this) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.grid.onColumnMoved(this, prevColumn);
|
|
||||||
}
|
|
||||||
|
|
||||||
public isAfter(other: Column) {
|
|
||||||
return this.gridX > other.gridX;
|
|
||||||
}
|
|
||||||
|
|
||||||
public isBefore(other: Column) {
|
|
||||||
return this.gridX < other.gridX;
|
return this.gridX < other.gridX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public isToTheRightOf(other: Column) {
|
||||||
|
return this.gridX > other.gridX;
|
||||||
|
}
|
||||||
|
|
||||||
public moveWindowUp(window: Window) {
|
public moveWindowUp(window: Window) {
|
||||||
this.windows.moveBack(window);
|
this.windows.moveBack(window);
|
||||||
this.grid.desktop.onLayoutChanged();
|
this.grid.desktop.onLayoutChanged();
|
||||||
@@ -63,11 +56,19 @@ class Column {
|
|||||||
return this.getWindowCount() === 0;
|
return this.getWindowCount() === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getPrevWindow(window: Window) {
|
public getFirstWindow(): Window {
|
||||||
|
return this.windows.getFirst()!;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getLastWindow(): Window {
|
||||||
|
return this.windows.getLast()!;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getAboveWindow(window: Window) {
|
||||||
return this.windows.getPrev(window);
|
return this.windows.getPrev(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getNextWindow(window: Window) {
|
public getBelowWindow(window: Window) {
|
||||||
return this.windows.getNext(window);
|
return this.windows.getNext(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,16 +93,17 @@ class Column {
|
|||||||
|
|
||||||
public setWidth(width: number, setPreferred: boolean) {
|
public setWidth(width: number, setPreferred: boolean) {
|
||||||
width = clamp(width, this.getMinWidth(), this.getMaxWidth());
|
width = clamp(width, this.getMinWidth(), this.getMaxWidth());
|
||||||
const oldWidth = this.width;
|
if (width === this.width) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.width = width;
|
this.width = width;
|
||||||
if (setPreferred) {
|
if (setPreferred) {
|
||||||
for (const window of this.windows.iterator()) {
|
for (const window of this.windows.iterator()) {
|
||||||
window.client.preferredWidth = width;
|
window.client.preferredWidth = width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (width !== oldWidth) {
|
this.grid.onColumnWidthChanged(this);
|
||||||
this.grid.onColumnWidthChanged(this, oldWidth, width);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public adjustWidth(widthDelta: number, setPreferred: boolean) {
|
public adjustWidth(widthDelta: number, setPreferred: boolean) {
|
||||||
@@ -131,6 +133,27 @@ class Column {
|
|||||||
return this.gridX + this.width;
|
return this.gridX + this.width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public onUserResizeWidth(
|
||||||
|
startWidth: number,
|
||||||
|
currentDelta: number,
|
||||||
|
resizingLeftSide: boolean,
|
||||||
|
neighbor?: { column: Column, startWidth: number },
|
||||||
|
) {
|
||||||
|
const oldColumnWidth = this.getWidth();
|
||||||
|
this.setWidth(startWidth + currentDelta, true);
|
||||||
|
const actualDelta = this.getWidth() - startWidth;
|
||||||
|
|
||||||
|
let leftEdgeDeltaStep = resizingLeftSide ? oldColumnWidth - this.getWidth() : 0;
|
||||||
|
if (neighbor !== undefined) {
|
||||||
|
const oldNeighborWidth = neighbor.column.getWidth();
|
||||||
|
neighbor.column.setWidth(neighbor.startWidth - actualDelta, true);
|
||||||
|
if (resizingLeftSide) {
|
||||||
|
leftEdgeDeltaStep -= neighbor.column.getWidth() - oldNeighborWidth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.grid.desktop.adjustScroll(-leftEdgeDeltaStep, true);
|
||||||
|
}
|
||||||
|
|
||||||
public adjustWindowHeight(window: Window, heightDelta: number, top: boolean) {
|
public adjustWindowHeight(window: Window, heightDelta: number, top: boolean) {
|
||||||
const otherWindow = top ? this.windows.getPrev(window) : this.windows.getNext(window);
|
const otherWindow = top ? this.windows.getPrev(window) : this.windows.getNext(window);
|
||||||
if (otherWindow === null) {
|
if (otherWindow === null) {
|
||||||
@@ -180,9 +203,17 @@ class Column {
|
|||||||
window.focus();
|
window.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public isFocused() {
|
||||||
|
const lastFocusedWindow = this.grid.getLastFocusedWindow();
|
||||||
|
if (lastFocusedWindow === null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return lastFocusedWindow.column === this && lastFocusedWindow.isFocused();
|
||||||
|
}
|
||||||
|
|
||||||
public arrange(x: number, visibleRange: Range, forceOpaque: boolean) {
|
public arrange(x: number, visibleRange: Range, forceOpaque: boolean) {
|
||||||
if (this.grid.config.offScreenOpacity < 1.0 && !forceOpaque) {
|
if (this.grid.config.offScreenOpacity < 1.0 && !forceOpaque) {
|
||||||
const opacity = this.isVisible(visibleRange, true) ? 100 : this.grid.config.offScreenOpacity;
|
const opacity = Range.contains(visibleRange, this) ? 100 : this.grid.config.offScreenOpacity;
|
||||||
for (const window of this.windows.iterator()) {
|
for (const window of this.windows.iterator()) {
|
||||||
window.client.kwinClient.opacity = opacity;
|
window.client.kwinClient.opacity = opacity;
|
||||||
}
|
}
|
||||||
@@ -244,18 +275,13 @@ class Column {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public isVisible(visibleRange: Desktop.Range, fullyVisible: boolean) {
|
public onWindowAdded(window: Window, bottom: boolean) {
|
||||||
if (fullyVisible) {
|
if (bottom) {
|
||||||
return this.getLeft() >= visibleRange.getLeft() &&
|
this.windows.insertEnd(window);
|
||||||
this.getRight() <= visibleRange.getRight();
|
|
||||||
} else {
|
} else {
|
||||||
return this.getRight() + this.grid.config.gapsInnerHorizontal > visibleRange.getLeft() &&
|
this.windows.insertStart(window);
|
||||||
this.getLeft() - this.grid.config.gapsInnerHorizontal < visibleRange.getRight();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public onWindowAdded(window: Window) {
|
|
||||||
this.windows.insertEnd(window);
|
|
||||||
if (this.width === 0) {
|
if (this.width === 0) {
|
||||||
this.setWidth(window.client.preferredWidth, false);
|
this.setWidth(window.client.preferredWidth, false);
|
||||||
}
|
}
|
||||||
@@ -272,7 +298,7 @@ class Column {
|
|||||||
|
|
||||||
public onWindowRemoved(window: Window, passFocus: boolean) {
|
public onWindowRemoved(window: Window, passFocus: boolean) {
|
||||||
const lastWindow = this.windows.length() === 1;
|
const lastWindow = this.windows.length() === 1;
|
||||||
const windowToFocus = this.getPrevWindow(window) ?? this.getNextWindow(window);
|
const windowToFocus = this.getAboveWindow(window) ?? this.getBelowWindow(window);
|
||||||
|
|
||||||
this.windows.remove(window);
|
this.windows.remove(window);
|
||||||
|
|
||||||
247
src/lib/layout/Desktop.ts
Normal file
247
src/lib/layout/Desktop.ts
Normal file
@@ -0,0 +1,247 @@
|
|||||||
|
class Desktop {
|
||||||
|
public readonly grid: Grid;
|
||||||
|
private scrollX: number;
|
||||||
|
private dirty: boolean;
|
||||||
|
private dirtyScroll: boolean;
|
||||||
|
private dirtyPins: boolean;
|
||||||
|
public clientArea: QmlRect;
|
||||||
|
public tilingArea: QmlRect;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
public readonly kwinDesktop: KwinDesktop,
|
||||||
|
private readonly pinManager: PinManager,
|
||||||
|
private readonly config: Desktop.Config,
|
||||||
|
private readonly getScreen: () => Output,
|
||||||
|
layoutConfig: LayoutConfig,
|
||||||
|
) {
|
||||||
|
this.scrollX = 0;
|
||||||
|
this.dirty = true;
|
||||||
|
this.dirtyScroll = true;
|
||||||
|
this.dirtyPins = true;
|
||||||
|
this.grid = new Grid(this, layoutConfig);
|
||||||
|
this.clientArea = Desktop.getClientArea(this.getScreen(), kwinDesktop);
|
||||||
|
this.tilingArea = Desktop.getTilingArea(this.clientArea, kwinDesktop, pinManager, config);
|
||||||
|
}
|
||||||
|
|
||||||
|
private updateArea() {
|
||||||
|
const newClientArea = Desktop.getClientArea(this.getScreen(), this.kwinDesktop);
|
||||||
|
if (rectEquals(newClientArea, this.clientArea) && !this.dirtyPins) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.clientArea = newClientArea;
|
||||||
|
this.tilingArea = Desktop.getTilingArea(newClientArea, this.kwinDesktop, this.pinManager, this.config);
|
||||||
|
this.dirty = true;
|
||||||
|
this.dirtyScroll = true;
|
||||||
|
this.dirtyPins = false;
|
||||||
|
this.grid.onScreenSizeChanged();
|
||||||
|
this.autoAdjustScroll();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static getClientArea(screen: Output, kwinDesktop: KwinDesktop) {
|
||||||
|
return Workspace.clientArea(ClientAreaOption.PlacementArea, screen, kwinDesktop);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static getTilingArea(clientArea: QmlRect, kwinDesktop: KwinDesktop, pinManager: PinManager, config: Desktop.Config) {
|
||||||
|
const availableSpace = pinManager.getAvailableSpace(kwinDesktop, clientArea);
|
||||||
|
const top = availableSpace.top + config.marginTop;
|
||||||
|
const bottom = availableSpace.bottom - config.marginBottom;
|
||||||
|
const left = availableSpace.left + config.marginLeft;
|
||||||
|
const right = availableSpace.right - config.marginRight;
|
||||||
|
return Qt.rect(
|
||||||
|
left,
|
||||||
|
top,
|
||||||
|
right - left,
|
||||||
|
bottom - top,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
public scrollIntoView(range: Range) {
|
||||||
|
const left = range.getLeft();
|
||||||
|
const right = range.getRight();
|
||||||
|
const initialVisibleRange = this.getCurrentVisibleRange();
|
||||||
|
|
||||||
|
let targetScrollX: number;
|
||||||
|
if (left < initialVisibleRange.getLeft()) {
|
||||||
|
targetScrollX = left;
|
||||||
|
} else if (right > initialVisibleRange.getRight()) {
|
||||||
|
targetScrollX = right - this.tilingArea.width;
|
||||||
|
} else {
|
||||||
|
targetScrollX = initialVisibleRange.getLeft();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setScroll(targetScrollX, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public scrollCenterRange(range: Range) {
|
||||||
|
const windowCenter = range.getLeft() + range.getWidth() / 2;
|
||||||
|
const screenCenter = this.scrollX + this.tilingArea.width / 2;
|
||||||
|
this.adjustScroll(Math.round(windowCenter - screenCenter), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public scrollCenterVisible(focusedColumn: Column) {
|
||||||
|
const columnRange = new Desktop.ColumnRange(focusedColumn);
|
||||||
|
const visibleRange = this.getCurrentVisibleRange();
|
||||||
|
columnRange.addNeighbors(visibleRange, this.grid.config.gapsInnerHorizontal);
|
||||||
|
this.scrollCenterRange(columnRange);
|
||||||
|
}
|
||||||
|
|
||||||
|
public autoAdjustScroll() {
|
||||||
|
const focusedColumn = this.grid.getLastFocusedColumn();
|
||||||
|
if (focusedColumn === null || focusedColumn.grid !== this.grid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.scrollToColumn(focusedColumn);
|
||||||
|
}
|
||||||
|
|
||||||
|
public scrollToColumn(column: Column) {
|
||||||
|
if (this.dirtyScroll || !Range.contains(this.getCurrentVisibleRange(), column)) {
|
||||||
|
this.config.scroller.scrollToColumn(this, column);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private getVisibleRange(scrollX: number) {
|
||||||
|
return Range.create(scrollX, this.tilingArea.width);
|
||||||
|
}
|
||||||
|
|
||||||
|
public getCurrentVisibleRange() {
|
||||||
|
return this.getVisibleRange(this.scrollX);
|
||||||
|
}
|
||||||
|
|
||||||
|
private clampScrollX(x: number) {
|
||||||
|
return this.config.clamper.clampScrollX(this, x);
|
||||||
|
}
|
||||||
|
|
||||||
|
public setScroll(x: number, force: boolean) {
|
||||||
|
const oldScrollX = this.scrollX;
|
||||||
|
this.scrollX = force ? x : this.clampScrollX(x);
|
||||||
|
if (this.scrollX !== oldScrollX) {
|
||||||
|
this.onLayoutChanged();
|
||||||
|
}
|
||||||
|
this.dirtyScroll = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public adjustScroll(dx: number, force: boolean) {
|
||||||
|
this.setScroll(this.scrollX + dx, force);
|
||||||
|
}
|
||||||
|
|
||||||
|
public arrange() {
|
||||||
|
// TODO (optimization): only arrange visible windows
|
||||||
|
this.updateArea();
|
||||||
|
if (!this.dirty) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.grid.arrange(this.tilingArea.x - this.scrollX, this.getCurrentVisibleRange());
|
||||||
|
this.dirty = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public forceArrange() {
|
||||||
|
this.dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public onLayoutChanged() {
|
||||||
|
this.dirty = true;
|
||||||
|
this.dirtyScroll = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public onPinsChanged() {
|
||||||
|
this.dirty = true;
|
||||||
|
this.dirtyScroll = true;
|
||||||
|
this.dirtyPins = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public destroy() {
|
||||||
|
this.grid.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Desktop {
|
||||||
|
export type Config = {
|
||||||
|
marginTop: number;
|
||||||
|
marginBottom: number;
|
||||||
|
marginLeft: number;
|
||||||
|
marginRight: number;
|
||||||
|
scroller: Desktop.Scroller;
|
||||||
|
clamper: Desktop.Clamper;
|
||||||
|
};
|
||||||
|
|
||||||
|
export class ColumnRange {
|
||||||
|
private left: Column;
|
||||||
|
private right: Column;
|
||||||
|
private width: number;
|
||||||
|
|
||||||
|
constructor(initialColumn: Column) {
|
||||||
|
this.left = initialColumn;
|
||||||
|
this.right = initialColumn;
|
||||||
|
this.width = initialColumn.getWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
public addNeighbors(visibleRange: Range, gap: number) {
|
||||||
|
const grid = this.left.grid;
|
||||||
|
|
||||||
|
const columnRange = this;
|
||||||
|
function canFit(column: Column) {
|
||||||
|
return columnRange.width + gap + column.getWidth() <= visibleRange.getWidth();
|
||||||
|
}
|
||||||
|
function isUsable(column: Column|null) {
|
||||||
|
return column !== null && canFit(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
let leftColumn = grid.getLeftColumn(this.left);
|
||||||
|
let rightColumn = grid.getRightColumn(this.right);
|
||||||
|
function checkColumns() {
|
||||||
|
if (!isUsable(leftColumn)) {
|
||||||
|
leftColumn = null;
|
||||||
|
}
|
||||||
|
if (!isUsable(rightColumn)) {
|
||||||
|
rightColumn = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
checkColumns();
|
||||||
|
|
||||||
|
const visibleCenter = visibleRange.getLeft() + visibleRange.getWidth() / 2;
|
||||||
|
while (leftColumn !== null || rightColumn !== null) {
|
||||||
|
const leftToCenter = leftColumn === null ? Infinity : Math.abs(leftColumn.getLeft() - visibleCenter);
|
||||||
|
const rightToCenter = rightColumn === null ? Infinity : Math.abs(rightColumn.getRight() - visibleCenter);
|
||||||
|
if (leftToCenter < rightToCenter) {
|
||||||
|
this.addLeft(leftColumn!, gap);
|
||||||
|
leftColumn = grid.getLeftColumn(leftColumn!);
|
||||||
|
} else {
|
||||||
|
this.addRight(rightColumn!, gap);
|
||||||
|
rightColumn = grid.getRightColumn(rightColumn!);
|
||||||
|
}
|
||||||
|
checkColumns();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public addLeft(column: Column, gap: number) {
|
||||||
|
this.left = column;
|
||||||
|
this.width += column.getWidth() + gap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public addRight(column: Column, gap: number) {
|
||||||
|
this.right = column;
|
||||||
|
this.width += column.getWidth() + gap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getLeft() {
|
||||||
|
return this.left.getLeft();
|
||||||
|
}
|
||||||
|
|
||||||
|
public getRight() {
|
||||||
|
return this.right.getRight();
|
||||||
|
}
|
||||||
|
|
||||||
|
public getWidth() {
|
||||||
|
return this.width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Scroller = {
|
||||||
|
scrollToColumn(desktop: Desktop, column: Column): void;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Clamper = {
|
||||||
|
clampScrollX(desktop: Desktop, x: number): number;
|
||||||
|
};
|
||||||
|
}
|
||||||
227
src/lib/layout/Grid.ts
Normal file
227
src/lib/layout/Grid.ts
Normal file
@@ -0,0 +1,227 @@
|
|||||||
|
class Grid {
|
||||||
|
public readonly desktop: Desktop;
|
||||||
|
public readonly config: LayoutConfig;
|
||||||
|
private readonly columns: LinkedList<Column>;
|
||||||
|
private lastFocusedColumn: Column|null;
|
||||||
|
private width: number;
|
||||||
|
private userResize: boolean; // is any part of the grid being resized by the user
|
||||||
|
private readonly userResizeFinishedDelayer: Delayer;
|
||||||
|
|
||||||
|
constructor(desktop: Desktop, config: LayoutConfig) {
|
||||||
|
this.desktop = desktop;
|
||||||
|
this.config = config;
|
||||||
|
this.columns = new LinkedList();
|
||||||
|
this.lastFocusedColumn = null;
|
||||||
|
this.width = 0;
|
||||||
|
this.userResize = false;
|
||||||
|
this.userResizeFinishedDelayer = new Delayer(50, () => {
|
||||||
|
// this delay prevents windows' contents from freezing after resizing
|
||||||
|
this.desktop.onLayoutChanged();
|
||||||
|
this.desktop.autoAdjustScroll();
|
||||||
|
this.desktop.arrange();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public moveColumn(column: Column, leftColumn: Column|null) {
|
||||||
|
if (column === leftColumn) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const movedLeft = leftColumn === null ? true : column.isToTheRightOf(leftColumn);
|
||||||
|
const firstMovedColumn = movedLeft ? column : this.getRightColumn(column);
|
||||||
|
this.columns.move(column, leftColumn);
|
||||||
|
this.columnsSetX(firstMovedColumn);
|
||||||
|
this.desktop.onLayoutChanged();
|
||||||
|
this.desktop.autoAdjustScroll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public moveColumnLeft(column: Column) {
|
||||||
|
this.columns.moveBack(column);
|
||||||
|
this.columnsSetX(column);
|
||||||
|
this.desktop.onLayoutChanged();
|
||||||
|
this.desktop.autoAdjustScroll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public moveColumnRight(column: Column) {
|
||||||
|
const rightColumn = this.columns.getNext(column);
|
||||||
|
if (rightColumn === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.moveColumnLeft(rightColumn);
|
||||||
|
}
|
||||||
|
|
||||||
|
public getWidth() {
|
||||||
|
return this.width;
|
||||||
|
}
|
||||||
|
|
||||||
|
public isUserResizing() {
|
||||||
|
return this.userResize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getLeftColumn(column: Column) {
|
||||||
|
return this.columns.getPrev(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
public getRightColumn(column: Column) {
|
||||||
|
return this.columns.getNext(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
public getFirstColumn() {
|
||||||
|
return this.columns.getFirst();
|
||||||
|
}
|
||||||
|
|
||||||
|
public getLastColumn() {
|
||||||
|
return this.columns.getLast();
|
||||||
|
}
|
||||||
|
|
||||||
|
public getColumnAtIndex(i: number) {
|
||||||
|
return this.columns.getItemAtIndex(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
public getLastFocusedColumn() {
|
||||||
|
if (this.lastFocusedColumn === null || this.lastFocusedColumn.grid !== this) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return this.lastFocusedColumn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getLastFocusedWindow() {
|
||||||
|
const lastFocusedColumn = this.getLastFocusedColumn();
|
||||||
|
if (lastFocusedColumn === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return lastFocusedColumn.getFocusTaker();
|
||||||
|
}
|
||||||
|
|
||||||
|
private columnsSetX(firstMovedColumn: Column|null) {
|
||||||
|
const lastUnmovedColumn = firstMovedColumn === null ? this.columns.getLast() : this.columns.getPrev(firstMovedColumn);
|
||||||
|
let x = lastUnmovedColumn === null ? 0 : lastUnmovedColumn.getRight() + this.config.gapsInnerHorizontal;
|
||||||
|
if (firstMovedColumn !== null) {
|
||||||
|
for (const column of this.columns.iteratorFrom(firstMovedColumn)) {
|
||||||
|
column.gridX = x;
|
||||||
|
x += column.getWidth() + this.config.gapsInnerHorizontal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.width = x - this.config.gapsInnerHorizontal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getLeftmostVisibleColumn(visibleRange: Range, fullyVisible: boolean) {
|
||||||
|
for (const column of this.columns.iterator()) {
|
||||||
|
if (Range.contains(visibleRange, column)) {
|
||||||
|
return column;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getRightmostVisibleColumn(visibleRange: Range, fullyVisible: boolean) {
|
||||||
|
let last = null;
|
||||||
|
for (const column of this.columns.iterator()) {
|
||||||
|
if (Range.contains(visibleRange, column)) {
|
||||||
|
last = column;
|
||||||
|
} else if (last !== null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return last;
|
||||||
|
}
|
||||||
|
|
||||||
|
public *getVisibleColumns(visibleRange: Range, fullyVisible: boolean) {
|
||||||
|
for (const column of this.columns.iterator()) {
|
||||||
|
if (Range.contains(visibleRange, column)) {
|
||||||
|
yield column;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public arrange(x: number, visibleRange: Range) {
|
||||||
|
for (const column of this.columns.iterator()) {
|
||||||
|
column.arrange(x, visibleRange, this.userResize);
|
||||||
|
x += column.getWidth() + this.config.gapsInnerHorizontal;
|
||||||
|
}
|
||||||
|
|
||||||
|
const focusedWindow = this.getLastFocusedWindow();
|
||||||
|
if (focusedWindow !== null) {
|
||||||
|
focusedWindow.client.ensureTransientsVisible(this.desktop.clientArea);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public onColumnAdded(column: Column, leftColumn: Column|null) {
|
||||||
|
if (leftColumn === null) {
|
||||||
|
this.columns.insertStart(column);
|
||||||
|
} else {
|
||||||
|
this.columns.insertAfter(column, leftColumn);
|
||||||
|
}
|
||||||
|
this.columnsSetX(column);
|
||||||
|
this.desktop.onLayoutChanged();
|
||||||
|
this.desktop.autoAdjustScroll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public onColumnRemoved(column: Column, passFocus: boolean) {
|
||||||
|
const isLastColumn = this.columns.length() === 1;
|
||||||
|
const rightColumn = this.getRightColumn(column);
|
||||||
|
const columnToFocus = isLastColumn ? null : this.getLeftColumn(column) ?? rightColumn;
|
||||||
|
if (column === this.lastFocusedColumn) {
|
||||||
|
this.lastFocusedColumn = columnToFocus;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.columns.remove(column);
|
||||||
|
this.columnsSetX(rightColumn);
|
||||||
|
|
||||||
|
this.desktop.onLayoutChanged();
|
||||||
|
if (passFocus && columnToFocus !== null) {
|
||||||
|
columnToFocus.focus();
|
||||||
|
} else {
|
||||||
|
this.desktop.autoAdjustScroll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public onColumnWidthChanged(column: Column) {
|
||||||
|
const rightColumn = this.columns.getNext(column);
|
||||||
|
this.columnsSetX(rightColumn);
|
||||||
|
this.desktop.onLayoutChanged();
|
||||||
|
if (!this.userResize) {
|
||||||
|
this.desktop.autoAdjustScroll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public onColumnFocused(column: Column) {
|
||||||
|
const lastFocusedColumn = this.getLastFocusedColumn();
|
||||||
|
if (lastFocusedColumn !== null && lastFocusedColumn !== column) {
|
||||||
|
lastFocusedColumn.restoreToTiled();
|
||||||
|
}
|
||||||
|
this.lastFocusedColumn = column;
|
||||||
|
this.desktop.scrollToColumn(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
public onScreenSizeChanged() {
|
||||||
|
for (const column of this.columns.iterator()) {
|
||||||
|
column.updateWidth();
|
||||||
|
column.resizeWindows();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public onUserResizeStarted() {
|
||||||
|
this.userResize = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public onUserResizeFinished() {
|
||||||
|
this.userResize = false;
|
||||||
|
this.userResizeFinishedDelayer.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
public evacuateTail(targetGrid: Grid, startColumn: Column) {
|
||||||
|
for (const column of this.columns.iteratorFrom(startColumn)) {
|
||||||
|
column.moveToGrid(targetGrid, targetGrid.getLastColumn());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public evacuate(targetGrid: Grid) {
|
||||||
|
for (const column of this.columns.iterator()) {
|
||||||
|
column.moveToGrid(targetGrid, targetGrid.getLastColumn());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public destroy() {
|
||||||
|
this.userResizeFinishedDelayer.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
12
src/lib/layout/LayoutConfig.ts
Normal file
12
src/lib/layout/LayoutConfig.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
type LayoutConfig = {
|
||||||
|
gapsInnerHorizontal: number;
|
||||||
|
gapsInnerVertical: number;
|
||||||
|
offScreenOpacity: number;
|
||||||
|
stackColumnsByDefault: boolean;
|
||||||
|
resizeNeighborColumn: boolean;
|
||||||
|
reMaximize: boolean;
|
||||||
|
skipSwitcher: boolean;
|
||||||
|
tiledKeepBelow: boolean;
|
||||||
|
maximizedKeepAbove: boolean;
|
||||||
|
untileOnDrag: boolean;
|
||||||
|
};
|
||||||
41
src/lib/layout/Range.ts
Normal file
41
src/lib/layout/Range.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
type Range = {
|
||||||
|
getLeft(): number;
|
||||||
|
getRight(): number;
|
||||||
|
getWidth(): number;
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace Range {
|
||||||
|
export function create(x: number, width: number) {
|
||||||
|
return new Basic(x, width);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fromRanges(leftRange: Range, rightRange: Range) {
|
||||||
|
const left = leftRange.getLeft();
|
||||||
|
const right = rightRange.getRight();
|
||||||
|
return new Basic(left, right - left);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function contains(parent: Range, child: Range) {
|
||||||
|
return child.getLeft() >= parent.getLeft() &&
|
||||||
|
child.getRight() <= parent.getRight();
|
||||||
|
}
|
||||||
|
|
||||||
|
class Basic {
|
||||||
|
constructor(
|
||||||
|
private readonly x: number,
|
||||||
|
private readonly width: number,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public getLeft() {
|
||||||
|
return this.x;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getRight() {
|
||||||
|
return this.x + this.width;
|
||||||
|
}
|
||||||
|
|
||||||
|
public getWidth() {
|
||||||
|
return this.width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,21 +10,20 @@ class Window {
|
|||||||
this.height = client.kwinClient.frameGeometry.height;
|
this.height = client.kwinClient.frameGeometry.height;
|
||||||
this.focusedState = {
|
this.focusedState = {
|
||||||
fullScreen: false,
|
fullScreen: false,
|
||||||
maximizedHorizontally: false,
|
maximizedMode: MaximizedMode.Unmaximized,
|
||||||
maximizedVertically: false,
|
|
||||||
};
|
};
|
||||||
this.skipArrange = false;
|
this.skipArrange = false;
|
||||||
this.column = column;
|
this.column = column;
|
||||||
column.onWindowAdded(this);
|
column.onWindowAdded(this, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public moveToColumn(targetColumn: Column) {
|
public moveToColumn(targetColumn: Column, bottom: boolean) {
|
||||||
if (targetColumn === this.column) {
|
if (targetColumn === this.column) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.column.onWindowRemoved(this, false);
|
this.column.onWindowRemoved(this, this.isFocused() && targetColumn.grid !== this.column.grid);
|
||||||
this.column = targetColumn;
|
this.column = targetColumn;
|
||||||
targetColumn.onWindowAdded(this);
|
targetColumn.onWindowAdded(this, bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
public arrange(x: number, y: number, width: number, height: number) {
|
public arrange(x: number, y: number, width: number, height: number) {
|
||||||
@@ -37,8 +36,11 @@ class Window {
|
|||||||
if (this.column.grid.config.reMaximize && this.isFocused()) {
|
if (this.column.grid.config.reMaximize && this.isFocused()) {
|
||||||
// do this here rather than in `onFocused` to ensure it happens after placement
|
// do this here rather than in `onFocused` to ensure it happens after placement
|
||||||
// (otherwise placement may not happen at all)
|
// (otherwise placement may not happen at all)
|
||||||
if (this.focusedState.maximizedVertically || this.focusedState.maximizedHorizontally) {
|
if (this.focusedState.maximizedMode !== MaximizedMode.Unmaximized) {
|
||||||
this.client.setMaximize(this.focusedState.maximizedVertically, this.focusedState.maximizedHorizontally);
|
this.client.setMaximize(
|
||||||
|
this.focusedState.maximizedMode === MaximizedMode.Horizontally || this.focusedState.maximizedMode === MaximizedMode.Maximized,
|
||||||
|
this.focusedState.maximizedMode === MaximizedMode.Vertically || this.focusedState.maximizedMode === MaximizedMode.Maximized,
|
||||||
|
);
|
||||||
maximized = true;
|
maximized = true;
|
||||||
}
|
}
|
||||||
if (this.focusedState.fullScreen) {
|
if (this.focusedState.fullScreen) {
|
||||||
@@ -64,6 +66,14 @@ class Window {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public onFocused() {
|
public onFocused() {
|
||||||
|
if (this.column.grid.config.reMaximize && (
|
||||||
|
this.focusedState.maximizedMode !== MaximizedMode.Unmaximized ||
|
||||||
|
this.focusedState.fullScreen
|
||||||
|
)) {
|
||||||
|
// We need to maximize/fullscreen this window, but we can't do it here.
|
||||||
|
// We need to do it in `arrange` to ensure it happens after placement.
|
||||||
|
this.column.grid.desktop.forceArrange();
|
||||||
|
}
|
||||||
this.column.onWindowFocused(this);
|
this.column.onWindowFocused(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,11 +83,10 @@ class Window {
|
|||||||
}
|
}
|
||||||
this.client.setFullScreen(false);
|
this.client.setFullScreen(false);
|
||||||
this.client.setMaximize(false, false);
|
this.client.setMaximize(false, false);
|
||||||
this.column.grid.desktop.onLayoutChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public onMaximizedChanged(horizontally: boolean, vertically: boolean) {
|
public onMaximizedChanged(maximizedMode: MaximizedMode) {
|
||||||
const maximized = horizontally || vertically;
|
const maximized = maximizedMode !== MaximizedMode.Unmaximized;
|
||||||
this.skipArrange = maximized;
|
this.skipArrange = maximized;
|
||||||
if (this.column.grid.config.tiledKeepBelow) {
|
if (this.column.grid.config.tiledKeepBelow) {
|
||||||
this.client.kwinClient.keepBelow = !maximized;
|
this.client.kwinClient.keepBelow = !maximized;
|
||||||
@@ -86,8 +95,7 @@ class Window {
|
|||||||
this.client.kwinClient.keepAbove = maximized;
|
this.client.kwinClient.keepAbove = maximized;
|
||||||
}
|
}
|
||||||
if (this.isFocused()) {
|
if (this.isFocused()) {
|
||||||
this.focusedState.maximizedHorizontally = horizontally;
|
this.focusedState.maximizedMode = maximizedMode;
|
||||||
this.focusedState.maximizedVertically = vertically;
|
|
||||||
}
|
}
|
||||||
this.column.grid.desktop.onLayoutChanged();
|
this.column.grid.desktop.onLayoutChanged();
|
||||||
}
|
}
|
||||||
@@ -106,31 +114,6 @@ class Window {
|
|||||||
this.column.grid.desktop.onLayoutChanged();
|
this.column.grid.desktop.onLayoutChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public onUserResize(oldGeometry: QmlRect, resizeNeighborColumn: boolean) {
|
|
||||||
const newGeometry = this.client.kwinClient.frameGeometry;
|
|
||||||
const widthDelta = newGeometry.width - oldGeometry.width;
|
|
||||||
const heightDelta = newGeometry.height - oldGeometry.height;
|
|
||||||
if (widthDelta !== 0) {
|
|
||||||
this.column.adjustWidth(widthDelta, true);
|
|
||||||
let leftEdgeDelta = newGeometry.left - oldGeometry.left;
|
|
||||||
const resizingLeftSide = leftEdgeDelta !== 0;
|
|
||||||
if (resizeNeighborColumn && this.column.grid.config.resizeNeighborColumn) {
|
|
||||||
const neighborColumn = resizingLeftSide ? this.column.grid.getPrevColumn(this.column) : this.column.grid.getNextColumn(this.column);
|
|
||||||
if (neighborColumn !== null) {
|
|
||||||
const oldNeighborWidth = neighborColumn.getWidth();
|
|
||||||
neighborColumn.adjustWidth(-widthDelta, true);
|
|
||||||
if (resizingLeftSide) {
|
|
||||||
leftEdgeDelta -= neighborColumn.getWidth() - oldNeighborWidth;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.column.grid.desktop.adjustScroll(-leftEdgeDelta, true);
|
|
||||||
}
|
|
||||||
if (heightDelta !== 0) {
|
|
||||||
this.column.adjustWindowHeight(this, heightDelta, newGeometry.y !== oldGeometry.y);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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, true);
|
||||||
@@ -144,8 +127,7 @@ class Window {
|
|||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
export type State = {
|
export type State = {
|
||||||
fullScreen: boolean,
|
fullScreen: boolean;
|
||||||
maximizedHorizontally: boolean,
|
maximizedMode: MaximizedMode;
|
||||||
maximizedVertically: boolean,
|
};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
19
src/lib/rules/ClientMatcher.ts
Normal file
19
src/lib/rules/ClientMatcher.ts
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
class ClientMatcher {
|
||||||
|
private readonly regex: RegExp;
|
||||||
|
|
||||||
|
constructor(regex: RegExp) {
|
||||||
|
this.regex = regex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public matches(kwinClient: KwinClient) {
|
||||||
|
return this.regex.test(ClientMatcher.getClientString(kwinClient));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getClientString(kwinClient: KwinClient) {
|
||||||
|
return ClientMatcher.getRuleString(kwinClient.resourceClass, kwinClient.caption);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getRuleString(ruleClass: string, ruleCaption: string) {
|
||||||
|
return ruleClass + "\0" + ruleCaption;
|
||||||
|
}
|
||||||
|
}
|
||||||
5
src/lib/rules/WindowRule.ts
Normal file
5
src/lib/rules/WindowRule.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
type WindowRule = {
|
||||||
|
class: string | undefined;
|
||||||
|
caption: string | undefined;
|
||||||
|
tile: boolean;
|
||||||
|
};
|
||||||
93
src/lib/rules/WindowRuleEnforcer.ts
Normal file
93
src/lib/rules/WindowRuleEnforcer.ts
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
class WindowRuleEnforcer {
|
||||||
|
private readonly preferFloating: ClientMatcher;
|
||||||
|
private readonly preferTiling: ClientMatcher;
|
||||||
|
private readonly followCaption: RegExp;
|
||||||
|
|
||||||
|
constructor(windowRules: WindowRule[]) {
|
||||||
|
const [floatRegex, tileRegex, followCaptionRegex] = WindowRuleEnforcer.createWindowRuleRegexes(windowRules);
|
||||||
|
this.preferFloating = new ClientMatcher(floatRegex);
|
||||||
|
this.preferTiling = new ClientMatcher(tileRegex);
|
||||||
|
this.followCaption = followCaptionRegex;
|
||||||
|
}
|
||||||
|
|
||||||
|
public shouldTile(kwinClient: KwinClient) {
|
||||||
|
return this.preferTiling.matches(kwinClient) || (
|
||||||
|
kwinClient.normalWindow &&
|
||||||
|
!kwinClient.transient &&
|
||||||
|
kwinClient.managed &&
|
||||||
|
kwinClient.pid > -1 &&
|
||||||
|
!this.preferFloating.matches(kwinClient)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public initClientSignalManager(world: World, kwinClient: KwinClient) {
|
||||||
|
if (!this.followCaption.test(kwinClient.resourceClass)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const enforcer = this;
|
||||||
|
const manager = new SignalManager();
|
||||||
|
manager.connect(kwinClient.captionChanged, () => {
|
||||||
|
const shouldTile = Clients.canTileNow(kwinClient) && enforcer.shouldTile(kwinClient);
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
const desktop = desktopManager.getDesktopForClient(kwinClient);
|
||||||
|
if (shouldTile && desktop !== undefined) {
|
||||||
|
clientManager.tileKwinClient(kwinClient, desktop.grid);
|
||||||
|
} else {
|
||||||
|
clientManager.floatKwinClient(kwinClient);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static createWindowRuleRegexes(windowRules: WindowRule[]) {
|
||||||
|
const floatRegexes: string[] = [];
|
||||||
|
const tileRegexes: string[] = [];
|
||||||
|
const followCaptionRegexes: string[] = [];
|
||||||
|
for (const windowRule of windowRules) {
|
||||||
|
const ruleClass = WindowRuleEnforcer.parseRegex(windowRule.class);
|
||||||
|
const ruleCaption = WindowRuleEnforcer.parseRegex(windowRule.caption);
|
||||||
|
const ruleString = ClientMatcher.getRuleString(
|
||||||
|
WindowRuleEnforcer.wrapParens(ruleClass),
|
||||||
|
WindowRuleEnforcer.wrapParens(ruleCaption)
|
||||||
|
);
|
||||||
|
|
||||||
|
(windowRule.tile ? tileRegexes : floatRegexes).push(ruleString);
|
||||||
|
if (ruleCaption !== ".*") {
|
||||||
|
followCaptionRegexes.push(ruleClass);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
WindowRuleEnforcer.joinRegexes(floatRegexes),
|
||||||
|
WindowRuleEnforcer.joinRegexes(tileRegexes),
|
||||||
|
WindowRuleEnforcer.joinRegexes(followCaptionRegexes),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private static parseRegex(rawRule: string | undefined) {
|
||||||
|
if (rawRule === undefined || rawRule === "" || rawRule === ".*") {
|
||||||
|
return ".*";
|
||||||
|
} else {
|
||||||
|
return rawRule;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static joinRegexes(regexes: string[]) {
|
||||||
|
if (regexes.length === 0) {
|
||||||
|
return new RegExp("a^"); // match nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
if (regexes.length === 1) {
|
||||||
|
return new RegExp("^(" + regexes[0] + ")$");
|
||||||
|
}
|
||||||
|
|
||||||
|
const joinedRegexes = regexes.map(WindowRuleEnforcer.wrapParens).join("|");
|
||||||
|
return new RegExp("^(" + joinedRegexes + ")$");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static wrapParens(str: string) {
|
||||||
|
return "(" + str + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,8 +17,8 @@ class Delayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function initQmlTimer() {
|
function initQmlTimer() {
|
||||||
return Qt.createQmlObject(
|
return <QmlTimer>Qt.createQmlObject(
|
||||||
`import QtQuick 2.15
|
`import QtQuick 6.0
|
||||||
Timer {}`,
|
Timer {}`,
|
||||||
qmlBase
|
qmlBase
|
||||||
);
|
);
|
||||||
24
src/lib/utils/RateLimiter.ts
Normal file
24
src/lib/utils/RateLimiter.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
class RateLimiter {
|
||||||
|
private i = 0;
|
||||||
|
private intervalStart = 0;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private readonly n: number,
|
||||||
|
private readonly intervalMs: number,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public acquire() {
|
||||||
|
const now = Date.now();
|
||||||
|
if (now - this.intervalStart >= this.intervalMs) {
|
||||||
|
this.i = 0;
|
||||||
|
this.intervalStart = now;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.i < this.n) {
|
||||||
|
this.i++;
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
37
src/lib/utils/ShortcutAction.ts
Normal file
37
src/lib/utils/ShortcutAction.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
class ShortcutAction {
|
||||||
|
private readonly shortcutHandler: ShortcutHandler;
|
||||||
|
|
||||||
|
constructor(keyBinding: ShortcutAction.KeyBinding, f: () => void) {
|
||||||
|
this.shortcutHandler = ShortcutAction.initShortcutHandler(keyBinding);
|
||||||
|
this.shortcutHandler.activated.connect(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public destroy() {
|
||||||
|
this.shortcutHandler.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static initShortcutHandler(keyBinding: ShortcutAction.KeyBinding) {
|
||||||
|
const sequenceLine = keyBinding.defaultKeySequence !== undefined ?
|
||||||
|
` sequence: "${keyBinding.defaultKeySequence}";
|
||||||
|
` :
|
||||||
|
"";
|
||||||
|
|
||||||
|
return <ShortcutHandler>Qt.createQmlObject(
|
||||||
|
`import QtQuick 6.0
|
||||||
|
import org.kde.kwin 3.0
|
||||||
|
ShortcutHandler {
|
||||||
|
name: "karousel-${keyBinding.name}";
|
||||||
|
text: "Karousel: ${keyBinding.description}";
|
||||||
|
${sequenceLine}}`,
|
||||||
|
qmlBase,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace ShortcutAction {
|
||||||
|
export type KeyBinding = {
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
defaultKeySequence?: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
39
src/lib/utils/collections.ts
Normal file
39
src/lib/utils/collections.ts
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
function union<T>(array0: T[], array1: T[]) {
|
||||||
|
const set = new Set([...array0, ...array1]);
|
||||||
|
return [...set];
|
||||||
|
}
|
||||||
|
|
||||||
|
function uniq(sortedArray: any[]) {
|
||||||
|
const filtered = [];
|
||||||
|
let lastItem;
|
||||||
|
for (const item of sortedArray) {
|
||||||
|
if (item !== lastItem) {
|
||||||
|
filtered.push(item);
|
||||||
|
lastItem = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return filtered;
|
||||||
|
}
|
||||||
|
|
||||||
|
function mapGetOrInit<K, V>(map: Map<K, V>, key: K, defaultItem: V) {
|
||||||
|
const item = map.get(key);
|
||||||
|
if (item !== undefined) {
|
||||||
|
return item;
|
||||||
|
} else {
|
||||||
|
map.set(key, defaultItem);
|
||||||
|
return defaultItem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function findMinPositive<T>(items: T[], evaluate: (item: T) => number) {
|
||||||
|
let bestScore = Infinity;
|
||||||
|
let bestItem = undefined;
|
||||||
|
for (const item of items) {
|
||||||
|
const score = evaluate(item);
|
||||||
|
if (score > 0 && score < bestScore) {
|
||||||
|
bestScore = score;
|
||||||
|
bestItem = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bestItem;
|
||||||
|
}
|
||||||
98
src/lib/utils/fillSpace.ts
Normal file
98
src/lib/utils/fillSpace.ts
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
function fillSpace(availableSpace: number, items: { min: number, max: number }[]) {
|
||||||
|
if (items.length === 0) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const middleSize = findMiddleSize(availableSpace, items);
|
||||||
|
const sizes = items.map(item => clamp(middleSize, item.min, item.max));
|
||||||
|
if (middleSize !== Math.floor(availableSpace / items.length)) {
|
||||||
|
distributeRemainder(availableSpace, middleSize, sizes, items);
|
||||||
|
}
|
||||||
|
return sizes;
|
||||||
|
|
||||||
|
function findMiddleSize(availableSpace: number, items: { min: number, max: number }[]) {
|
||||||
|
const ranges = buildRanges(items);
|
||||||
|
let requiredSpace = items.reduce((acc, item) => acc + item.min, 0);
|
||||||
|
for (const range of ranges) {
|
||||||
|
const rangeSize = range.end - range.start;
|
||||||
|
const maxRequiredSpaceDelta = rangeSize * range.n;
|
||||||
|
if (requiredSpace + maxRequiredSpaceDelta >= availableSpace) {
|
||||||
|
const positionInRange = (availableSpace - requiredSpace) / maxRequiredSpaceDelta;
|
||||||
|
return Math.floor(range.start + rangeSize * positionInRange);
|
||||||
|
}
|
||||||
|
requiredSpace += maxRequiredSpaceDelta;
|
||||||
|
}
|
||||||
|
return ranges[ranges.length-1].end;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildRanges(items: { min: number, max: number }[]) {
|
||||||
|
const fenceposts = extractFenceposts(items);
|
||||||
|
if (fenceposts.length === 1) {
|
||||||
|
return [{
|
||||||
|
start: fenceposts[0].value,
|
||||||
|
end: fenceposts[0].value,
|
||||||
|
n: items.length,
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
const ranges: Range[] = [];
|
||||||
|
let n = 0;
|
||||||
|
for (let i = 1; i < fenceposts.length; i++) {
|
||||||
|
const startFencepost = fenceposts[i-1];
|
||||||
|
const endFencepost = fenceposts[i];
|
||||||
|
n = n - startFencepost.nMax + startFencepost.nMin;
|
||||||
|
ranges.push({
|
||||||
|
start: startFencepost.value,
|
||||||
|
end: endFencepost.value,
|
||||||
|
n: n,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return ranges;
|
||||||
|
}
|
||||||
|
|
||||||
|
function extractFenceposts(items: { min: number, max: number }[]) {
|
||||||
|
const fenceposts = new Map<number, Fencepost>();
|
||||||
|
for (const item of items) {
|
||||||
|
mapGetOrInit(fenceposts, item.min, { value: item.min, nMin: 0, nMax: 0 }).nMin++;
|
||||||
|
mapGetOrInit(fenceposts, item.max, { value: item.max, nMin: 0, nMax: 0 }).nMax++;
|
||||||
|
}
|
||||||
|
|
||||||
|
const array = Array.from(fenceposts.values());
|
||||||
|
array.sort((a, b) => a.value - b.value);
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
function distributeRemainder(availableSpace: number, middleSize: number, sizes: number[], constraints: { max: number }[]) {
|
||||||
|
const indexes = Array.from(sizes.keys())
|
||||||
|
.filter(i => sizes[i] === middleSize);
|
||||||
|
indexes.sort((a, b) => constraints[a].max - constraints[b].max);
|
||||||
|
|
||||||
|
const requiredSpace = sum(...sizes);
|
||||||
|
let remainder = availableSpace - requiredSpace;
|
||||||
|
let n = indexes.length;
|
||||||
|
for (const i of indexes) {
|
||||||
|
if (remainder <= 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const enlargable = constraints[i].max - sizes[i];
|
||||||
|
if (enlargable > 0) {
|
||||||
|
const enlarge = Math.min(enlargable, Math.ceil(remainder / n));
|
||||||
|
sizes[i] += enlarge;
|
||||||
|
remainder -= enlarge;
|
||||||
|
}
|
||||||
|
n--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Range = {
|
||||||
|
start: number,
|
||||||
|
end: number,
|
||||||
|
n: number,
|
||||||
|
};
|
||||||
|
|
||||||
|
type Fencepost = {
|
||||||
|
value: number,
|
||||||
|
nMin: number,
|
||||||
|
nMax: number,
|
||||||
|
}
|
||||||
|
}
|
||||||
10
src/lib/utils/functions.ts
Normal file
10
src/lib/utils/functions.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
interface Function {
|
||||||
|
partial<H extends any[], T extends any[], R>(
|
||||||
|
this: (...args: [...H, ...T]) => R,
|
||||||
|
...head: H
|
||||||
|
) : (...tail: T) => R;
|
||||||
|
}
|
||||||
|
|
||||||
|
Function.prototype.partial = function<H extends any[], T extends any[]>(...head: H) {
|
||||||
|
return (...tail: T) => this(...head, ...tail);
|
||||||
|
}
|
||||||
20
src/lib/utils/math.ts
Normal file
20
src/lib/utils/math.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
function clamp(value: number, min: number, max: number) {
|
||||||
|
if (value < min) {
|
||||||
|
return min;
|
||||||
|
}
|
||||||
|
if (value > max) {
|
||||||
|
return max;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
function sum(...list: number[]) {
|
||||||
|
return list.reduce((acc, val) => acc + val);
|
||||||
|
}
|
||||||
|
|
||||||
|
function rectEquals(a: QmlRect, b: QmlRect) {
|
||||||
|
return a.x === b.x &&
|
||||||
|
a.y === b.y &&
|
||||||
|
a.width === b.width &&
|
||||||
|
a.height === b.height;
|
||||||
|
}
|
||||||
3
src/lib/utils/strings.ts
Normal file
3
src/lib/utils/strings.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
function applyMacro(base: string, value: string) {
|
||||||
|
return base.replace("{}", String(value));
|
||||||
|
}
|
||||||
56
src/lib/workspace.ts
Normal file
56
src/lib/workspace.ts
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
function initWorkspaceSignalHandlers(world: World) {
|
||||||
|
const manager = new SignalManager();
|
||||||
|
|
||||||
|
manager.connect(Workspace.windowAdded, (kwinClient: KwinClient) => {
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
clientManager.addClient(kwinClient)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
manager.connect(Workspace.windowRemoved, (kwinClient: KwinClient) => {
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
clientManager.removeClient(kwinClient, true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
manager.connect(Workspace.windowActivated, (kwinClient: KwinClient|null) => {
|
||||||
|
if (kwinClient === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
clientManager.onClientFocused(kwinClient);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
manager.connect(Workspace.currentDesktopChanged, () => {
|
||||||
|
world.do(() => {}); // re-arrange desktop
|
||||||
|
});
|
||||||
|
|
||||||
|
manager.connect(Workspace.currentActivityChanged, () => {
|
||||||
|
world.do(() => {}); // re-arrange desktop
|
||||||
|
});
|
||||||
|
|
||||||
|
manager.connect(Workspace.screensChanged, () => {
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
desktopManager.selectScreen(Workspace.activeScreen);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
manager.connect(Workspace.activitiesChanged, () => {
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
desktopManager.updateActivities();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
manager.connect(Workspace.desktopsChanged, () => {
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
desktopManager.updateDesktops();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
manager.connect(Workspace.virtualScreenSizeChanged, () => {
|
||||||
|
world.onScreenResized();
|
||||||
|
});
|
||||||
|
|
||||||
|
return manager;
|
||||||
|
}
|
||||||
@@ -1,15 +1,17 @@
|
|||||||
class ClientManager {
|
class ClientManager {
|
||||||
private readonly world: World;
|
|
||||||
private readonly config: ClientManager.Config;
|
private readonly config: ClientManager.Config;
|
||||||
private readonly desktopManager: DesktopManager;
|
|
||||||
private readonly pinManager: PinManager;
|
|
||||||
private readonly clientMap: Map<KwinClient, ClientWrapper>;
|
private readonly clientMap: Map<KwinClient, ClientWrapper>;
|
||||||
private lastFocusedClient: KwinClient|null;
|
private lastFocusedClient: KwinClient|null;
|
||||||
private readonly windowRuleEnforcer: WindowRuleEnforcer;
|
private readonly windowRuleEnforcer: WindowRuleEnforcer;
|
||||||
|
|
||||||
constructor(config: Config, world: World, desktopManager: DesktopManager, pinManager: PinManager) {
|
constructor(
|
||||||
|
config: Config,
|
||||||
|
private readonly world: World,
|
||||||
|
private readonly desktopManager: DesktopManager,
|
||||||
|
private readonly pinManager: PinManager,
|
||||||
|
) {
|
||||||
this.world = world;
|
this.world = world;
|
||||||
this.config = { keepAbove: config.floatingKeepAbove };
|
this.config = config;
|
||||||
this.desktopManager = desktopManager;
|
this.desktopManager = desktopManager;
|
||||||
this.pinManager = pinManager;
|
this.pinManager = pinManager;
|
||||||
this.clientMap = new Map();
|
this.clientMap = new Map();
|
||||||
@@ -31,9 +33,17 @@ class ClientManager {
|
|||||||
let constructState: (client: ClientWrapper) => ClientState.State;
|
let constructState: (client: ClientWrapper) => ClientState.State;
|
||||||
if (kwinClient.dock) {
|
if (kwinClient.dock) {
|
||||||
constructState = () => new ClientState.Docked(this.world, kwinClient);
|
constructState = () => new ClientState.Docked(this.world, kwinClient);
|
||||||
} else if (this.windowRuleEnforcer.shouldTile(kwinClient)) {
|
} else if (
|
||||||
const grid = this.desktopManager.getDesktopForClient(kwinClient).grid;
|
Clients.canTileEver(kwinClient) &&
|
||||||
constructState = (client: ClientWrapper) => new ClientState.Tiled(this.world, client, grid);
|
!kwinClient.fullScreen &&
|
||||||
|
!Clients.isFullScreenGeometry(kwinClient) &&
|
||||||
|
this.windowRuleEnforcer.shouldTile(kwinClient)
|
||||||
|
) {
|
||||||
|
Clients.makeTileable(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);
|
||||||
} 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);
|
||||||
}
|
}
|
||||||
@@ -58,7 +68,7 @@ class ClientManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private findTransientFor(kwinClient: KwinClient) {
|
private findTransientFor(kwinClient: KwinClient) {
|
||||||
if (!kwinClient.transient) {
|
if (!kwinClient.transient || kwinClient.transientFor === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,41 +86,41 @@ class ClientManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (client.stateManager.getState() instanceof ClientState.Tiled) {
|
if (client.stateManager.getState() instanceof ClientState.Tiled) {
|
||||||
client.stateManager.setState(() => new ClientState.TiledMinimized(), kwinClient === this.lastFocusedClient);
|
client.stateManager.setState(
|
||||||
|
() => new ClientState.TiledMinimized(this.world, client),
|
||||||
|
kwinClient === this.lastFocusedClient,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public unminimizeClient(kwinClient: KwinClient) {
|
public tileClient(client: ClientWrapper, grid: Grid) {
|
||||||
const client = this.clientMap.get(kwinClient);
|
|
||||||
if (client === undefined) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (client.stateManager.getState() instanceof ClientState.TiledMinimized) {
|
|
||||||
const grid = this.desktopManager.getDesktopForClient(kwinClient).grid;
|
|
||||||
client.stateManager.setState(() => new ClientState.Tiled(this.world, client, grid), false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public tileClient(kwinClient: KwinClient) {
|
|
||||||
const client = this.clientMap.get(kwinClient);
|
|
||||||
if (client === undefined) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (client.stateManager.getState() instanceof ClientState.Tiled) {
|
if (client.stateManager.getState() instanceof ClientState.Tiled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const grid = this.desktopManager.getDesktopForClient(kwinClient).grid;
|
|
||||||
client.stateManager.setState(() => new ClientState.Tiled(this.world, client, grid), false);
|
client.stateManager.setState(() => new ClientState.Tiled(this.world, client, grid), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public untileClient(kwinClient: KwinClient) {
|
public floatClient(client: ClientWrapper) {
|
||||||
|
if (client.stateManager.getState() instanceof ClientState.Floating) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
client.stateManager.setState(() => new ClientState.Floating(this.world, client, this.config, true), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public tileKwinClient(kwinClient: KwinClient, grid: Grid) {
|
||||||
const client = this.clientMap.get(kwinClient);
|
const client = this.clientMap.get(kwinClient);
|
||||||
if (client === undefined) {
|
if (client === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (client.stateManager.getState() instanceof ClientState.Tiled) {
|
this.tileClient(client, grid);
|
||||||
client.stateManager.setState(() => new ClientState.Floating(this.world, client, this.config, true), false);
|
}
|
||||||
|
|
||||||
|
public floatKwinClient(kwinClient: KwinClient) {
|
||||||
|
const client = this.clientMap.get(kwinClient);
|
||||||
|
if (client === undefined) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
this.floatClient(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
public pinClient(kwinClient: KwinClient) {
|
public pinClient(kwinClient: KwinClient) {
|
||||||
@@ -118,6 +128,11 @@ class ClientManager {
|
|||||||
if (client === undefined) {
|
if (client === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (client.getMaximizedMode() !== MaximizedMode.Unmaximized) {
|
||||||
|
// the client is not really kwin-tiled, just maximized
|
||||||
|
kwinClient.tile = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
client.stateManager.setState(() => new ClientState.Pinned(this.world, this.pinManager, this.desktopManager, kwinClient, this.config), false);
|
client.stateManager.setState(() => new ClientState.Pinned(this.world, this.pinManager, this.desktopManager, kwinClient, this.config), false);
|
||||||
this.pinManager.addClient(kwinClient);
|
this.pinManager.addClient(kwinClient);
|
||||||
for (const desktop of this.desktopManager.getDesktopsForClient(kwinClient)) {
|
for (const desktop of this.desktopManager.getDesktopsForClient(kwinClient)) {
|
||||||
@@ -147,8 +162,11 @@ class ClientManager {
|
|||||||
const clientState = client.stateManager.getState();
|
const clientState = client.stateManager.getState();
|
||||||
if ((clientState instanceof ClientState.Floating || clientState instanceof ClientState.Pinned) && Clients.canTileEver(kwinClient)) {
|
if ((clientState instanceof ClientState.Floating || clientState instanceof ClientState.Pinned) && Clients.canTileEver(kwinClient)) {
|
||||||
Clients.makeTileable(kwinClient);
|
Clients.makeTileable(kwinClient);
|
||||||
const grid = this.desktopManager.getDesktopForClient(kwinClient).grid;
|
const desktop = this.desktopManager.getDesktopForClient(kwinClient);
|
||||||
client.stateManager.setState(() => new ClientState.Tiled(this.world, client, grid), false);
|
if (desktop === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
client.stateManager.setState(() => new ClientState.Tiled(this.world, client, desktop.grid), false);
|
||||||
} else if (clientState instanceof ClientState.Tiled) {
|
} else if (clientState instanceof ClientState.Tiled) {
|
||||||
client.stateManager.setState(() => new ClientState.Floating(this.world, client, this.config, true), false);
|
client.stateManager.setState(() => new ClientState.Floating(this.world, client, this.config, true), false);
|
||||||
}
|
}
|
||||||
@@ -160,27 +178,27 @@ class ClientManager {
|
|||||||
|
|
||||||
public onClientFocused(kwinClient: KwinClient) {
|
public onClientFocused(kwinClient: KwinClient) {
|
||||||
this.lastFocusedClient = kwinClient;
|
this.lastFocusedClient = kwinClient;
|
||||||
const window = this.findTiledWindow(kwinClient, true);
|
const window = this.findTiledWindow(kwinClient);
|
||||||
if (window !== null) {
|
if (window !== null) {
|
||||||
window.onFocused();
|
window.onFocused();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public findTiledWindow(kwinClient: KwinClient, followTransient: boolean) {
|
public findTiledWindow(kwinClient: KwinClient) {
|
||||||
const client = this.clientMap.get(kwinClient);
|
const client = this.clientMap.get(kwinClient);
|
||||||
if (client === undefined) {
|
if (client === undefined) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.findTiledWindowOfClient(client, followTransient);
|
return this.findTiledWindowOfClient(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
private findTiledWindowOfClient(client: ClientWrapper, followTransient: boolean): Window|null {
|
private findTiledWindowOfClient(client: ClientWrapper): Window|null {
|
||||||
const clientState = client.stateManager.getState();
|
const clientState = client.stateManager.getState();
|
||||||
if (clientState instanceof ClientState.Tiled) {
|
if (clientState instanceof ClientState.Tiled) {
|
||||||
return clientState.window;
|
return clientState.window;
|
||||||
} else if (followTransient && client.transientFor !== null) {
|
} else if (client.transientFor !== null) {
|
||||||
return this.findTiledWindowOfClient(client.transientFor, true);
|
return this.findTiledWindowOfClient(client.transientFor);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -199,6 +217,6 @@ class ClientManager {
|
|||||||
|
|
||||||
namespace ClientManager {
|
namespace ClientManager {
|
||||||
export type Config = {
|
export type Config = {
|
||||||
keepAbove: boolean,
|
floatingKeepAbove: boolean;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
@@ -1,18 +1,17 @@
|
|||||||
class ClientWrapper {
|
class ClientWrapper {
|
||||||
public readonly kwinClient: KwinClient;
|
|
||||||
public readonly stateManager: ClientState.Manager;
|
public readonly stateManager: ClientState.Manager;
|
||||||
public transientFor: ClientWrapper | null;
|
|
||||||
private readonly transients: ClientWrapper[];
|
private readonly transients: ClientWrapper[];
|
||||||
private readonly rulesSignalManager: SignalManager | null;
|
private readonly signalManager: SignalManager;
|
||||||
public preferredWidth: number;
|
public preferredWidth: number;
|
||||||
|
private maximizedMode: MaximizedMode | undefined;
|
||||||
private readonly manipulatingGeometry: Doer;
|
private readonly manipulatingGeometry: Doer;
|
||||||
private lastPlacement: QmlRect | null; // workaround for issue #19
|
private lastPlacement: QmlRect | null; // workaround for issue #19
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
kwinClient: KwinClient,
|
public readonly kwinClient: KwinClient,
|
||||||
constructInitialState: (client: ClientWrapper) => ClientState.State,
|
constructInitialState: (client: ClientWrapper) => ClientState.State,
|
||||||
transientFor: ClientWrapper | null,
|
public transientFor: ClientWrapper | null,
|
||||||
rulesSignalManager: SignalManager | null,
|
private readonly rulesSignalManager: SignalManager | null,
|
||||||
) {
|
) {
|
||||||
this.kwinClient = kwinClient;
|
this.kwinClient = kwinClient;
|
||||||
this.transientFor = transientFor;
|
this.transientFor = transientFor;
|
||||||
@@ -20,6 +19,7 @@ class ClientWrapper {
|
|||||||
if (transientFor !== null) {
|
if (transientFor !== null) {
|
||||||
transientFor.addTransient(this);
|
transientFor.addTransient(this);
|
||||||
}
|
}
|
||||||
|
this.signalManager = ClientWrapper.initSignalManager(this);
|
||||||
this.rulesSignalManager = rulesSignalManager;
|
this.rulesSignalManager = rulesSignalManager;
|
||||||
this.preferredWidth = kwinClient.frameGeometry.width;
|
this.preferredWidth = kwinClient.frameGeometry.width;
|
||||||
this.manipulatingGeometry = new Doer();
|
this.manipulatingGeometry = new Doer();
|
||||||
@@ -35,12 +35,18 @@ class ClientWrapper {
|
|||||||
}
|
}
|
||||||
this.lastPlacement = Qt.rect(x, y, width, height);
|
this.lastPlacement = Qt.rect(x, y, width, height);
|
||||||
this.kwinClient.frameGeometry = this.lastPlacement;
|
this.kwinClient.frameGeometry = this.lastPlacement;
|
||||||
|
if (this.kwinClient.frameGeometry !== this.lastPlacement) {
|
||||||
|
// frameGeometry assignment failed. This sometimes happens on Wayland
|
||||||
|
// when a window is off-screen, effectively making it stuck there.
|
||||||
|
this.kwinClient.frameGeometry.x = x; // This makes it unstuck.
|
||||||
|
this.kwinClient.frameGeometry = this.lastPlacement;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private moveTransient(dx: number, dy: number, desktopNumber: number) {
|
private moveTransient(dx: number, dy: number, kwinDesktops: KwinDesktop[]) {
|
||||||
if (this.stateManager.getState() instanceof ClientState.Floating) {
|
if (this.stateManager.getState() instanceof ClientState.Floating) {
|
||||||
if (this.kwinClient.desktop === desktopNumber) {
|
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 + dx,
|
||||||
@@ -51,32 +57,52 @@ class ClientWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const transient of this.transients) {
|
for (const transient of this.transients) {
|
||||||
transient.moveTransient(dx, dy, desktopNumber);
|
transient.moveTransient(dx, dy, kwinDesktops);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public moveTransients(dx: number, dy: number) {
|
public moveTransients(dx: number, dy: number) {
|
||||||
for (const transient of this.transients) {
|
for (const transient of this.transients) {
|
||||||
transient.moveTransient(dx, dy, this.kwinClient.desktop);
|
transient.moveTransient(dx, dy, this.kwinClient.desktops);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public focus() {
|
public focus() {
|
||||||
workspace.activeClient = this.kwinClient;
|
Workspace.activeWindow = this.kwinClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
public isFocused() {
|
public isFocused() {
|
||||||
return workspace.activeClient === this.kwinClient;
|
return Workspace.activeWindow === this.kwinClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
public setMaximize(horizontally: boolean, vertically: boolean) {
|
public setMaximize(horizontally: boolean, vertically: boolean) {
|
||||||
|
if (!this.kwinClient.maximizable) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.maximizedMode === undefined) {
|
||||||
|
if (horizontally && vertically) {
|
||||||
|
this.maximizedMode = MaximizedMode.Maximized;
|
||||||
|
} else if (horizontally) {
|
||||||
|
this.maximizedMode = MaximizedMode.Horizontally;
|
||||||
|
} else if (vertically) {
|
||||||
|
this.maximizedMode = MaximizedMode.Vertically;
|
||||||
|
} else {
|
||||||
|
this.maximizedMode = MaximizedMode.Unmaximized;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.manipulatingGeometry.do(() => {
|
this.manipulatingGeometry.do(() => {
|
||||||
this.kwinClient.setMaximize(vertically, horizontally);
|
this.kwinClient.setMaximize(vertically, horizontally);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public setFullScreen(fullScreen: boolean) {
|
public setFullScreen(fullScreen: boolean) {
|
||||||
|
if (!this.kwinClient.fullScreenable) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.manipulatingGeometry.do(() => {
|
this.manipulatingGeometry.do(() => {
|
||||||
this.kwinClient.fullScreen = fullScreen;
|
this.kwinClient.fullScreen = fullScreen;
|
||||||
});
|
});
|
||||||
@@ -92,6 +118,10 @@ class ClientWrapper {
|
|||||||
return this.kwinClient.shade;
|
return this.kwinClient.shade;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getMaximizedMode() {
|
||||||
|
return this.maximizedMode;
|
||||||
|
}
|
||||||
|
|
||||||
public isManipulatingGeometry(newGeometry: QmlRect | null) {
|
public isManipulatingGeometry(newGeometry: QmlRect | null) {
|
||||||
if (newGeometry !== null && newGeometry === this.lastPlacement) {
|
if (newGeometry !== null && newGeometry === this.lastPlacement) {
|
||||||
return true;
|
return true;
|
||||||
@@ -118,7 +148,7 @@ class ClientWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ensureVisible(screenSize: QmlRect) {
|
public ensureVisible(screenSize: QmlRect) {
|
||||||
if (this.kwinClient.desktop !== workspace.currentDesktop) {
|
if (!Clients.isOnVirtualDesktop(this.kwinClient, Workspace.currentDesktop)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const frame = this.kwinClient.frameGeometry;
|
const frame = this.kwinClient.frameGeometry;
|
||||||
@@ -131,6 +161,7 @@ class ClientWrapper {
|
|||||||
|
|
||||||
public destroy(passFocus: boolean) {
|
public destroy(passFocus: boolean) {
|
||||||
this.stateManager.destroy(passFocus);
|
this.stateManager.destroy(passFocus);
|
||||||
|
this.signalManager.destroy();
|
||||||
if (this.rulesSignalManager !== null) {
|
if (this.rulesSignalManager !== null) {
|
||||||
this.rulesSignalManager.destroy();
|
this.rulesSignalManager.destroy();
|
||||||
}
|
}
|
||||||
@@ -141,4 +172,17 @@ class ClientWrapper {
|
|||||||
transient.transientFor = null;
|
transient.transientFor = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static initSignalManager(client: ClientWrapper) {
|
||||||
|
const manager = new SignalManager();
|
||||||
|
|
||||||
|
manager.connect(client.kwinClient.maximizedAboutToChange, (maximizedMode: MaximizedMode) => {
|
||||||
|
if (maximizedMode !== MaximizedMode.Unmaximized && client.kwinClient.tile !== null) {
|
||||||
|
client.kwinClient.tile = null;
|
||||||
|
}
|
||||||
|
client.maximizedMode = maximizedMode;
|
||||||
|
});
|
||||||
|
|
||||||
|
return manager;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
61
src/lib/world/Clients.ts
Normal file
61
src/lib/world/Clients.ts
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
namespace Clients {
|
||||||
|
const prohibitedClasses = [
|
||||||
|
"ksmserver-logout-greeter",
|
||||||
|
"xwaylandvideobridge",
|
||||||
|
];
|
||||||
|
|
||||||
|
export function canTileEver(kwinClient: KwinClient) {
|
||||||
|
return kwinClient.moveable &&
|
||||||
|
kwinClient.resizeable &&
|
||||||
|
!kwinClient.popupWindow &&
|
||||||
|
!prohibitedClasses.includes(kwinClient.resourceClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function canTileNow(kwinClient: KwinClient) {
|
||||||
|
return canTileEver(kwinClient) &&
|
||||||
|
!kwinClient.minimized &&
|
||||||
|
kwinClient.desktops.length === 1 &&
|
||||||
|
kwinClient.activities.length === 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function makeTileable(kwinClient: KwinClient) {
|
||||||
|
if (kwinClient.minimized) {
|
||||||
|
kwinClient.minimized = false;
|
||||||
|
}
|
||||||
|
if (kwinClient.desktops.length !== 1) {
|
||||||
|
kwinClient.desktops = [Workspace.currentDesktop];
|
||||||
|
}
|
||||||
|
if (kwinClient.activities.length !== 1) {
|
||||||
|
kwinClient.activities = [Workspace.currentActivity];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getKwinDesktopApprox(kwinClient: KwinClient) {
|
||||||
|
switch (kwinClient.desktops.length) {
|
||||||
|
case 0:
|
||||||
|
return Workspace.currentDesktop;
|
||||||
|
case 1:
|
||||||
|
return kwinClient.desktops[0];
|
||||||
|
default:
|
||||||
|
if (kwinClient.desktops.includes(Workspace.currentDesktop)) {
|
||||||
|
return Workspace.currentDesktop;
|
||||||
|
} else {
|
||||||
|
return kwinClient.desktops[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isFullScreenGeometry(kwinClient: KwinClient) {
|
||||||
|
const fullScreenArea = Workspace.clientArea(ClientAreaOption.FullScreenArea, kwinClient.output, getKwinDesktopApprox(kwinClient));
|
||||||
|
return kwinClient.clientGeometry.width === fullScreenArea.width &&
|
||||||
|
kwinClient.clientGeometry.height === fullScreenArea.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isOnVirtualDesktop(kwinClient: KwinClient, kwinDesktop: KwinDesktop) {
|
||||||
|
return kwinClient.desktops.length === 0 || kwinClient.desktops.includes(kwinDesktop);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isOnOneOfVirtualDesktops(kwinClient: KwinClient, kwinDesktops: KwinDesktop[]) {
|
||||||
|
return kwinClient.desktops.length === 0 || kwinClient.desktops.some(d => kwinDesktops.includes(d));
|
||||||
|
}
|
||||||
|
}
|
||||||
142
src/lib/world/DesktopManager.ts
Normal file
142
src/lib/world/DesktopManager.ts
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
class DesktopManager {
|
||||||
|
private readonly desktops: Map<string, Desktop>; // key is activityId|desktopId
|
||||||
|
private selectedScreen: Output;
|
||||||
|
private kwinActivities: Set<string>;
|
||||||
|
private kwinDesktops: Set<KwinDesktop>;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private readonly pinManager: PinManager,
|
||||||
|
private readonly config: Desktop.Config,
|
||||||
|
public readonly layoutConfig: LayoutConfig,
|
||||||
|
currentActivity: string,
|
||||||
|
currentDesktop: KwinDesktop,
|
||||||
|
) {
|
||||||
|
this.pinManager = pinManager;
|
||||||
|
this.config = config;
|
||||||
|
this.layoutConfig = layoutConfig;
|
||||||
|
this.desktops = new Map();
|
||||||
|
this.selectedScreen = Workspace.activeScreen;
|
||||||
|
this.kwinActivities = new Set(Workspace.activities);
|
||||||
|
this.kwinDesktops = new Set(Workspace.desktops);
|
||||||
|
this.addDesktop(currentActivity, currentDesktop);
|
||||||
|
}
|
||||||
|
|
||||||
|
public getDesktop(activity: string, kwinDesktop: KwinDesktop) {
|
||||||
|
const desktopKey = DesktopManager.getDesktopKey(activity, kwinDesktop);
|
||||||
|
const desktop = this.desktops.get(desktopKey);
|
||||||
|
if (desktop !== undefined) {
|
||||||
|
return desktop;
|
||||||
|
} else {
|
||||||
|
return this.addDesktop(activity, kwinDesktop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public getCurrentDesktop() {
|
||||||
|
return this.getDesktop(Workspace.currentActivity, Workspace.currentDesktop);
|
||||||
|
}
|
||||||
|
|
||||||
|
public getDesktopInCurrentActivity(kwinDesktop: KwinDesktop) {
|
||||||
|
return this.getDesktop(Workspace.currentActivity, kwinDesktop);
|
||||||
|
}
|
||||||
|
|
||||||
|
public getDesktopForClient(kwinClient: KwinClient) {
|
||||||
|
if (kwinClient.activities.length !== 1 || kwinClient.desktops.length !== 1) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return this.getDesktop(kwinClient.activities[0], kwinClient.desktops[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private addDesktop(activity: string, kwinDesktop: KwinDesktop) {
|
||||||
|
const desktopKey = DesktopManager.getDesktopKey(activity, kwinDesktop);
|
||||||
|
const desktop = new Desktop(
|
||||||
|
kwinDesktop,
|
||||||
|
this.pinManager,
|
||||||
|
this.config,
|
||||||
|
() => this.selectedScreen,
|
||||||
|
this.layoutConfig,
|
||||||
|
);
|
||||||
|
this.desktops.set(desktopKey, desktop);
|
||||||
|
return desktop;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static getDesktopKey(activity: string, kwinDesktop: KwinDesktop) {
|
||||||
|
return activity + "|" + kwinDesktop.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public updateActivities() {
|
||||||
|
const newActivities = new Set(Workspace.activities);
|
||||||
|
for (const activity of this.kwinActivities) {
|
||||||
|
if (!newActivities.has(activity)) {
|
||||||
|
this.removeActivity(activity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.kwinActivities = newActivities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public updateDesktops() {
|
||||||
|
const newDesktops = new Set(Workspace.desktops);
|
||||||
|
for (const desktop of this.kwinDesktops) {
|
||||||
|
if (!newDesktops.has(desktop)) {
|
||||||
|
this.removeKwinDesktop(desktop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.kwinDesktops = newDesktops;
|
||||||
|
}
|
||||||
|
|
||||||
|
public selectScreen(screen: Output) {
|
||||||
|
this.selectedScreen = screen;
|
||||||
|
}
|
||||||
|
|
||||||
|
private removeActivity(activity: string) {
|
||||||
|
for (const kwinDesktop of this.kwinDesktops) {
|
||||||
|
this.destroyDesktop(activity, kwinDesktop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private removeKwinDesktop(kwinDesktop: KwinDesktop) {
|
||||||
|
for (const activity of this.kwinActivities) {
|
||||||
|
this.destroyDesktop(activity, kwinDesktop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private destroyDesktop(activity: string, kwinDesktop: KwinDesktop) {
|
||||||
|
const desktopKey = DesktopManager.getDesktopKey(activity, kwinDesktop);
|
||||||
|
const desktop = this.desktops.get(desktopKey);
|
||||||
|
if (desktop !== undefined) {
|
||||||
|
desktop.destroy();
|
||||||
|
this.desktops.delete(desktopKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public destroy() {
|
||||||
|
for (const desktop of this.desktops.values()) {
|
||||||
|
desktop.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public *getAllDesktops() {
|
||||||
|
for (const desktop of this.desktops.values()) {
|
||||||
|
yield desktop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public getDesktopsForClient(kwinClient: KwinClient) {
|
||||||
|
const desktops = this.getDesktops(kwinClient.activities, kwinClient.desktops); // workaround for QTBUG-109880
|
||||||
|
return desktops;
|
||||||
|
}
|
||||||
|
|
||||||
|
// empty array means all
|
||||||
|
public *getDesktops(activities: string[], kwinDesktops: KwinDesktop[]) {
|
||||||
|
const matchedActivities = activities.length > 0 ? activities : this.kwinActivities.keys();
|
||||||
|
const matchedDesktops = kwinDesktops.length > 0 ? kwinDesktops : this.kwinDesktops.keys();
|
||||||
|
for (const matchedActivity of matchedActivities) {
|
||||||
|
for (const matchedDesktop of matchedDesktops) {
|
||||||
|
const desktopKey = DesktopManager.getDesktopKey(matchedActivity, matchedDesktop);
|
||||||
|
const desktop = this.desktops.get(desktopKey);
|
||||||
|
if (desktop !== undefined) {
|
||||||
|
yield desktop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,11 +13,11 @@ class PinManager {
|
|||||||
this.pinnedClients.delete(kwinClient);
|
this.pinnedClients.delete(kwinClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getAvailableSpace(desktopNumber: number, 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.top, screen.bottom, screen.left, screen.right);
|
||||||
let lots = [baseLot];
|
let lots = [baseLot];
|
||||||
for (const client of this.pinnedClients) {
|
for (const client of this.pinnedClients) {
|
||||||
if (!Clients.isOnVirtualDesktop(client, desktopNumber)) {
|
if (!Clients.isOnVirtualDesktop(client, kwinDesktop) || client.minimized) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,19 +1,35 @@
|
|||||||
class World {
|
class World {
|
||||||
public readonly untileOnDrag: boolean;
|
|
||||||
private readonly desktopManager: DesktopManager;
|
private readonly desktopManager: DesktopManager;
|
||||||
public readonly clientManager: ClientManager;
|
private readonly clientManager: ClientManager;
|
||||||
private readonly pinManager: PinManager;
|
private readonly pinManager: PinManager;
|
||||||
private readonly workspaceSignalManager: SignalManager;
|
private readonly workspaceSignalManager: SignalManager;
|
||||||
|
private readonly shortcutActions: ShortcutAction[];
|
||||||
private readonly screenResizedDelayer: Delayer;
|
private readonly screenResizedDelayer: Delayer;
|
||||||
|
|
||||||
constructor(config: Config) {
|
constructor(config: Config) {
|
||||||
this.untileOnDrag = config.untileOnDrag;
|
|
||||||
this.workspaceSignalManager = initWorkspaceSignalHandlers(this);
|
this.workspaceSignalManager = initWorkspaceSignalHandlers(this);
|
||||||
|
|
||||||
|
let presetWidths = {
|
||||||
|
next: (currentWidth: number, minWidth: number, maxWidth: number) => currentWidth,
|
||||||
|
prev: (currentWidth: number, minWidth: number, maxWidth: number) => currentWidth,
|
||||||
|
getWidths: (minWidth: number, maxWidth: number): number[] => [],
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
presetWidths = new PresetWidths(config.presetWidths, config.gapsInnerHorizontal);
|
||||||
|
} catch (error: any) {
|
||||||
|
notificationInvalidPresetWidths.sendEvent();
|
||||||
|
log("failed to parse presetWidths:", error);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.shortcutActions = registerKeyBindings(this, {
|
||||||
|
manualScrollStep: config.manualScrollStep,
|
||||||
|
presetWidths: presetWidths,
|
||||||
|
columnResizer: config.scrollingCentered ? new RawResizer(presetWidths) : new ContextualResizer(presetWidths),
|
||||||
|
});
|
||||||
|
|
||||||
this.screenResizedDelayer = new Delayer(1000, () => {
|
this.screenResizedDelayer = new Delayer(1000, () => {
|
||||||
// this delay ensures that docks get taken into account by `workspace.clientArea`
|
// this delay ensures that docks are taken into account by `Workspace.clientArea`
|
||||||
const desktopManager = this.desktopManager; // workaround for bug in Qt5's JS engine
|
for (const desktop of this.desktopManager.getAllDesktops()) {
|
||||||
for (const desktop of desktopManager.desktops()) {
|
|
||||||
desktop.onLayoutChanged();
|
desktop.onLayoutChanged();
|
||||||
}
|
}
|
||||||
this.update();
|
this.update();
|
||||||
@@ -31,6 +47,7 @@ class World {
|
|||||||
skipSwitcher: config.skipSwitcher,
|
skipSwitcher: config.skipSwitcher,
|
||||||
tiledKeepBelow: config.tiledKeepBelow,
|
tiledKeepBelow: config.tiledKeepBelow,
|
||||||
maximizedKeepAbove: config.floatingKeepAbove,
|
maximizedKeepAbove: config.floatingKeepAbove,
|
||||||
|
untileOnDrag: config.untileOnDrag,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.desktopManager = new DesktopManager(
|
this.desktopManager = new DesktopManager(
|
||||||
@@ -40,32 +57,39 @@ class World {
|
|||||||
marginBottom: config.gapsOuterBottom,
|
marginBottom: config.gapsOuterBottom,
|
||||||
marginLeft: config.gapsOuterLeft,
|
marginLeft: config.gapsOuterLeft,
|
||||||
marginRight: config.gapsOuterRight,
|
marginRight: config.gapsOuterRight,
|
||||||
overscroll: config.overscroll,
|
scroller: World.createScroller(config),
|
||||||
scroller: config.scrollingLazy ? new ScrollerLazy() :
|
clamper: config.scrollingLazy ? new EdgeClamper() : new CenterClamper(),
|
||||||
config.scrollingCentered ? new ScrollerCentered() :
|
|
||||||
config.scrollingGrouped ? new ScrollerGrouped(layoutConfig) :
|
|
||||||
console.assert(false),
|
|
||||||
},
|
},
|
||||||
layoutConfig,
|
layoutConfig,
|
||||||
workspace.currentActivity,
|
Workspace.currentActivity,
|
||||||
|
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();
|
||||||
this.update();
|
this.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static createScroller(config: Config) {
|
||||||
|
if (config.scrollingLazy) {
|
||||||
|
return new LazyScroller();
|
||||||
|
} else if (config.scrollingCentered) {
|
||||||
|
return new CenteredScroller();
|
||||||
|
} else if (config.scrollingGrouped) {
|
||||||
|
return new GroupedScroller();
|
||||||
|
} else {
|
||||||
|
log("No scrolling mode selected, using default");
|
||||||
|
return new LazyScroller();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private addExistingClients() {
|
private addExistingClients() {
|
||||||
const kwinClients = workspace.clientList();
|
const kwinClients = Workspace.windows;
|
||||||
for (let i = 0; i < kwinClients.length; i++) {
|
for (let i = 0; i < kwinClients.length; i++) {
|
||||||
const kwinClient = kwinClients[i];
|
const kwinClient = kwinClients[i];
|
||||||
this.clientManager.addClient(kwinClient);
|
this.clientManager.addClient(kwinClient);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateDesktops() {
|
|
||||||
this.desktopManager.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
private update() {
|
private update() {
|
||||||
this.desktopManager.getCurrentDesktop().arrange();
|
this.desktopManager.getCurrentDesktop().arrange();
|
||||||
}
|
}
|
||||||
@@ -77,10 +101,9 @@ class World {
|
|||||||
|
|
||||||
public doIfTiled(
|
public doIfTiled(
|
||||||
kwinClient: KwinClient,
|
kwinClient: KwinClient,
|
||||||
followTransient: boolean,
|
|
||||||
f: (clientManager: ClientManager, desktopManager: DesktopManager, window: Window, column: Column, grid: Grid) => void,
|
f: (clientManager: ClientManager, desktopManager: DesktopManager, window: Window, column: Column, grid: Grid) => void,
|
||||||
) {
|
) {
|
||||||
const window = this.clientManager.findTiledWindow(kwinClient, followTransient);
|
const window = this.clientManager.findTiledWindow(kwinClient);
|
||||||
if (window === null) {
|
if (window === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -91,14 +114,19 @@ class World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public doIfTiledFocused(
|
public doIfTiledFocused(
|
||||||
followTransient: boolean,
|
|
||||||
f: (clientManager: ClientManager, desktopManager: DesktopManager, window: Window, column: Column, grid: Grid) => void,
|
f: (clientManager: ClientManager, desktopManager: DesktopManager, window: Window, column: Column, grid: Grid) => void,
|
||||||
) {
|
) {
|
||||||
this.doIfTiled(workspace.activeClient, followTransient, f);
|
if (Workspace.activeWindow === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.doIfTiled(Workspace.activeWindow, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public destroy() {
|
public destroy() {
|
||||||
this.workspaceSignalManager.destroy();
|
this.workspaceSignalManager.destroy();
|
||||||
|
for (const shortcutAction of this.shortcutActions) {
|
||||||
|
shortcutAction.destroy();
|
||||||
|
}
|
||||||
this.clientManager.destroy();
|
this.clientManager.destroy();
|
||||||
this.desktopManager.destroy();
|
this.desktopManager.destroy();
|
||||||
}
|
}
|
||||||
@@ -16,7 +16,7 @@ namespace ClientState {
|
|||||||
|
|
||||||
private static initSignalManager(world: World, kwinClient: KwinClient) {
|
private static initSignalManager(world: World, kwinClient: KwinClient) {
|
||||||
const manager = new SignalManager();
|
const manager = new SignalManager();
|
||||||
manager.connect(kwinClient.frameGeometryChanged, (kwinClient: KwinClient, oldGeometry: QmlRect) => {
|
manager.connect(kwinClient.frameGeometryChanged, () => {
|
||||||
world.onScreenResized();
|
world.onScreenResized();
|
||||||
});
|
});
|
||||||
return manager;
|
return manager;
|
||||||
@@ -7,7 +7,7 @@ namespace ClientState {
|
|||||||
constructor(world: World, client: ClientWrapper, config: ClientManager.Config, limitHeight: boolean) {
|
constructor(world: World, client: ClientWrapper, config: ClientManager.Config, limitHeight: boolean) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
if (config.keepAbove) {
|
if (config.floatingKeepAbove) {
|
||||||
client.kwinClient.keepAbove = true;
|
client.kwinClient.keepAbove = true;
|
||||||
}
|
}
|
||||||
if (limitHeight && client.kwinClient.tile === null) {
|
if (limitHeight && client.kwinClient.tile === null) {
|
||||||
@@ -18,13 +18,15 @@ namespace ClientState {
|
|||||||
|
|
||||||
public destroy(passFocus: boolean) {
|
public destroy(passFocus: boolean) {
|
||||||
this.signalManager.destroy();
|
this.signalManager.destroy();
|
||||||
if (this.config.keepAbove) {
|
|
||||||
this.client.kwinClient.keepAbove = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: move to `Tiled.restoreClientAfterTiling`
|
||||||
private static limitHeight(client: ClientWrapper) {
|
private static limitHeight(client: ClientWrapper) {
|
||||||
const placementArea = workspace.clientArea(ClientAreaOption.PlacementArea, client.kwinClient.screen, client.kwinClient.desktop);
|
const placementArea = Workspace.clientArea(
|
||||||
|
ClientAreaOption.PlacementArea,
|
||||||
|
client.kwinClient.output,
|
||||||
|
Clients.getKwinDesktopApprox(client.kwinClient),
|
||||||
|
);
|
||||||
const clientRect = client.kwinClient.frameGeometry;
|
const clientRect = client.kwinClient.frameGeometry;
|
||||||
const width = client.preferredWidth;
|
const width = client.preferredWidth;
|
||||||
client.place(
|
client.place(
|
||||||
@@ -46,7 +48,7 @@ namespace ClientState {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
manager.connect(kwinClient.frameGeometryChanged, () => {
|
manager.connect(kwinClient.frameGeometryChanged, () => {
|
||||||
// on Wayland, this fires after `tileChanged`
|
// on Wayland, this fires after `tileChanged`
|
||||||
if (kwinClient.tile !== null) {
|
if (kwinClient.tile !== null) {
|
||||||
@@ -54,7 +56,7 @@ namespace ClientState {
|
|||||||
clientManager.pinClient(kwinClient);
|
clientManager.pinClient(kwinClient);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
return manager;
|
return manager;
|
||||||
}
|
}
|
||||||
@@ -21,6 +21,6 @@ namespace ClientState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type State = {
|
export type State = {
|
||||||
destroy(passFocus: boolean): void,
|
destroy(passFocus: boolean): void;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ namespace ClientState {
|
|||||||
this.pinManager = pinManager;
|
this.pinManager = pinManager;
|
||||||
this.desktopManager = desktopManager;
|
this.desktopManager = desktopManager;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
if (config.keepAbove) {
|
if (config.floatingKeepAbove) {
|
||||||
kwinClient.keepAbove = true;
|
kwinClient.keepAbove = true;
|
||||||
}
|
}
|
||||||
this.signalManager = Pinned.initSignalManager(world, pinManager, kwinClient);
|
this.signalManager = Pinned.initSignalManager(world, pinManager, kwinClient);
|
||||||
@@ -19,9 +19,6 @@ namespace ClientState {
|
|||||||
|
|
||||||
public destroy(passFocus: boolean) {
|
public destroy(passFocus: boolean) {
|
||||||
this.signalManager.destroy();
|
this.signalManager.destroy();
|
||||||
if (this.config.keepAbove) {
|
|
||||||
this.kwinClient.keepAbove = true;
|
|
||||||
}
|
|
||||||
this.pinManager.removeClient(this.kwinClient);
|
this.pinManager.removeClient(this.kwinClient);
|
||||||
for (const desktop of this.desktopManager.getDesktopsForClient(this.kwinClient)) {
|
for (const desktop of this.desktopManager.getDesktopsForClient(this.kwinClient)) {
|
||||||
desktop.onPinsChanged();
|
desktop.onPinsChanged();
|
||||||
@@ -30,8 +27,8 @@ namespace ClientState {
|
|||||||
|
|
||||||
private static initSignalManager(world: World, pinManager: PinManager, kwinClient: KwinClient) {
|
private static initSignalManager(world: World, pinManager: PinManager, kwinClient: KwinClient) {
|
||||||
const manager = new SignalManager();
|
const manager = new SignalManager();
|
||||||
let oldDesktopNumber = kwinClient.desktop;
|
|
||||||
let oldActivities = kwinClient.activities;
|
let oldActivities = kwinClient.activities;
|
||||||
|
let oldDesktops = kwinClient.desktops;
|
||||||
|
|
||||||
manager.connect(kwinClient.tileChanged, () => {
|
manager.connect(kwinClient.tileChanged, () => {
|
||||||
if (kwinClient.tile === null) {
|
if (kwinClient.tile === null) {
|
||||||
@@ -41,7 +38,7 @@ namespace ClientState {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
manager.connect(kwinClient.frameGeometryChanged, (kwinClient: KwinClient, oldGeometry: QmlRect) => {
|
manager.connect(kwinClient.frameGeometryChanged, () => {
|
||||||
if (kwinClient.tile === null) {
|
if (kwinClient.tile === null) {
|
||||||
world.do((clientManager, desktopManager) => {
|
world.do((clientManager, desktopManager) => {
|
||||||
clientManager.unpinClient(kwinClient);
|
clientManager.unpinClient(kwinClient);
|
||||||
@@ -53,28 +50,35 @@ namespace ClientState {
|
|||||||
for (const desktop of desktopManager.getDesktopsForClient(kwinClient)) {
|
for (const desktop of desktopManager.getDesktopsForClient(kwinClient)) {
|
||||||
desktop.onPinsChanged();
|
desktop.onPinsChanged();
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
manager.connect(kwinClient.desktopChanged, () => {
|
manager.connect(kwinClient.minimizedChanged, () => {
|
||||||
const changedDesktops = oldDesktopNumber === -1 || kwinClient.desktop === -1 ?
|
|
||||||
[] :
|
|
||||||
[oldDesktopNumber, kwinClient.desktop];
|
|
||||||
world.do((clientManager, desktopManager) => {
|
world.do((clientManager, desktopManager) => {
|
||||||
for (const desktop of desktopManager.getDesktops(changedDesktops, kwinClient.activities)) {
|
for (const desktop of desktopManager.getDesktopsForClient(kwinClient)) {
|
||||||
desktop.onPinsChanged();
|
desktop.onPinsChanged();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
oldDesktopNumber = kwinClient.desktop;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
manager.connect(kwinClient.activitiesChanged, (kwinClient: KwinClient) => {
|
manager.connect(kwinClient.desktopsChanged, () => {
|
||||||
const desktops = kwinClient.desktop === -1 ? [] : [kwinClient.desktop];
|
const changedDesktops = oldDesktops.length === 0 || kwinClient.desktops.length === 0 ?
|
||||||
|
[] :
|
||||||
|
union(oldDesktops, kwinClient.desktops);
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
for (const desktop of desktopManager.getDesktops(kwinClient.activities, changedDesktops)) {
|
||||||
|
desktop.onPinsChanged();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
oldDesktops = kwinClient.desktops;
|
||||||
|
});
|
||||||
|
|
||||||
|
manager.connect(kwinClient.activitiesChanged, () => {
|
||||||
const changedActivities = oldActivities.length === 0 || kwinClient.activities.length === 0 ?
|
const changedActivities = oldActivities.length === 0 || kwinClient.activities.length === 0 ?
|
||||||
[] :
|
[] :
|
||||||
union(oldActivities, kwinClient.activities);
|
union(oldActivities, kwinClient.activities);
|
||||||
world.do((clientManager, desktopManager) => {
|
world.do((clientManager, desktopManager) => {
|
||||||
for (const desktop of desktopManager.getDesktops(desktops, changedActivities)) {
|
for (const desktop of desktopManager.getDesktops(changedActivities, kwinClient.desktops)) {
|
||||||
desktop.onPinsChanged();
|
desktop.onPinsChanged();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
239
src/lib/world/clientState/Tiled.ts
Normal file
239
src/lib/world/clientState/Tiled.ts
Normal file
@@ -0,0 +1,239 @@
|
|||||||
|
namespace ClientState {
|
||||||
|
export class Tiled implements State {
|
||||||
|
public readonly window: Window;
|
||||||
|
private readonly defaultState: Tiled.WindowState;
|
||||||
|
private readonly signalManager: SignalManager;
|
||||||
|
private static readonly maxExternalFrameGeometryChangedIntervalMs = 1000;
|
||||||
|
|
||||||
|
constructor(world: World, client: ClientWrapper, grid: Grid) {
|
||||||
|
this.defaultState = { skipSwitcher: client.kwinClient.skipSwitcher };
|
||||||
|
Tiled.prepareClientForTiling(client, grid.config);
|
||||||
|
|
||||||
|
const column = new Column(grid, grid.getLastFocusedColumn() ?? grid.getLastColumn());
|
||||||
|
const window = new Window(client, column);
|
||||||
|
|
||||||
|
this.window = window;
|
||||||
|
this.signalManager = Tiled.initSignalManager(world, window, grid.config);
|
||||||
|
}
|
||||||
|
|
||||||
|
public destroy(passFocus: boolean) {
|
||||||
|
this.signalManager.destroy();
|
||||||
|
|
||||||
|
const window = this.window;
|
||||||
|
const grid = window.column.grid;
|
||||||
|
const client = window.client;
|
||||||
|
window.destroy(passFocus);
|
||||||
|
|
||||||
|
Tiled.restoreClientAfterTiling(client, grid.config, this.defaultState, grid.desktop.clientArea);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static initSignalManager(world: World, window: Window, config: LayoutConfig) {
|
||||||
|
const client = window.client;
|
||||||
|
const kwinClient = client.kwinClient;
|
||||||
|
const manager = new SignalManager();
|
||||||
|
|
||||||
|
manager.connect(kwinClient.desktopsChanged, () => {
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
const desktop = desktopManager.getDesktopForClient(kwinClient);
|
||||||
|
if (desktop === undefined) {
|
||||||
|
// windows on multiple desktops are not supported
|
||||||
|
clientManager.floatClient(client);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Tiled.moveWindowToGrid(window, desktop.grid);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
manager.connect(kwinClient.activitiesChanged, () => {
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
const desktop = desktopManager.getDesktopForClient(kwinClient);
|
||||||
|
if (desktop === undefined) {
|
||||||
|
// windows on multiple activities are not supported
|
||||||
|
clientManager.floatClient(client);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Tiled.moveWindowToGrid(window, desktop.grid);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
manager.connect(kwinClient.minimizedChanged, () => {
|
||||||
|
console.assert(kwinClient.minimized);
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
clientManager.minimizeClient(kwinClient);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
manager.connect(kwinClient.maximizedAboutToChange, (maximizedMode: MaximizedMode) => {
|
||||||
|
world.do(() => {
|
||||||
|
window.onMaximizedChanged(maximizedMode);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
let resizing = false;
|
||||||
|
let resizeStartWidth = 0;
|
||||||
|
let resizeNeighbor: { column: Column, startWidth: number } | undefined;
|
||||||
|
manager.connect(kwinClient.interactiveMoveResizeStarted, () => {
|
||||||
|
if (kwinClient.move) {
|
||||||
|
if (config.untileOnDrag) {
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
clientManager.floatClient(client);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (kwinClient.resize) {
|
||||||
|
resizing = true;
|
||||||
|
resizeStartWidth = window.column.getWidth();
|
||||||
|
if (config.resizeNeighborColumn) {
|
||||||
|
const resizeNeighborColumn = Tiled.getResizeNeighborColumn(window);
|
||||||
|
if (resizeNeighborColumn !== null) {
|
||||||
|
resizeNeighbor = {
|
||||||
|
column: resizeNeighborColumn,
|
||||||
|
startWidth: resizeNeighborColumn.getWidth(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
window.column.grid.onUserResizeStarted();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
manager.connect(kwinClient.interactiveMoveResizeFinished, () => {
|
||||||
|
if (resizing) {
|
||||||
|
resizing = false;
|
||||||
|
resizeNeighbor = undefined;
|
||||||
|
window.column.grid.onUserResizeFinished();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let externalFrameGeometryChangedRateLimiter = new RateLimiter(4, Tiled.maxExternalFrameGeometryChangedIntervalMs);
|
||||||
|
manager.connect(kwinClient.frameGeometryChanged, (oldGeometry: QmlRect) => {
|
||||||
|
// on Wayland, this fires after `tileChanged`
|
||||||
|
if (kwinClient.tile !== null) {
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
clientManager.pinClient(kwinClient);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const newGeometry = client.kwinClient.frameGeometry;
|
||||||
|
const oldCenterX = oldGeometry.x + oldGeometry.width/2;
|
||||||
|
const oldCenterY = oldGeometry.y + oldGeometry.height/2;
|
||||||
|
const newCenterX = newGeometry.x + newGeometry.width/2;
|
||||||
|
const newCenterY = newGeometry.y + newGeometry.height/2;
|
||||||
|
const dx = Math.round(newCenterX - oldCenterX);
|
||||||
|
const dy = Math.round(newCenterY - oldCenterY);
|
||||||
|
if (dx !== 0 || dy !== 0) {
|
||||||
|
// TODO: instead of passing dx and dy, remember relative (to the parent) x and y for each
|
||||||
|
// transient window and use them for `moveTransients` and `ensureTransientsVisible`
|
||||||
|
client.moveTransients(dx, dy);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (kwinClient.resize) {
|
||||||
|
world.do(() => {
|
||||||
|
if (newGeometry.width !== oldGeometry.width) {
|
||||||
|
window.column.onUserResizeWidth(
|
||||||
|
resizeStartWidth,
|
||||||
|
newGeometry.width - resizeStartWidth,
|
||||||
|
newGeometry.left !== oldGeometry.left,
|
||||||
|
resizeNeighbor,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (newGeometry.height !== oldGeometry.height) {
|
||||||
|
window.column.adjustWindowHeight(
|
||||||
|
window,
|
||||||
|
newGeometry.height - oldGeometry.height,
|
||||||
|
newGeometry.y !== oldGeometry.y,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (
|
||||||
|
!window.column.grid.isUserResizing() &&
|
||||||
|
!client.isManipulatingGeometry(newGeometry) &&
|
||||||
|
client.getMaximizedMode() === MaximizedMode.Unmaximized &&
|
||||||
|
!Clients.isFullScreenGeometry(kwinClient) // not using `kwinClient.fullScreen` because it may not be set yet at this point
|
||||||
|
) {
|
||||||
|
if (externalFrameGeometryChangedRateLimiter.acquire()) {
|
||||||
|
world.do(() => window.onFrameGeometryChanged());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
manager.connect(kwinClient.fullScreenChanged, () => {
|
||||||
|
world.do(() => window.onFullScreenChanged(kwinClient.fullScreen));
|
||||||
|
});
|
||||||
|
|
||||||
|
manager.connect(kwinClient.tileChanged, () => {
|
||||||
|
// on X11, this fires after `frameGeometryChanged`
|
||||||
|
if (kwinClient.tile !== null) {
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
clientManager.pinClient(kwinClient);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static getResizeNeighborColumn(window: Window) {
|
||||||
|
const kwinClient = window.client.kwinClient;
|
||||||
|
const column = window.column;
|
||||||
|
if (Workspace.cursorPos.x > kwinClient.clientGeometry.right) {
|
||||||
|
return column.grid.getRightColumn(column);
|
||||||
|
} else if (Workspace.cursorPos.x < kwinClient.clientGeometry.left) {
|
||||||
|
return column.grid.getLeftColumn(column);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static moveWindowToGrid(window: Window, grid: Grid) {
|
||||||
|
if (grid === window.column.grid) {
|
||||||
|
// window already on the given grid
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const newColumn = new Column(grid, grid.getLastFocusedColumn() ?? grid.getLastColumn());
|
||||||
|
window.moveToColumn(newColumn, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static prepareClientForTiling(client: ClientWrapper, config: LayoutConfig) {
|
||||||
|
if (config.skipSwitcher) {
|
||||||
|
client.kwinClient.skipSwitcher = true;
|
||||||
|
}
|
||||||
|
if (config.tiledKeepBelow) {
|
||||||
|
client.kwinClient.keepBelow = true;
|
||||||
|
}
|
||||||
|
client.kwinClient.keepAbove = false;
|
||||||
|
client.setFullScreen(false);
|
||||||
|
if (client.kwinClient.tile !== null) {
|
||||||
|
client.setMaximize(false, true); // disable quick tile mode
|
||||||
|
}
|
||||||
|
client.setMaximize(false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static restoreClientAfterTiling(client: ClientWrapper, config: LayoutConfig, defaultState: Tiled.WindowState, screenSize: QmlRect) {
|
||||||
|
if (config.skipSwitcher) {
|
||||||
|
client.kwinClient.skipSwitcher = defaultState.skipSwitcher;
|
||||||
|
}
|
||||||
|
if (config.tiledKeepBelow) {
|
||||||
|
client.kwinClient.keepBelow = false;
|
||||||
|
}
|
||||||
|
if (config.offScreenOpacity < 1.0) {
|
||||||
|
client.kwinClient.opacity = 1.0;
|
||||||
|
}
|
||||||
|
client.setShade(false);
|
||||||
|
client.setFullScreen(false);
|
||||||
|
if (client.kwinClient.tile === null) {
|
||||||
|
client.setMaximize(false, false);
|
||||||
|
}
|
||||||
|
client.ensureVisible(screenSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Tiled {
|
||||||
|
export type WindowState = {
|
||||||
|
skipSwitcher: boolean;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
31
src/lib/world/clientState/TiledMinimized.ts
Normal file
31
src/lib/world/clientState/TiledMinimized.ts
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
namespace ClientState {
|
||||||
|
export class TiledMinimized implements State {
|
||||||
|
private readonly signalManager: SignalManager;
|
||||||
|
|
||||||
|
constructor(world: World, client: ClientWrapper) {
|
||||||
|
this.signalManager = TiledMinimized.initSignalManager(world, client);
|
||||||
|
}
|
||||||
|
|
||||||
|
public destroy(passFocus: boolean) {
|
||||||
|
this.signalManager.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static initSignalManager(world: World, client: ClientWrapper) {
|
||||||
|
const manager = new SignalManager();
|
||||||
|
|
||||||
|
manager.connect(client.kwinClient.minimizedChanged, () => {
|
||||||
|
console.assert(!client.kwinClient.minimized);
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
const desktop = desktopManager.getDesktopForClient(client.kwinClient);
|
||||||
|
if (desktop !== undefined) {
|
||||||
|
clientManager.tileClient(client, desktop.grid);
|
||||||
|
} else {
|
||||||
|
clientManager.floatClient(client);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return manager;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
function init() {
|
|
||||||
const config = loadConfig();
|
|
||||||
const world = new World(config);
|
|
||||||
registerKeyBindings(world, config);
|
|
||||||
return world;
|
|
||||||
}
|
|
||||||
@@ -1,3 +1,7 @@
|
|||||||
|
function init() {
|
||||||
|
return new World(loadConfig());
|
||||||
|
}
|
||||||
|
|
||||||
function loadConfig(): Config {
|
function loadConfig(): Config {
|
||||||
const config: any = {};
|
const config: any = {};
|
||||||
for (const entry of configDef) {
|
for (const entry of configDef) {
|
||||||
8
src/main/tsconfig.json
Normal file
8
src/main/tsconfig.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"extends": "../tsconfig.json",
|
||||||
|
"include": [
|
||||||
|
"../extern/**/*",
|
||||||
|
"../lib/**/*",
|
||||||
|
"./**/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
class ClientMatcher {
|
|
||||||
private readonly rules: Map<string, RegExp>;
|
|
||||||
|
|
||||||
constructor(rules: Map<string, RegExp>) {
|
|
||||||
this.rules = rules;
|
|
||||||
}
|
|
||||||
|
|
||||||
public matches(kwinClient: KwinClient) {
|
|
||||||
const rule = this.rules.get(kwinClient.resourceClass);
|
|
||||||
if (rule === undefined) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return rule.test(kwinClient.caption);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
type WindowRule = {
|
|
||||||
class: string,
|
|
||||||
caption: string,
|
|
||||||
tile: boolean,
|
|
||||||
};
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
class WindowRuleEnforcer {
|
|
||||||
private readonly preferFloating: ClientMatcher;
|
|
||||||
private readonly preferTiling: ClientMatcher;
|
|
||||||
private readonly followCaption: Set<string>;
|
|
||||||
|
|
||||||
constructor(windowRules: WindowRule[]) {
|
|
||||||
const [mapFloat, mapTile] = WindowRuleEnforcer.createWindowRuleMaps(windowRules);
|
|
||||||
this.preferFloating = new ClientMatcher(mapFloat);
|
|
||||||
this.preferTiling = new ClientMatcher(mapTile);
|
|
||||||
this.followCaption = new Set([...mapFloat.keys(), ...mapTile.keys()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public shouldTile(kwinClient: KwinClient) {
|
|
||||||
return Clients.canTileNow(kwinClient) && (
|
|
||||||
this.preferTiling.matches(kwinClient) || (
|
|
||||||
kwinClient.normalWindow &&
|
|
||||||
!kwinClient.transient &&
|
|
||||||
kwinClient.managed &&
|
|
||||||
!this.preferFloating.matches(kwinClient)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public initClientSignalManager(world: World, kwinClient: KwinClient) {
|
|
||||||
if (!this.followCaption.has(kwinClient.resourceClass)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const enforcer = this;
|
|
||||||
const manager = new SignalManager();
|
|
||||||
manager.connect(kwinClient.captionChanged, () => {
|
|
||||||
const shouldTile = enforcer.shouldTile(kwinClient);
|
|
||||||
world.do((clientManager, desktopManager) => {
|
|
||||||
if (shouldTile) {
|
|
||||||
clientManager.tileClient(kwinClient);
|
|
||||||
} else {
|
|
||||||
clientManager.untileClient(kwinClient);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return manager;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static createWindowRuleMaps(windowRules: WindowRule[]) {
|
|
||||||
const mapFloat = new Map<string, string[]>();
|
|
||||||
const mapTile = new Map<string, string[]>();
|
|
||||||
for (const windowRule of windowRules) {
|
|
||||||
const map = windowRule.tile ? mapTile : mapFloat;
|
|
||||||
let captions = map.get(windowRule.class);
|
|
||||||
if (captions === undefined) {
|
|
||||||
captions = [];
|
|
||||||
map.set(windowRule.class, captions);
|
|
||||||
}
|
|
||||||
if (windowRule.caption !== undefined) {
|
|
||||||
captions.push(windowRule.caption);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
|
||||||
WindowRuleEnforcer.createWindowRuleRegexMap(mapFloat),
|
|
||||||
WindowRuleEnforcer.createWindowRuleRegexMap(mapTile),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
private static createWindowRuleRegexMap(windowRuleMap: Map<string, string[]>) {
|
|
||||||
const regexMap = new Map<string, RegExp>;
|
|
||||||
for (const [k, v] of windowRuleMap) {
|
|
||||||
regexMap.set(k, WindowRuleEnforcer.joinRegexes(v));
|
|
||||||
}
|
|
||||||
return regexMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static joinRegexes(regexes: string[]) {
|
|
||||||
if (regexes.length == 0) {
|
|
||||||
return new RegExp("");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (regexes.length == 1) {
|
|
||||||
return new RegExp("^" + regexes[0] + "$");
|
|
||||||
}
|
|
||||||
|
|
||||||
const joinedRegexes = regexes.map(WindowRuleEnforcer.wrapParens).join("|");
|
|
||||||
return new RegExp("^" + joinedRegexes + "$");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static wrapParens(str: string) {
|
|
||||||
return "(" + str + ")";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
23
src/tests/flows/centerFocused.ts
Normal file
23
src/tests/flows/centerFocused.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
tests.register("Center focused", 1, () => {
|
||||||
|
const config = getDefaultConfig();
|
||||||
|
const { qtMock, workspaceMock, world } = init(config);
|
||||||
|
|
||||||
|
const [client0, client1, client2] = workspaceMock.createClientsWithWidths(300, 152, 300);
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
Assert.assert(clientManager.hasClient(client0));
|
||||||
|
Assert.assert(clientManager.hasClient(client1));
|
||||||
|
Assert.assert(clientManager.hasClient(client2));
|
||||||
|
});
|
||||||
|
Assert.assert(workspaceMock.activeWindow === client2);
|
||||||
|
Assert.columnsFillTilingArea([client0, client1, client2]);
|
||||||
|
|
||||||
|
qtMock.fireShortcut("karousel-grid-scroll-focused");
|
||||||
|
Assert.centered(config, screen, client2);
|
||||||
|
Assert.fullyVisible(client1.frameGeometry);
|
||||||
|
Assert.fullyVisible(client2.frameGeometry);
|
||||||
|
|
||||||
|
qtMock.fireShortcut("karousel-focus-left");
|
||||||
|
Assert.centered(config, screen, client2, { message: "No scrolling should have occured" });
|
||||||
|
Assert.fullyVisible(client1.frameGeometry);
|
||||||
|
Assert.fullyVisible(client2.frameGeometry);
|
||||||
|
});
|
||||||
124
src/tests/flows/columnsSqueezeSide.ts
Normal file
124
src/tests/flows/columnsSqueezeSide.ts
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
tests.register("columns squeeze side", 1, () => {
|
||||||
|
const baseTestCases = [
|
||||||
|
{ widths: [500, 500], blocked: [false, false], possible: true },
|
||||||
|
{ widths: [500, 768], blocked: [false, false], possible: true },
|
||||||
|
{ widths: [500, 500], blocked: [false, true], possible: true },
|
||||||
|
{ widths: [500, 200, 200], blocked: [false, false, false], possible: true },
|
||||||
|
{ widths: [500, 200, 200], blocked: [false, false, true], possible: true },
|
||||||
|
{ widths: [500, 200, 200], blocked: [true, false, true], possible: true },
|
||||||
|
{ widths: [500, 500, 500], blocked: [false, true, true], possible: false },
|
||||||
|
];
|
||||||
|
|
||||||
|
const testCasesLeft = baseTestCases.map((baseTestCase, i) => ({
|
||||||
|
...baseTestCase,
|
||||||
|
name: "left " + i,
|
||||||
|
action: "karousel-columns-squeeze-left",
|
||||||
|
focus: baseTestCase.widths.length-1,
|
||||||
|
}));
|
||||||
|
|
||||||
|
const testCasesRight = baseTestCases.map((baseTestCase, i) => ({
|
||||||
|
...baseTestCase,
|
||||||
|
widths: baseTestCase.widths.slice().reverse(),
|
||||||
|
blocked: baseTestCase.blocked.slice().reverse(),
|
||||||
|
name: "right " + i,
|
||||||
|
action: "karousel-columns-squeeze-right",
|
||||||
|
focus: 0,
|
||||||
|
}));
|
||||||
|
|
||||||
|
const testCases = [...testCasesLeft, ...testCasesRight];
|
||||||
|
|
||||||
|
for (const testCase of testCases) {
|
||||||
|
const assertOpt = { message: `Case: ${testCase.name}` };
|
||||||
|
|
||||||
|
const config = getDefaultConfig();
|
||||||
|
const { qtMock, workspaceMock, world } = init(config);
|
||||||
|
|
||||||
|
const clients = workspaceMock.createClientsWithWidths(...testCase.widths);
|
||||||
|
workspaceMock.activeWindow = clients[testCase.focus];
|
||||||
|
for (let i = 0; i < clients.length; i++) {
|
||||||
|
if (testCase.blocked[i]) {
|
||||||
|
clients[i].minSize = new MockQmlSize(testCase.widths[i], 100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (testCase.possible) {
|
||||||
|
qtMock.fireShortcut(testCase.action);
|
||||||
|
Assert.columnsFillTilingArea(clients, assertOpt);
|
||||||
|
for (let i = 0; i < clients.length; i++) {
|
||||||
|
if (testCase.blocked[i]) {
|
||||||
|
Assert.equal(clients[i].frameGeometry.width, testCase.widths[i], assertOpt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const frames = clients.map(client => client.frameGeometry);
|
||||||
|
qtMock.fireShortcut(testCase.action);
|
||||||
|
const newFrames = clients.map(client => client.frameGeometry);
|
||||||
|
for (let i = 0; i < clients.length; i++) {
|
||||||
|
Assert.equalRects(frames[i], newFrames[i], assertOpt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
tests.register("columns squeeze side (just scroll)", 1, () => {
|
||||||
|
const baseTestCases = [
|
||||||
|
{ focus: 0, startVisible: [true, true, false], endVisible: [true, true, false] },
|
||||||
|
{ focus: 1, startVisible: [false, true, true], endVisible: [true, true, false] },
|
||||||
|
{ focus: 2, startVisible: [false, true, true], endVisible: [false, true, true] },
|
||||||
|
];
|
||||||
|
|
||||||
|
const testCasesLeft = baseTestCases.map((baseTestCase, i) => ({
|
||||||
|
...baseTestCase,
|
||||||
|
name: "left " + i,
|
||||||
|
action: "karousel-columns-squeeze-left",
|
||||||
|
scrollStart: false,
|
||||||
|
}));
|
||||||
|
|
||||||
|
const testCasesRight = baseTestCases.map((baseTestCase, i) => ({
|
||||||
|
focus: 2 - baseTestCase.focus,
|
||||||
|
startVisible: baseTestCase.startVisible.slice().reverse(),
|
||||||
|
endVisible: baseTestCase.endVisible.slice().reverse(),
|
||||||
|
name: "right " + i,
|
||||||
|
action: "karousel-columns-squeeze-right",
|
||||||
|
scrollStart: true,
|
||||||
|
}));
|
||||||
|
|
||||||
|
const testCases = [...testCasesLeft, ...testCasesRight];
|
||||||
|
|
||||||
|
for (const testCase of testCases) {
|
||||||
|
const assertMsg = `Case: ${testCase.name}`;
|
||||||
|
|
||||||
|
const config = getDefaultConfig();
|
||||||
|
const { qtMock, workspaceMock, world } = init(config);
|
||||||
|
|
||||||
|
function assertVisible(clients: KwinClient[], visible: boolean[]) {
|
||||||
|
for (let i = 0; i < clients.length; i++) {
|
||||||
|
if (visible[i]) {
|
||||||
|
Assert.fullyVisible(clients[i].frameGeometry, { message: assertMsg, skip: 1 });
|
||||||
|
} else {
|
||||||
|
Assert.notFullyVisible(clients[i].frameGeometry, { message: assertMsg, skip: 1 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const clients = workspaceMock.createClientsWithWidths(300, 300, 300);
|
||||||
|
for (const client of clients) {
|
||||||
|
client.minSize = new MockQmlSize(300, 100);
|
||||||
|
}
|
||||||
|
if (testCase.scrollStart) {
|
||||||
|
qtMock.fireShortcut("karousel-grid-scroll-start");
|
||||||
|
}
|
||||||
|
workspaceMock.activeWindow = clients[testCase.focus];
|
||||||
|
assertVisible(clients, testCase.startVisible);
|
||||||
|
|
||||||
|
qtMock.fireShortcut(testCase.action);
|
||||||
|
assertVisible(clients, testCase.endVisible);
|
||||||
|
|
||||||
|
const frames = clients.map(client => client.frameGeometry);
|
||||||
|
qtMock.fireShortcut(testCase.action);
|
||||||
|
const newFrames = clients.map(client => client.frameGeometry);
|
||||||
|
for (let i = 0; i < clients.length; i++) {
|
||||||
|
Assert.equalRects(frames[i], newFrames[i], { message: assertMsg });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
44
src/tests/flows/externalResize.ts
Normal file
44
src/tests/flows/externalResize.ts
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
tests.register("External resize", 1, () => {
|
||||||
|
const config = getDefaultConfig();
|
||||||
|
const { qtMock, workspaceMock, world } = init(config);
|
||||||
|
|
||||||
|
function getClientDesiredFrame(width: number) {
|
||||||
|
return new MockQmlRect(10, 10, width, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTiledFrame(width: number) {
|
||||||
|
return new MockQmlRect(
|
||||||
|
Math.round((screen.width - width) / 2),
|
||||||
|
tilingArea.top,
|
||||||
|
width,
|
||||||
|
tilingArea.height,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const [client] = workspaceMock.createClientsWithFrames(getClientDesiredFrame(100));
|
||||||
|
Assert.equalRects(client.frameGeometry, getTiledFrame(100), { message: "We should tile the window, respecting its desired width" });
|
||||||
|
|
||||||
|
function testExternalResizing() {
|
||||||
|
client.frameGeometry = getClientDesiredFrame(110);
|
||||||
|
Assert.equalRects(client.frameGeometry, getTiledFrame(110), { message: "We should re-arrange the window, respecting its new desired width" });
|
||||||
|
|
||||||
|
client.frameGeometry = getClientDesiredFrame(120);
|
||||||
|
Assert.equalRects(client.frameGeometry, getTiledFrame(120), { message: "We should re-arrange the window, respecting its new desired width" });
|
||||||
|
|
||||||
|
client.frameGeometry = getClientDesiredFrame(130);
|
||||||
|
Assert.equalRects(client.frameGeometry, getTiledFrame(130), { message: "We should re-arrange the window, respecting its new desired width" });
|
||||||
|
|
||||||
|
client.frameGeometry = getClientDesiredFrame(140);
|
||||||
|
Assert.equalRects(client.frameGeometry, getTiledFrame(140), { message: "We should re-arrange the window, respecting its new desired width" });
|
||||||
|
|
||||||
|
client.frameGeometry = getClientDesiredFrame(200);
|
||||||
|
Assert.equalRects(client.frameGeometry, getClientDesiredFrame(200), { message: "We should give up and let the client have its desired frame" });
|
||||||
|
}
|
||||||
|
|
||||||
|
timeControl(addTime => {
|
||||||
|
testExternalResizing();
|
||||||
|
addTime(1000);
|
||||||
|
// the concession has expired, let's test again
|
||||||
|
testExternalResizing();
|
||||||
|
});
|
||||||
|
});
|
||||||
191
src/tests/flows/layering.ts
Normal file
191
src/tests/flows/layering.ts
Normal file
@@ -0,0 +1,191 @@
|
|||||||
|
tests.register("tiledKeepBelow", 10, () => {
|
||||||
|
const config = getDefaultConfig();
|
||||||
|
config.tiledKeepBelow = true;
|
||||||
|
config.floatingKeepAbove = false;
|
||||||
|
const { qtMock, workspaceMock, world } = init(config);
|
||||||
|
|
||||||
|
const pinGeometry = new MockQmlRect(0, 0, 200, screen.height);
|
||||||
|
|
||||||
|
const [client] = workspaceMock.createClients(1);
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
Assert.assert(clientManager.findTiledWindow(client) !== null);
|
||||||
|
});
|
||||||
|
Assert.assert(client.keepBelow);
|
||||||
|
Assert.assert(!client.keepAbove);
|
||||||
|
|
||||||
|
qtMock.fireShortcut("karousel-window-toggle-floating");
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
Assert.assert(clientManager.findTiledWindow(client) === null);
|
||||||
|
});
|
||||||
|
Assert.assert(!client.keepBelow);
|
||||||
|
Assert.assert(!client.keepAbove);
|
||||||
|
|
||||||
|
client.pin(pinGeometry);
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
Assert.assert(clientManager.findTiledWindow(client) === null);
|
||||||
|
});
|
||||||
|
Assert.assert(!client.keepBelow);
|
||||||
|
Assert.assert(!client.keepAbove);
|
||||||
|
|
||||||
|
client.unpin();
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
Assert.assert(clientManager.findTiledWindow(client) === null);
|
||||||
|
});
|
||||||
|
Assert.assert(!client.keepBelow);
|
||||||
|
Assert.assert(!client.keepAbove);
|
||||||
|
|
||||||
|
qtMock.fireShortcut("karousel-window-toggle-floating");
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
Assert.assert(clientManager.findTiledWindow(client) !== null);
|
||||||
|
});
|
||||||
|
Assert.assert(client.keepBelow);
|
||||||
|
Assert.assert(!client.keepAbove);
|
||||||
|
|
||||||
|
client.pin(pinGeometry);
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
Assert.assert(clientManager.findTiledWindow(client) === null);
|
||||||
|
});
|
||||||
|
Assert.assert(!client.keepBelow);
|
||||||
|
Assert.assert(!client.keepAbove);
|
||||||
|
|
||||||
|
qtMock.fireShortcut("karousel-window-toggle-floating");
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
Assert.assert(clientManager.findTiledWindow(client) !== null);
|
||||||
|
});
|
||||||
|
Assert.assert(client.keepBelow);
|
||||||
|
Assert.assert(!client.keepAbove);
|
||||||
|
});
|
||||||
|
|
||||||
|
tests.register("floatingKeepAbove", 10, () => {
|
||||||
|
const config = getDefaultConfig();
|
||||||
|
config.tiledKeepBelow = false;
|
||||||
|
config.floatingKeepAbove = true;
|
||||||
|
const { qtMock, workspaceMock, world } = init(config);
|
||||||
|
|
||||||
|
const pinGeometry = new MockQmlRect(0, 0, 200, screen.height);
|
||||||
|
|
||||||
|
const [client] = workspaceMock.createClients(1);
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
Assert.assert(clientManager.findTiledWindow(client) !== null);
|
||||||
|
});
|
||||||
|
Assert.assert(!client.keepBelow);
|
||||||
|
Assert.assert(!client.keepAbove);
|
||||||
|
|
||||||
|
qtMock.fireShortcut("karousel-window-toggle-floating");
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
Assert.assert(clientManager.findTiledWindow(client) === null);
|
||||||
|
});
|
||||||
|
Assert.assert(!client.keepBelow);
|
||||||
|
Assert.assert(client.keepAbove);
|
||||||
|
|
||||||
|
client.pin(pinGeometry);
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
Assert.assert(clientManager.findTiledWindow(client) === null);
|
||||||
|
});
|
||||||
|
Assert.assert(!client.keepBelow);
|
||||||
|
Assert.assert(client.keepAbove);
|
||||||
|
|
||||||
|
client.unpin();
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
Assert.assert(clientManager.findTiledWindow(client) === null);
|
||||||
|
});
|
||||||
|
Assert.assert(!client.keepBelow);
|
||||||
|
Assert.assert(client.keepAbove);
|
||||||
|
|
||||||
|
qtMock.fireShortcut("karousel-window-toggle-floating");
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
Assert.assert(clientManager.findTiledWindow(client) !== null);
|
||||||
|
});
|
||||||
|
Assert.assert(!client.keepBelow);
|
||||||
|
Assert.assert(!client.keepAbove);
|
||||||
|
|
||||||
|
client.pin(pinGeometry);
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
Assert.assert(clientManager.findTiledWindow(client) === null);
|
||||||
|
});
|
||||||
|
Assert.assert(!client.keepBelow);
|
||||||
|
Assert.assert(client.keepAbove);
|
||||||
|
|
||||||
|
qtMock.fireShortcut("karousel-window-toggle-floating");
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
Assert.assert(clientManager.findTiledWindow(client) !== null);
|
||||||
|
});
|
||||||
|
Assert.assert(!client.keepBelow);
|
||||||
|
Assert.assert(!client.keepAbove);
|
||||||
|
});
|
||||||
|
|
||||||
|
tests.register("No layering", 10, () => {
|
||||||
|
const config = getDefaultConfig();
|
||||||
|
config.tiledKeepBelow = false;
|
||||||
|
config.floatingKeepAbove = false;
|
||||||
|
// In this mode, Karousel shouldn't change keepBelow or keepAbove.
|
||||||
|
// Except when tiling a window, keepAbove should still be cleared.
|
||||||
|
|
||||||
|
const pinGeometry = new MockQmlRect(0, 0, 200, screen.height);
|
||||||
|
|
||||||
|
const testCases = [
|
||||||
|
{ keepBelow: false, keepAbove: false },
|
||||||
|
{ keepBelow: false, keepAbove: true },
|
||||||
|
{ keepBelow: true, keepAbove: false },
|
||||||
|
{ keepBelow: true, keepAbove: true },
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const testCase of testCases) {
|
||||||
|
const assertOptions = { message: JSON.stringify(testCase) };
|
||||||
|
|
||||||
|
const { qtMock, workspaceMock, world } = init(config);
|
||||||
|
|
||||||
|
const [client] = workspaceMock.createClients(1);
|
||||||
|
client.keepBelow = testCase.keepBelow;
|
||||||
|
client.keepAbove = testCase.keepAbove;
|
||||||
|
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
Assert.assert(clientManager.findTiledWindow(client) !== null, assertOptions);
|
||||||
|
});
|
||||||
|
Assert.equal(client.keepBelow, testCase.keepBelow, assertOptions);
|
||||||
|
Assert.equal(client.keepAbove, testCase.keepAbove, assertOptions);
|
||||||
|
|
||||||
|
qtMock.fireShortcut("karousel-window-toggle-floating");
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
Assert.assert(clientManager.findTiledWindow(client) === null, assertOptions);
|
||||||
|
});
|
||||||
|
Assert.equal(client.keepBelow, testCase.keepBelow, assertOptions);
|
||||||
|
Assert.equal(client.keepAbove, testCase.keepAbove, assertOptions);
|
||||||
|
|
||||||
|
client.pin(pinGeometry);
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
Assert.assert(clientManager.findTiledWindow(client) === null, assertOptions);
|
||||||
|
});
|
||||||
|
Assert.equal(client.keepBelow, testCase.keepBelow, assertOptions);
|
||||||
|
Assert.equal(client.keepAbove, testCase.keepAbove, assertOptions);
|
||||||
|
|
||||||
|
client.unpin();
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
Assert.assert(clientManager.findTiledWindow(client) === null, assertOptions);
|
||||||
|
});
|
||||||
|
Assert.equal(client.keepBelow, testCase.keepBelow, assertOptions);
|
||||||
|
Assert.equal(client.keepAbove, testCase.keepAbove, assertOptions);
|
||||||
|
|
||||||
|
qtMock.fireShortcut("karousel-window-toggle-floating");
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
Assert.assert(clientManager.findTiledWindow(client) !== null, assertOptions);
|
||||||
|
});
|
||||||
|
Assert.equal(client.keepBelow, testCase.keepBelow, assertOptions);
|
||||||
|
Assert.assert(!client.keepAbove, assertOptions);
|
||||||
|
client.keepAbove = testCase.keepAbove;
|
||||||
|
|
||||||
|
client.pin(pinGeometry);
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
Assert.assert(clientManager.findTiledWindow(client) === null, assertOptions);
|
||||||
|
});
|
||||||
|
Assert.equal(client.keepBelow, testCase.keepBelow, assertOptions);
|
||||||
|
Assert.equal(client.keepAbove, testCase.keepAbove, assertOptions);
|
||||||
|
|
||||||
|
qtMock.fireShortcut("karousel-window-toggle-floating");
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
Assert.assert(clientManager.findTiledWindow(client) !== null, assertOptions);
|
||||||
|
});
|
||||||
|
Assert.equal(client.keepBelow, testCase.keepBelow, assertOptions);
|
||||||
|
Assert.assert(!client.keepAbove, assertOptions);
|
||||||
|
}
|
||||||
|
});
|
||||||
98
src/tests/flows/layout.ts
Normal file
98
src/tests/flows/layout.ts
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
tests.register("Focus and move windows", 1, () => {
|
||||||
|
const config = getDefaultConfig();
|
||||||
|
const { qtMock, workspaceMock, world } = init(config);
|
||||||
|
|
||||||
|
const [client1, client2, client3] = workspaceMock.createClients(3);
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
Assert.assert(clientManager.hasClient(client1));
|
||||||
|
Assert.assert(clientManager.hasClient(client2));
|
||||||
|
Assert.assert(clientManager.hasClient(client3));
|
||||||
|
});
|
||||||
|
Assert.assert(workspaceMock.activeWindow === client3);
|
||||||
|
|
||||||
|
function testLayout(shortcutName: string, grid: KwinClient[][]) {
|
||||||
|
qtMock.fireShortcut(shortcutName);
|
||||||
|
Assert.grid(config, screen, 100, grid, true, { skip: 1 });
|
||||||
|
}
|
||||||
|
|
||||||
|
function testFocus(shortcutName: string, expectedFocus: KwinClient) {
|
||||||
|
qtMock.fireShortcut(shortcutName);
|
||||||
|
Assert.assert(workspaceMock.activeWindow === expectedFocus, {
|
||||||
|
message: `wrong activeWindow: ${workspaceMock.activeWindow?.pid}`,
|
||||||
|
skip: 1,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
testLayout("karousel-column-move-right", [ [client1], [client2], [client3] ]);
|
||||||
|
|
||||||
|
testLayout("karousel-window-move-left", [ [client1], [client2,client3] ]);
|
||||||
|
testLayout("karousel-window-move-left", [ [client1], [client3], [client2] ]);
|
||||||
|
testLayout("karousel-window-move-left", [ [client1,client3], [client2] ]);
|
||||||
|
testFocus("karousel-focus-right", client2);
|
||||||
|
testLayout("karousel-window-move-left", [ [client1,client3,client2] ]);
|
||||||
|
testLayout("karousel-window-move-left", [ [client2], [client1,client3] ]);
|
||||||
|
testLayout("karousel-window-move-left", [ [client2], [client1,client3] ]);
|
||||||
|
testFocus("karousel-focus-2", client3);
|
||||||
|
testFocus("karousel-focus-up", client1);
|
||||||
|
testLayout("karousel-column-move-left", [ [client1,client3], [client2] ]);
|
||||||
|
testLayout("karousel-window-move-right", [ [client3], [client1], [client2] ]);
|
||||||
|
|
||||||
|
testFocus("karousel-focus-3", client2);
|
||||||
|
testLayout("karousel-window-move-start", [ [client2], [client3], [client1] ]);
|
||||||
|
testLayout("karousel-window-move-to-column-3", [ [client3], [client1,client2] ]);
|
||||||
|
testLayout("karousel-column-move-left", [ [client1,client2], [client3] ]);
|
||||||
|
testLayout("karousel-column-move-end", [ [client3], [client1,client2] ]);
|
||||||
|
testLayout("karousel-column-move-to-column-1", [ [client1,client2], [client3] ]);
|
||||||
|
testLayout("karousel-column-move-right", [ [client3], [client1,client2] ]);
|
||||||
|
|
||||||
|
testLayout("karousel-window-move-previous", [ [client3], [client2,client1] ]);
|
||||||
|
testLayout("karousel-window-move-previous", [ [client3], [client2], [client1] ]);
|
||||||
|
testLayout("karousel-window-move-previous", [ [client3,client2], [client1] ]);
|
||||||
|
testLayout("karousel-window-move-previous", [ [client2,client3], [client1] ]);
|
||||||
|
testLayout("karousel-window-move-previous", [ [client2], [client3], [client1] ]);
|
||||||
|
testLayout("karousel-window-move-previous", [ [client2], [client3], [client1] ]);
|
||||||
|
testLayout("karousel-window-move-next", [ [client2,client3], [client1] ]);
|
||||||
|
testLayout("karousel-window-move-next", [ [client3,client2], [client1] ]);
|
||||||
|
testLayout("karousel-window-move-next", [ [client3], [client2], [client1] ]);
|
||||||
|
testLayout("karousel-window-move-next", [ [client3], [client2,client1] ]);
|
||||||
|
testLayout("karousel-window-move-next", [ [client3], [client1,client2] ]);
|
||||||
|
testLayout("karousel-window-move-next", [ [client3], [client1], [client2] ]);
|
||||||
|
testLayout("karousel-window-move-next", [ [client3], [client1], [client2] ]);
|
||||||
|
testLayout("karousel-window-move-left", [ [client3], [client1,client2] ]);
|
||||||
|
|
||||||
|
const col1Win1 = client3;
|
||||||
|
const col2Win1 = client1;
|
||||||
|
const col2Win2 = client2;
|
||||||
|
|
||||||
|
testFocus("karousel-focus-up", col2Win1);
|
||||||
|
testFocus("karousel-focus-up", col2Win1);
|
||||||
|
testFocus("karousel-focus-down", col2Win2);
|
||||||
|
testFocus("karousel-focus-left", col1Win1);
|
||||||
|
testFocus("karousel-focus-left", col1Win1);
|
||||||
|
testFocus("karousel-focus-right", col2Win2);
|
||||||
|
testFocus("karousel-focus-right", col2Win2);
|
||||||
|
|
||||||
|
testFocus("karousel-focus-2", col2Win2);
|
||||||
|
testFocus("karousel-focus-1", col1Win1);
|
||||||
|
testFocus("karousel-focus-2", col2Win2);
|
||||||
|
testFocus("karousel-focus-start", col1Win1);
|
||||||
|
testFocus("karousel-focus-end", col2Win2);
|
||||||
|
|
||||||
|
testFocus("karousel-focus-up", col2Win1);
|
||||||
|
testFocus("karousel-focus-left", col1Win1);
|
||||||
|
testFocus("karousel-focus-right", col2Win1);
|
||||||
|
testFocus("karousel-focus-2", col2Win1);
|
||||||
|
testFocus("karousel-focus-1", col1Win1);
|
||||||
|
testFocus("karousel-focus-2", col2Win1);
|
||||||
|
testFocus("karousel-focus-start", col1Win1);
|
||||||
|
testFocus("karousel-focus-end", col2Win1);
|
||||||
|
|
||||||
|
testFocus("karousel-focus-down", col2Win2);
|
||||||
|
testFocus("karousel-focus-start", col1Win1);
|
||||||
|
testFocus("karousel-focus-next", col2Win1);
|
||||||
|
testFocus("karousel-focus-next", col2Win2);
|
||||||
|
testFocus("karousel-focus-next", col2Win2);
|
||||||
|
testFocus("karousel-focus-previous", col2Win1);
|
||||||
|
testFocus("karousel-focus-previous", col1Win1);
|
||||||
|
testFocus("karousel-focus-previous", col1Win1);
|
||||||
|
});
|
||||||
47
src/tests/flows/lazyScroller.ts
Normal file
47
src/tests/flows/lazyScroller.ts
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
tests.register("LazyScroller", 20, () => {
|
||||||
|
const config = getDefaultConfig();
|
||||||
|
config.scrollingLazy = true;
|
||||||
|
config.scrollingCentered = false;
|
||||||
|
config.scrollingGrouped = false;
|
||||||
|
const { qtMock, workspaceMock, world } = init(config);
|
||||||
|
|
||||||
|
const [client1] = workspaceMock.createClientsWithWidths(300);
|
||||||
|
Assert.grid(config, screen, 300, [[client1]], true);
|
||||||
|
|
||||||
|
const [client2] = workspaceMock.createClientsWithWidths(300);
|
||||||
|
Assert.grid(config, screen, 300, [[client1], [client2]], true);
|
||||||
|
|
||||||
|
const [client3] = workspaceMock.createClientsWithWidths(300);
|
||||||
|
Assert.grid(config, screen, 300, [[client1], [client2], [client3]], false);
|
||||||
|
Assert.equal(client3.frameGeometry.right, tilingArea.right);
|
||||||
|
|
||||||
|
runOneOf(
|
||||||
|
() => workspaceMock.activeWindow = client2,
|
||||||
|
() => qtMock.fireShortcut("karousel-focus-2"),
|
||||||
|
() => qtMock.fireShortcut("karousel-focus-left"),
|
||||||
|
);
|
||||||
|
Assert.grid(config, screen, 300, [[client1], [client2], [client3]], false);
|
||||||
|
Assert.equal(client3.frameGeometry.right, tilingArea.right);
|
||||||
|
|
||||||
|
runOneOf(
|
||||||
|
() => workspaceMock.activeWindow = client1,
|
||||||
|
() => qtMock.fireShortcut("karousel-focus-1"),
|
||||||
|
() => qtMock.fireShortcut("karousel-focus-left"),
|
||||||
|
() => qtMock.fireShortcut("karousel-focus-start"),
|
||||||
|
);
|
||||||
|
workspaceMock.activeWindow = client1;
|
||||||
|
Assert.grid(config, screen, 300, [[client1], [client2], [client3]], false);
|
||||||
|
Assert.equal(client1.frameGeometry.left, tilingArea.left);
|
||||||
|
|
||||||
|
qtMock.fireShortcut("karousel-grid-scroll-focused");
|
||||||
|
Assert.grid(config, screen, 300, [[client1], [client2], [client3]], false);
|
||||||
|
Assert.grid(config, screen, 300, [[client1]], true);
|
||||||
|
|
||||||
|
runOneOf(
|
||||||
|
() => workspaceMock.activeWindow = client2,
|
||||||
|
() => qtMock.fireShortcut("karousel-focus-2"),
|
||||||
|
() => qtMock.fireShortcut("karousel-focus-right"),
|
||||||
|
);
|
||||||
|
Assert.grid(config, screen, 300, [[client1], [client2], [client3]], false);
|
||||||
|
Assert.equal(client1.frameGeometry.left, tilingArea.left);
|
||||||
|
});
|
||||||
145
src/tests/flows/maximization.ts
Normal file
145
src/tests/flows/maximization.ts
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
tests.register("Maximization", 100, () => {
|
||||||
|
const config = getDefaultConfig();
|
||||||
|
const { qtMock, workspaceMock, world } = init(config);
|
||||||
|
|
||||||
|
const [kwinClient] = workspaceMock.createClientsWithWidths(300);
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
Assert.assert(clientManager.hasClient(kwinClient));
|
||||||
|
});
|
||||||
|
|
||||||
|
const columnLeftX = screen.width/2 - 300/2;
|
||||||
|
const columnTopY = tilingArea.top;
|
||||||
|
const columnHeight = tilingArea.height;
|
||||||
|
Assert.rect(kwinClient.frameGeometry, columnLeftX, columnTopY, 300, columnHeight);
|
||||||
|
|
||||||
|
kwinClient.fullScreen = true;
|
||||||
|
Assert.equalRects(kwinClient.frameGeometry, screen);
|
||||||
|
|
||||||
|
kwinClient.fullScreen = false;
|
||||||
|
Assert.rect(kwinClient.frameGeometry, columnLeftX, columnTopY, 300, columnHeight);
|
||||||
|
|
||||||
|
kwinClient.setMaximize(true, true);
|
||||||
|
Assert.equalRects(kwinClient.frameGeometry, screen);
|
||||||
|
|
||||||
|
kwinClient.setMaximize(true, false);
|
||||||
|
Assert.rect(kwinClient.frameGeometry, columnLeftX, 0, 300, screen.height);
|
||||||
|
|
||||||
|
kwinClient.setMaximize(false, false);
|
||||||
|
Assert.rect(kwinClient.frameGeometry, columnLeftX, columnTopY, 300, columnHeight);
|
||||||
|
});
|
||||||
|
|
||||||
|
tests.register("Maximize with transient", 100, () => {
|
||||||
|
const config = getDefaultConfig();
|
||||||
|
const { qtMock, workspaceMock, world } = init(config);
|
||||||
|
|
||||||
|
const parent = new MockKwinClient(new MockQmlRect(10, 20, 300, 200));
|
||||||
|
const child = new MockKwinClient(new MockQmlRect(14, 24, 50, 50), parent);
|
||||||
|
|
||||||
|
workspaceMock.createWindows(parent);
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
Assert.assert(clientManager.hasClient(parent));
|
||||||
|
});
|
||||||
|
|
||||||
|
runOneOf(
|
||||||
|
() => parent.fullScreen = true,
|
||||||
|
() => parent.setMaximize(true, true),
|
||||||
|
);
|
||||||
|
Assert.equalRects(parent.frameGeometry, screen);
|
||||||
|
|
||||||
|
workspaceMock.createWindows(child);
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
Assert.assert(clientManager.hasClient(child));
|
||||||
|
});
|
||||||
|
Assert.rect(child.frameGeometry, 14, 24, 50, 50);
|
||||||
|
Assert.equalRects(parent.frameGeometry, screen);
|
||||||
|
});
|
||||||
|
|
||||||
|
tests.register("Re-maximize disabled", 100, () => {
|
||||||
|
const config = getDefaultConfig();
|
||||||
|
config.reMaximize = false;
|
||||||
|
const { qtMock, workspaceMock, world } = init(config);
|
||||||
|
|
||||||
|
const [client1, client2] = workspaceMock.createClientsWithWidths(300, 400);
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
Assert.assert(clientManager.hasClient(client1));
|
||||||
|
Assert.assert(clientManager.hasClient(client2));
|
||||||
|
});
|
||||||
|
|
||||||
|
const columnsWidth = 300 + 400 + config.gapsInnerHorizontal;
|
||||||
|
const column1LeftX = screen.width/2 - columnsWidth/2;
|
||||||
|
const column2LeftX = column1LeftX + 300 + config.gapsInnerHorizontal;
|
||||||
|
const columnTopY = tilingArea.top;
|
||||||
|
const columnHeight = tilingArea.height;
|
||||||
|
Assert.rect(client1.frameGeometry, column1LeftX, columnTopY, 300, columnHeight);
|
||||||
|
Assert.rect(client2.frameGeometry, column2LeftX, columnTopY, 400, columnHeight);
|
||||||
|
|
||||||
|
runOneOf(
|
||||||
|
() => client2.fullScreen = true,
|
||||||
|
() => client2.setMaximize(true, true),
|
||||||
|
);
|
||||||
|
Assert.rect(client1.frameGeometry, column1LeftX, columnTopY, 300, columnHeight);
|
||||||
|
Assert.equalRects(client2.frameGeometry, screen);
|
||||||
|
|
||||||
|
runOneOf(
|
||||||
|
() => workspaceMock.activeWindow = client1,
|
||||||
|
() => qtMock.fireShortcut("karousel-focus-1"),
|
||||||
|
() => qtMock.fireShortcut("karousel-focus-left"),
|
||||||
|
() => qtMock.fireShortcut("karousel-focus-start"),
|
||||||
|
);
|
||||||
|
Assert.rect(client1.frameGeometry, column1LeftX, columnTopY, 300, columnHeight);
|
||||||
|
Assert.rect(client2.frameGeometry, column2LeftX, columnTopY, 400, columnHeight);
|
||||||
|
|
||||||
|
runOneOf(
|
||||||
|
() => workspaceMock.activeWindow = client2,
|
||||||
|
() => qtMock.fireShortcut("karousel-focus-2"),
|
||||||
|
() => qtMock.fireShortcut("karousel-focus-right"),
|
||||||
|
() => qtMock.fireShortcut("karousel-focus-end"),
|
||||||
|
);
|
||||||
|
Assert.rect(client1.frameGeometry, column1LeftX, columnTopY, 300, columnHeight);
|
||||||
|
Assert.rect(client2.frameGeometry, column2LeftX, columnTopY, 400, columnHeight);
|
||||||
|
});
|
||||||
|
|
||||||
|
tests.register("Re-maximize enabled", 100, () => {
|
||||||
|
const config = getDefaultConfig();
|
||||||
|
config.reMaximize = true;
|
||||||
|
const { qtMock, workspaceMock, world } = init(config);
|
||||||
|
|
||||||
|
const [client1, client2] = workspaceMock.createClientsWithWidths(300, 400);
|
||||||
|
world.do((clientManager, desktopManager) => {
|
||||||
|
Assert.assert(clientManager.hasClient(client1));
|
||||||
|
Assert.assert(clientManager.hasClient(client2));
|
||||||
|
});
|
||||||
|
|
||||||
|
const columnsWidth = 300 + 400 + config.gapsInnerHorizontal;
|
||||||
|
const column1LeftX = screen.width/2 - columnsWidth/2;
|
||||||
|
const column2LeftX = column1LeftX + 300 + config.gapsInnerHorizontal;
|
||||||
|
const columnTopY = tilingArea.top;
|
||||||
|
const columnHeight = tilingArea.height;
|
||||||
|
Assert.rect(client1.frameGeometry, column1LeftX, columnTopY, 300, columnHeight);
|
||||||
|
Assert.rect(client2.frameGeometry, column2LeftX, columnTopY, 400, columnHeight);
|
||||||
|
|
||||||
|
runOneOf(
|
||||||
|
() => client2.fullScreen = true,
|
||||||
|
() => client2.setMaximize(true, true),
|
||||||
|
);
|
||||||
|
Assert.rect(client1.frameGeometry, column1LeftX, columnTopY, 300, columnHeight);
|
||||||
|
Assert.equalRects(client2.frameGeometry, screen);
|
||||||
|
|
||||||
|
runOneOf(
|
||||||
|
() => workspaceMock.activeWindow = client1,
|
||||||
|
() => qtMock.fireShortcut("karousel-focus-1"),
|
||||||
|
() => qtMock.fireShortcut("karousel-focus-left"),
|
||||||
|
() => qtMock.fireShortcut("karousel-focus-start"),
|
||||||
|
);
|
||||||
|
Assert.rect(client1.frameGeometry, column1LeftX, columnTopY, 300, columnHeight);
|
||||||
|
Assert.rect(client2.frameGeometry, column2LeftX, columnTopY, 400, columnHeight);
|
||||||
|
|
||||||
|
runOneOf(
|
||||||
|
() => workspaceMock.activeWindow = client2,
|
||||||
|
() => qtMock.fireShortcut("karousel-focus-2"),
|
||||||
|
() => qtMock.fireShortcut("karousel-focus-right"),
|
||||||
|
() => qtMock.fireShortcut("karousel-focus-end"),
|
||||||
|
);
|
||||||
|
Assert.rect(client1.frameGeometry, column1LeftX, columnTopY, 300, columnHeight);
|
||||||
|
Assert.equalRects(client2.frameGeometry, screen);
|
||||||
|
});
|
||||||
40
src/tests/flows/passFocus.ts
Normal file
40
src/tests/flows/passFocus.ts
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
tests.register("Pass focus", 20, () => {
|
||||||
|
const config = getDefaultConfig();
|
||||||
|
const { qtMock, workspaceMock, world } = init(config);
|
||||||
|
|
||||||
|
const [client0, client1a, client1b, client1c, client4, client5, client6] = workspaceMock.createClients(7);
|
||||||
|
workspaceMock.activeWindow = client1b;
|
||||||
|
qtMock.fireShortcut("karousel-window-move-left");
|
||||||
|
workspaceMock.activeWindow = client1c;
|
||||||
|
qtMock.fireShortcut("karousel-window-move-left");
|
||||||
|
workspaceMock.activeWindow = client1b;
|
||||||
|
workspaceMock.activeWindow = client5;
|
||||||
|
|
||||||
|
function removeWindow(client: MockKwinClient) {
|
||||||
|
runOneOf(
|
||||||
|
() => workspaceMock.removeWindow(client),
|
||||||
|
() => client.desktops = [workspaceMock.desktops[1]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
removeWindow(client5);
|
||||||
|
Assert.equal(workspaceMock.activeWindow, client4);
|
||||||
|
|
||||||
|
qtMock.fireShortcut("karousel-column-move-to-desktop-2");
|
||||||
|
Assert.equal(workspaceMock.activeWindow, client1b);
|
||||||
|
|
||||||
|
removeWindow(client1b);
|
||||||
|
Assert.equal(workspaceMock.activeWindow, client1a);
|
||||||
|
|
||||||
|
removeWindow(client1a);
|
||||||
|
Assert.equal(workspaceMock.activeWindow, client1c);
|
||||||
|
|
||||||
|
removeWindow(client1c);
|
||||||
|
Assert.equal(workspaceMock.activeWindow, client0);
|
||||||
|
|
||||||
|
removeWindow(client0);
|
||||||
|
Assert.equal(workspaceMock.activeWindow, client6);
|
||||||
|
|
||||||
|
removeWindow(client6);
|
||||||
|
Assert.equal(workspaceMock.activeWindow, null);
|
||||||
|
});
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user