Compare commits
186 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
3a8baf4cd7 | ||
|
|
dc14171ae7 | ||
|
|
6dcf8979c2 | ||
|
|
fe5661c07f | ||
|
|
90b783b34b | ||
|
|
fb40bd9592 | ||
|
|
768d95450d | ||
|
|
e95a0e44c9 | ||
|
|
c1b8d05919 | ||
|
|
e98ce18105 | ||
|
|
25a9efc8e4 | ||
|
|
db48644944 | ||
|
|
950e0de076 | ||
|
|
05ffe0895e | ||
|
|
61db5ca69f | ||
|
|
f7b5dd0b9c | ||
|
|
f83f60c98f | ||
|
|
3e8734eefb | ||
|
|
bed0ea7ed8 | ||
|
|
92c99f0b87 | ||
|
|
b2024bc8aa | ||
|
|
58f358313b | ||
|
|
352a7061f6 | ||
|
|
7314c0ee24 | ||
|
|
c65361853c | ||
|
|
fa53e765b3 | ||
|
|
4d35681ee2 | ||
|
|
1824bcdf85 | ||
|
|
ce1b402bf2 | ||
|
|
2df6d5d8e6 | ||
|
|
e7d33030ba | ||
|
|
2bd000f0a6 | ||
|
|
6313d8f18e | ||
|
|
464ec3bcb1 | ||
|
|
fae793cb09 | ||
|
|
d7346a6fab | ||
|
|
0e5efd2be7 | ||
|
|
a1a315790e | ||
|
|
9d62499bf0 | ||
|
|
97cf61d1dd | ||
|
|
5d83c6dd2c | ||
|
|
8915e8a9da | ||
|
|
22e4c47189 | ||
|
|
552d2b851f | ||
|
|
c4ce795359 | ||
|
|
1ac1fc3c2b | ||
|
|
d0e041d16a | ||
|
|
8fc3fc976d | ||
|
|
e0eeace9dc | ||
|
|
84e2a06b35 | ||
|
|
3373e02658 | ||
|
|
43f425c868 | ||
|
|
5c5127f7ce | ||
|
|
8664f05998 | ||
|
|
e4f6a32d42 | ||
|
|
2882bb8d5d | ||
|
|
5ef71c92ce | ||
|
|
de59979a6e | ||
|
|
71d7d60837 | ||
|
|
7f44d23dd0 | ||
|
|
aceffae5f9 | ||
|
|
09e5eaca88 | ||
|
|
734dd8a4cc | ||
|
|
aeabb396f9 | ||
|
|
05b9ebc325 | ||
|
|
4728afb5ea | ||
|
|
653cb20e43 | ||
|
|
0cb2b68bf6 | ||
|
|
b8b8900754 | ||
|
|
14c006b5b1 | ||
|
|
9fe6be9b91 | ||
|
|
97d1592318 | ||
|
|
cc8cc04b05 | ||
|
|
cc74d3610a | ||
|
|
088725402e | ||
|
|
25b7507b30 | ||
|
|
9b32caafdc | ||
|
|
668d579d63 | ||
|
|
f4e9822f29 | ||
|
|
bdb0a4aeb0 | ||
|
|
dde1a12fce | ||
|
|
c57c8391fb | ||
|
|
ec64b47ceb | ||
|
|
b055345e48 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,4 +1,4 @@
|
||||
/package/contents/code/main.js
|
||||
/package/contents/config/main.xml
|
||||
/karousel.tar.gz
|
||||
/karousel*.tar.gz
|
||||
/.idea
|
||||
|
||||
9
Makefile
9
Makefile
@@ -1,6 +1,7 @@
|
||||
.PHONY: *
|
||||
|
||||
TSC_SCRIPT_FLAGS = --lib es2020 ./src/extern/qt.d.ts
|
||||
VERSION = $(shell grep '"Version":' ./package/metadata.json | grep -o '[0-9\.]*')
|
||||
|
||||
config:
|
||||
mkdir -p ./package/contents/config
|
||||
@@ -10,13 +11,13 @@ build:
|
||||
tsc --outFile ./package/contents/code/main.js
|
||||
|
||||
install: build config
|
||||
kpackagetool5 --type=KWin/Script -i ./package || kpackagetool5 --type=KWin/Script -u ./package
|
||||
kpackagetool6 --type=KWin/Script -i ./package || kpackagetool6 --type=KWin/Script -u ./package
|
||||
|
||||
uninstall:
|
||||
kpackagetool5 --type=KWin/Script -r ./package
|
||||
kpackagetool6 --type=KWin/Script -r karousel
|
||||
|
||||
package:
|
||||
tar -czf ./karousel.tar.gz ./package
|
||||
package: build config
|
||||
tar -czf ./karousel_${subst .,_,${VERSION}}.tar.gz ./package
|
||||
|
||||
logs:
|
||||
journalctl -t kwin_x11 -g '^qml:|^file://.*karousel' -f
|
||||
|
||||
20
README.md
20
README.md
@@ -13,9 +13,16 @@ unprompted reflow of window content.
|
||||
Windows are automatically centered when possible. And when running out of width, windows can be
|
||||
scrolled through horizontally.
|
||||
|
||||
Similar window managers include [PaperWM](https://github.com/paperwm/PaperWM) and
|
||||
Similar window managers include [PaperWM](https://github.com/paperwm/PaperWM),
|
||||
[Niri](https://github.com/YaLTeR/niri), and
|
||||
[Cardboard](https://gitlab.com/cardboardwm/cardboard).
|
||||
|
||||
## Dependencies
|
||||
Karousel requires the following QML modules:
|
||||
- QtQuick 6.0
|
||||
- org.kde.kwin 3.0
|
||||
- org.kde.notification 1.0
|
||||
|
||||
## Limitations
|
||||
- Doesn't support multiple screens
|
||||
- Doesn't support windows on all desktops
|
||||
@@ -28,9 +35,9 @@ Here's the default ones:
|
||||
| --- | --- |
|
||||
| Meta+Space | Toggle floating |
|
||||
| Meta+A | Move focus left |
|
||||
| Meta+D | Move focus right |
|
||||
| Meta+W | Move focus up |
|
||||
| Meta+S | Move focus down |
|
||||
| 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+S | Move focus down (Clashes with default KDE shortcuts, may require manual remapping) |
|
||||
| Meta+Home | Move focus to start |
|
||||
| Meta+End | Move focus to end |
|
||||
| Meta+Shift+A | Move window left (Moves window out of and into columns) |
|
||||
@@ -39,13 +46,14 @@ Here's the default ones:
|
||||
| Meta+Shift+S | Move window down |
|
||||
| Meta+Shift+Home | Move window to start |
|
||||
| Meta+Shift+End | Move window to end |
|
||||
| Meta+X | Toggle stacked layout for focused column |
|
||||
| Meta+X | Toggle stacked layout for focused column (One window in the column visible, others shaded; not supported on Wayland) |
|
||||
| Meta+Ctrl+Shift+A | Move column left |
|
||||
| Meta+Ctrl+Shift+D | Move column right |
|
||||
| Meta+Ctrl+Shift+Home | Move column to start |
|
||||
| Meta+Ctrl+Shift+End | Move column to end |
|
||||
| Meta+Ctrl++ | Increase column width |
|
||||
| Meta+Ctrl+- | Decrease column width |
|
||||
| Meta+Ctrl+X | Equalize widths of visible columns |
|
||||
| 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+D | Scroll one column to the right |
|
||||
@@ -53,7 +61,7 @@ Here's the default ones:
|
||||
| Meta+Alt+PgDown | Scroll right |
|
||||
| Meta+Alt+Home | Scroll to start |
|
||||
| Meta+Alt+End | Scroll to end |
|
||||
| Meta+[N] | Move focus to column N |
|
||||
| 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+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+F[N] | Move column to desktop N |
|
||||
|
||||
@@ -5,9 +5,20 @@ console.log(`<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
for (const entry of configDef) {
|
||||
console.log(` <entry name="${entry.name}" type="${entry.type}">
|
||||
<default>${entry.default}</default>
|
||||
<default>${escapeXml(entry.default)}</default>
|
||||
</entry>`);
|
||||
}
|
||||
|
||||
console.log(` </group>
|
||||
</kcfg>`);
|
||||
|
||||
function escapeXml(input: any) {
|
||||
if (typeof input === "string") {
|
||||
return input
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>');
|
||||
} else {
|
||||
return input;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ type KeyBinding = {
|
||||
description: string;
|
||||
comment?: string;
|
||||
defaultKeySequence: string;
|
||||
action: string;
|
||||
}
|
||||
|
||||
type NumKeyBinding = {
|
||||
@@ -12,7 +11,6 @@ type NumKeyBinding = {
|
||||
comment?: string;
|
||||
defaultModifiers: string;
|
||||
fKeys: boolean;
|
||||
action: string;
|
||||
}
|
||||
|
||||
function formatComment(comment: string | undefined) {
|
||||
@@ -21,7 +19,7 @@ function formatComment(comment: string | undefined) {
|
||||
|
||||
function printCols(...columns: (string[] | string)[]) {
|
||||
const nCols = columns.length;
|
||||
if (nCols == 0) {
|
||||
if (nCols === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -30,7 +28,7 @@ function printCols(...columns: (string[] | string)[]) {
|
||||
).map(
|
||||
(column: string[] | string) => column.length
|
||||
));
|
||||
if (nRows == Infinity) {
|
||||
if (nRows === Infinity) {
|
||||
// we only have single string columns
|
||||
nRows = 1;
|
||||
}
|
||||
|
||||
@@ -11,19 +11,153 @@
|
||||
<layout class="QVBoxLayout" name="layout_main">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabContainer">
|
||||
<widget class="QWidget" name="tab_general">
|
||||
<widget class="QWidget" name="tab_behavior">
|
||||
<attribute name="title">
|
||||
<string>General</string>
|
||||
<string>Behavior</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="layout_tab_general" columnstretch="0,1">
|
||||
<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">
|
||||
<attribute name="title">
|
||||
<string>Parameters</string>
|
||||
</attribute>
|
||||
<layout class="QFormLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_gapsOuterTop">
|
||||
<property name="text">
|
||||
<string>Top margin:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
@@ -45,9 +179,6 @@
|
||||
<property name="text">
|
||||
<string>Bottom margin:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
@@ -69,9 +200,6 @@
|
||||
<property name="text">
|
||||
<string>Left margin:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
@@ -93,9 +221,6 @@
|
||||
<property name="text">
|
||||
<string>Right margin:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
@@ -117,9 +242,6 @@
|
||||
<property name="text">
|
||||
<string>Horizontal gaps between windows:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
@@ -141,9 +263,6 @@
|
||||
<property name="text">
|
||||
<string>Vertical gaps between windows:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
@@ -161,40 +280,13 @@
|
||||
</item>
|
||||
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_overscroll">
|
||||
<property name="text">
|
||||
<string>Overscroll amount:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QSpinBox" name="kcfg_overscroll">
|
||||
<property name="suffix">
|
||||
<string> px</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_manualScrollStep">
|
||||
<property name="text">
|
||||
<string>Manual scroll step size:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<item row="6" column="1">
|
||||
<widget class="QSpinBox" name="kcfg_manualScrollStep">
|
||||
<property name="suffix">
|
||||
<string> px</string>
|
||||
@@ -208,44 +300,55 @@
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_manualResizeStep">
|
||||
<property name="text">
|
||||
<string>Manual resize step size:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QSpinBox" name="kcfg_manualResizeStep">
|
||||
<property name="suffix">
|
||||
<string> px</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>999</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="label_offScreenOpacity">
|
||||
<property name="text">
|
||||
<string>Obscured window opacity:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<widget class="QCheckBox" name="kcfg_untileOnDrag">
|
||||
<property name="text">
|
||||
<string>Un-tile windows by dragging them</string>
|
||||
<widget class="QSpinBox" name="kcfg_offScreenOpacity">
|
||||
<property name="suffix">
|
||||
<string> %</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
<item row="9" column="1">
|
||||
<widget class="QCheckBox" name="kcfg_stackColumnsByDefault">
|
||||
<property name="text">
|
||||
<string>Stack columns by default</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
<item row="10" column="1">
|
||||
<widget class="QCheckBox" name="kcfg_resizeNeighborColumn">
|
||||
<property name="text">
|
||||
<string>Resize neighbor column on edge resize</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
<item row="11" column="0" colspan="2">
|
||||
<spacer name="bottomSpacer_tab_general">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
||||
<widget class="QWidget" name="tab_windowRules">
|
||||
<attribute name="title">
|
||||
<string>Window Rules</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="layout_tab_windowRules">
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="kcfg_windowRules">
|
||||
<property name="tabChangesFocus">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import QtQuick 2.15
|
||||
import QtQuick 6.0
|
||||
import org.kde.kwin 3.0
|
||||
import org.kde.notification 1.0
|
||||
import "./main.js" as Karousel
|
||||
import "../code/main.js" as Karousel
|
||||
|
||||
Item {
|
||||
id: qmlBase
|
||||
@@ -1,20 +1,21 @@
|
||||
{
|
||||
"KPackageStructure": "KWin/Script",
|
||||
"KPlugin": {
|
||||
"Name": "Karousel",
|
||||
"Description": "Manual columnar tiling extension for KWin",
|
||||
"Description": "Scrollable tiling extension for KWin",
|
||||
"Icon": "preferences-system-windows",
|
||||
"Authors": [{
|
||||
"Email": "peter.fajdiga@gmail.com",
|
||||
"Name": "Peter Fajdiga"
|
||||
}],
|
||||
"Id": "karousel",
|
||||
"ServiceTypes": ["KWin/Script"],
|
||||
"Version": "0.4",
|
||||
"Version": "0.9",
|
||||
"License": "GPLv3",
|
||||
"Website": "https://github.com/peterfajdiga/karousel",
|
||||
"BugReportUrl": "https://github.com/peterfajdiga/karousel/issues"
|
||||
},
|
||||
"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"
|
||||
}
|
||||
|
||||
229
src/Actions.ts
229
src/Actions.ts
@@ -1,47 +1,47 @@
|
||||
namespace Actions {
|
||||
export function init(world: World, config: Config) {
|
||||
return {
|
||||
focusLeft: () => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
export function getAction(world: World, config: Config, name: string) {
|
||||
switch (name) {
|
||||
case "focus-left": return () => {
|
||||
world.doIfTiledFocused(true, (clientManager, desktopManager, window, column, grid) => {
|
||||
const prevColumn = grid.getPrevColumn(column);
|
||||
if (prevColumn === null) {
|
||||
return;
|
||||
}
|
||||
prevColumn.focus();
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
focusRight: () => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
case "focus-right": return () => {
|
||||
world.doIfTiledFocused(true, (clientManager, desktopManager, window, column, grid) => {
|
||||
const nextColumn = grid.getNextColumn(column);
|
||||
if (nextColumn === null) {
|
||||
return;
|
||||
}
|
||||
nextColumn.focus();
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
focusUp: () => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
case "focus-up": return () => {
|
||||
world.doIfTiledFocused(true, (clientManager, desktopManager, window, column, grid) => {
|
||||
const prevWindow = column.getPrevWindow(window);
|
||||
if (prevWindow === null) {
|
||||
return;
|
||||
}
|
||||
prevWindow.focus();
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
focusDown: () => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
case "focus-down": return () => {
|
||||
world.doIfTiledFocused(true, (clientManager, desktopManager, window, column, grid) => {
|
||||
const nextWindow = column.getNextWindow(window);
|
||||
if (nextWindow === null) {
|
||||
return;
|
||||
}
|
||||
nextWindow.focus();
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
focusStart: () => {
|
||||
case "focus-start": return () => {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
const grid = desktopManager.getCurrentDesktop().grid;
|
||||
const firstColumn = grid.getFirstColumn();
|
||||
@@ -50,9 +50,9 @@ namespace Actions {
|
||||
}
|
||||
firstColumn.focus();
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
focusEnd: () => {
|
||||
case "focus-end": return () => {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
const grid = desktopManager.getCurrentDesktop().grid;
|
||||
const lastColumn = grid.getLastColumn();
|
||||
@@ -61,10 +61,10 @@ namespace Actions {
|
||||
}
|
||||
lastColumn.focus();
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
windowMoveLeft: () => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
case "window-move-left": return () => {
|
||||
world.doIfTiledFocused(true, (clientManager, desktopManager, window, column, grid) => {
|
||||
if (column.getWindowCount() === 1) {
|
||||
// move from own column into existing column
|
||||
const prevColumn = grid.getPrevColumn(column);
|
||||
@@ -79,10 +79,10 @@ namespace Actions {
|
||||
window.moveToColumn(newColumn);
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
windowMoveRight: () => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
case "window-move-right": return () => {
|
||||
world.doIfTiledFocused(true, (clientManager, desktopManager, window, column, grid) => {
|
||||
if (column.getWindowCount() === 1) {
|
||||
// move from own column into existing column
|
||||
const nextColumn = grid.getNextColumn(column);
|
||||
@@ -97,94 +97,100 @@ namespace Actions {
|
||||
window.moveToColumn(newColumn);
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
windowMoveUp: () => {
|
||||
case "window-move-up": return () => {
|
||||
// TODO (optimization): only arrange moved windows
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
world.doIfTiledFocused(true, (clientManager, desktopManager, window, column, grid) => {
|
||||
column.moveWindowUp(window);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
windowMoveDown: () => {
|
||||
case "window-move-down": return () => {
|
||||
// TODO (optimization): only arrange moved windows
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
world.doIfTiledFocused(true, (clientManager, desktopManager, window, column, grid) => {
|
||||
column.moveWindowDown(window);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
windowMoveStart: () => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
case "window-move-start": return () => {
|
||||
world.doIfTiledFocused(true, (clientManager, desktopManager, window, column, grid) => {
|
||||
const newColumn = new Column(grid, null);
|
||||
window.moveToColumn(newColumn);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
windowMoveEnd: () => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
case "window-move-end": return () => {
|
||||
world.doIfTiledFocused(true, (clientManager, desktopManager, window, column, grid) => {
|
||||
const newColumn = new Column(grid, grid.getLastColumn());
|
||||
window.moveToColumn(newColumn);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
windowToggleFloating: () => {
|
||||
const kwinClient = workspace.activeClient;
|
||||
case "window-toggle-floating": return () => {
|
||||
const kwinClient = Workspace.activeWindow;
|
||||
world.do((clientManager, desktopManager) => {
|
||||
clientManager.toggleFloatingClient(kwinClient);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
columnMoveLeft: () => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
case "column-move-left": return () => {
|
||||
world.doIfTiledFocused(true, (clientManager, desktopManager, window, column, grid) => {
|
||||
grid.moveColumnLeft(column);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
columnMoveRight: () => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
case "column-move-right": return () => {
|
||||
world.doIfTiledFocused(true, (clientManager, desktopManager, window, column, grid) => {
|
||||
grid.moveColumnRight(column);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
columnMoveStart: () => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
case "column-move-start": return () => {
|
||||
world.doIfTiledFocused(true, (clientManager, desktopManager, window, column, grid) => {
|
||||
column.moveAfter(null);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
columnMoveEnd: () => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
case "column-move-end": return () => {
|
||||
world.doIfTiledFocused(true, (clientManager, desktopManager, window, column, grid) => {
|
||||
column.moveAfter(grid.getLastColumn());
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
columnToggleStacked: () => {
|
||||
world.doIfTiledFocused(false, (world, desktopManager, window, column, grid) => {
|
||||
case "column-toggle-stacked": return () => {
|
||||
world.doIfTiledFocused(false, (clientManager, desktopManager, window, column, grid) => {
|
||||
column.toggleStacked();
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
columnWidthIncrease: () => {
|
||||
world.doIfTiledFocused(false, (world, desktopManager, window, column, grid) => {
|
||||
grid.increaseColumnWidth(column);
|
||||
case "column-width-increase": return () => {
|
||||
world.doIfTiledFocused(false, (clientManager, desktopManager, window, column, grid) => {
|
||||
config.columnResizer.increaseWidth(column, config.manualResizeStep);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
columnWidthDecrease: () => {
|
||||
world.doIfTiledFocused(false, (world, desktopManager, window, column, grid) => {
|
||||
grid.decreaseColumnWidth(column);
|
||||
case "column-width-decrease": return () => {
|
||||
world.doIfTiledFocused(false, (clientManager, desktopManager, window, column, grid) => {
|
||||
config.columnResizer.decreaseWidth(column, config.manualResizeStep);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
gridScrollLeft: () => {
|
||||
case "columns-width-equalize": return () => {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
desktopManager.getCurrentDesktop().equalizeVisibleColumnsWidths();
|
||||
});
|
||||
};
|
||||
|
||||
case "grid-scroll-left": return () => {
|
||||
gridScroll(world, -config.manualScrollStep);
|
||||
},
|
||||
};
|
||||
|
||||
gridScrollRight: () => {
|
||||
case "grid-scroll-right": return () => {
|
||||
gridScroll(world, config.manualScrollStep);
|
||||
},
|
||||
};
|
||||
|
||||
gridScrollStart: () => {
|
||||
case "grid-scroll-start": return () => {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
const grid = desktopManager.getCurrentDesktop().grid;
|
||||
const firstColumn = grid.getFirstColumn();
|
||||
@@ -193,9 +199,9 @@ namespace Actions {
|
||||
}
|
||||
grid.desktop.scrollToColumn(firstColumn);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
gridScrollEnd: () => {
|
||||
case "grid-scroll-end": return () => {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
const grid = desktopManager.getCurrentDesktop().grid;
|
||||
const lastColumn = grid.getLastColumn();
|
||||
@@ -204,18 +210,18 @@ namespace Actions {
|
||||
}
|
||||
grid.desktop.scrollToColumn(lastColumn);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
gridScrollFocused: () => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
grid.desktop.scrollCenterColumn(column);
|
||||
case "grid-scroll-focused": return () => {
|
||||
world.doIfTiledFocused(true, (clientManager, desktopManager, window, column, grid) => {
|
||||
grid.desktop.scrollCenterRange(column);
|
||||
})
|
||||
},
|
||||
};
|
||||
|
||||
gridScrollLeftColumn: () => {
|
||||
case "grid-scroll-left-column": return () => {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
const grid = desktopManager.getCurrentDesktop().grid;
|
||||
const column = grid.getLeftmostVisibleColumn(grid.desktop.getCurrentScrollPos(), true);
|
||||
const column = grid.getLeftmostVisibleColumn(grid.desktop.getCurrentVisibleRange(), true);
|
||||
if (column === null) {
|
||||
return;
|
||||
}
|
||||
@@ -227,12 +233,12 @@ namespace Actions {
|
||||
|
||||
grid.desktop.scrollToColumn(prevColumn);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
gridScrollRightColumn: () => {
|
||||
case "grid-scroll-right-column": return () => {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
const grid = desktopManager.getCurrentDesktop().grid;
|
||||
const column = grid.getRightmostVisibleColumn(grid.desktop.getCurrentScrollPos(), true);
|
||||
const column = grid.getRightmostVisibleColumn(grid.desktop.getCurrentVisibleRange(), true);
|
||||
if (column === null) {
|
||||
return;
|
||||
}
|
||||
@@ -244,39 +250,41 @@ namespace Actions {
|
||||
|
||||
grid.desktop.scrollToColumn(nextColumn);
|
||||
});
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
default: throw new Error("unknown action: " + name);
|
||||
}
|
||||
}
|
||||
|
||||
export function initNum(world: World) {
|
||||
return {
|
||||
focusColumn: (columnIndex: number) => {
|
||||
export function getNumAction(world: World, name: string) {
|
||||
switch (name) {
|
||||
case "focus-": return (columnIndex: number) => {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
const grid = desktopManager.getCurrentDesktop().grid;
|
||||
const targetColumn = grid.getColumnAtIndex(columnIndex);
|
||||
if (targetColumn === null) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
targetColumn.focus();
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
windowMoveToColumn: (columnIndex: number) => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
case "window-move-to-column-": return (columnIndex: number) => {
|
||||
world.doIfTiledFocused(true, (clientManager, desktopManager, window, column, grid) => {
|
||||
const targetColumn = grid.getColumnAtIndex(columnIndex);
|
||||
if (targetColumn === null) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
window.moveToColumn(targetColumn);
|
||||
grid.desktop.autoAdjustScroll();
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
columnMoveToColumn: (columnIndex: number) => {
|
||||
world.doIfTiledFocused(true, (world, desktopManager, window, column, grid) => {
|
||||
case "column-move-to-column-": return (columnIndex: number) => {
|
||||
world.doIfTiledFocused(true, (clientManager, desktopManager, window, column, grid) => {
|
||||
const targetColumn = grid.getColumnAtIndex(columnIndex);
|
||||
if (targetColumn === null || targetColumn === column) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
if (targetColumn.isAfter(column)) {
|
||||
column.moveAfter(targetColumn);
|
||||
@@ -284,30 +292,38 @@ namespace Actions {
|
||||
column.moveAfter(grid.getPrevColumn(targetColumn));
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
columnMoveToDesktop: (desktopIndex: number) => {
|
||||
case "column-move-to-desktop-": return (desktopIndex: number) => {
|
||||
world.doIfTiledFocused(true, (clientManager, desktopManager, window, column, oldGrid) => {
|
||||
const desktopNumber = desktopIndex + 1;
|
||||
const newGrid = desktopManager.getDesktopInCurrentActivity(desktopNumber).grid;
|
||||
const kwinDesktop = Workspace.desktops[desktopIndex];
|
||||
if (kwinDesktop === undefined) {
|
||||
return;
|
||||
}
|
||||
const newGrid = desktopManager.getDesktopInCurrentActivity(kwinDesktop).grid;
|
||||
if (newGrid === null || newGrid === oldGrid) {
|
||||
return;
|
||||
}
|
||||
column.moveToGrid(newGrid, newGrid.getLastColumn());
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
tailMoveToDesktop: (desktopIndex: number) => {
|
||||
case "tail-move-to-desktop-": return (desktopIndex: number) => {
|
||||
world.doIfTiledFocused(true, (clientManager, desktopManager, window, column, oldGrid) => {
|
||||
const desktopNumber = desktopIndex + 1;
|
||||
const newGrid = desktopManager.getDesktopInCurrentActivity(desktopNumber).grid;
|
||||
const kwinDesktop = Workspace.desktops[desktopIndex];
|
||||
if (kwinDesktop === undefined) {
|
||||
return;
|
||||
}
|
||||
const newGrid = desktopManager.getDesktopInCurrentActivity(kwinDesktop).grid;
|
||||
if (newGrid === null || newGrid === oldGrid) {
|
||||
return;
|
||||
}
|
||||
oldGrid.evacuateTail(newGrid, column);
|
||||
});
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
default: throw new Error("unknown num action: " + name);
|
||||
}
|
||||
}
|
||||
|
||||
function gridScroll(world: World, amount: number) {
|
||||
@@ -319,5 +335,12 @@ namespace Actions {
|
||||
|
||||
export type Config = {
|
||||
manualScrollStep: number,
|
||||
manualResizeStep: number,
|
||||
columnResizer: ColumnResizer,
|
||||
};
|
||||
|
||||
export type ColumnResizer = {
|
||||
increaseWidth(column: Column, step: number): void,
|
||||
decreaseWidth(column: Column, step: number): void,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
enum ClientAreaOption {
|
||||
PlacementArea,
|
||||
MovementArea,
|
||||
MaximizeArea,
|
||||
MaximizeFullArea,
|
||||
FullScreenArea,
|
||||
WorkArea,
|
||||
FullArea,
|
||||
ScreenArea,
|
||||
}
|
||||
96
src/behavior/columnResizer/ContextualResizer.ts
Normal file
96
src/behavior/columnResizer/ContextualResizer.ts
Normal file
@@ -0,0 +1,96 @@
|
||||
class ContextualResizer {
|
||||
public increaseWidth(column: Column, step: number) {
|
||||
const grid = column.grid;
|
||||
const desktop = grid.desktop;
|
||||
const visibleRange = desktop.getCurrentVisibleRange();
|
||||
if(!column.isVisible(visibleRange, true) || column.getWidth() >= column.getMaxWidth()) {
|
||||
return;
|
||||
}
|
||||
|
||||
let leftVisibleColumn = grid.getLeftmostVisibleColumn(visibleRange, true);
|
||||
let rightVisibleColumn = grid.getRightmostVisibleColumn(visibleRange, true);
|
||||
if (leftVisibleColumn === null || rightVisibleColumn === null) {
|
||||
console.assert(false); // should at least see self
|
||||
return;
|
||||
}
|
||||
|
||||
const leftSpace = leftVisibleColumn.getLeft() - visibleRange.getLeft();
|
||||
const rightSpace = visibleRange.getRight() - rightVisibleColumn.getRight();
|
||||
|
||||
const newWidth = ContextualResizer.findNextStep(
|
||||
[
|
||||
visibleRange.getWidth(),
|
||||
column.getWidth() + step,
|
||||
column.getWidth() + leftSpace + rightSpace,
|
||||
column.getWidth() + leftSpace + rightSpace + leftVisibleColumn.getWidth() + grid.config.gapsInnerHorizontal,
|
||||
column.getWidth() + leftSpace + rightSpace + rightVisibleColumn.getWidth() + grid.config.gapsInnerHorizontal,
|
||||
],
|
||||
width => width - column.getWidth(),
|
||||
)
|
||||
if (newWidth === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
column.setWidth(newWidth, true);
|
||||
desktop.scrollCenterVisible(column);
|
||||
}
|
||||
|
||||
public decreaseWidth(column: Column, step: number) {
|
||||
const grid = column.grid;
|
||||
const desktop = grid.desktop;
|
||||
const visibleRange = desktop.getCurrentVisibleRange();
|
||||
if(!column.isVisible(visibleRange, true) || column.getWidth() <= column.getMinWidth()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const leftVisibleColumn = grid.getLeftmostVisibleColumn(visibleRange, true);
|
||||
const rightVisibleColumn = grid.getRightmostVisibleColumn(visibleRange, true);
|
||||
if (leftVisibleColumn === null || rightVisibleColumn === null) {
|
||||
console.assert(false); // should at least see self
|
||||
return;
|
||||
}
|
||||
|
||||
let leftOffScreenColumn = grid.getPrevColumn(leftVisibleColumn);
|
||||
if (leftOffScreenColumn === column) {
|
||||
leftOffScreenColumn = null;
|
||||
}
|
||||
let rightOffScreenColumn = grid.getNextColumn(rightVisibleColumn);
|
||||
if (rightOffScreenColumn === column) {
|
||||
rightOffScreenColumn = null;
|
||||
}
|
||||
|
||||
const visibleColumnsWidth = rightVisibleColumn.getRight() - leftVisibleColumn.getLeft();
|
||||
const unusedWidth = visibleRange.getWidth() - visibleColumnsWidth;
|
||||
const leftOffScreen = leftOffScreenColumn === null ? 0 : leftOffScreenColumn.getWidth() + grid.config.gapsInnerHorizontal - unusedWidth;
|
||||
const rightOffScreen = rightOffScreenColumn === null ? 0 : rightOffScreenColumn.getWidth() + grid.config.gapsInnerHorizontal - unusedWidth;
|
||||
|
||||
const newWidth = ContextualResizer.findNextStep(
|
||||
[
|
||||
visibleRange.getWidth(),
|
||||
column.getWidth() - step,
|
||||
column.getWidth() - leftOffScreen,
|
||||
column.getWidth() - rightOffScreen,
|
||||
],
|
||||
width => column.getWidth() - width,
|
||||
)
|
||||
if (newWidth === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
column.setWidth(newWidth, true);
|
||||
desktop.scrollCenterVisible(column);
|
||||
}
|
||||
|
||||
private static findNextStep(steps: number[], evaluate: (step: number) => number) {
|
||||
let bestScore = Infinity;
|
||||
let bestStep = undefined;
|
||||
for (const step of steps) {
|
||||
const score = evaluate(step);
|
||||
if (score > 0 && score < bestScore) {
|
||||
bestScore = score;
|
||||
bestStep = step;
|
||||
}
|
||||
}
|
||||
return bestStep;
|
||||
}
|
||||
}
|
||||
9
src/behavior/columnResizer/RawResizer.ts
Normal file
9
src/behavior/columnResizer/RawResizer.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
class RawResizer {
|
||||
public increaseWidth(column: Column, step: number) {
|
||||
column.adjustWidth(step, true);
|
||||
}
|
||||
|
||||
public decreaseWidth(column: Column, step: number) {
|
||||
column.adjustWidth(-step, true);
|
||||
}
|
||||
}
|
||||
13
src/behavior/scrollClamper/CenterClamper.ts
Normal file
13
src/behavior/scrollClamper/CenterClamper.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
class CenterClamper {
|
||||
public clampScrollX(desktop: Desktop, x: number) {
|
||||
const firstColumn = desktop.grid.getFirstColumn();
|
||||
if (firstColumn === null) {
|
||||
return 0;
|
||||
}
|
||||
const lastColumn = desktop.grid.getLastColumn()!;
|
||||
|
||||
let minScroll = Math.round((firstColumn.getWidth() - desktop.tilingArea.width) / 2);
|
||||
let maxScroll = Math.round(desktop.grid.getWidth() - (desktop.tilingArea.width + lastColumn.getWidth()) / 2);
|
||||
return clamp(x, minScroll, maxScroll);
|
||||
}
|
||||
}
|
||||
10
src/behavior/scrollClamper/EdgeClamper.ts
Normal file
10
src/behavior/scrollClamper/EdgeClamper.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
class EdgeClamper {
|
||||
public clampScrollX(desktop: Desktop, x: number) {
|
||||
let minScroll = 0;
|
||||
let maxScroll = desktop.grid.getWidth() - desktop.tilingArea.width;
|
||||
if (maxScroll < 0) {
|
||||
return Math.round(maxScroll / 2);
|
||||
}
|
||||
return clamp(x, minScroll, maxScroll);
|
||||
}
|
||||
}
|
||||
5
src/behavior/scroller/CenteredScroller.ts
Normal file
5
src/behavior/scroller/CenteredScroller.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
class CenteredScroller {
|
||||
public scrollToColumn(desktop: Desktop, column: Column) {
|
||||
desktop.scrollCenterRange(column);
|
||||
}
|
||||
}
|
||||
5
src/behavior/scroller/GroupedScroller.ts
Normal file
5
src/behavior/scroller/GroupedScroller.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
class GroupedScroller {
|
||||
public scrollToColumn(desktop: Desktop, column: Column) {
|
||||
desktop.scrollCenterVisible(column);
|
||||
}
|
||||
}
|
||||
5
src/behavior/scroller/LazyScroller.ts
Normal file
5
src/behavior/scroller/LazyScroller.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
class LazyScroller {
|
||||
public scrollToColumn(desktop: Desktop, column: Column) {
|
||||
desktop.scrollIntoView(column);
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,18 @@ type Config = {
|
||||
gapsOuterRight: number,
|
||||
gapsInnerHorizontal: number,
|
||||
gapsInnerVertical: number,
|
||||
overscroll: number,
|
||||
manualScrollStep: number,
|
||||
manualResizeStep: 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,
|
||||
};
|
||||
|
||||
@@ -4,29 +4,36 @@ const defaultWindowRules = `[
|
||||
"tile": false
|
||||
},
|
||||
{
|
||||
"class": "kcalc",
|
||||
"class": "(org\\\\.kde\\\\.)?plasmashell",
|
||||
"tile": false
|
||||
},
|
||||
{
|
||||
"class": "kfind",
|
||||
"class": "(org\\\\.kde\\\\.)?kded6",
|
||||
"tile": false
|
||||
},
|
||||
{
|
||||
"class": "(org\\\\.kde\\\\.)?kcalc",
|
||||
"tile": false
|
||||
},
|
||||
{
|
||||
"class": "(org\\\\.kde\\\\.)?kfind",
|
||||
"tile": true
|
||||
},
|
||||
{
|
||||
"class": "kruler",
|
||||
"class": "(org\\\\.kde\\\\.)?kruler",
|
||||
"tile": false
|
||||
},
|
||||
{
|
||||
"class": "krunner",
|
||||
"class": "(org\\\\.kde\\\\.)?krunner",
|
||||
"tile": false
|
||||
},
|
||||
{
|
||||
"class": "(org\\\\.kde\\\\.)?yakuake",
|
||||
"tile": false
|
||||
},
|
||||
{
|
||||
"class": "zoom",
|
||||
"caption": "Zoom Cloud Meetings",
|
||||
"tile": false
|
||||
},
|
||||
{
|
||||
"class": "zoom",
|
||||
"caption": "zoom",
|
||||
"caption": "Zoom Cloud Meetings|zoom|zoom <2>",
|
||||
"tile": false
|
||||
},
|
||||
{
|
||||
@@ -53,63 +60,108 @@ const defaultWindowRules = `[
|
||||
|
||||
const configDef = [
|
||||
{
|
||||
"name": "gapsOuterTop",
|
||||
"type": "UInt",
|
||||
"default": 18
|
||||
name: "gapsOuterTop",
|
||||
type: "UInt",
|
||||
default: 18,
|
||||
},
|
||||
{
|
||||
"name": "gapsOuterBottom",
|
||||
"type": "UInt",
|
||||
"default": 18
|
||||
name: "gapsOuterBottom",
|
||||
type: "UInt",
|
||||
default: 18,
|
||||
},
|
||||
{
|
||||
"name": "gapsOuterLeft",
|
||||
"type": "UInt",
|
||||
"default": 18
|
||||
name: "gapsOuterLeft",
|
||||
type: "UInt",
|
||||
default: 18,
|
||||
},
|
||||
{
|
||||
"name": "gapsOuterRight",
|
||||
"type": "UInt",
|
||||
"default": 18
|
||||
name: "gapsOuterRight",
|
||||
type: "UInt",
|
||||
default: 18,
|
||||
},
|
||||
{
|
||||
"name": "gapsInnerHorizontal",
|
||||
"type": "UInt",
|
||||
"default": 18
|
||||
name: "gapsInnerHorizontal",
|
||||
type: "UInt",
|
||||
default: 18,
|
||||
},
|
||||
{
|
||||
"name": "gapsInnerVertical",
|
||||
"type": "UInt",
|
||||
"default": 18
|
||||
name: "gapsInnerVertical",
|
||||
type: "UInt",
|
||||
default: 18,
|
||||
},
|
||||
{
|
||||
"name": "overscroll",
|
||||
"type": "UInt",
|
||||
"default": 18
|
||||
name: "manualScrollStep",
|
||||
type: "UInt",
|
||||
default: 200,
|
||||
},
|
||||
{
|
||||
"name": "manualScrollStep",
|
||||
"type": "UInt",
|
||||
"default": 200
|
||||
name: "manualResizeStep",
|
||||
type: "UInt",
|
||||
default: 600,
|
||||
},
|
||||
{
|
||||
"name": "untileOnDrag",
|
||||
"type": "Bool",
|
||||
"default": true
|
||||
name: "offScreenOpacity",
|
||||
type: "UInt",
|
||||
default: 100,
|
||||
},
|
||||
{
|
||||
"name": "stackColumnsByDefault",
|
||||
"type": "Bool",
|
||||
"default": false
|
||||
name: "untileOnDrag",
|
||||
type: "Bool",
|
||||
default: true,
|
||||
},
|
||||
{
|
||||
"name": "resizeNeighborColumn",
|
||||
"type": "Bool",
|
||||
"default": false
|
||||
name: "stackColumnsByDefault",
|
||||
type: "Bool",
|
||||
default: false,
|
||||
},
|
||||
{
|
||||
"name": "windowRules",
|
||||
"type": "String",
|
||||
"default": defaultWindowRules
|
||||
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,4 +1,4 @@
|
||||
function loadConfig() {
|
||||
function loadConfig(): Config {
|
||||
const config: any = {};
|
||||
for (const entry of configDef) {
|
||||
config[entry.name] = KWin.readConfig(entry.name, entry.default);
|
||||
|
||||
144
src/extern/kwin.d.ts
vendored
144
src/extern/kwin.d.ts
vendored
@@ -1,83 +1,101 @@
|
||||
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;
|
||||
declare const Workspace: {
|
||||
readonly activities: string[];
|
||||
readonly desktops: KwinDesktop[];
|
||||
readonly currentDesktop: KwinDesktop;
|
||||
readonly currentActivity: string;
|
||||
readonly activeScreen: Output;
|
||||
readonly windows: KwinClient[];
|
||||
readonly cursorPos: QmlPoint;
|
||||
|
||||
// Read-write Properties
|
||||
activeClient: KwinClient;
|
||||
activeWindow: KwinClient;
|
||||
|
||||
// Signals
|
||||
currentDesktopChanged: QSignal<[oldDesktopNumber: number]>
|
||||
clientAdded: QSignal<[KwinClient]>;
|
||||
clientRemoved: QSignal<[AbstractClient]>;
|
||||
clientMinimized: QSignal<[AbstractClient]>;
|
||||
clientUnminimized: QSignal<[AbstractClient]>;
|
||||
clientMaximizeSet: QSignal<[AbstractClient, horizontally: boolean, vertically: boolean]>;
|
||||
clientActivated: QSignal<[AbstractClient]>;
|
||||
numberDesktopsChanged: QSignal<[oldNumberOfVirtualDesktops: number]>;
|
||||
currentActivityChanged: QSignal<[newActivity: string]>;
|
||||
virtualScreenSizeChanged: QSignal<[void]>;
|
||||
readonly currentDesktopChanged: QSignal<[]>
|
||||
readonly windowAdded: QSignal<[KwinClient]>;
|
||||
readonly windowRemoved: QSignal<[KwinClient]>;
|
||||
readonly windowActivated: QSignal<[KwinClient]>;
|
||||
readonly desktopsChanged: QSignal<[]>;
|
||||
readonly activitiesChanged: QSignal<[]>;
|
||||
readonly currentActivityChanged: QSignal<[]>;
|
||||
readonly virtualScreenSizeChanged: QSignal<[]>;
|
||||
|
||||
// Functions
|
||||
clientArea(option: ClientAreaOption, screenNumber: number, desktopNumber: number);
|
||||
clientList(): TopLevel[];
|
||||
clientArea(option: ClientAreaOption, output: Output, kwinDesktop: KwinDesktop);
|
||||
};
|
||||
|
||||
type Tile = any;
|
||||
|
||||
interface AbstractClient {
|
||||
// Read-only Properties
|
||||
readonly caption: string;
|
||||
readonly minSize: QSize;
|
||||
readonly transient: boolean;
|
||||
readonly transientFor: AbstractClient;
|
||||
readonly move: boolean;
|
||||
readonly resize: boolean;
|
||||
readonly resizeable: boolean;
|
||||
|
||||
// Read-write Properties
|
||||
fullScreen: boolean;
|
||||
activities: string[]; // empty array means all activities
|
||||
keepBelow: boolean;
|
||||
shade: boolean;
|
||||
minimized: boolean;
|
||||
tile: Tile;
|
||||
|
||||
// Signals
|
||||
fullScreenChanged: QSignal<[void]>;
|
||||
desktopChanged: QSignal<[void]>;
|
||||
activitiesChanged: QSignal<[AbstractClient]>;
|
||||
captionChanged: QSignal<[void]>;
|
||||
tileChanged: QSignal<[Tile]>;
|
||||
moveResizedChanged: QSignal<[void]>;
|
||||
moveResizeCursorChanged: QSignal<[void]>;
|
||||
clientStartUserMovedResized: QSignal<[void]>;
|
||||
|
||||
// Functions
|
||||
setMaximize(vertically: boolean, horizontally: boolean): void;
|
||||
const enum ClientAreaOption {
|
||||
PlacementArea,
|
||||
MovementArea,
|
||||
MaximizeArea,
|
||||
MaximizeFullArea,
|
||||
FullScreenArea,
|
||||
WorkArea,
|
||||
FullArea,
|
||||
ScreenArea,
|
||||
}
|
||||
|
||||
interface TopLevel extends AbstractClient {
|
||||
// Read-only Properties
|
||||
readonly screen: number;
|
||||
const enum MaximizedMode {
|
||||
Unmaximized,
|
||||
Vertically,
|
||||
Horizontally,
|
||||
Maximized,
|
||||
}
|
||||
|
||||
type Tile = unknown;
|
||||
type Output = unknown;
|
||||
|
||||
interface KwinClient {
|
||||
readonly shadeable: boolean;
|
||||
readonly caption: string;
|
||||
readonly minSize: QmlSize;
|
||||
readonly transient: boolean;
|
||||
readonly transientFor: KwinClient;
|
||||
readonly move: boolean;
|
||||
readonly resize: boolean;
|
||||
readonly moveable: boolean;
|
||||
readonly resizeable: boolean;
|
||||
readonly fullScreenable: boolean;
|
||||
readonly maximizable: boolean;
|
||||
readonly output: Output;
|
||||
readonly resourceClass: QByteArray;
|
||||
readonly dock: boolean;
|
||||
readonly normalWindow: boolean;
|
||||
readonly managed: boolean;
|
||||
readonly popupWindow: boolean;
|
||||
|
||||
// Read-write Properties
|
||||
frameGeometry: QRect;
|
||||
desktop: number; // -1 means all desktops
|
||||
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;
|
||||
opacity: number;
|
||||
|
||||
// Signals
|
||||
frameGeometryChanged: QSignal<[TopLevel, oldGeometry: QRect]>;
|
||||
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;
|
||||
}
|
||||
|
||||
interface KwinClient extends TopLevel {}
|
||||
interface KwinDesktop {
|
||||
readonly id: string;
|
||||
}
|
||||
|
||||
type ShortcutHandler = {
|
||||
readonly activated: QSignal<[]>;
|
||||
destroy(): void;
|
||||
};
|
||||
|
||||
20
src/extern/qt.d.ts
vendored
20
src/extern/qt.d.ts
vendored
@@ -1,10 +1,11 @@
|
||||
declare const console: {
|
||||
log(...args: any[]);
|
||||
trace();
|
||||
assert(boolean);
|
||||
};
|
||||
|
||||
declare const Qt: {
|
||||
rect(x: number, y: number, width: number, height: number): QRect;
|
||||
rect(x: number, y: number, width: number, height: number): QmlRect;
|
||||
createQmlObject(qml: string, parent: QmlObject);
|
||||
};
|
||||
|
||||
@@ -12,18 +13,23 @@ type QmlObject = unknown;
|
||||
|
||||
type QByteArray = string;
|
||||
|
||||
type QRect = {
|
||||
type QmlPoint = {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
type QmlRect = {
|
||||
x: number;
|
||||
y: number;
|
||||
width: number;
|
||||
height: number;
|
||||
top: number;
|
||||
bottom: number;
|
||||
bottom: number; // top + height
|
||||
left: number;
|
||||
right: number;
|
||||
right: number; // left + width
|
||||
};
|
||||
|
||||
type QSize = {
|
||||
type QmlSize = {
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
@@ -33,9 +39,9 @@ type QSignal<T extends unknown[]> = {
|
||||
disconnect(handler: (...args: [...T]) => void): void;
|
||||
};
|
||||
|
||||
type QQmlTimer = {
|
||||
type QmlTimer = {
|
||||
interval: number;
|
||||
triggered: QSignal<[void]>;
|
||||
readonly triggered: QSignal<[]>;
|
||||
restart(): void;
|
||||
destroy(): void;
|
||||
};
|
||||
|
||||
@@ -1,211 +1,185 @@
|
||||
const keyBindings: KeyBinding[] = [
|
||||
{
|
||||
"name": "window-toggle-floating",
|
||||
"description": "Toggle floating",
|
||||
"defaultKeySequence": "Meta+Space",
|
||||
"action": "windowToggleFloating",
|
||||
name: "window-toggle-floating",
|
||||
description: "Toggle floating",
|
||||
defaultKeySequence: "Meta+Space",
|
||||
},
|
||||
{
|
||||
"name": "focus-left",
|
||||
"description": "Move focus left",
|
||||
"defaultKeySequence": "Meta+A",
|
||||
"action": "focusLeft",
|
||||
name: "focus-left",
|
||||
description: "Move focus left",
|
||||
defaultKeySequence: "Meta+A",
|
||||
},
|
||||
{
|
||||
"name": "focus-right",
|
||||
"description": "Move focus right",
|
||||
"comment": "Clashes with default KDE shortcuts, may require manual remapping",
|
||||
"defaultKeySequence": "Meta+D",
|
||||
"action": "focusRight",
|
||||
name: "focus-right",
|
||||
description: "Move focus right",
|
||||
comment: "Clashes with default KDE shortcuts, may require manual remapping",
|
||||
defaultKeySequence: "Meta+D",
|
||||
},
|
||||
{
|
||||
"name": "focus-up",
|
||||
"description": "Move focus up",
|
||||
"comment": "Clashes with default KDE shortcuts, may require manual remapping",
|
||||
"defaultKeySequence": "Meta+W",
|
||||
"action": "focusUp",
|
||||
name: "focus-up",
|
||||
description: "Move focus up",
|
||||
comment: "Clashes with default KDE shortcuts, may require manual remapping",
|
||||
defaultKeySequence: "Meta+W",
|
||||
},
|
||||
{
|
||||
"name": "focus-down",
|
||||
"description": "Move focus down",
|
||||
"comment": "Clashes with default KDE shortcuts, may require manual remapping",
|
||||
"defaultKeySequence": "Meta+S",
|
||||
"action": "focusDown",
|
||||
name: "focus-down",
|
||||
description: "Move focus down",
|
||||
comment: "Clashes with default KDE shortcuts, may require manual remapping",
|
||||
defaultKeySequence: "Meta+S",
|
||||
},
|
||||
{
|
||||
"name": "focus-start",
|
||||
"description": "Move focus to start",
|
||||
"defaultKeySequence": "Meta+Home",
|
||||
"action": "focusStart",
|
||||
name: "focus-start",
|
||||
description: "Move focus to start",
|
||||
defaultKeySequence: "Meta+Home",
|
||||
},
|
||||
{
|
||||
"name": "focus-end",
|
||||
"description": "Move focus to end",
|
||||
"defaultKeySequence": "Meta+End",
|
||||
"action": "focusEnd",
|
||||
name: "focus-end",
|
||||
description: "Move focus to end",
|
||||
defaultKeySequence: "Meta+End",
|
||||
},
|
||||
{
|
||||
"name": "window-move-left",
|
||||
"description": "Move window left",
|
||||
"comment": "Moves window out of and into columns",
|
||||
"defaultKeySequence": "Meta+Shift+A",
|
||||
"action": "windowMoveLeft",
|
||||
name: "window-move-left",
|
||||
description: "Move window left",
|
||||
comment: "Moves window out of and into columns",
|
||||
defaultKeySequence: "Meta+Shift+A",
|
||||
},
|
||||
{
|
||||
"name": "window-move-right",
|
||||
"description": "Move window right",
|
||||
"comment": "Moves window out of and into columns",
|
||||
"defaultKeySequence": "Meta+Shift+D",
|
||||
"action": "windowMoveRight",
|
||||
name: "window-move-right",
|
||||
description: "Move window right",
|
||||
comment: "Moves window out of and into columns",
|
||||
defaultKeySequence: "Meta+Shift+D",
|
||||
},
|
||||
{
|
||||
"name": "window-move-up",
|
||||
"description": "Move window up",
|
||||
"defaultKeySequence": "Meta+Shift+W",
|
||||
"action": "windowMoveUp",
|
||||
name: "window-move-up",
|
||||
description: "Move window up",
|
||||
defaultKeySequence: "Meta+Shift+W",
|
||||
},
|
||||
{
|
||||
"name": "window-move-down",
|
||||
"description": "Move window down",
|
||||
"defaultKeySequence": "Meta+Shift+S",
|
||||
"action": "windowMoveDown",
|
||||
name: "window-move-down",
|
||||
description: "Move window down",
|
||||
defaultKeySequence: "Meta+Shift+S",
|
||||
},
|
||||
{
|
||||
"name": "window-move-start",
|
||||
"description": "Move window to start",
|
||||
"defaultKeySequence": "Meta+Shift+Home",
|
||||
"action": "windowMoveStart",
|
||||
name: "window-move-start",
|
||||
description: "Move window to start",
|
||||
defaultKeySequence: "Meta+Shift+Home",
|
||||
},
|
||||
{
|
||||
"name": "window-move-end",
|
||||
"description": "Move window to end",
|
||||
"defaultKeySequence": "Meta+Shift+End",
|
||||
"action": "windowMoveEnd",
|
||||
name: "window-move-end",
|
||||
description: "Move window to end",
|
||||
defaultKeySequence: "Meta+Shift+End",
|
||||
},
|
||||
{
|
||||
"name": "column-toggle-stacked",
|
||||
"description": "Toggle stacked layout for focused column",
|
||||
"defaultKeySequence": "Meta+X",
|
||||
"action": "columnToggleStacked",
|
||||
name: "column-toggle-stacked",
|
||||
description: "Toggle stacked layout for focused column",
|
||||
comment: "One window in the column visible, others shaded; not supported on Wayland",
|
||||
defaultKeySequence: "Meta+X",
|
||||
},
|
||||
{
|
||||
"name": "column-move-left",
|
||||
"description": "Move column left",
|
||||
"defaultKeySequence": "Meta+Ctrl+Shift+A",
|
||||
"action": "columnMoveLeft",
|
||||
name: "column-move-left",
|
||||
description: "Move column left",
|
||||
defaultKeySequence: "Meta+Ctrl+Shift+A",
|
||||
},
|
||||
{
|
||||
"name": "column-move-right",
|
||||
"description": "Move column right",
|
||||
"defaultKeySequence": "Meta+Ctrl+Shift+D",
|
||||
"action": "columnMoveRight",
|
||||
name: "column-move-right",
|
||||
description: "Move column right",
|
||||
defaultKeySequence: "Meta+Ctrl+Shift+D",
|
||||
},
|
||||
{
|
||||
"name": "column-move-start",
|
||||
"description": "Move column to start",
|
||||
"defaultKeySequence": "Meta+Ctrl+Shift+Home",
|
||||
"action": "columnMoveStart",
|
||||
name: "column-move-start",
|
||||
description: "Move column to start",
|
||||
defaultKeySequence: "Meta+Ctrl+Shift+Home",
|
||||
},
|
||||
{
|
||||
"name": "column-move-end",
|
||||
"description": "Move column to end",
|
||||
"defaultKeySequence": "Meta+Ctrl+Shift+End",
|
||||
"action": "columnMoveEnd",
|
||||
name: "column-move-end",
|
||||
description: "Move column to end",
|
||||
defaultKeySequence: "Meta+Ctrl+Shift+End",
|
||||
},
|
||||
{
|
||||
"name": "column-width-increase",
|
||||
"description": "Increase column width",
|
||||
"defaultKeySequence": "Meta+Ctrl++",
|
||||
"action": "columnWidthIncrease",
|
||||
name: "column-width-increase",
|
||||
description: "Increase column width",
|
||||
defaultKeySequence: "Meta+Ctrl++",
|
||||
},
|
||||
{
|
||||
"name": "column-width-decrease",
|
||||
"description": "Decrease column width",
|
||||
"defaultKeySequence": "Meta+Ctrl+-",
|
||||
"action": "columnWidthDecrease",
|
||||
name: "column-width-decrease",
|
||||
description: "Decrease column width",
|
||||
defaultKeySequence: "Meta+Ctrl+-",
|
||||
},
|
||||
{
|
||||
"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: "columns-width-equalize",
|
||||
description: "Equalize widths of visible columns",
|
||||
defaultKeySequence: "Meta+Ctrl+X",
|
||||
},
|
||||
{
|
||||
"name": "grid-scroll-left-column",
|
||||
"description": "Scroll one column to the left",
|
||||
"defaultKeySequence": "Meta+Alt+A",
|
||||
"action": "gridScrollLeftColumn",
|
||||
name: "grid-scroll-focused",
|
||||
description: "Center focused window",
|
||||
comment: "Scrolls so that the focused window is centered in the screen",
|
||||
defaultKeySequence: "Meta+Alt+Return",
|
||||
},
|
||||
{
|
||||
"name": "grid-scroll-right-column",
|
||||
"description": "Scroll one column to the right",
|
||||
"defaultKeySequence": "Meta+Alt+D",
|
||||
"action": "gridScrollRightColumn",
|
||||
name: "grid-scroll-left-column",
|
||||
description: "Scroll one column to the left",
|
||||
defaultKeySequence: "Meta+Alt+A",
|
||||
},
|
||||
{
|
||||
"name": "grid-scroll-left",
|
||||
"description": "Scroll left",
|
||||
"defaultKeySequence": "Meta+Alt+PgUp",
|
||||
"action": "gridScrollLeft",
|
||||
name: "grid-scroll-right-column",
|
||||
description: "Scroll one column to the right",
|
||||
defaultKeySequence: "Meta+Alt+D",
|
||||
},
|
||||
{
|
||||
"name": "grid-scroll-right",
|
||||
"description": "Scroll right",
|
||||
"defaultKeySequence": "Meta+Alt+PgDown",
|
||||
"action": "gridScrollRight",
|
||||
name: "grid-scroll-left",
|
||||
description: "Scroll left",
|
||||
defaultKeySequence: "Meta+Alt+PgUp",
|
||||
},
|
||||
{
|
||||
"name": "grid-scroll-start",
|
||||
"description": "Scroll to start",
|
||||
"defaultKeySequence": "Meta+Alt+Home",
|
||||
"action": "gridScrollStart",
|
||||
name: "grid-scroll-right",
|
||||
description: "Scroll right",
|
||||
defaultKeySequence: "Meta+Alt+PgDown",
|
||||
},
|
||||
{
|
||||
"name": "grid-scroll-end",
|
||||
"description": "Scroll to end",
|
||||
"defaultKeySequence": "Meta+Alt+End",
|
||||
"action": "gridScrollEnd",
|
||||
name: "grid-scroll-start",
|
||||
description: "Scroll to start",
|
||||
defaultKeySequence: "Meta+Alt+Home",
|
||||
},
|
||||
{
|
||||
name: "grid-scroll-end",
|
||||
description: "Scroll to end",
|
||||
defaultKeySequence: "Meta+Alt+End",
|
||||
},
|
||||
];
|
||||
|
||||
const numKeyBindings: NumKeyBinding[] = [
|
||||
{
|
||||
"name": "focus-",
|
||||
"description": "Move focus to column ",
|
||||
"comment": "Clashes with default KDE shortcuts, may require manual remapping",
|
||||
"defaultModifiers": "Meta",
|
||||
"fKeys": false,
|
||||
"action": "focusColumn",
|
||||
name: "focus-",
|
||||
description: "Move focus to column ",
|
||||
comment: "Clashes with default KDE shortcuts, may require manual remapping",
|
||||
defaultModifiers: "Meta",
|
||||
fKeys: false,
|
||||
},
|
||||
{
|
||||
"name": "window-move-to-column-",
|
||||
"description": "Move window to column ",
|
||||
"comment": "Requires manual remapping according to your keyboard layout, e.g. Meta+Shift+1 -> Meta+!",
|
||||
"defaultModifiers": "Meta+Shift",
|
||||
"fKeys": false,
|
||||
"action": "windowMoveToColumn",
|
||||
name: "window-move-to-column-",
|
||||
description: "Move window to column ",
|
||||
comment: "Requires manual remapping according to your keyboard layout, e.g. Meta+Shift+1 -> Meta+!",
|
||||
defaultModifiers: "Meta+Shift",
|
||||
fKeys: false,
|
||||
},
|
||||
{
|
||||
"name": "column-move-to-column-",
|
||||
"description": "Move column to position ",
|
||||
"comment": "Requires manual remapping according to your keyboard layout, e.g. Meta+Ctrl+Shift+1 -> Meta+Ctrl+!",
|
||||
"defaultModifiers": "Meta+Ctrl+Shift",
|
||||
"fKeys": false,
|
||||
"action": "columnMoveToColumn",
|
||||
name: "column-move-to-column-",
|
||||
description: "Move column to position ",
|
||||
comment: "Requires manual remapping according to your keyboard layout, e.g. Meta+Ctrl+Shift+1 -> Meta+Ctrl+!",
|
||||
defaultModifiers: "Meta+Ctrl+Shift",
|
||||
fKeys: false,
|
||||
},
|
||||
{
|
||||
"name": "column-move-to-desktop-",
|
||||
"description": "Move column to desktop ",
|
||||
"defaultModifiers": "Meta+Ctrl+Shift",
|
||||
"fKeys": true,
|
||||
"action": "columnMoveToDesktop",
|
||||
name: "column-move-to-desktop-",
|
||||
description: "Move column to desktop ",
|
||||
defaultModifiers: "Meta+Ctrl+Shift",
|
||||
fKeys: true,
|
||||
},
|
||||
{
|
||||
"name": "tail-move-to-desktop-",
|
||||
"description": "Move this and all following columns to desktop ",
|
||||
"defaultModifiers": "Meta+Ctrl+Shift+Alt",
|
||||
"fKeys": true,
|
||||
"action": "tailMoveToDesktop",
|
||||
name: "tail-move-to-desktop-",
|
||||
description: "Move this and all following columns to desktop ",
|
||||
defaultModifiers: "Meta+Ctrl+Shift+Alt",
|
||||
fKeys: true,
|
||||
},
|
||||
];
|
||||
|
||||
@@ -3,7 +3,6 @@ type KeyBinding = {
|
||||
description: string;
|
||||
comment?: string;
|
||||
defaultKeySequence: string;
|
||||
action: keyof ReturnType<typeof Actions.init>;
|
||||
};
|
||||
|
||||
type NumKeyBinding = {
|
||||
@@ -12,7 +11,6 @@ type NumKeyBinding = {
|
||||
comment?: string;
|
||||
defaultModifiers: string;
|
||||
fKeys: boolean;
|
||||
action: keyof ReturnType<typeof Actions.initNum>;
|
||||
};
|
||||
|
||||
function catchWrap(f: () => void) {
|
||||
@@ -26,40 +24,44 @@ function catchWrap(f: () => void) {
|
||||
};
|
||||
}
|
||||
|
||||
function registerKeyBinding(name: string, description: string, keySequence: string, callback: () => void) {
|
||||
KWin.registerShortcut(
|
||||
"karousel-" + name,
|
||||
"Karousel: " + description,
|
||||
keySequence,
|
||||
catchWrap(callback),
|
||||
);
|
||||
function registerKeyBinding(world: World, config: Actions.Config, shortcutActions: ShortcutAction[], keyBinding: KeyBinding) {
|
||||
shortcutActions.push(new ShortcutAction(
|
||||
keyBinding,
|
||||
catchWrap(Actions.getAction(world, config, keyBinding.name)),
|
||||
));
|
||||
}
|
||||
|
||||
function registerNumKeyBindings(name: string, description: string, modifiers: string, fKeys: boolean, callback: (i: number) => void) {
|
||||
const numPrefix = fKeys ? "F" : "";
|
||||
const n = fKeys ? 12 : 9;
|
||||
function registerNumKeyBindings(world: World, 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 ?
|
||||
modifiers + "+" + numPrefix + numKey :
|
||||
numKeyBinding.defaultModifiers + "+" + numPrefix + numKey :
|
||||
"";
|
||||
registerKeyBinding(
|
||||
name + numKey,
|
||||
description + numKey,
|
||||
keySequence,
|
||||
() => callback(i),
|
||||
);
|
||||
const action = Actions.getNumAction(world, numKeyBinding.name);
|
||||
shortcutActions.push(new ShortcutAction(
|
||||
{
|
||||
name: numKeyBinding.name + numKey,
|
||||
description: numKeyBinding.description + numKey,
|
||||
defaultKeySequence: keySequence,
|
||||
},
|
||||
catchWrap(() => action(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]);
|
||||
// TODO: refactor
|
||||
function registerKeyBindings(world: World, config: Actions.Config) {
|
||||
const shortcutActions: ShortcutAction[] = [];
|
||||
|
||||
for (const keyBinding of keyBindings) {
|
||||
registerKeyBinding(world, config, shortcutActions, keyBinding);
|
||||
}
|
||||
|
||||
const numActions = Actions.initNum(world);
|
||||
for (const binding of numKeyBindings) {
|
||||
registerNumKeyBindings(binding.name, binding.description, binding.defaultModifiers, binding.fKeys, numActions[binding.action]);
|
||||
for (const numKeyBinding of numKeyBindings) {
|
||||
registerNumKeyBindings(world, shortcutActions, numKeyBinding);
|
||||
}
|
||||
|
||||
return shortcutActions;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ class Column {
|
||||
this.grid = targetGrid;
|
||||
targetGrid.onColumnAdded(this, prevColumn);
|
||||
for (const window of this.windows.iterator()) {
|
||||
window.client.kwinClient.desktop = targetGrid.desktop.desktopNumber;
|
||||
window.client.kwinClient.desktops = [targetGrid.desktop.kwinDesktop];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,16 +92,17 @@ class Column {
|
||||
|
||||
public setWidth(width: number, setPreferred: boolean) {
|
||||
width = clamp(width, this.getMinWidth(), this.getMaxWidth());
|
||||
const oldWidth = this.width;
|
||||
if (width === this.width) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.width = width;
|
||||
if (setPreferred) {
|
||||
for (const window of this.windows.iterator()) {
|
||||
window.client.preferredWidth = width;
|
||||
}
|
||||
}
|
||||
if (width !== oldWidth) {
|
||||
this.grid.onColumnWidthChanged(this, oldWidth, width);
|
||||
}
|
||||
this.grid.onColumnWidthChanged(this);
|
||||
}
|
||||
|
||||
public adjustWidth(widthDelta: number, setPreferred: boolean) {
|
||||
@@ -180,8 +181,15 @@ class Column {
|
||||
window.focus();
|
||||
}
|
||||
|
||||
public arrange(x: number) {
|
||||
if (this.stacked && this.windows.length() >= 2) {
|
||||
public arrange(x: number, visibleRange: Range, forceOpaque: boolean) {
|
||||
if (this.grid.config.offScreenOpacity < 1.0 && !forceOpaque) {
|
||||
const opacity = this.isVisible(visibleRange, true) ? 100 : this.grid.config.offScreenOpacity;
|
||||
for (const window of this.windows.iterator()) {
|
||||
window.client.kwinClient.opacity = opacity;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.stacked && this.windows.length() >= 2 && this.canStack()) {
|
||||
this.arrangeStacked(x);
|
||||
return;
|
||||
}
|
||||
@@ -228,13 +236,22 @@ class Column {
|
||||
this.grid.desktop.onLayoutChanged();
|
||||
}
|
||||
|
||||
public isVisible(scrollPos: Desktop.ScrollPos, fullyVisible: boolean) {
|
||||
private canStack() {
|
||||
for (const window of this.windows.iterator()) {
|
||||
if (!window.client.kwinClient.shadeable) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public isVisible(visibleRange: Desktop.Range, fullyVisible: boolean) {
|
||||
if (fullyVisible) {
|
||||
return this.getLeft() >= scrollPos.getLeft() &&
|
||||
this.getRight() <= scrollPos.getRight();
|
||||
return this.getLeft() >= visibleRange.getLeft() &&
|
||||
this.getRight() <= visibleRange.getRight();
|
||||
} else {
|
||||
return this.getRight() + this.grid.config.gapsInnerHorizontal > scrollPos.getLeft() &&
|
||||
this.getLeft() - this.grid.config.gapsInnerHorizontal < scrollPos.getRight();
|
||||
return this.getRight() + this.grid.config.gapsInnerHorizontal > visibleRange.getLeft() &&
|
||||
this.getLeft() - this.grid.config.gapsInnerHorizontal < visibleRange.getRight();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,138 +1,162 @@
|
||||
class Desktop {
|
||||
public readonly grid: Grid;
|
||||
public readonly desktopNumber: number;
|
||||
public readonly kwinDesktop: KwinDesktop;
|
||||
private readonly pinManager: PinManager;
|
||||
private readonly config: Desktop.Config;
|
||||
private scrollX: number;
|
||||
private dirty: boolean;
|
||||
public clientArea: QRect;
|
||||
public tilingArea: QRect;
|
||||
private dirtyScroll: boolean;
|
||||
private dirtyPins: boolean;
|
||||
public clientArea: QmlRect;
|
||||
public tilingArea: QmlRect;
|
||||
|
||||
constructor(desktopNumber: number, config: Desktop.Config, layoutConfig: LayoutConfig) {
|
||||
constructor(kwinDesktop: KwinDesktop, pinManager: PinManager, config: Desktop.Config, layoutConfig: LayoutConfig) {
|
||||
this.pinManager = pinManager;
|
||||
this.config = config;
|
||||
this.scrollX = 0;
|
||||
this.dirty = false;
|
||||
this.desktopNumber = desktopNumber;
|
||||
this.dirty = true;
|
||||
this.dirtyScroll = true;
|
||||
this.dirtyPins = true;
|
||||
this.kwinDesktop = kwinDesktop;
|
||||
this.grid = new Grid(this, layoutConfig);
|
||||
this.clientArea = Desktop.getClientArea(desktopNumber);
|
||||
this.tilingArea = Desktop.getTilingArea(this.clientArea, config);
|
||||
this.clientArea = Desktop.getClientArea(kwinDesktop);
|
||||
this.tilingArea = Desktop.getTilingArea(this.clientArea, kwinDesktop, pinManager, config);
|
||||
}
|
||||
|
||||
private updateArea() {
|
||||
const newClientArea = Desktop.getClientArea(this.desktopNumber);
|
||||
if (newClientArea === this.clientArea) {
|
||||
const newClientArea = Desktop.getClientArea(this.kwinDesktop);
|
||||
if (newClientArea === this.clientArea && !this.dirtyPins) {
|
||||
return;
|
||||
}
|
||||
this.clientArea = newClientArea;
|
||||
this.tilingArea = Desktop.getTilingArea(newClientArea, this.config);
|
||||
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(desktopNumber: number) {
|
||||
return workspace.clientArea(ClientAreaOption.PlacementArea, 0, desktopNumber);
|
||||
private static getClientArea(kwinDesktop: KwinDesktop) {
|
||||
return Workspace.clientArea(ClientAreaOption.PlacementArea, Workspace.activeScreen, kwinDesktop);
|
||||
}
|
||||
|
||||
private static getTilingArea(clientArea: QRect, config: Desktop.Config) {
|
||||
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(
|
||||
clientArea.x + config.marginLeft,
|
||||
clientArea.y + config.marginTop,
|
||||
clientArea.width - config.marginLeft - config.marginRight,
|
||||
clientArea.height - config.marginTop - config.marginBottom,
|
||||
left,
|
||||
top,
|
||||
right - left,
|
||||
bottom - top,
|
||||
)
|
||||
}
|
||||
|
||||
// calculates Desktop.Pos that scrolls the column into view
|
||||
public getScrollPosForColumn(column: Column) {
|
||||
const left = column.getLeft();
|
||||
const right = column.getRight();
|
||||
const initialScrollPos = this.getCurrentScrollPos();
|
||||
public scrollIntoView(range: Desktop.Range) {
|
||||
const left = range.getLeft();
|
||||
const right = range.getRight();
|
||||
const initialVisibleRange = this.getCurrentVisibleRange();
|
||||
|
||||
let targetScrollX: number;
|
||||
if (left < initialScrollPos.getLeft()) {
|
||||
if (left < initialVisibleRange.getLeft()) {
|
||||
targetScrollX = left;
|
||||
} else if (right > initialScrollPos.getRight()) {
|
||||
} else if (right > initialVisibleRange.getRight()) {
|
||||
targetScrollX = right - this.tilingArea.width;
|
||||
} else {
|
||||
return this.getScrollPos(this.clampScrollX(this.scrollX));
|
||||
targetScrollX = initialVisibleRange.getLeft();
|
||||
}
|
||||
|
||||
const overscroll = this.getTargetOverscroll(targetScrollX, left < initialScrollPos.getLeft());
|
||||
return this.getScrollPos(this.clampScrollX(targetScrollX + overscroll));
|
||||
this.setScroll(targetScrollX, false);
|
||||
}
|
||||
|
||||
private getTargetOverscroll(targetScrollX: number, scrollLeft: boolean) {
|
||||
if (this.config.overscroll === 0) {
|
||||
return 0;
|
||||
}
|
||||
const visibleColumnsWidth = this.grid.getVisibleColumnsWidth(this.getScrollPos(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 scrollToColumn(column: Column) {
|
||||
this.setScroll(this.getScrollPosForColumn(column).x, true);
|
||||
}
|
||||
|
||||
public scrollCenterColumn(column: Column) {
|
||||
const windowCenter = column.getLeft() + column.getWidth() / 2;
|
||||
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 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) {
|
||||
this.removeOverscroll();
|
||||
return;
|
||||
}
|
||||
|
||||
if (focusedColumn.grid !== this.grid) {
|
||||
if (focusedColumn === null || focusedColumn.grid !== this.grid) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.scrollToColumn(focusedColumn);
|
||||
}
|
||||
|
||||
private getScrollPos(scrollX: number) {
|
||||
return new Desktop.ScrollPos(scrollX, this.tilingArea.width);
|
||||
public scrollToColumn(column: Column) {
|
||||
if (this.dirtyScroll || !column.isVisible(this.getCurrentVisibleRange(), true)) {
|
||||
this.config.scroller.scrollToColumn(this, column);
|
||||
}
|
||||
}
|
||||
|
||||
public getCurrentScrollPos() {
|
||||
return this.getScrollPos(this.scrollX);
|
||||
private getVisibleRange(scrollX: number) {
|
||||
return new Desktop.RangeImpl(scrollX, this.tilingArea.width);
|
||||
}
|
||||
|
||||
public getCurrentVisibleRange() {
|
||||
return this.getVisibleRange(this.scrollX);
|
||||
}
|
||||
|
||||
private clampScrollX(x: number) {
|
||||
let minScroll = 0;
|
||||
let maxScroll = this.grid.getWidth() - this.tilingArea.width;
|
||||
if (maxScroll < 0) {
|
||||
const centerScroll = Math.round(maxScroll / 2);
|
||||
minScroll = centerScroll;
|
||||
maxScroll = centerScroll;
|
||||
}
|
||||
return clamp(x, minScroll, maxScroll);
|
||||
return this.config.clamper.clampScrollX(this, x);
|
||||
}
|
||||
|
||||
private setScroll(x: number, force: boolean) {
|
||||
public setScroll(x: number, force: boolean) {
|
||||
const oldScrollX = this.scrollX;
|
||||
this.scrollX = force ? x : this.clampScrollX(x);
|
||||
if (this.scrollX !== oldScrollX) {
|
||||
this.onLayoutChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private applyScrollPos(scrollPos: Desktop.ScrollPos) {
|
||||
this.setScroll(scrollPos.x, true);
|
||||
this.dirtyScroll = false;
|
||||
}
|
||||
|
||||
public adjustScroll(dx: number, force: boolean) {
|
||||
this.setScroll(this.scrollX + dx, force);
|
||||
}
|
||||
|
||||
private removeOverscroll() {
|
||||
this.setScroll(this.scrollX, false);
|
||||
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;
|
||||
|
||||
const minWidths = visibleColumns.map(column => column.getMinWidth()).sort((a, b) => b - a);
|
||||
for (const minWidth of minWidths) {
|
||||
if (minWidth > remainingWidth / remainingColumns) {
|
||||
remainingWidth -= minWidth;
|
||||
remainingColumns--;
|
||||
}
|
||||
}
|
||||
|
||||
const avgWidth = remainingWidth / remainingColumns;
|
||||
for (const column of visibleColumns) {
|
||||
const minWidth = column.getMinWidth();
|
||||
if (minWidth > avgWidth) {
|
||||
column.setWidth(minWidth, true);
|
||||
} else {
|
||||
const columnWidth = Math.round(remainingWidth / remainingColumns);
|
||||
column.setWidth(columnWidth, true);
|
||||
remainingWidth -= column.getWidth();
|
||||
remainingColumns--;
|
||||
}
|
||||
}
|
||||
|
||||
this.scrollCenterRange(Desktop.RangeImpl.fromRanges(
|
||||
visibleColumns[0],
|
||||
visibleColumns[visibleColumns.length - 1],
|
||||
));
|
||||
}
|
||||
|
||||
public arrange() {
|
||||
@@ -141,12 +165,19 @@ class Desktop {
|
||||
if (!this.dirty) {
|
||||
return;
|
||||
}
|
||||
this.grid.arrange(this.tilingArea.x - this.scrollX);
|
||||
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() {
|
||||
@@ -160,12 +191,19 @@ namespace Desktop {
|
||||
marginBottom: number,
|
||||
marginLeft: number,
|
||||
marginRight: number,
|
||||
overscroll: number,
|
||||
scroller: Desktop.Scroller,
|
||||
clamper: Desktop.Clamper,
|
||||
};
|
||||
|
||||
export class ScrollPos {
|
||||
public readonly x: number;
|
||||
public readonly width: number;
|
||||
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;
|
||||
@@ -179,5 +217,95 @@ namespace Desktop {
|
||||
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 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: Desktop.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.getPrevColumn(this.left);
|
||||
let rightColumn = grid.getNextColumn(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.getPrevColumn(leftColumn!);
|
||||
} else {
|
||||
this.addRight(rightColumn!, gap);
|
||||
rightColumn = grid.getNextColumn(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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import Range = Desktop.Range;
|
||||
|
||||
class Grid {
|
||||
public readonly desktop: Desktop;
|
||||
public readonly config: LayoutConfig;
|
||||
@@ -41,6 +43,10 @@ class Grid {
|
||||
return this.width;
|
||||
}
|
||||
|
||||
public isUserResizing() {
|
||||
return this.userResize;
|
||||
}
|
||||
|
||||
public getPrevColumn(column: Column) {
|
||||
return this.columns.getPrev(column);
|
||||
}
|
||||
@@ -88,39 +94,41 @@ class Grid {
|
||||
this.width = x - this.config.gapsInnerHorizontal;
|
||||
}
|
||||
|
||||
public getLeftmostVisibleColumn(scrollPos: Desktop.ScrollPos, fullyVisible: boolean) {
|
||||
const scrollX = scrollPos.getLeft();
|
||||
public getLeftmostVisibleColumn(visibleRange: Desktop.Range, fullyVisible: boolean) {
|
||||
for (const column of this.columns.iterator()) {
|
||||
const x = fullyVisible ? column.getLeft() : column.getRight() + (this.config.gapsInnerHorizontal - 1);
|
||||
if (x >= scrollX) {
|
||||
if (column.isVisible(visibleRange, fullyVisible)) {
|
||||
return column;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public getRightmostVisibleColumn(scrollPos: Desktop.ScrollPos, fullyVisible: boolean) {
|
||||
const scrollX = scrollPos.getRight();
|
||||
public getRightmostVisibleColumn(visibleRange: Desktop.Range, fullyVisible: boolean) {
|
||||
let last = null;
|
||||
for (const column of this.columns.iterator()) {
|
||||
const x = fullyVisible ? column.getRight() : column.getLeft() - (this.config.gapsInnerHorizontal - 1);
|
||||
if (x <= scrollX) {
|
||||
if (column.isVisible(visibleRange, fullyVisible)) {
|
||||
last = column;
|
||||
} else {
|
||||
} else if (last !== null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return last;
|
||||
}
|
||||
|
||||
public getVisibleColumnsWidth(scrollPos: Desktop.ScrollPos, fullyVisible: boolean) {
|
||||
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.columns.iterator()) {
|
||||
if (column.isVisible(scrollPos, fullyVisible)) {
|
||||
width += column.getWidth();
|
||||
nVisible++;
|
||||
}
|
||||
for (const column of this.getVisibleColumns(visibleRange, fullyVisible)) {
|
||||
width += column.getWidth();
|
||||
nVisible++;
|
||||
}
|
||||
|
||||
if (nVisible > 0) {
|
||||
@@ -130,84 +138,9 @@ class Grid {
|
||||
return width;
|
||||
}
|
||||
|
||||
private getLeftOffScreenColumn(scrollPos: Desktop.ScrollPos) {
|
||||
const leftVisible = this.getLeftmostVisibleColumn(scrollPos, true);
|
||||
if (leftVisible === null) {
|
||||
return null;
|
||||
}
|
||||
return this.getPrevColumn(leftVisible);
|
||||
}
|
||||
|
||||
private getRightOffScreenColumn(scrollPos: Desktop.ScrollPos) {
|
||||
const rightVisible = this.getRightmostVisibleColumn(scrollPos, true);
|
||||
if (rightVisible === null) {
|
||||
return null;
|
||||
}
|
||||
return this.getNextColumn(rightVisible);
|
||||
}
|
||||
|
||||
public increaseColumnWidth(column: Column) {
|
||||
const scrollPos = this.desktop.getScrollPosForColumn(column);
|
||||
if (this.width < scrollPos.width) {
|
||||
column.adjustWidth(scrollPos.width - this.width, false);
|
||||
return;
|
||||
}
|
||||
|
||||
let leftColumn = this.getLeftmostVisibleColumn(scrollPos, false);
|
||||
if (leftColumn === column) {
|
||||
leftColumn = null;
|
||||
}
|
||||
let rightColumn = this.getRightmostVisibleColumn(scrollPos, false);
|
||||
if (rightColumn === column) {
|
||||
rightColumn = null;
|
||||
}
|
||||
if (leftColumn === null && rightColumn === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const leftVisibleWidth = leftColumn === null ? Infinity : leftColumn.getRight() - scrollPos.getLeft();
|
||||
const rightVisibleWidth = rightColumn === null ? Infinity : scrollPos.getRight() - rightColumn.getLeft();
|
||||
const expandLeft = leftVisibleWidth < rightVisibleWidth;
|
||||
const widthDelta = (expandLeft ? leftVisibleWidth : rightVisibleWidth) + this.config.gapsInnerHorizontal;
|
||||
if (expandLeft) {
|
||||
this.desktop.adjustScroll(widthDelta, false);
|
||||
}
|
||||
column.adjustWidth(widthDelta, true);
|
||||
}
|
||||
|
||||
public decreaseColumnWidth(column: Column) {
|
||||
const scrollPos = this.desktop.getScrollPosForColumn(column);
|
||||
if (this.width <= scrollPos.width) {
|
||||
column.setWidth(Math.round(column.getWidth() / 2), false);
|
||||
return;
|
||||
}
|
||||
|
||||
let leftColumn = this.getLeftOffScreenColumn(scrollPos);
|
||||
if (leftColumn === column) {
|
||||
leftColumn = null;
|
||||
}
|
||||
let rightColumn = this.getRightOffScreenColumn(scrollPos);
|
||||
if (rightColumn === column) {
|
||||
rightColumn = null;
|
||||
}
|
||||
if (leftColumn === null && rightColumn === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const leftInvisibleWidth = leftColumn === null ? Infinity : scrollPos.getLeft() - leftColumn.getLeft();
|
||||
const rightInvisibleWidth = rightColumn === null ? Infinity : rightColumn.getRight() - scrollPos.getRight();
|
||||
const shrinkLeft = leftInvisibleWidth < rightInvisibleWidth;
|
||||
const widthDelta = (shrinkLeft ? leftInvisibleWidth : rightInvisibleWidth);
|
||||
if (shrinkLeft) {
|
||||
const maxDelta = column.getWidth() - column.getMinWidth();
|
||||
this.desktop.adjustScroll(-Math.min(widthDelta, maxDelta), false);
|
||||
}
|
||||
column.adjustWidth(-widthDelta, true);
|
||||
}
|
||||
|
||||
public arrange(x: number) {
|
||||
public arrange(x: number, visibleRange: Range) {
|
||||
for (const column of this.columns.iterator()) {
|
||||
column.arrange(x);
|
||||
column.arrange(x, visibleRange, this.userResize);
|
||||
x += column.getWidth() + this.config.gapsInnerHorizontal;
|
||||
}
|
||||
|
||||
@@ -239,12 +172,12 @@ class Grid {
|
||||
this.columns.remove(column);
|
||||
this.columnsSetX(nextColumn);
|
||||
|
||||
this.desktop.onLayoutChanged();
|
||||
if (passFocus && columnToFocus !== null) {
|
||||
columnToFocus.focus();
|
||||
} else {
|
||||
this.desktop.autoAdjustScroll();
|
||||
}
|
||||
this.desktop.onLayoutChanged();
|
||||
}
|
||||
|
||||
public onColumnMoved(column: Column, prevColumn: Column|null) {
|
||||
@@ -256,13 +189,13 @@ class Grid {
|
||||
this.desktop.autoAdjustScroll();
|
||||
}
|
||||
|
||||
public onColumnWidthChanged(column: Column, oldWidth: number, width: number) {
|
||||
public onColumnWidthChanged(column: Column) {
|
||||
const nextColumn = this.columns.getNext(column);
|
||||
this.columnsSetX(nextColumn);
|
||||
this.desktop.onLayoutChanged();
|
||||
if (!this.userResize) {
|
||||
this.desktop.autoAdjustScroll();
|
||||
}
|
||||
this.desktop.onLayoutChanged();
|
||||
}
|
||||
|
||||
public onColumnFocused(column: Column) {
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
type LayoutConfig = {
|
||||
gapsInnerHorizontal: number,
|
||||
gapsInnerVertical: number,
|
||||
offScreenOpacity: number,
|
||||
stackColumnsByDefault: boolean,
|
||||
resizeNeighborColumn: boolean,
|
||||
reMaximize: boolean,
|
||||
skipSwitcher: boolean,
|
||||
tiledKeepBelow: boolean,
|
||||
maximizedKeepAbove: boolean,
|
||||
};
|
||||
|
||||
@@ -2,11 +2,16 @@ class Window {
|
||||
public column: Column;
|
||||
public readonly client: ClientWrapper;
|
||||
public height: number;
|
||||
public readonly focusedState: Window.State;
|
||||
private skipArrange: boolean;
|
||||
|
||||
constructor(client: ClientWrapper, column: Column) {
|
||||
this.client = client;
|
||||
this.height = client.kwinClient.frameGeometry.height;
|
||||
this.focusedState = {
|
||||
fullScreen: false,
|
||||
maximizedMode: MaximizedMode.Unmaximized,
|
||||
};
|
||||
this.skipArrange = false;
|
||||
this.column = column;
|
||||
column.onWindowAdded(this);
|
||||
@@ -26,7 +31,26 @@ class Window {
|
||||
// window is maximized, fullscreen, or being manually resized, prevent fighting with the user
|
||||
return;
|
||||
}
|
||||
this.client.place(x, y, width, height);
|
||||
|
||||
let maximized = false;
|
||||
if (this.column.grid.config.reMaximize && this.isFocused()) {
|
||||
// do this here rather than in `onFocused` to ensure it happens after placement
|
||||
// (otherwise placement may not happen at all)
|
||||
if (this.focusedState.maximizedMode > MaximizedMode.Unmaximized) {
|
||||
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;
|
||||
}
|
||||
if (this.focusedState.fullScreen) {
|
||||
this.client.setFullScreen(true);
|
||||
maximized = true;
|
||||
}
|
||||
}
|
||||
if (!maximized) {
|
||||
this.client.place(x, y, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
public focus() {
|
||||
@@ -54,20 +78,36 @@ class Window {
|
||||
this.column.grid.desktop.onLayoutChanged();
|
||||
}
|
||||
|
||||
public onMaximizedChanged(horizontally: boolean, vertically: boolean) {
|
||||
const maximized = horizontally || vertically;
|
||||
public onMaximizedChanged(maximizedMode: MaximizedMode) {
|
||||
const maximized = maximizedMode > MaximizedMode.Unmaximized;
|
||||
this.skipArrange = maximized;
|
||||
this.client.kwinClient.keepBelow = !maximized;
|
||||
if (this.column.grid.config.tiledKeepBelow) {
|
||||
this.client.kwinClient.keepBelow = !maximized;
|
||||
}
|
||||
if (this.column.grid.config.maximizedKeepAbove) {
|
||||
this.client.kwinClient.keepAbove = maximized;
|
||||
}
|
||||
if (this.isFocused()) {
|
||||
this.focusedState.maximizedMode = maximizedMode;
|
||||
}
|
||||
this.column.grid.desktop.onLayoutChanged();
|
||||
}
|
||||
|
||||
public onFullScreenChanged(fullScreen: boolean) {
|
||||
this.skipArrange = fullScreen;
|
||||
if (this.isFocused()) {
|
||||
if (this.column.grid.config.tiledKeepBelow) {
|
||||
this.client.kwinClient.keepBelow = !fullScreen;
|
||||
}
|
||||
if (this.column.grid.config.maximizedKeepAbove) {
|
||||
this.client.kwinClient.keepAbove = fullScreen;
|
||||
}
|
||||
if (this.isFocused()) {
|
||||
this.focusedState.fullScreen = fullScreen;
|
||||
}
|
||||
this.column.grid.desktop.onLayoutChanged();
|
||||
}
|
||||
|
||||
public onUserResize(oldGeometry: QRect, resizeNeighborColumn: boolean) {
|
||||
public onUserResize(oldGeometry: QmlRect, resizeNeighborColumn: boolean) {
|
||||
const newGeometry = this.client.kwinClient.frameGeometry;
|
||||
const widthDelta = newGeometry.width - oldGeometry.width;
|
||||
const heightDelta = newGeometry.height - oldGeometry.height;
|
||||
@@ -102,3 +142,10 @@ class Window {
|
||||
this.column.onWindowRemoved(this, passFocus);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Window {
|
||||
export type State = {
|
||||
fullScreen: boolean,
|
||||
maximizedMode: MaximizedMode,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
function init() {
|
||||
const config = loadConfig();
|
||||
const world = new World(config);
|
||||
registerKeyBindings(world, config);
|
||||
return world;
|
||||
return new World(loadConfig());
|
||||
}
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
class ClientMatcher {
|
||||
private readonly rules: Map<string, RegExp>;
|
||||
private readonly regex: RegExp;
|
||||
|
||||
constructor(rules: Map<string, RegExp>) {
|
||||
this.rules = rules;
|
||||
constructor(regex: RegExp) {
|
||||
this.regex = regex;
|
||||
}
|
||||
|
||||
public matches(kwinClient: TopLevel) {
|
||||
const rule = this.rules.get(kwinClient.resourceClass);
|
||||
if (rule === undefined) {
|
||||
return false;
|
||||
}
|
||||
return rule.test(kwinClient.caption);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
type WindowRule = {
|
||||
class: string,
|
||||
caption: string,
|
||||
class: string | undefined,
|
||||
caption: string | undefined,
|
||||
tile: boolean,
|
||||
};
|
||||
|
||||
@@ -1,24 +1,31 @@
|
||||
class WindowRuleEnforcer {
|
||||
private readonly preferFloating: ClientMatcher;
|
||||
private readonly preferTiling: ClientMatcher;
|
||||
private readonly followCaption: Set<string>;
|
||||
private readonly followCaption: RegExp;
|
||||
|
||||
constructor(windowRules: WindowRule[]) {
|
||||
const [mapFloat, mapTile] = createWindowRuleMaps(windowRules);
|
||||
this.preferFloating = new ClientMatcher(mapFloat);
|
||||
this.preferTiling = new ClientMatcher(mapTile);
|
||||
this.followCaption = new Set([...mapFloat.keys(), ...mapTile.keys()]);
|
||||
const [floatRegex, tileRegex, followCaptionRegex] = WindowRuleEnforcer.createWindowRuleRegexes(windowRules);
|
||||
log("floatRegex", floatRegex);
|
||||
log("tileRegex", tileRegex);
|
||||
log("followCaptionRegex", followCaptionRegex);
|
||||
this.preferFloating = new ClientMatcher(floatRegex);
|
||||
this.preferTiling = new ClientMatcher(tileRegex);
|
||||
this.followCaption = followCaptionRegex;
|
||||
}
|
||||
|
||||
public shouldTile(kwinClient: TopLevel) {
|
||||
public shouldTile(kwinClient: KwinClient) {
|
||||
return Clients.canTileNow(kwinClient) && (
|
||||
this.preferTiling.matches(kwinClient) ||
|
||||
kwinClient.normalWindow && kwinClient.managed && !this.preferFloating.matches(kwinClient)
|
||||
this.preferTiling.matches(kwinClient) || (
|
||||
kwinClient.normalWindow &&
|
||||
!kwinClient.transient &&
|
||||
kwinClient.managed &&
|
||||
!this.preferFloating.matches(kwinClient)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public initClientSignalManager(world: World, kwinClient: TopLevel) {
|
||||
if (!this.followCaption.has(kwinClient.resourceClass)) {
|
||||
public initClientSignalManager(world: World, kwinClient: KwinClient) {
|
||||
if (!this.followCaption.test(kwinClient.resourceClass)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -27,59 +34,61 @@ class WindowRuleEnforcer {
|
||||
manager.connect(kwinClient.captionChanged, () => {
|
||||
const shouldTile = enforcer.shouldTile(kwinClient);
|
||||
world.do((clientManager, desktopManager) => {
|
||||
if (shouldTile) {
|
||||
clientManager.tileClient(kwinClient);
|
||||
const desktop = desktopManager.getDesktopForClient(kwinClient);
|
||||
if (shouldTile && desktop !== undefined) {
|
||||
clientManager.tileKwinClient(kwinClient, desktop.grid);
|
||||
} else {
|
||||
clientManager.untileClient(kwinClient);
|
||||
clientManager.floatKwinClient(kwinClient);
|
||||
}
|
||||
});
|
||||
});
|
||||
return manager;
|
||||
}
|
||||
}
|
||||
|
||||
function 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);
|
||||
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(ruleClass, ruleCaption);
|
||||
|
||||
(windowRule.tile ? tileRegexes : floatRegexes).push(ruleString);
|
||||
if (ruleCaption !== ".*") {
|
||||
followCaptionRegexes.push(ruleClass);
|
||||
}
|
||||
}
|
||||
if (windowRule.caption !== undefined) {
|
||||
captions.push(windowRule.caption);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
createWindowRuleRegexMap(mapFloat),
|
||||
createWindowRuleRegexMap(mapTile),
|
||||
];
|
||||
}
|
||||
private static joinRegexes(regexes: string[]) {
|
||||
if (regexes.length === 0) {
|
||||
return new RegExp("a^"); // match nothing
|
||||
}
|
||||
|
||||
function createWindowRuleRegexMap(windowRuleMap: Map<string, string[]>) {
|
||||
const regexMap = new Map<string, RegExp>;
|
||||
for (const [k, v] of windowRuleMap) {
|
||||
regexMap.set(k, joinRegexes(v));
|
||||
}
|
||||
return regexMap;
|
||||
}
|
||||
if (regexes.length === 1) {
|
||||
return new RegExp("^" + regexes[0] + "$");
|
||||
}
|
||||
|
||||
function joinRegexes(regexes: string[]) {
|
||||
if (regexes.length == 0) {
|
||||
return new RegExp("");
|
||||
const joinedRegexes = regexes.map(WindowRuleEnforcer.wrapParens).join("|");
|
||||
return new RegExp("^" + joinedRegexes + "$");
|
||||
}
|
||||
|
||||
if (regexes.length == 1) {
|
||||
return new RegExp("^" + regexes[0] + "$");
|
||||
private static wrapParens(str: string) {
|
||||
return "(" + str + ")";
|
||||
}
|
||||
|
||||
const joinedRegexes = regexes.map(wrapParens).join("|");
|
||||
return new RegExp("^" + joinedRegexes + "$");
|
||||
}
|
||||
|
||||
function wrapParens(str: string) {
|
||||
return "(" + str + ")";
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Delayer {
|
||||
private readonly timer: QQmlTimer;
|
||||
private readonly timer: QmlTimer;
|
||||
|
||||
constructor(delay: number, f: () => void) {
|
||||
this.timer = initQmlTimer();
|
||||
@@ -18,7 +18,7 @@ class Delayer {
|
||||
|
||||
function initQmlTimer() {
|
||||
return Qt.createQmlObject(
|
||||
`import QtQuick 2.15
|
||||
`import QtQuick 6.0
|
||||
Timer {}`,
|
||||
qmlBase
|
||||
);
|
||||
|
||||
25
src/utils/ShortcutAction.ts
Normal file
25
src/utils/ShortcutAction.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
class ShortcutAction {
|
||||
private readonly shortcutHandler: ShortcutHandler;
|
||||
|
||||
constructor(keyBinding: KeyBinding, f: () => void) {
|
||||
this.shortcutHandler = ShortcutAction.initShortcutHandler(keyBinding);
|
||||
this.shortcutHandler.activated.connect(f);
|
||||
}
|
||||
|
||||
public destroy() {
|
||||
this.shortcutHandler.destroy();
|
||||
}
|
||||
|
||||
private static initShortcutHandler(keyBinding: KeyBinding) {
|
||||
return Qt.createQmlObject(
|
||||
`import QtQuick 6.0
|
||||
import org.kde.kwin 3.0
|
||||
ShortcutHandler {
|
||||
name: "karousel-${keyBinding.name}";
|
||||
text: "Karousel: ${keyBinding.description}";
|
||||
sequence: "${keyBinding.defaultKeySequence}";
|
||||
}`,
|
||||
qmlBase,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -7,3 +7,8 @@ function clamp(value: number, min: number, max: number) {
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function union<T>(array0: T[], array1: T[]) {
|
||||
const set = new Set([...array0, ...array1]);
|
||||
return [...set];
|
||||
}
|
||||
|
||||
@@ -1,49 +1,23 @@
|
||||
function initWorkspaceSignalHandlers(world: World) {
|
||||
const manager = new SignalManager();
|
||||
|
||||
manager.connect(workspace.clientAdded, (kwinClient: KwinClient) => {
|
||||
manager.connect(Workspace.windowAdded, (kwinClient: KwinClient) => {
|
||||
if (Clients.canTileEver(kwinClient)) {
|
||||
// never open new tileable clients on all desktops or activities
|
||||
if (kwinClient.desktop <= 0) {
|
||||
kwinClient.desktop = workspace.currentDesktop;
|
||||
}
|
||||
if (kwinClient.activities.length !== 1) {
|
||||
kwinClient.activities = [workspace.currentActivity];
|
||||
}
|
||||
Clients.makeTileable(kwinClient);
|
||||
}
|
||||
world.do((clientManager, desktopManager) => {
|
||||
clientManager.addClient(kwinClient)
|
||||
});
|
||||
});
|
||||
|
||||
manager.connect(workspace.clientRemoved, (kwinClient: AbstractClient) => {
|
||||
manager.connect(Workspace.windowRemoved, (kwinClient: KwinClient) => {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
clientManager.removeClient(kwinClient, true);
|
||||
});
|
||||
});
|
||||
|
||||
manager.connect(workspace.clientMinimized, (kwinClient: AbstractClient) => {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
clientManager.minimizeClient(kwinClient);
|
||||
});
|
||||
});
|
||||
|
||||
manager.connect(workspace.clientUnminimized, (kwinClient: AbstractClient) => {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
clientManager.unminimizeClient(kwinClient);
|
||||
});
|
||||
});
|
||||
|
||||
manager.connect(workspace.clientMaximizeSet, (kwinClient: AbstractClient, horizontally: boolean, vertically: boolean) => {
|
||||
if ((horizontally || vertically) && kwinClient.tile !== null) {
|
||||
kwinClient.tile = null;
|
||||
}
|
||||
world.doIfTiled(kwinClient, false, (world, desktopManager, window, column, grid) => {
|
||||
window.onMaximizedChanged(horizontally, vertically);
|
||||
});
|
||||
});
|
||||
|
||||
manager.connect(workspace.clientActivated, (kwinClient: AbstractClient) => {
|
||||
manager.connect(Workspace.windowActivated, (kwinClient: KwinClient) => {
|
||||
if (kwinClient === null) {
|
||||
return;
|
||||
}
|
||||
@@ -52,19 +26,27 @@ function initWorkspaceSignalHandlers(world: World) {
|
||||
});
|
||||
});
|
||||
|
||||
manager.connect(workspace.currentDesktopChanged, () => {
|
||||
manager.connect(Workspace.currentDesktopChanged, () => {
|
||||
world.do(() => {}); // re-arrange desktop
|
||||
});
|
||||
|
||||
manager.connect(workspace.currentActivityChanged, () => {
|
||||
manager.connect(Workspace.currentActivityChanged, () => {
|
||||
world.do(() => {}); // re-arrange desktop
|
||||
});
|
||||
|
||||
manager.connect(workspace.numberDesktopsChanged, (oldNumberOfVirtualDesktops: number) => {
|
||||
world.updateDesktops();
|
||||
manager.connect(Workspace.desktopsChanged, () => {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
desktopManager.updateDesktops();
|
||||
})
|
||||
});
|
||||
|
||||
manager.connect(workspace.virtualScreenSizeChanged, () => {
|
||||
manager.connect(Workspace.activitiesChanged, () => {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
desktopManager.updateActivities();
|
||||
})
|
||||
});
|
||||
|
||||
manager.connect(Workspace.virtualScreenSizeChanged, () => {
|
||||
world.onScreenResized();
|
||||
});
|
||||
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
class ClientManager {
|
||||
private readonly world: World;
|
||||
private readonly config: ClientManager.Config;
|
||||
private readonly desktopManager: DesktopManager;
|
||||
private readonly clientMap: Map<AbstractClient, ClientWrapper>;
|
||||
private lastFocusedClient: AbstractClient|null;
|
||||
private readonly pinManager: PinManager;
|
||||
private readonly clientMap: Map<KwinClient, ClientWrapper>;
|
||||
private lastFocusedClient: KwinClient|null;
|
||||
private readonly windowRuleEnforcer: WindowRuleEnforcer;
|
||||
|
||||
constructor(config: Config, world: World, desktopManager: DesktopManager) {
|
||||
constructor(config: Config, world: World, desktopManager: DesktopManager, pinManager: PinManager) {
|
||||
this.world = world;
|
||||
this.config = { keepAbove: config.floatingKeepAbove };
|
||||
this.desktopManager = desktopManager;
|
||||
this.pinManager = pinManager;
|
||||
this.clientMap = new Map();
|
||||
this.lastFocusedClient = null;
|
||||
|
||||
@@ -21,25 +25,29 @@ class ClientManager {
|
||||
this.windowRuleEnforcer = new WindowRuleEnforcer(parsedWindowRules);
|
||||
}
|
||||
|
||||
public addClient(kwinClient: TopLevel) {
|
||||
public addClient(kwinClient: KwinClient) {
|
||||
console.assert(!this.hasClient(kwinClient));
|
||||
const desktop = this.desktopManager.getDesktopForClient(kwinClient);
|
||||
|
||||
let constructState: (client: ClientWrapper) => ClientState.State;
|
||||
if (kwinClient.dock) {
|
||||
constructState = () => new ClientState.Docked(this.world, kwinClient);
|
||||
} else if (this.windowRuleEnforcer.shouldTile(kwinClient) && desktop !== undefined) {
|
||||
constructState = (client: ClientWrapper) => new ClientState.Tiled(this.world, client, desktop.grid);
|
||||
} else {
|
||||
constructState = (client: ClientWrapper) => new ClientState.Floating(this.world, client, this.config, false);
|
||||
}
|
||||
|
||||
const client = new ClientWrapper(
|
||||
kwinClient,
|
||||
new ClientState.Floating(null),
|
||||
constructState,
|
||||
this.findTransientFor(kwinClient),
|
||||
this.windowRuleEnforcer.initClientSignalManager(this.world, kwinClient),
|
||||
);
|
||||
this.clientMap.set(kwinClient, client);
|
||||
|
||||
if (kwinClient.dock) {
|
||||
client.stateManager.setState(() => new ClientState.Docked(this.world, kwinClient), false);
|
||||
} else if (this.windowRuleEnforcer.shouldTile(kwinClient)) {
|
||||
const grid = this.desktopManager.getDesktopForClient(client.kwinClient).grid;
|
||||
client.stateManager.setState(() => new ClientState.Tiled(this.world, client, grid), false);
|
||||
}
|
||||
}
|
||||
|
||||
public removeClient(kwinClient: AbstractClient, passFocus: boolean) {
|
||||
public removeClient(kwinClient: KwinClient, passFocus: boolean) {
|
||||
console.assert(this.hasClient(kwinClient));
|
||||
const client = this.clientMap.get(kwinClient);
|
||||
if (client === undefined) {
|
||||
@@ -49,7 +57,7 @@ class ClientManager {
|
||||
this.clientMap.delete(kwinClient);
|
||||
}
|
||||
|
||||
private findTransientFor(kwinClient: AbstractClient) {
|
||||
private findTransientFor(kwinClient: KwinClient) {
|
||||
if (!kwinClient.transient) {
|
||||
return null;
|
||||
}
|
||||
@@ -62,70 +70,98 @@ class ClientManager {
|
||||
return transientFor;
|
||||
}
|
||||
|
||||
public minimizeClient(kwinClient: AbstractClient) {
|
||||
public minimizeClient(kwinClient: KwinClient) {
|
||||
const client = this.clientMap.get(kwinClient);
|
||||
if (client === undefined) {
|
||||
return;
|
||||
}
|
||||
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: AbstractClient) {
|
||||
const client = this.clientMap.get(kwinClient);
|
||||
if (client === undefined) {
|
||||
return;
|
||||
}
|
||||
if (client.stateManager.getState() instanceof ClientState.TiledMinimized) {
|
||||
const grid = this.desktopManager.getDesktopForClient(client.kwinClient).grid;
|
||||
client.stateManager.setState(() => new ClientState.Tiled(this.world, client, grid), false);
|
||||
}
|
||||
}
|
||||
|
||||
public tileClient(kwinClient: AbstractClient) {
|
||||
const client = this.clientMap.get(kwinClient);
|
||||
if (client === undefined) {
|
||||
return;
|
||||
}
|
||||
public tileClient(client: ClientWrapper, grid: Grid) {
|
||||
if (client.stateManager.getState() instanceof ClientState.Tiled) {
|
||||
return;
|
||||
}
|
||||
const grid = this.desktopManager.getDesktopForClient(client.kwinClient).grid;
|
||||
client.stateManager.setState(() => new ClientState.Tiled(this.world, client, grid), false);
|
||||
}
|
||||
|
||||
public untileClient(kwinClient: AbstractClient) {
|
||||
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);
|
||||
if (client === undefined) {
|
||||
return;
|
||||
}
|
||||
if (client.stateManager.getState() instanceof ClientState.Tiled) {
|
||||
client.stateManager.setState(() => new ClientState.Floating(client), false);
|
||||
this.tileClient(client, grid);
|
||||
}
|
||||
|
||||
public floatKwinClient(kwinClient: KwinClient) {
|
||||
const client = this.clientMap.get(kwinClient);
|
||||
if (client === undefined) {
|
||||
return;
|
||||
}
|
||||
this.floatClient(client);
|
||||
}
|
||||
|
||||
public pinClient(kwinClient: KwinClient) {
|
||||
const client = this.clientMap.get(kwinClient);
|
||||
if (client === undefined) {
|
||||
return;
|
||||
}
|
||||
client.stateManager.setState(() => new ClientState.Pinned(this.world, this.pinManager, this.desktopManager, kwinClient, this.config), false);
|
||||
this.pinManager.addClient(kwinClient);
|
||||
for (const desktop of this.desktopManager.getDesktopsForClient(kwinClient)) {
|
||||
desktop.onPinsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public toggleFloatingClient(kwinClient: TopLevel) {
|
||||
public unpinClient(kwinClient: KwinClient) {
|
||||
const client = this.clientMap.get(kwinClient);
|
||||
if (client === undefined) {
|
||||
return;
|
||||
}
|
||||
console.assert(client.stateManager.getState() instanceof ClientState.Pinned);
|
||||
client.stateManager.setState(() => new ClientState.Floating(this.world, client, this.config, false), false);
|
||||
this.pinManager.removeClient(kwinClient);
|
||||
for (const desktop of this.desktopManager.getDesktopsForClient(kwinClient)) {
|
||||
desktop.onPinsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public toggleFloatingClient(kwinClient: KwinClient) {
|
||||
const client = this.clientMap.get(kwinClient);
|
||||
if (client === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
const clientState = client.stateManager.getState();
|
||||
if (clientState instanceof ClientState.Floating && Clients.canTileEver(kwinClient)) {
|
||||
if ((clientState instanceof ClientState.Floating || clientState instanceof ClientState.Pinned) && Clients.canTileEver(kwinClient)) {
|
||||
Clients.makeTileable(kwinClient);
|
||||
const grid = this.desktopManager.getDesktopForClient(client.kwinClient).grid;
|
||||
client.stateManager.setState(() => new ClientState.Tiled(this.world, client, grid), false);
|
||||
const desktop = this.desktopManager.getDesktopForClient(kwinClient);
|
||||
if (desktop === undefined) {
|
||||
return;
|
||||
}
|
||||
client.stateManager.setState(() => new ClientState.Tiled(this.world, client, desktop.grid), false);
|
||||
} else if (clientState instanceof ClientState.Tiled) {
|
||||
client.stateManager.setState(() => new ClientState.Floating(client), false);
|
||||
client.stateManager.setState(() => new ClientState.Floating(this.world, client, this.config, true), false);
|
||||
}
|
||||
}
|
||||
|
||||
public hasClient(kwinClient: AbstractClient) {
|
||||
public hasClient(kwinClient: KwinClient) {
|
||||
return this.clientMap.has(kwinClient);
|
||||
}
|
||||
|
||||
public onClientFocused(kwinClient: AbstractClient) {
|
||||
public onClientFocused(kwinClient: KwinClient) {
|
||||
this.lastFocusedClient = kwinClient;
|
||||
const window = this.findTiledWindow(kwinClient, true);
|
||||
if (window !== null) {
|
||||
@@ -133,7 +169,7 @@ class ClientManager {
|
||||
}
|
||||
}
|
||||
|
||||
public findTiledWindow(kwinClient: AbstractClient, followTransient: boolean) {
|
||||
public findTiledWindow(kwinClient: KwinClient, followTransient: boolean) {
|
||||
const client = this.clientMap.get(kwinClient);
|
||||
if (client === undefined) {
|
||||
return null;
|
||||
@@ -163,3 +199,9 @@ class ClientManager {
|
||||
this.removeAllClients();
|
||||
}
|
||||
}
|
||||
|
||||
namespace ClientManager {
|
||||
export type Config = {
|
||||
keepAbove: boolean,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
class ClientWrapper {
|
||||
public readonly kwinClient: TopLevel;
|
||||
public readonly kwinClient: KwinClient;
|
||||
public readonly stateManager: ClientState.Manager;
|
||||
public transientFor: ClientWrapper | null;
|
||||
private readonly transients: ClientWrapper[];
|
||||
private readonly signalManager: SignalManager;
|
||||
private readonly rulesSignalManager: SignalManager | null;
|
||||
public preferredWidth: number;
|
||||
private maximizedMode: MaximizedMode | undefined;
|
||||
private readonly manipulatingGeometry: Doer;
|
||||
private lastPlacement: QmlRect | null; // workaround for issue #19
|
||||
|
||||
constructor(
|
||||
kwinClient: TopLevel,
|
||||
initialState: ClientState.State,
|
||||
kwinClient: KwinClient,
|
||||
constructInitialState: (client: ClientWrapper) => ClientState.State,
|
||||
transientFor: ClientWrapper | null,
|
||||
rulesSignalManager: SignalManager | null,
|
||||
) {
|
||||
this.kwinClient = kwinClient;
|
||||
this.stateManager = new ClientState.Manager(initialState);
|
||||
this.transientFor = transientFor;
|
||||
this.transients = [];
|
||||
if (transientFor !== null) {
|
||||
@@ -25,6 +26,8 @@ class ClientWrapper {
|
||||
this.rulesSignalManager = rulesSignalManager;
|
||||
this.preferredWidth = kwinClient.frameGeometry.width;
|
||||
this.manipulatingGeometry = new Doer();
|
||||
this.lastPlacement = null;
|
||||
this.stateManager = new ClientState.Manager(constructInitialState(this));
|
||||
}
|
||||
|
||||
public place(x: number, y: number, width: number, height: number) {
|
||||
@@ -33,14 +36,20 @@ class ClientWrapper {
|
||||
// window is being manually resized, prevent fighting with the user
|
||||
return;
|
||||
}
|
||||
this.kwinClient.frameGeometry = Qt.rect(x, y, width, height);
|
||||
this.lastPlacement = Qt.rect(x, y, width, height);
|
||||
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) {
|
||||
// TODO: prevent moving off the grid
|
||||
private moveTransient(dx: number, dy: number, kwinDesktops: KwinDesktop[]) {
|
||||
if (this.stateManager.getState() instanceof ClientState.Floating) {
|
||||
if (this.kwinClient.desktop === desktopNumber) {
|
||||
if (Clients.isOnOneOfVirtualDesktops(this.kwinClient, kwinDesktops)) {
|
||||
const frame = this.kwinClient.frameGeometry;
|
||||
this.kwinClient.frameGeometry = Qt.rect(
|
||||
frame.x + dx,
|
||||
@@ -51,26 +60,52 @@ class ClientWrapper {
|
||||
}
|
||||
|
||||
for (const transient of this.transients) {
|
||||
transient.moveTransient(dx, dy, desktopNumber);
|
||||
transient.moveTransient(dx, dy, kwinDesktops);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public moveTransients(dx: number, dy: number) {
|
||||
for (const transient of this.transients) {
|
||||
transient.moveTransient(dx, dy, this.kwinClient.desktops);
|
||||
}
|
||||
}
|
||||
|
||||
public focus() {
|
||||
workspace.activeClient = this.kwinClient;
|
||||
Workspace.activeWindow = this.kwinClient;
|
||||
}
|
||||
|
||||
public isFocused() {
|
||||
return workspace.activeClient === this.kwinClient;
|
||||
return Workspace.activeWindow === this.kwinClient;
|
||||
}
|
||||
|
||||
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.kwinClient.setMaximize(vertically, horizontally);
|
||||
});
|
||||
}
|
||||
|
||||
public setFullScreen(fullScreen: boolean) {
|
||||
if (!this.kwinClient.fullScreenable) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.manipulatingGeometry.do(() => {
|
||||
this.kwinClient.fullScreen = fullScreen;
|
||||
});
|
||||
@@ -86,41 +121,17 @@ class ClientWrapper {
|
||||
return this.kwinClient.shade;
|
||||
}
|
||||
|
||||
public isManipulatingGeometry() {
|
||||
public getMaximizedMode() {
|
||||
return this.maximizedMode;
|
||||
}
|
||||
|
||||
public isManipulatingGeometry(newGeometry: QmlRect | null) {
|
||||
if (newGeometry !== null && newGeometry === this.lastPlacement) {
|
||||
return true;
|
||||
}
|
||||
return this.manipulatingGeometry.isDoing();
|
||||
}
|
||||
|
||||
public prepareForTiling() {
|
||||
this.kwinClient.keepBelow = true;
|
||||
this.setFullScreen(false);
|
||||
if (this.kwinClient.tile !== null) {
|
||||
this.setMaximize(false, true); // disable quick tile mode
|
||||
}
|
||||
this.setMaximize(false, false);
|
||||
}
|
||||
|
||||
public restoreAfterTiling(screenSize: QRect) {
|
||||
this.kwinClient.keepBelow = false;
|
||||
this.setShade(false);
|
||||
this.setFullScreen(false);
|
||||
if (this.kwinClient.tile === null) {
|
||||
this.setMaximize(false, false);
|
||||
}
|
||||
this.ensureVisible(screenSize);
|
||||
}
|
||||
|
||||
public prepareForFloating() {
|
||||
const placementArea = workspace.clientArea(ClientAreaOption.PlacementArea, this.kwinClient.screen, this.kwinClient.desktop);
|
||||
const clientRect = this.kwinClient.frameGeometry;
|
||||
const width = this.preferredWidth;
|
||||
this.place(
|
||||
clientRect.x,
|
||||
clientRect.y,
|
||||
width,
|
||||
Math.min(clientRect.height, Math.round(placementArea.height / 2)),
|
||||
);
|
||||
}
|
||||
|
||||
private addTransient(transient: ClientWrapper) {
|
||||
this.transients.push(transient);
|
||||
}
|
||||
@@ -130,7 +141,7 @@ class ClientWrapper {
|
||||
this.transients.splice(i, 1);
|
||||
}
|
||||
|
||||
public ensureTransientsVisible(screenSize: QRect) {
|
||||
public ensureTransientsVisible(screenSize: QmlRect) {
|
||||
for (const transient of this.transients) {
|
||||
if (transient.stateManager.getState() instanceof ClientState.Floating) {
|
||||
transient.ensureVisible(screenSize);
|
||||
@@ -139,15 +150,15 @@ class ClientWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
public ensureVisible(screenSize: QRect) {
|
||||
if (this.kwinClient.desktop !== workspace.currentDesktop) {
|
||||
public ensureVisible(screenSize: QmlRect) {
|
||||
if (!Clients.isOnVirtualDesktop(this.kwinClient, Workspace.currentDesktop)) {
|
||||
return;
|
||||
}
|
||||
const frame = this.kwinClient.frameGeometry;
|
||||
if (frame.left < 0) {
|
||||
frame.x = 0;
|
||||
} else if (frame.right > screenSize.width) {
|
||||
frame.x = screenSize.width - frame.width;
|
||||
if (frame.left < screenSize.left) {
|
||||
frame.x = screenSize.left;
|
||||
} else if (frame.right > screenSize.right) {
|
||||
frame.x = screenSize.right - frame.width;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,20 +178,14 @@ class ClientWrapper {
|
||||
|
||||
private static initSignalManager(client: ClientWrapper) {
|
||||
const manager = new SignalManager();
|
||||
manager.connect(client.kwinClient.frameGeometryChanged, (kwinClient: TopLevel, oldGeometry: QRect) => {
|
||||
if (client.stateManager.getState() instanceof ClientState.Tiled) {
|
||||
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);
|
||||
for (const transient of client.transients) {
|
||||
transient.moveTransient(dx, dy, client.kwinClient.desktop);
|
||||
}
|
||||
|
||||
manager.connect(client.kwinClient.maximizedAboutToChange, (maximizedMode: MaximizedMode) => {
|
||||
if (maximizedMode > MaximizedMode.Unmaximized && client.kwinClient.tile !== null) {
|
||||
client.kwinClient.tile = null;
|
||||
}
|
||||
client.maximizedMode = maximizedMode;
|
||||
});
|
||||
|
||||
return manager;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,49 @@
|
||||
namespace Clients {
|
||||
export function canTileEver(kwinClient: AbstractClient) {
|
||||
return kwinClient.resizeable;
|
||||
export function canTileEver(kwinClient: KwinClient) {
|
||||
return kwinClient.moveable && kwinClient.resizeable && !kwinClient.popupWindow;
|
||||
}
|
||||
|
||||
export function canTileNow(kwinClient: TopLevel) {
|
||||
return canTileEver(kwinClient) && !kwinClient.minimized && kwinClient.desktop > 0 && kwinClient.activities.length === 1;
|
||||
export function canTileNow(kwinClient: KwinClient) {
|
||||
return canTileEver(kwinClient) && !kwinClient.minimized && kwinClient.desktops.length === 1 && kwinClient.activities.length === 1;
|
||||
}
|
||||
|
||||
export function makeTileable(kwinClient: TopLevel) {
|
||||
export function makeTileable(kwinClient: KwinClient) {
|
||||
if (kwinClient.minimized) {
|
||||
kwinClient.minimized = false;
|
||||
}
|
||||
if (kwinClient.desktop <= 0) {
|
||||
kwinClient.desktop = workspace.currentDesktop;
|
||||
if (kwinClient.desktops.length !== 1) {
|
||||
kwinClient.desktops = [Workspace.currentDesktop];
|
||||
}
|
||||
if (kwinClient.activities.length !== 1) {
|
||||
kwinClient.activities = [workspace.currentActivity];
|
||||
kwinClient.activities = [Workspace.currentActivity];
|
||||
}
|
||||
}
|
||||
|
||||
export function isMaximizedGeometry(kwinClient: TopLevel) {
|
||||
const maximizeArea = workspace.clientArea(ClientAreaOption.MaximizeArea, kwinClient.screen, kwinClient.desktop);
|
||||
return kwinClient.frameGeometry === maximizeArea;
|
||||
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: TopLevel) {
|
||||
const fullScreenArea = workspace.clientArea(ClientAreaOption.FullScreenArea, kwinClient.screen, kwinClient.desktop);
|
||||
export function isFullScreenGeometry(kwinClient: KwinClient) {
|
||||
const fullScreenArea = Workspace.clientArea(ClientAreaOption.FullScreenArea, kwinClient.output, getKwinDesktopApprox(kwinClient));
|
||||
return kwinClient.frameGeometry === fullScreenArea;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,105 +1,126 @@
|
||||
class DesktopManager {
|
||||
private readonly pinManager: PinManager;
|
||||
private readonly config: Desktop.Config;
|
||||
public readonly layoutConfig: LayoutConfig;
|
||||
private readonly desktopsPerActivity: Map<string, Desktop[]>;
|
||||
private nVirtualDesktops: number;
|
||||
private readonly desktops: Map<string, Desktop>; // key is activityId|desktopId
|
||||
private kwinActivities: Set<string>;
|
||||
private kwinDesktops: Set<KwinDesktop>;
|
||||
|
||||
constructor(config: Desktop.Config, layoutConfig: LayoutConfig, currentActivity: string) {
|
||||
constructor(pinManager: PinManager, config: Desktop.Config, layoutConfig: LayoutConfig, currentActivity: string, currentDesktop: KwinDesktop) {
|
||||
this.pinManager = pinManager;
|
||||
this.config = config;
|
||||
this.layoutConfig = layoutConfig;
|
||||
this.desktopsPerActivity = new Map();
|
||||
this.nVirtualDesktops = 0;
|
||||
this.update()
|
||||
this.addActivity(currentActivity);
|
||||
this.desktops = new Map();
|
||||
this.kwinActivities = new Set(Workspace.activities);
|
||||
this.kwinDesktops = new Set(Workspace.desktops);
|
||||
this.addDesktop(currentActivity, currentDesktop);
|
||||
}
|
||||
|
||||
public update() {
|
||||
this.setNVirtualDesktops(workspace.desktops);
|
||||
}
|
||||
|
||||
public getDesktop(activity: string, desktopNumber: number) {
|
||||
const desktopIndex = desktopNumber - 1;
|
||||
if (desktopIndex >= this.nVirtualDesktops || desktopIndex < 0) {
|
||||
throw new Error("invalid desktop number: " + String(desktopNumber));
|
||||
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);
|
||||
}
|
||||
if (!this.desktopsPerActivity.has(activity)) {
|
||||
this.addActivity(activity);
|
||||
}
|
||||
return this.desktopsPerActivity.get(activity)![desktopIndex];
|
||||
}
|
||||
|
||||
public getCurrentDesktop() {
|
||||
return this.getDesktop(workspace.currentActivity, workspace.currentDesktop);
|
||||
return this.getDesktop(Workspace.currentActivity, Workspace.currentDesktop);
|
||||
}
|
||||
|
||||
public getDesktopInCurrentActivity(desktopNumber: number) {
|
||||
return this.getDesktop(workspace.currentActivity, desktopNumber);
|
||||
public getDesktopInCurrentActivity(kwinDesktop: KwinDesktop) {
|
||||
return this.getDesktop(Workspace.currentActivity, kwinDesktop);
|
||||
}
|
||||
|
||||
public getDesktopForClient(kwinClient: TopLevel) {
|
||||
console.assert(kwinClient.activities.length === 1);
|
||||
return this.getDesktop(kwinClient.activities[0], kwinClient.desktop);
|
||||
}
|
||||
|
||||
private setNVirtualDesktops(nVirtualDesktops: number) {
|
||||
if (nVirtualDesktops > this.nVirtualDesktops) {
|
||||
this.addDesktopsToActivities(nVirtualDesktops - this.nVirtualDesktops);
|
||||
} else if (nVirtualDesktops < this.nVirtualDesktops) {
|
||||
this.removeDesktopsFromActivities(this.nVirtualDesktops - nVirtualDesktops);
|
||||
public getDesktopForClient(kwinClient: KwinClient) {
|
||||
if (kwinClient.activities.length !== 1 || kwinClient.desktops.length !== 1) {
|
||||
return undefined;
|
||||
}
|
||||
this.nVirtualDesktops = nVirtualDesktops;
|
||||
return this.getDesktop(kwinClient.activities[0], kwinClient.desktops[0]);
|
||||
}
|
||||
|
||||
private addDesktopsToActivities(n: number) {
|
||||
for (const desktops of this.desktopsPerActivity.values()) {
|
||||
this.addDesktops(desktops, n);
|
||||
}
|
||||
private addDesktop(activity: string, kwinDesktop: KwinDesktop) {
|
||||
const desktopKey = DesktopManager.getDesktopKey(activity, kwinDesktop);
|
||||
const desktop = new Desktop(kwinDesktop, this.pinManager, this.config, this.layoutConfig);
|
||||
this.desktops.set(desktopKey, desktop);
|
||||
return desktop;
|
||||
}
|
||||
|
||||
private addDesktops(desktops: Desktop[], n: number) {
|
||||
const nStart = desktops.length;
|
||||
for (let i = 0; i < n; i++) {
|
||||
const desktopNumber = nStart + i + 1;
|
||||
desktops.push(new Desktop(desktopNumber, this.config, this.layoutConfig));
|
||||
}
|
||||
private static getDesktopKey(activity: string, kwinDesktop: KwinDesktop) {
|
||||
return activity + "|" + kwinDesktop.id;
|
||||
}
|
||||
|
||||
private removeDesktopsFromActivities(n: number) {
|
||||
const lastRemainingDesktopIndex = this.nVirtualDesktops - n - 1;
|
||||
for (const desktops of this.desktopsPerActivity.values()) {
|
||||
const targetDesktop = desktops[lastRemainingDesktopIndex];
|
||||
for (let i = 0; i < n; i++) {
|
||||
const removedDesktop = desktops.pop()!;
|
||||
removedDesktop.grid.evacuate(targetDesktop.grid);
|
||||
public updateActivities() {
|
||||
const newActivities = new Set(Workspace.activities);
|
||||
for (const activity of this.kwinActivities) {
|
||||
if (!newActivities.has(activity)) {
|
||||
this.removeActivity(activity);
|
||||
}
|
||||
}
|
||||
this.kwinActivities = newActivities;
|
||||
}
|
||||
|
||||
private addActivity(activity: string) {
|
||||
const desktops: Desktop[] = [];
|
||||
this.addDesktops(desktops, this.nVirtualDesktops);
|
||||
this.desktopsPerActivity.set(activity, desktops);
|
||||
public updateDesktops() {
|
||||
const newDesktops = new Set(Workspace.desktops);
|
||||
for (const desktop of this.kwinDesktops) {
|
||||
if (!newDesktops.has(desktop)) {
|
||||
this.removeKwinDesktop(desktop);
|
||||
}
|
||||
}
|
||||
this.kwinDesktops = newDesktops;
|
||||
}
|
||||
|
||||
private removeActivity(activity: string) {
|
||||
const removedDesktops = this.desktopsPerActivity.get(activity)!;
|
||||
this.desktopsPerActivity.delete(activity);
|
||||
const targetActivityDesktops = this.desktopsPerActivity.values().next().value;
|
||||
for (let i = 0; i < removedDesktops.length; i++) {
|
||||
removedDesktops[i].grid.evacuate(targetActivityDesktops[i]);
|
||||
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()) {
|
||||
for (const desktop of this.desktops.values()) {
|
||||
desktop.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
public *desktops() {
|
||||
for (const desktops of this.desktopsPerActivity.values()) {
|
||||
for (const desktop of desktops) {
|
||||
yield desktop;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
86
src/world/PinManager.ts
Normal file
86
src/world/PinManager.ts
Normal file
@@ -0,0 +1,86 @@
|
||||
class PinManager {
|
||||
private readonly pinnedClients: Set<KwinClient>;
|
||||
|
||||
constructor() {
|
||||
this.pinnedClients = new Set();
|
||||
}
|
||||
|
||||
public addClient(kwinClient: KwinClient) {
|
||||
this.pinnedClients.add(kwinClient);
|
||||
}
|
||||
|
||||
public removeClient(kwinClient: KwinClient) {
|
||||
this.pinnedClients.delete(kwinClient);
|
||||
}
|
||||
|
||||
public getAvailableSpace(kwinDesktop: KwinDesktop, screen: QmlRect) {
|
||||
const baseLot = new PinManager.Lot(screen.top, screen.bottom, screen.left, screen.right);
|
||||
let lots = [baseLot];
|
||||
for (const client of this.pinnedClients) {
|
||||
if (!Clients.isOnVirtualDesktop(client, kwinDesktop)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const newLots: PinManager.Lot[] = [];
|
||||
for (const lot of lots) {
|
||||
lot.split(newLots, client.frameGeometry);
|
||||
}
|
||||
lots = newLots;
|
||||
}
|
||||
|
||||
let largestLot = baseLot;
|
||||
let largestArea = 0;
|
||||
for (const lot of lots) {
|
||||
const area = lot.area();
|
||||
if (area > largestArea) {
|
||||
largestArea = area;
|
||||
largestLot = lot;
|
||||
}
|
||||
}
|
||||
return largestLot;
|
||||
}
|
||||
}
|
||||
|
||||
namespace PinManager {
|
||||
export class Lot {
|
||||
private static readonly minWidth = 200;
|
||||
private static readonly minHeight = 200;
|
||||
|
||||
constructor(
|
||||
public readonly top: number,
|
||||
public readonly bottom: number,
|
||||
public readonly left: number,
|
||||
public readonly right: number,
|
||||
) {}
|
||||
|
||||
public split(destLots: Lot[], obstacle: QmlRect) {
|
||||
if (!this.contains(obstacle)) {
|
||||
// don't split
|
||||
destLots.push(this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (obstacle.top - this.top >= Lot.minHeight) {
|
||||
destLots.push(new Lot(this.top, obstacle.top, this.left, this.right));
|
||||
}
|
||||
if (this.bottom - obstacle.bottom >= Lot.minHeight) {
|
||||
destLots.push(new Lot(obstacle.bottom, this.bottom, this.left, this.right));
|
||||
}
|
||||
if (obstacle.left - this.left >= Lot.minWidth) {
|
||||
destLots.push(new Lot(this.top, this.bottom, this.left, obstacle.left));
|
||||
}
|
||||
if (this.right - obstacle.right >= Lot.minWidth) {
|
||||
destLots.push(new Lot(this.top, this.bottom, obstacle.right, this.right));
|
||||
}
|
||||
}
|
||||
|
||||
private contains(obstacle: QmlRect) {
|
||||
return obstacle.right > this.left && obstacle.left < this.right &&
|
||||
obstacle.bottom > this.top && obstacle.top < this.bottom;
|
||||
}
|
||||
|
||||
public area() {
|
||||
return (this.bottom - this.top) * (this.right - this.left);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,50 +2,72 @@ class World {
|
||||
public readonly untileOnDrag: boolean;
|
||||
private readonly desktopManager: DesktopManager;
|
||||
public readonly clientManager: ClientManager;
|
||||
private readonly pinManager: PinManager;
|
||||
private readonly workspaceSignalManager: SignalManager;
|
||||
private readonly shortcutActions: ShortcutAction[];
|
||||
private readonly screenResizedDelayer: Delayer;
|
||||
|
||||
constructor(config: Config) {
|
||||
this.untileOnDrag = config.untileOnDrag;
|
||||
this.workspaceSignalManager = initWorkspaceSignalHandlers(this);
|
||||
this.shortcutActions = registerKeyBindings(this, {
|
||||
manualScrollStep: config.manualScrollStep,
|
||||
manualResizeStep: config.manualResizeStep,
|
||||
columnResizer: config.scrollingCentered ? new RawResizer() : new ContextualResizer(),
|
||||
});
|
||||
|
||||
this.screenResizedDelayer = new Delayer(1000, () => {
|
||||
// this delay ensures that docks get taken into account by `workspace.clientArea`
|
||||
const desktopManager = this.desktopManager; // workaround for bug in Qt5's JS engine
|
||||
for (const desktop of desktopManager.desktops()) {
|
||||
// this delay ensures that docks are taken into account by `Workspace.clientArea`
|
||||
for (const desktop of this.desktopManager.getAllDesktops()) {
|
||||
desktop.onLayoutChanged();
|
||||
}
|
||||
this.update();
|
||||
});
|
||||
|
||||
this.pinManager = new PinManager();
|
||||
|
||||
const layoutConfig = {
|
||||
gapsInnerHorizontal: config.gapsInnerHorizontal,
|
||||
gapsInnerVertical: config.gapsInnerVertical,
|
||||
offScreenOpacity: config.offScreenOpacity / 100.0,
|
||||
stackColumnsByDefault: config.stackColumnsByDefault,
|
||||
resizeNeighborColumn: config.resizeNeighborColumn,
|
||||
reMaximize: config.reMaximize,
|
||||
skipSwitcher: config.skipSwitcher,
|
||||
tiledKeepBelow: config.tiledKeepBelow,
|
||||
maximizedKeepAbove: config.floatingKeepAbove,
|
||||
};
|
||||
|
||||
this.desktopManager = new DesktopManager(
|
||||
this.pinManager,
|
||||
{
|
||||
marginTop: config.gapsOuterTop,
|
||||
marginBottom: config.gapsOuterBottom,
|
||||
marginLeft: config.gapsOuterLeft,
|
||||
marginRight: config.gapsOuterRight,
|
||||
overscroll: config.overscroll,
|
||||
scroller: config.scrollingLazy ? new LazyScroller() :
|
||||
config.scrollingCentered ? new CenteredScroller() :
|
||||
config.scrollingGrouped ? new GroupedScroller() :
|
||||
console.assert(false),
|
||||
clamper: config.scrollingLazy ? new EdgeClamper() : new CenterClamper(),
|
||||
},
|
||||
config,
|
||||
workspace.currentActivity,
|
||||
layoutConfig,
|
||||
Workspace.currentActivity,
|
||||
Workspace.currentDesktop,
|
||||
);
|
||||
this.clientManager = new ClientManager(config, this, this.desktopManager);
|
||||
this.clientManager = new ClientManager(config, this, this.desktopManager, this.pinManager);
|
||||
this.addExistingClients();
|
||||
this.update();
|
||||
}
|
||||
|
||||
private addExistingClients() {
|
||||
const kwinClients = workspace.clientList();
|
||||
const kwinClients = Workspace.windows;
|
||||
for (let i = 0; i < kwinClients.length; i++) {
|
||||
const kwinClient = kwinClients[i];
|
||||
this.clientManager.addClient(kwinClient);
|
||||
}
|
||||
}
|
||||
|
||||
public updateDesktops() {
|
||||
this.desktopManager.update();
|
||||
}
|
||||
|
||||
private update() {
|
||||
this.desktopManager.getCurrentDesktop().arrange();
|
||||
}
|
||||
@@ -56,7 +78,7 @@ class World {
|
||||
}
|
||||
|
||||
public doIfTiled(
|
||||
kwinClient: AbstractClient,
|
||||
kwinClient: KwinClient,
|
||||
followTransient: boolean,
|
||||
f: (clientManager: ClientManager, desktopManager: DesktopManager, window: Window, column: Column, grid: Grid) => void,
|
||||
) {
|
||||
@@ -74,11 +96,14 @@ class World {
|
||||
followTransient: boolean,
|
||||
f: (clientManager: ClientManager, desktopManager: DesktopManager, window: Window, column: Column, grid: Grid) => void,
|
||||
) {
|
||||
this.doIfTiled(workspace.activeClient, followTransient, f);
|
||||
this.doIfTiled(Workspace.activeWindow, followTransient, f);
|
||||
}
|
||||
|
||||
public destroy() {
|
||||
this.workspaceSignalManager.destroy();
|
||||
for (const shortcutAction of this.shortcutActions) {
|
||||
shortcutAction.destroy();
|
||||
}
|
||||
this.clientManager.destroy();
|
||||
this.desktopManager.destroy();
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ namespace ClientState {
|
||||
private readonly world: World;
|
||||
private readonly signalManager: SignalManager;
|
||||
|
||||
constructor(world: World, kwinClient: TopLevel) {
|
||||
constructor(world: World, kwinClient: KwinClient) {
|
||||
this.world = world;
|
||||
this.signalManager = Docked.initSignalManager(world, kwinClient);
|
||||
world.onScreenResized();
|
||||
@@ -14,9 +14,9 @@ namespace ClientState {
|
||||
this.world.onScreenResized();
|
||||
}
|
||||
|
||||
private static initSignalManager(world: World, kwinClient: TopLevel) {
|
||||
private static initSignalManager(world: World, kwinClient: KwinClient) {
|
||||
const manager = new SignalManager();
|
||||
manager.connect(kwinClient.frameGeometryChanged, (kwinClient: TopLevel, oldGeometry: QRect) => {
|
||||
manager.connect(kwinClient.frameGeometryChanged, () => {
|
||||
world.onScreenResized();
|
||||
});
|
||||
return manager;
|
||||
|
||||
@@ -1,11 +1,66 @@
|
||||
namespace ClientState {
|
||||
export class Floating implements State {
|
||||
constructor(client: ClientWrapper | null) {
|
||||
if (client !== null && client.kwinClient.tile === null) {
|
||||
client.prepareForFloating();
|
||||
private readonly client: ClientWrapper;
|
||||
private readonly config: ClientManager.Config;
|
||||
private readonly signalManager: SignalManager;
|
||||
|
||||
constructor(world: World, client: ClientWrapper, config: ClientManager.Config, limitHeight: boolean) {
|
||||
this.client = client;
|
||||
this.config = config;
|
||||
if (config.keepAbove) {
|
||||
client.kwinClient.keepAbove = true;
|
||||
}
|
||||
if (limitHeight && client.kwinClient.tile === null) {
|
||||
Floating.limitHeight(client);
|
||||
}
|
||||
this.signalManager = Floating.initSignalManager(world, client.kwinClient);
|
||||
}
|
||||
|
||||
public destroy(passFocus: boolean) {
|
||||
this.signalManager.destroy();
|
||||
if (this.config.keepAbove) {
|
||||
this.client.kwinClient.keepAbove = false;
|
||||
}
|
||||
}
|
||||
|
||||
public destroy(passFocus: boolean) {}
|
||||
private static limitHeight(client: ClientWrapper) {
|
||||
const placementArea = Workspace.clientArea(
|
||||
ClientAreaOption.PlacementArea,
|
||||
client.kwinClient.output,
|
||||
Clients.getKwinDesktopApprox(client.kwinClient),
|
||||
);
|
||||
const clientRect = client.kwinClient.frameGeometry;
|
||||
const width = client.preferredWidth;
|
||||
client.place(
|
||||
clientRect.x,
|
||||
clientRect.y,
|
||||
width,
|
||||
Math.min(clientRect.height, Math.round(placementArea.height / 2)),
|
||||
);
|
||||
}
|
||||
|
||||
private static initSignalManager(world: World, kwinClient: KwinClient) {
|
||||
const manager = new SignalManager();
|
||||
|
||||
manager.connect(kwinClient.tileChanged, () => {
|
||||
// on X11, this fires after `frameGeometryChanged`
|
||||
if (kwinClient.tile !== null) {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
clientManager.pinClient(kwinClient);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
manager.connect(kwinClient.frameGeometryChanged, () => {
|
||||
// on Wayland, this fires after `tileChanged`
|
||||
if (kwinClient.tile !== null) {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
clientManager.pinClient(kwinClient);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return manager;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,6 @@ namespace ClientState {
|
||||
}
|
||||
|
||||
export type State = {
|
||||
destroy(passFocus: boolean): void;
|
||||
destroy(passFocus: boolean): void,
|
||||
};
|
||||
}
|
||||
|
||||
86
src/world/clientState/Pinned.ts
Normal file
86
src/world/clientState/Pinned.ts
Normal file
@@ -0,0 +1,86 @@
|
||||
namespace ClientState {
|
||||
export class Pinned implements State {
|
||||
private readonly kwinClient: KwinClient;
|
||||
private readonly pinManager: PinManager;
|
||||
private readonly desktopManager: DesktopManager;
|
||||
private readonly config: ClientManager.Config;
|
||||
private readonly signalManager: SignalManager;
|
||||
|
||||
constructor(world: World, pinManager: PinManager, desktopManager: DesktopManager, kwinClient: KwinClient, config: ClientManager.Config) {
|
||||
this.kwinClient = kwinClient;
|
||||
this.pinManager = pinManager;
|
||||
this.desktopManager = desktopManager;
|
||||
this.config = config;
|
||||
if (config.keepAbove) {
|
||||
kwinClient.keepAbove = true;
|
||||
}
|
||||
this.signalManager = Pinned.initSignalManager(world, pinManager, kwinClient);
|
||||
}
|
||||
|
||||
public destroy(passFocus: boolean) {
|
||||
this.signalManager.destroy();
|
||||
if (this.config.keepAbove) {
|
||||
this.kwinClient.keepAbove = true;
|
||||
}
|
||||
this.pinManager.removeClient(this.kwinClient);
|
||||
for (const desktop of this.desktopManager.getDesktopsForClient(this.kwinClient)) {
|
||||
desktop.onPinsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private static initSignalManager(world: World, pinManager: PinManager, kwinClient: KwinClient) {
|
||||
const manager = new SignalManager();
|
||||
let oldActivities = kwinClient.activities;
|
||||
let oldDesktops = kwinClient.desktops;
|
||||
|
||||
manager.connect(kwinClient.tileChanged, () => {
|
||||
if (kwinClient.tile === null) {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
clientManager.unpinClient(kwinClient);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
manager.connect(kwinClient.frameGeometryChanged, () => {
|
||||
if (kwinClient.tile === null) {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
clientManager.unpinClient(kwinClient);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
world.do((clientManager, desktopManager) => {
|
||||
for (const desktop of desktopManager.getDesktopsForClient(kwinClient)) {
|
||||
desktop.onPinsChanged();
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
manager.connect(kwinClient.desktopsChanged, () => {
|
||||
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 ?
|
||||
[] :
|
||||
union(oldActivities, kwinClient.activities);
|
||||
world.do((clientManager, desktopManager) => {
|
||||
for (const desktop of desktopManager.getDesktops(changedActivities, kwinClient.desktops)) {
|
||||
desktop.onPinsChanged();
|
||||
}
|
||||
});
|
||||
oldActivities = kwinClient.activities;
|
||||
});
|
||||
|
||||
return manager;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
namespace ClientState {
|
||||
export class Tiled implements State {
|
||||
public readonly window: Window;
|
||||
private readonly defaultState: Tiled.WindowState;
|
||||
private readonly signalManager: SignalManager;
|
||||
|
||||
constructor(world: World, client: ClientWrapper, grid: Grid) {
|
||||
client.prepareForTiling();
|
||||
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);
|
||||
@@ -21,7 +23,7 @@ namespace ClientState {
|
||||
const client = window.client;
|
||||
window.destroy(passFocus);
|
||||
|
||||
client.restoreAfterTiling(grid.desktop.clientArea);
|
||||
Tiled.restoreClientAfterTiling(client, grid.config, this.defaultState, grid.desktop.clientArea);
|
||||
}
|
||||
|
||||
private static initSignalManager(world: World, window: Window) {
|
||||
@@ -29,93 +31,164 @@ namespace ClientState {
|
||||
const kwinClient = client.kwinClient;
|
||||
const manager = new SignalManager();
|
||||
|
||||
manager.connect(kwinClient.desktopChanged, () => {
|
||||
manager.connect(kwinClient.desktopsChanged, () => {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
if (kwinClient.desktop === -1) {
|
||||
// windows on all desktops are not supported
|
||||
clientManager.untileClient(kwinClient);
|
||||
const desktop = desktopManager.getDesktopForClient(kwinClient);
|
||||
if (desktop === undefined) {
|
||||
// windows on multiple desktops are not supported
|
||||
clientManager.floatKwinClient(kwinClient);
|
||||
return;
|
||||
}
|
||||
Tiled.moveWindowToCorrectGrid(desktopManager, window);
|
||||
Tiled.moveWindowToGrid(window, desktop.grid);
|
||||
});
|
||||
});
|
||||
|
||||
manager.connect(kwinClient.activitiesChanged, (kwinClient: AbstractClient) => {
|
||||
manager.connect(kwinClient.activitiesChanged, () => {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
if (kwinClient.activities.length !== 1) {
|
||||
const desktop = desktopManager.getDesktopForClient(kwinClient);
|
||||
if (desktop === undefined) {
|
||||
// windows on multiple activities are not supported
|
||||
clientManager.untileClient(kwinClient);
|
||||
clientManager.floatKwinClient(kwinClient);
|
||||
return;
|
||||
}
|
||||
Tiled.moveWindowToCorrectGrid(desktopManager, window);
|
||||
Tiled.moveWindowToGrid(window, desktop.grid);
|
||||
});
|
||||
})
|
||||
|
||||
let lastResize = false;
|
||||
manager.connect(kwinClient.moveResizedChanged, () => {
|
||||
manager.connect(kwinClient.minimizedChanged, () => {
|
||||
console.assert(kwinClient.minimized);
|
||||
world.do((clientManager, desktopManager) => {
|
||||
if (world.untileOnDrag && kwinClient.move) {
|
||||
clientManager.untileClient(kwinClient);
|
||||
return;
|
||||
}
|
||||
|
||||
const grid = window.column.grid;
|
||||
const resize = kwinClient.resize;
|
||||
if (!lastResize && resize) {
|
||||
grid.onUserResizeStarted();
|
||||
}
|
||||
if (lastResize && !resize) {
|
||||
grid.onUserResizeFinished();
|
||||
}
|
||||
lastResize = resize;
|
||||
clientManager.minimizeClient(kwinClient);
|
||||
});
|
||||
});
|
||||
|
||||
let cursorChangedAfterResizeStart = false;
|
||||
manager.connect(kwinClient.moveResizeCursorChanged, () => {
|
||||
cursorChangedAfterResizeStart = true;
|
||||
});
|
||||
manager.connect(kwinClient.clientStartUserMovedResized, () => {
|
||||
cursorChangedAfterResizeStart = false;
|
||||
manager.connect(kwinClient.maximizedAboutToChange, (maximizedMode: MaximizedMode) => {
|
||||
world.do(() => {
|
||||
window.onMaximizedChanged(maximizedMode);
|
||||
});
|
||||
});
|
||||
|
||||
manager.connect(kwinClient.frameGeometryChanged, (kwinClient: TopLevel, oldGeometry: QRect) => {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
if (kwinClient.resize) {
|
||||
window.onUserResize(oldGeometry, !cursorChangedAfterResizeStart);
|
||||
} else if (!client.isManipulatingGeometry() && !Clients.isMaximizedGeometry(kwinClient) && !Clients.isFullScreenGeometry(kwinClient)) {
|
||||
window.onFrameGeometryChanged();
|
||||
let resizing = false;
|
||||
let resizingBorder = false;
|
||||
manager.connect(kwinClient.interactiveMoveResizeStarted, () => {
|
||||
if (kwinClient.move) {
|
||||
if (world.untileOnDrag) {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
clientManager.floatKwinClient(kwinClient);
|
||||
});
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (kwinClient.resize) {
|
||||
resizing = true;
|
||||
resizingBorder = Workspace.cursorPos.x > kwinClient.frameGeometry.right ||
|
||||
Workspace.cursorPos.x < kwinClient.frameGeometry.left;
|
||||
window.column.grid.onUserResizeStarted();
|
||||
}
|
||||
});
|
||||
|
||||
manager.connect(kwinClient.interactiveMoveResizeFinished, () => {
|
||||
if (resizing) {
|
||||
resizing = false;
|
||||
window.column.grid.onUserResizeFinished();
|
||||
}
|
||||
});
|
||||
|
||||
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) {
|
||||
client.moveTransients(dx, dy);
|
||||
}
|
||||
|
||||
if (kwinClient.resize) {
|
||||
world.do(() => window.onUserResize(oldGeometry, resizingBorder));
|
||||
} 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
|
||||
) {
|
||||
world.do(() => window.onFrameGeometryChanged());
|
||||
}
|
||||
});
|
||||
|
||||
manager.connect(kwinClient.fullScreenChanged, () => {
|
||||
window.onFullScreenChanged(kwinClient.fullScreen);
|
||||
world.do(() => window.onFullScreenChanged(kwinClient.fullScreen));
|
||||
});
|
||||
|
||||
manager.connect(kwinClient.tileChanged, (tile: Tile) => {
|
||||
if (tile !== null) {
|
||||
manager.connect(kwinClient.tileChanged, () => {
|
||||
// on X11, this fires after `frameGeometryChanged`
|
||||
if (kwinClient.tile !== null) {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
clientManager.untileClient(kwinClient);
|
||||
})
|
||||
clientManager.pinClient(kwinClient);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return manager;
|
||||
}
|
||||
|
||||
private static moveWindowToCorrectGrid(desktopManager: DesktopManager, window: Window) {
|
||||
const kwinClient = window.client.kwinClient;
|
||||
|
||||
const oldGrid = window.column.grid;
|
||||
const newGrid = desktopManager.getDesktopForClient(kwinClient).grid;
|
||||
if (oldGrid === newGrid) {
|
||||
// window already on the correct grid
|
||||
private static moveWindowToGrid(window: Window, grid: Grid) {
|
||||
if (grid === window.column.grid) {
|
||||
// window already on the given grid
|
||||
return;
|
||||
}
|
||||
|
||||
const newColumn = new Column(newGrid, newGrid.getLastFocusedColumn() ?? newGrid.getLastColumn());
|
||||
const newColumn = new Column(grid, grid.getLastFocusedColumn() ?? grid.getLastColumn());
|
||||
window.moveToColumn(newColumn);
|
||||
}
|
||||
|
||||
private static prepareClientForTiling(client: ClientWrapper, config: LayoutConfig) {
|
||||
if (config.skipSwitcher) {
|
||||
client.kwinClient.skipSwitcher = true;
|
||||
}
|
||||
if (config.tiledKeepBelow) {
|
||||
client.kwinClient.keepBelow = true;
|
||||
}
|
||||
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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,31 @@
|
||||
namespace ClientState {
|
||||
export class TiledMinimized implements State {
|
||||
public destroy(passFocus: boolean) {}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user