Update krohnkite
This commit is contained in:
parent
a1e79918bc
commit
eac0297b22
@ -69,6 +69,7 @@ class KWinConfig {
|
|||||||
this.maximizeSoleTile = KWIN.readConfig("maximizeSoleTile", false);
|
this.maximizeSoleTile = KWIN.readConfig("maximizeSoleTile", false);
|
||||||
this.tileLayoutInitialAngle = KWIN.readConfig("tileLayoutInitialRotationAngle", "0");
|
this.tileLayoutInitialAngle = KWIN.readConfig("tileLayoutInitialRotationAngle", "0");
|
||||||
this.columnsLayoutInitialAngle = KWIN.readConfig("columnsLayoutInitialRotationAngle", "0");
|
this.columnsLayoutInitialAngle = KWIN.readConfig("columnsLayoutInitialRotationAngle", "0");
|
||||||
|
this.columnsBalanced = KWIN.readConfig("columnsBalanced", false);
|
||||||
this.monocleMaximize = KWIN.readConfig("monocleMaximize", true);
|
this.monocleMaximize = KWIN.readConfig("monocleMaximize", true);
|
||||||
this.monocleMinimizeRest = KWIN.readConfig("monocleMinimizeRest", false);
|
this.monocleMinimizeRest = KWIN.readConfig("monocleMinimizeRest", false);
|
||||||
this.stairReverse = KWIN.readConfig("stairReverse", false);
|
this.stairReverse = KWIN.readConfig("stairReverse", false);
|
||||||
@ -171,7 +172,7 @@ class KWinDriver {
|
|||||||
}
|
}
|
||||||
addWindow(client) {
|
addWindow(client) {
|
||||||
if (!client.deleted &&
|
if (!client.deleted &&
|
||||||
client.pid > 1 &&
|
client.pid >= 0 &&
|
||||||
!client.popupWindow &&
|
!client.popupWindow &&
|
||||||
client.normalWindow &&
|
client.normalWindow &&
|
||||||
!client.hidden &&
|
!client.hidden &&
|
||||||
@ -582,6 +583,9 @@ class KWinWindow {
|
|||||||
KWINCONFIG.floatingClass.indexOf(resourceName) >= 0 ||
|
KWINCONFIG.floatingClass.indexOf(resourceName) >= 0 ||
|
||||||
matchWords(this.window.caption, KWINCONFIG.floatingTitle) >= 0);
|
matchWords(this.window.caption, KWINCONFIG.floatingTitle) >= 0);
|
||||||
}
|
}
|
||||||
|
get minimized() {
|
||||||
|
return this.window.minimized;
|
||||||
|
}
|
||||||
get surface() {
|
get surface() {
|
||||||
let activity;
|
let activity;
|
||||||
if (this.window.activities.length === 0)
|
if (this.window.activities.length === 0)
|
||||||
@ -799,6 +803,7 @@ class TestWindow {
|
|||||||
this.geometry = geometry || new Rect(0, 0, 100, 100);
|
this.geometry = geometry || new Rect(0, 0, 100, 100);
|
||||||
this.keepAbove = false;
|
this.keepAbove = false;
|
||||||
this.maximized = false;
|
this.maximized = false;
|
||||||
|
this.minimized = false;
|
||||||
this.noBorder = false;
|
this.noBorder = false;
|
||||||
}
|
}
|
||||||
commit(geometry, noBorder, keepAbove) {
|
commit(geometry, noBorder, keepAbove) {
|
||||||
@ -880,8 +885,7 @@ class TilingController {
|
|||||||
window.setDraggingState();
|
window.setDraggingState();
|
||||||
}
|
}
|
||||||
if (window.state === WindowState.Dragging) {
|
if (window.state === WindowState.Dragging) {
|
||||||
const wr = toRect(windowRect);
|
if (layout.drag(new EngineContext(ctx, this.engine), toRect(windowRect), window, srf.workingArea)) {
|
||||||
if (layout.drag(new EngineContext(ctx, this.engine), wr.activationPoint, window, srf.workingArea)) {
|
|
||||||
this.engine.arrange(ctx);
|
this.engine.arrange(ctx);
|
||||||
}
|
}
|
||||||
this.dragCompleteTime = Date.now();
|
this.dragCompleteTime = Date.now();
|
||||||
@ -1440,6 +1444,9 @@ class EngineContext {
|
|||||||
return;
|
return;
|
||||||
this.engine.windows.moveNew(window, target, after);
|
this.engine.windows.moveNew(window, target, after);
|
||||||
}
|
}
|
||||||
|
getWindowById(id) {
|
||||||
|
return this.engine.windows.getWindowById(id);
|
||||||
|
}
|
||||||
showNotification(text) {
|
showNotification(text) {
|
||||||
this.drvctx.showNotification(text);
|
this.drvctx.showNotification(text);
|
||||||
}
|
}
|
||||||
@ -1490,11 +1497,12 @@ class LayoutStoreEntry {
|
|||||||
return this.loadLayout(this.currentID);
|
return this.loadLayout(this.currentID);
|
||||||
}
|
}
|
||||||
setLayout(targetID) {
|
setLayout(targetID) {
|
||||||
const targetLayout = this.loadLayout(targetID);
|
let targetLayout = this.loadLayout(targetID);
|
||||||
if (targetLayout instanceof MonocleLayout &&
|
if (targetLayout instanceof MonocleLayout &&
|
||||||
this.currentLayout instanceof MonocleLayout) {
|
this.currentLayout instanceof MonocleLayout) {
|
||||||
this.currentID = this.previousID;
|
this.currentID = this.previousID;
|
||||||
this.previousID = targetID;
|
this.previousID = targetID;
|
||||||
|
targetLayout = this.loadLayout(this.currentID);
|
||||||
}
|
}
|
||||||
else if (this.currentID !== targetID) {
|
else if (this.currentID !== targetID) {
|
||||||
this.previousID = this.currentID;
|
this.previousID = this.currentID;
|
||||||
@ -1691,6 +1699,9 @@ class WindowClass {
|
|||||||
visible(srf) {
|
visible(srf) {
|
||||||
return this.window.visible(srf);
|
return this.window.visible(srf);
|
||||||
}
|
}
|
||||||
|
get minimized() {
|
||||||
|
return this.window.minimized;
|
||||||
|
}
|
||||||
toString() {
|
toString() {
|
||||||
return "Window(" + String(this.window) + ")";
|
return "Window(" + String(this.window) + ")";
|
||||||
}
|
}
|
||||||
@ -1937,6 +1948,11 @@ class ColumnLayout {
|
|||||||
this.windowIds = new Set();
|
this.windowIds = new Set();
|
||||||
this.renderedWindowsIds = [];
|
this.renderedWindowsIds = [];
|
||||||
this.renderedWindowsRects = [];
|
this.renderedWindowsRects = [];
|
||||||
|
this.numberFloatedOrMinimized = 0;
|
||||||
|
this.timestamp = 0;
|
||||||
|
}
|
||||||
|
get size() {
|
||||||
|
return this.windowIds.size - this.numberFloatedOrMinimized;
|
||||||
}
|
}
|
||||||
set isHorizontal(value) {
|
set isHorizontal(value) {
|
||||||
if (value)
|
if (value)
|
||||||
@ -1944,6 +1960,9 @@ class ColumnLayout {
|
|||||||
else
|
else
|
||||||
this.parts.angle = 0;
|
this.parts.angle = 0;
|
||||||
}
|
}
|
||||||
|
isEmpty() {
|
||||||
|
return this.windowIds.size === this.numberFloatedOrMinimized;
|
||||||
|
}
|
||||||
apply(ctx, tileables, area) {
|
apply(ctx, tileables, area) {
|
||||||
this.renderedWindowsIds = [];
|
this.renderedWindowsIds = [];
|
||||||
let columnTileables = tileables.filter((w) => {
|
let columnTileables = tileables.filter((w) => {
|
||||||
@ -1970,12 +1989,38 @@ class ColumnLayout {
|
|||||||
return null;
|
return null;
|
||||||
return this.renderedWindowsIds[winId + 1];
|
return this.renderedWindowsIds[winId + 1];
|
||||||
}
|
}
|
||||||
|
getWindowIdOnRight(x) {
|
||||||
|
for (let i = 0; i < this.renderedWindowsIds.length; i++) {
|
||||||
|
if (x < this.renderedWindowsRects[i].center[0] + 10)
|
||||||
|
return this.renderedWindowsIds[i];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
getWindowIdOnTop(y) {
|
||||||
|
for (let i = 0; i < this.renderedWindowsIds.length; i++) {
|
||||||
|
if (y < this.renderedWindowsRects[i].center[1] + 10)
|
||||||
|
return this.renderedWindowsIds[i];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
adjust(area, tiles, basis, delta) {
|
adjust(area, tiles, basis, delta) {
|
||||||
let columnTiles = tiles.filter((t) => this.windowIds.has(t.id));
|
let columnTiles = tiles.filter((t) => this.windowIds.has(t.id));
|
||||||
this.parts.adjust(area, columnTiles, basis, delta);
|
this.parts.adjust(area, columnTiles, basis, delta);
|
||||||
}
|
}
|
||||||
actualizeWindowIds(ids) {
|
actualizeWindowIds(ctx, ids) {
|
||||||
this.windowIds = new Set([...this.windowIds].filter((id) => ids.has(id)));
|
let window;
|
||||||
|
let floatedOrMinimized = 0;
|
||||||
|
this.windowIds = new Set([...this.windowIds].filter((id) => {
|
||||||
|
window = ctx.getWindowById(id);
|
||||||
|
if (ids.has(id))
|
||||||
|
return true;
|
||||||
|
else if (window !== null && (window.minimized || window.floating)) {
|
||||||
|
floatedOrMinimized += 1;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}));
|
||||||
|
this.numberFloatedOrMinimized = floatedOrMinimized;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ColumnLayout.id = "Column";
|
ColumnLayout.id = "Column";
|
||||||
@ -1983,9 +2028,13 @@ class ColumnsLayout {
|
|||||||
get description() {
|
get description() {
|
||||||
return "Columns";
|
return "Columns";
|
||||||
}
|
}
|
||||||
|
get columns() {
|
||||||
|
return this._columns;
|
||||||
|
}
|
||||||
constructor() {
|
constructor() {
|
||||||
this.classID = ColumnsLayout.id;
|
this.classID = ColumnsLayout.id;
|
||||||
this.parts = [new ColumnLayout()];
|
this.parts = [new ColumnLayout()];
|
||||||
|
this._columns = [];
|
||||||
this.direction = new windRose(CONFIG.columnsLayoutInitialAngle);
|
this.direction = new windRose(CONFIG.columnsLayoutInitialAngle);
|
||||||
}
|
}
|
||||||
adjust(area, tiles, basis, delta) {
|
adjust(area, tiles, basis, delta) {
|
||||||
@ -1993,24 +2042,24 @@ class ColumnsLayout {
|
|||||||
if (columnId === null)
|
if (columnId === null)
|
||||||
return;
|
return;
|
||||||
let isReverse = this.direction.east || this.direction.south;
|
let isReverse = this.direction.east || this.direction.south;
|
||||||
let columnsLength = this.parts.length;
|
let columnsLength = this.columns.length;
|
||||||
if (((this.direction.east || this.direction.west) &&
|
if (((this.direction.east || this.direction.west) &&
|
||||||
(delta.east !== 0 || delta.west !== 0)) ||
|
(delta.east !== 0 || delta.west !== 0)) ||
|
||||||
((this.direction.north || this.direction.south) &&
|
((this.direction.north || this.direction.south) &&
|
||||||
(delta.north !== 0 || delta.south !== 0))) {
|
(delta.north !== 0 || delta.south !== 0))) {
|
||||||
let oldWeights;
|
let oldWeights;
|
||||||
if (isReverse) {
|
if (isReverse) {
|
||||||
oldWeights = this.parts
|
oldWeights = this.columns
|
||||||
.slice(0)
|
.slice(0)
|
||||||
.reverse()
|
.reverse()
|
||||||
.map((column) => column.weight);
|
.map((column) => column.weight);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
oldWeights = this.parts.map((column) => column.weight);
|
oldWeights = this.columns.map((column) => column.weight);
|
||||||
}
|
}
|
||||||
const weights = LayoutUtils.adjustAreaWeights(area, oldWeights, CONFIG.tileLayoutGap, isReverse ? columnsLength - 1 - columnId : columnId, delta, this.direction.east || this.direction.west);
|
const weights = LayoutUtils.adjustAreaWeights(area, oldWeights, CONFIG.tileLayoutGap, isReverse ? columnsLength - 1 - columnId : columnId, delta, this.direction.east || this.direction.west);
|
||||||
weights.forEach((weight, i) => {
|
weights.forEach((weight, i) => {
|
||||||
this.parts[isReverse ? columnsLength - 1 - i : i].weight =
|
this.columns[isReverse ? columnsLength - 1 - i : i].weight =
|
||||||
weight * columnsLength;
|
weight * columnsLength;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -2018,69 +2067,73 @@ class ColumnsLayout {
|
|||||||
(this.direction.east || this.direction.west)) ||
|
(this.direction.east || this.direction.west)) ||
|
||||||
((delta.east !== 0 || delta.west !== 0) &&
|
((delta.east !== 0 || delta.west !== 0) &&
|
||||||
(this.direction.north || this.direction.south))) {
|
(this.direction.north || this.direction.south))) {
|
||||||
this.parts[columnId].adjust(area, tiles, basis, delta);
|
this.columns[columnId].adjust(area, tiles, basis, delta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
apply(ctx, tileables, area) {
|
apply(ctx, tileables, area) {
|
||||||
print(`columnsApply: ${this.direction}`);
|
this.arrangeTileables(ctx, tileables);
|
||||||
this.arrangeTileables(tileables);
|
if (this.columns.length === 0)
|
||||||
|
return;
|
||||||
let weights;
|
let weights;
|
||||||
if (this.direction.east || this.direction.south) {
|
if (this.direction.east || this.direction.south) {
|
||||||
weights = this.parts
|
weights = this.columns
|
||||||
.slice(0)
|
.slice(0)
|
||||||
.reverse()
|
.reverse()
|
||||||
.map((tile) => tile.weight);
|
.map((tile) => tile.weight);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
weights = this.parts.map((tile) => tile.weight);
|
weights = this.columns.map((tile) => tile.weight);
|
||||||
}
|
}
|
||||||
const rects = LayoutUtils.splitAreaWeighted(area, weights, CONFIG.tileLayoutGap, this.direction.east || this.direction.west);
|
const rects = LayoutUtils.splitAreaWeighted(area, weights, CONFIG.tileLayoutGap, this.direction.east || this.direction.west);
|
||||||
if (this.direction.east || this.direction.south) {
|
if (this.direction.east || this.direction.south) {
|
||||||
let i = 0;
|
let i = 0;
|
||||||
for (var idx = this.parts.length - 1; idx >= 0; idx--) {
|
for (var idx = this.columns.length - 1; idx >= 0; idx--) {
|
||||||
this.parts[idx].isHorizontal = this.direction.south;
|
this.columns[idx].isHorizontal = this.direction.south;
|
||||||
this.parts[idx].apply(ctx, tileables, rects[i]);
|
this.columns[idx].apply(ctx, tileables, rects[i]);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (var idx = 0; idx < this.parts.length; idx++) {
|
for (var idx = 0; idx < this.columns.length; idx++) {
|
||||||
this.parts[idx].isHorizontal = this.direction.north;
|
this.columns[idx].isHorizontal = this.direction.north;
|
||||||
this.parts[idx].apply(ctx, tileables, rects[idx]);
|
this.columns[idx].apply(ctx, tileables, rects[idx]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
drag(ctx, activationPoint, window, workingArea) {
|
drag(ctx, draggingRect, window, workingArea) {
|
||||||
if (this.parts.length === 1 && this.parts[0].windowIds.size === 1)
|
const activationPoint = draggingRect.activationPoint;
|
||||||
|
const middlePoint = draggingRect.center;
|
||||||
|
if (this.columns.length === 0 ||
|
||||||
|
(this.columns.length === 1 && this.columns[0].windowIds.size === 1))
|
||||||
return false;
|
return false;
|
||||||
let columnId = this.getColumnId(window);
|
let columnId = this.getColumnId(window);
|
||||||
let windowId = window.id;
|
let windowId = window.id;
|
||||||
if (((this.direction.north && workingArea.isTopZone(activationPoint)) ||
|
if (((this.direction.north && workingArea.isTopZone(activationPoint)) ||
|
||||||
(this.direction.south && workingArea.isBottomZone(activationPoint)) ||
|
(this.direction.south && workingArea.isBottomZone(middlePoint)) ||
|
||||||
(this.direction.west && workingArea.isLeftZone(activationPoint)) ||
|
(this.direction.west && workingArea.isLeftZone(activationPoint)) ||
|
||||||
(this.direction.east && workingArea.isRightZone(activationPoint))) &&
|
(this.direction.east && workingArea.isRightZone(activationPoint))) &&
|
||||||
!(this.parts[0].windowIds.size === 1 &&
|
!(this.columns[0].windowIds.size === 1 &&
|
||||||
this.parts[0].windowIds.has(windowId))) {
|
this.columns[0].windowIds.has(windowId))) {
|
||||||
if (columnId !== null)
|
if (columnId !== null)
|
||||||
this.parts[columnId].windowIds.delete(windowId);
|
this.columns[columnId].windowIds.delete(windowId);
|
||||||
this.insertColumn(0);
|
const column = this.insertColumn(true);
|
||||||
this.parts[0].windowIds.add(windowId);
|
column.windowIds.add(windowId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (((this.direction.north && workingArea.isBottomZone(activationPoint)) ||
|
if (((this.direction.north && workingArea.isBottomZone(middlePoint)) ||
|
||||||
(this.direction.south && workingArea.isTopZone(activationPoint)) ||
|
(this.direction.south && workingArea.isTopZone(activationPoint)) ||
|
||||||
(this.direction.west && workingArea.isRightZone(activationPoint)) ||
|
(this.direction.west && workingArea.isRightZone(activationPoint)) ||
|
||||||
(this.direction.east && workingArea.isLeftZone(activationPoint))) &&
|
(this.direction.east && workingArea.isLeftZone(activationPoint))) &&
|
||||||
!(this.parts[this.parts.length - 1].windowIds.size === 1 &&
|
!(this.columns[this.columns.length - 1].windowIds.size === 1 &&
|
||||||
this.parts[this.parts.length - 1].windowIds.has(windowId))) {
|
this.columns[this.columns.length - 1].windowIds.has(windowId))) {
|
||||||
if (columnId !== null)
|
if (columnId !== null)
|
||||||
this.parts[columnId].windowIds.delete(windowId);
|
this.columns[columnId].windowIds.delete(windowId);
|
||||||
this.insertColumn(this.parts.length);
|
const column = this.insertColumn(false);
|
||||||
this.parts[this.parts.length - 1].windowIds.add(windowId);
|
column.windowIds.add(windowId);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for (let colIdx = 0; colIdx < this.parts.length; colIdx++) {
|
for (let colIdx = 0; colIdx < this.columns.length; colIdx++) {
|
||||||
const column = this.parts[colIdx];
|
const column = this.columns[colIdx];
|
||||||
for (let i = 0; i < column.renderedWindowsRects.length; i++) {
|
for (let i = 0; i < column.renderedWindowsRects.length; i++) {
|
||||||
const renderedRect = column.renderedWindowsRects[i];
|
const renderedRect = column.renderedWindowsRects[i];
|
||||||
if ((this.direction.west &&
|
if ((this.direction.west &&
|
||||||
@ -2097,7 +2150,7 @@ class ColumnsLayout {
|
|||||||
return false;
|
return false;
|
||||||
const renderedId = column.renderedWindowsIds[i];
|
const renderedId = column.renderedWindowsIds[i];
|
||||||
if (columnId !== null && columnId !== colIdx)
|
if (columnId !== null && columnId !== colIdx)
|
||||||
this.parts[columnId].windowIds.delete(windowId);
|
this.columns[columnId].windowIds.delete(windowId);
|
||||||
column.windowIds.add(windowId);
|
column.windowIds.add(windowId);
|
||||||
ctx.moveWindowByWinId(window, renderedId);
|
ctx.moveWindowByWinId(window, renderedId);
|
||||||
return true;
|
return true;
|
||||||
@ -2117,7 +2170,7 @@ class ColumnsLayout {
|
|||||||
return false;
|
return false;
|
||||||
const renderedId = column.renderedWindowsIds[i];
|
const renderedId = column.renderedWindowsIds[i];
|
||||||
if (columnId !== null && columnId !== colIdx)
|
if (columnId !== null && columnId !== colIdx)
|
||||||
this.parts[columnId].windowIds.delete(windowId);
|
this.columns[columnId].windowIds.delete(windowId);
|
||||||
column.windowIds.add(windowId);
|
column.windowIds.add(windowId);
|
||||||
ctx.moveWindowByWinId(window, renderedId, true);
|
ctx.moveWindowByWinId(window, renderedId, true);
|
||||||
return true;
|
return true;
|
||||||
@ -2126,51 +2179,68 @@ class ColumnsLayout {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
arrangeTileables(tileables) {
|
arrangeTileables(ctx, tileables) {
|
||||||
let latestTimestamp = 0;
|
let latestTimestamp = 0;
|
||||||
let columnId = null;
|
let partId = null;
|
||||||
let newWindows = new Set();
|
let newWindows = [];
|
||||||
let tileableIds = new Set();
|
let tileableIds = new Set();
|
||||||
let currentColumnId = 0;
|
let currentColumnId = 0;
|
||||||
tileables.forEach((tileable) => {
|
tileables.forEach((tileable) => {
|
||||||
tileable.state = WindowState.Tiled;
|
tileable.state = WindowState.Tiled;
|
||||||
columnId = this.getColumnId(tileable);
|
partId = this.getPartsId(tileable);
|
||||||
if (columnId !== null) {
|
if (partId !== null) {
|
||||||
if (tileable.timestamp > latestTimestamp) {
|
if (this.parts[partId].timestamp < tileable.timestamp) {
|
||||||
|
this.parts[partId].timestamp = tileable.timestamp;
|
||||||
|
}
|
||||||
|
if (this.parts[partId].timestamp > latestTimestamp) {
|
||||||
latestTimestamp = tileable.timestamp;
|
latestTimestamp = tileable.timestamp;
|
||||||
currentColumnId = columnId;
|
currentColumnId = partId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
newWindows.add(tileable.id);
|
newWindows.push(tileable.id);
|
||||||
}
|
}
|
||||||
tileableIds.add(tileable.id);
|
tileableIds.add(tileable.id);
|
||||||
});
|
});
|
||||||
|
if (CONFIG.columnsBalanced) {
|
||||||
|
for (var [_, id] of newWindows.entries()) {
|
||||||
|
let minSizeColumn = this.parts.reduce((prev, curr) => {
|
||||||
|
return prev.size < curr.size ? prev : curr;
|
||||||
|
});
|
||||||
|
minSizeColumn.windowIds.add(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
this.parts[currentColumnId].windowIds = new Set([
|
this.parts[currentColumnId].windowIds = new Set([
|
||||||
...this.parts[currentColumnId].windowIds,
|
...this.parts[currentColumnId].windowIds,
|
||||||
...newWindows,
|
...newWindows,
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
this.parts.forEach((column) => {
|
this.parts.forEach((column) => {
|
||||||
column.actualizeWindowIds(tileableIds);
|
column.actualizeWindowIds(ctx, tileableIds);
|
||||||
});
|
});
|
||||||
this.parts = this.parts.filter((column) => column.windowIds.size !== 0);
|
this.parts = this.parts.filter((column) => column.windowIds.size !== 0);
|
||||||
if (this.parts.length === 0)
|
if (this.parts.length === 0)
|
||||||
this.parts.push(new ColumnLayout());
|
this.insertColumn(true);
|
||||||
this.applyColumnsPosition();
|
this.applyColumnsPosition();
|
||||||
}
|
}
|
||||||
getColumnId(t) {
|
getColumnId(t) {
|
||||||
|
for (var i = 0; i < this.columns.length; i++) {
|
||||||
|
if (this.columns[i].windowIds.has(t.id))
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
getPartsId(t) {
|
||||||
for (var i = 0; i < this.parts.length; i++) {
|
for (var i = 0; i < this.parts.length; i++) {
|
||||||
if (this.parts[i].windowIds.has(t.id))
|
if (this.parts[i].windowIds.has(t.id))
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
getCurrentWinId(ctx) {
|
getCurrentColumnId(currentWindowId) {
|
||||||
return ctx.currentWindow === null ? null : ctx.currentWindow.id;
|
|
||||||
}
|
|
||||||
getCurrentColumnIdx(currentWindowId) {
|
|
||||||
if (currentWindowId !== null) {
|
if (currentWindowId !== null) {
|
||||||
for (const [i, column] of this.parts.entries()) {
|
for (const [i, column] of this.columns.entries()) {
|
||||||
if (column.windowIds.has(currentWindowId))
|
if (column.windowIds.has(currentWindowId))
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@ -2178,141 +2248,199 @@ class ColumnsLayout {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
applyColumnsPosition() {
|
applyColumnsPosition() {
|
||||||
const length = this.parts.length;
|
this._columns = this.parts.filter((column) => !column.isEmpty());
|
||||||
if (length === 1) {
|
const columnsLength = this.columns.length;
|
||||||
this.parts[0].position = "single";
|
if (columnsLength === 1) {
|
||||||
|
this.columns[0].position = "single";
|
||||||
}
|
}
|
||||||
else if (length > 1) {
|
else if (columnsLength > 1) {
|
||||||
this.parts[0].position = "left";
|
this.columns[0].position = "left";
|
||||||
this.parts[length - 1].position = "right";
|
this.columns[columnsLength - 1].position = "right";
|
||||||
for (let i = 1; i < length - 1; i++) {
|
for (let i = 1; i < columnsLength - 1; i++) {
|
||||||
this.parts[i].position = "middle";
|
this.columns[i].position = "middle";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
toColumnWithBiggerIndex(ctx) {
|
toColumnWithBiggerIndex(ctx) {
|
||||||
let currentWindowId = this.getCurrentWinId(ctx);
|
const currentWindow = ctx.currentWindow;
|
||||||
let activeColumnId = this.getCurrentColumnIdx(currentWindowId);
|
const currentWindowId = currentWindow !== null ? currentWindow.id : null;
|
||||||
if (currentWindowId === null ||
|
const activeColumnId = this.getCurrentColumnId(currentWindowId);
|
||||||
|
if (currentWindow === null ||
|
||||||
|
currentWindowId === null ||
|
||||||
activeColumnId === null ||
|
activeColumnId === null ||
|
||||||
(this.parts[activeColumnId].windowIds.size < 2 &&
|
(this.columns[activeColumnId].size < 2 &&
|
||||||
(this.parts[activeColumnId].position === "right" ||
|
(this.columns[activeColumnId].position === "right" ||
|
||||||
this.parts[activeColumnId].position === "single")))
|
this.columns[activeColumnId].position === "single")))
|
||||||
return;
|
return false;
|
||||||
if (this.parts[activeColumnId].position === "single" ||
|
let targetColumn;
|
||||||
this.parts[activeColumnId].position === "right") {
|
const column = this.columns[activeColumnId];
|
||||||
this.insertColumn(this.parts.length);
|
const center = column.renderedWindowsRects[column.renderedWindowsIds.indexOf(currentWindowId)].center;
|
||||||
}
|
column.windowIds.delete(currentWindowId);
|
||||||
this.parts[activeColumnId].windowIds.delete(currentWindowId);
|
if (column.position === "single" || column.position === "right") {
|
||||||
this.parts[activeColumnId + 1].windowIds.add(currentWindowId);
|
targetColumn = this.insertColumn(false);
|
||||||
}
|
targetColumn.windowIds.add(currentWindowId);
|
||||||
toColumnWithSmallerIndex(ctx) {
|
|
||||||
let currentWindowId = this.getCurrentWinId(ctx);
|
|
||||||
let activeColumnId = this.getCurrentColumnIdx(currentWindowId);
|
|
||||||
if (currentWindowId === null ||
|
|
||||||
activeColumnId === null ||
|
|
||||||
(this.parts[activeColumnId].windowIds.size < 2 &&
|
|
||||||
(this.parts[activeColumnId].position === "left" ||
|
|
||||||
this.parts[activeColumnId].position === "single")))
|
|
||||||
return;
|
|
||||||
if (this.parts[activeColumnId].position === "single" ||
|
|
||||||
this.parts[activeColumnId].position === "left") {
|
|
||||||
this.insertColumn(0);
|
|
||||||
this.parts[1].windowIds.delete(currentWindowId);
|
|
||||||
this.parts[0].windowIds.add(currentWindowId);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.parts[activeColumnId].windowIds.delete(currentWindowId);
|
targetColumn = this.columns[activeColumnId + 1];
|
||||||
this.parts[activeColumnId - 1].windowIds.add(currentWindowId);
|
targetColumn.windowIds.add(currentWindowId);
|
||||||
}
|
}
|
||||||
|
let idOnTarget;
|
||||||
|
if (this.direction.north || this.direction.south)
|
||||||
|
idOnTarget = targetColumn.getWindowIdOnRight(center[0]);
|
||||||
|
else
|
||||||
|
idOnTarget = targetColumn.getWindowIdOnTop(center[1]);
|
||||||
|
if (idOnTarget !== null)
|
||||||
|
ctx.moveWindowByWinId(currentWindow, idOnTarget);
|
||||||
|
else {
|
||||||
|
const targetId = targetColumn.renderedWindowsIds[targetColumn.renderedWindowsIds.length - 1];
|
||||||
|
ctx.moveWindowByWinId(currentWindow, targetId);
|
||||||
|
}
|
||||||
|
this.applyColumnsPosition();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
toColumnWithSmallerIndex(ctx) {
|
||||||
|
const currentWindow = ctx.currentWindow;
|
||||||
|
const currentWindowId = currentWindow !== null ? currentWindow.id : null;
|
||||||
|
const activeColumnId = this.getCurrentColumnId(currentWindowId);
|
||||||
|
if (currentWindow === null ||
|
||||||
|
currentWindowId === null ||
|
||||||
|
activeColumnId === null ||
|
||||||
|
(this.columns[activeColumnId].windowIds.size < 2 &&
|
||||||
|
(this.columns[activeColumnId].position === "left" ||
|
||||||
|
this.columns[activeColumnId].position === "single")))
|
||||||
|
return false;
|
||||||
|
let targetColumn;
|
||||||
|
const column = this.columns[activeColumnId];
|
||||||
|
const center = column.renderedWindowsRects[column.renderedWindowsIds.indexOf(currentWindowId)].center;
|
||||||
|
column.windowIds.delete(currentWindowId);
|
||||||
|
if (column.position === "single" || column.position === "left") {
|
||||||
|
targetColumn = this.insertColumn(true);
|
||||||
|
targetColumn.windowIds.add(currentWindowId);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
targetColumn = this.columns[activeColumnId - 1];
|
||||||
|
targetColumn.windowIds.add(currentWindowId);
|
||||||
|
}
|
||||||
|
let idOnTarget;
|
||||||
|
if (this.direction.north || this.direction.south)
|
||||||
|
idOnTarget = targetColumn.getWindowIdOnRight(center[0]);
|
||||||
|
else
|
||||||
|
idOnTarget = targetColumn.getWindowIdOnTop(center[1]);
|
||||||
|
if (idOnTarget !== null)
|
||||||
|
ctx.moveWindowByWinId(currentWindow, idOnTarget);
|
||||||
|
else {
|
||||||
|
const targetId = targetColumn.renderedWindowsIds[targetColumn.renderedWindowsIds.length - 1];
|
||||||
|
ctx.moveWindowByWinId(currentWindow, targetId);
|
||||||
|
}
|
||||||
|
this.applyColumnsPosition();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
toUpOrLeft(ctx) {
|
toUpOrLeft(ctx) {
|
||||||
let currentWindow = ctx.currentWindow;
|
let currentWindow = ctx.currentWindow;
|
||||||
let currentWindowId = currentWindow !== null ? currentWindow.id : null;
|
let currentWindowId = currentWindow !== null ? currentWindow.id : null;
|
||||||
let activeColumnId = this.getCurrentColumnIdx(currentWindowId);
|
let activeColumnId = this.getCurrentColumnId(currentWindowId);
|
||||||
if (currentWindow === null ||
|
if (currentWindow === null ||
|
||||||
currentWindowId === null ||
|
currentWindowId === null ||
|
||||||
activeColumnId === null ||
|
activeColumnId === null ||
|
||||||
this.parts[activeColumnId].windowIds.size < 2)
|
this.columns[activeColumnId].windowIds.size < 2)
|
||||||
return;
|
return false;
|
||||||
let upperWinId = this.parts[activeColumnId].getUpperWindowId(currentWindowId);
|
let upperWinId = this.columns[activeColumnId].getUpperWindowId(currentWindowId);
|
||||||
if (upperWinId === null)
|
if (upperWinId === null)
|
||||||
return;
|
return false;
|
||||||
ctx.moveWindowByWinId(currentWindow, upperWinId);
|
ctx.moveWindowByWinId(currentWindow, upperWinId);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
toBottomOrRight(ctx) {
|
toBottomOrRight(ctx) {
|
||||||
let currentWindow = ctx.currentWindow;
|
let currentWindow = ctx.currentWindow;
|
||||||
let currentWindowId = currentWindow !== null ? currentWindow.id : null;
|
let currentWindowId = currentWindow !== null ? currentWindow.id : null;
|
||||||
let activeColumnId = this.getCurrentColumnIdx(currentWindowId);
|
let activeColumnId = this.getCurrentColumnId(currentWindowId);
|
||||||
if (currentWindow === null ||
|
if (currentWindow === null ||
|
||||||
currentWindowId === null ||
|
currentWindowId === null ||
|
||||||
activeColumnId === null ||
|
activeColumnId === null ||
|
||||||
this.parts[activeColumnId].windowIds.size < 2)
|
this.columns[activeColumnId].windowIds.size < 2)
|
||||||
return;
|
return false;
|
||||||
let lowerWinId = this.parts[activeColumnId].getLowerWindowId(currentWindowId);
|
let lowerWinId = this.columns[activeColumnId].getLowerWindowId(currentWindowId);
|
||||||
if (lowerWinId === null)
|
if (lowerWinId === null)
|
||||||
return;
|
return false;
|
||||||
ctx.moveWindowByWinId(currentWindow, lowerWinId, true);
|
ctx.moveWindowByWinId(currentWindow, lowerWinId, true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
showDirection(ctx) {
|
||||||
|
let notification;
|
||||||
|
if (this.direction.east)
|
||||||
|
notification = "vertical ⟰";
|
||||||
|
else if (this.direction.north)
|
||||||
|
notification = "horizontal ⭆";
|
||||||
|
else if (this.direction.west)
|
||||||
|
notification = "vertical ⟱";
|
||||||
|
else if (this.direction.south)
|
||||||
|
notification = "horizontal ⭅";
|
||||||
|
else
|
||||||
|
notification = "";
|
||||||
|
ctx.showNotification(notification);
|
||||||
}
|
}
|
||||||
handleShortcut(ctx, input) {
|
handleShortcut(ctx, input) {
|
||||||
|
let isApply = false;
|
||||||
switch (input) {
|
switch (input) {
|
||||||
case Shortcut.SwapLeft:
|
case Shortcut.SwapLeft:
|
||||||
if (this.direction.north || this.direction.south) {
|
if (this.direction.north || this.direction.south) {
|
||||||
this.toUpOrLeft(ctx);
|
isApply = this.toUpOrLeft(ctx);
|
||||||
}
|
}
|
||||||
else if (this.direction.east) {
|
else if (this.direction.east) {
|
||||||
this.toColumnWithBiggerIndex(ctx);
|
isApply = this.toColumnWithBiggerIndex(ctx);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
this.toColumnWithSmallerIndex(ctx);
|
isApply = this.toColumnWithSmallerIndex(ctx);
|
||||||
break;
|
break;
|
||||||
case Shortcut.SwapRight:
|
case Shortcut.SwapRight:
|
||||||
if (this.direction.north || this.direction.south) {
|
if (this.direction.north || this.direction.south) {
|
||||||
this.toBottomOrRight(ctx);
|
isApply = this.toBottomOrRight(ctx);
|
||||||
}
|
}
|
||||||
else if (this.direction.east) {
|
else if (this.direction.east) {
|
||||||
this.toColumnWithSmallerIndex(ctx);
|
isApply = this.toColumnWithSmallerIndex(ctx);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
this.toColumnWithBiggerIndex(ctx);
|
isApply = this.toColumnWithBiggerIndex(ctx);
|
||||||
break;
|
break;
|
||||||
case Shortcut.SwapUp:
|
case Shortcut.SwapUp:
|
||||||
if (this.direction.north) {
|
if (this.direction.north) {
|
||||||
this.toColumnWithSmallerIndex(ctx);
|
isApply = this.toColumnWithSmallerIndex(ctx);
|
||||||
}
|
}
|
||||||
else if (this.direction.south) {
|
else if (this.direction.south) {
|
||||||
this.toColumnWithBiggerIndex(ctx);
|
isApply = this.toColumnWithBiggerIndex(ctx);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
this.toUpOrLeft(ctx);
|
isApply = this.toUpOrLeft(ctx);
|
||||||
break;
|
break;
|
||||||
case Shortcut.SwapDown:
|
case Shortcut.SwapDown:
|
||||||
if (this.direction.north) {
|
if (this.direction.north) {
|
||||||
this.toColumnWithBiggerIndex(ctx);
|
isApply = this.toColumnWithBiggerIndex(ctx);
|
||||||
}
|
}
|
||||||
else if (this.direction.south) {
|
else if (this.direction.south) {
|
||||||
print("hello");
|
isApply = this.toColumnWithSmallerIndex(ctx);
|
||||||
this.toColumnWithSmallerIndex(ctx);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
this.toBottomOrRight(ctx);
|
isApply = this.toBottomOrRight(ctx);
|
||||||
break;
|
break;
|
||||||
case Shortcut.Rotate:
|
case Shortcut.Rotate:
|
||||||
this.direction.cwRotation();
|
this.direction.cwRotation();
|
||||||
print(`cwRotation: north:${this.direction.north},east:${this.direction.east},south:${this.direction.south},west:${this.direction.west}`);
|
this.showDirection(ctx);
|
||||||
|
isApply = true;
|
||||||
break;
|
break;
|
||||||
case Shortcut.RotatePart:
|
case Shortcut.RotatePart:
|
||||||
this.direction.ccwRotation();
|
this.direction.ccwRotation();
|
||||||
print(`ccwRotation: north:${this.direction.north},east:${this.direction.east},south:${this.direction.south},west:${this.direction.west}`);
|
this.showDirection(ctx);
|
||||||
|
isApply = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return isApply;
|
||||||
}
|
}
|
||||||
insertColumn(index) {
|
insertColumn(onTop) {
|
||||||
this.parts.splice(index, 0, new ColumnLayout());
|
let column = new ColumnLayout();
|
||||||
this.applyColumnsPosition();
|
this.parts.splice(onTop ? 0 : this.parts.length, 0, column);
|
||||||
|
return column;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ColumnsLayout.id = "Columns";
|
ColumnsLayout.id = "Columns";
|
||||||
|
@ -64,11 +64,17 @@
|
|||||||
<label>Enable/disable Columns layout</label>
|
<label>Enable/disable Columns layout</label>
|
||||||
<default>true</default>
|
<default>true</default>
|
||||||
</entry>
|
</entry>
|
||||||
|
|
||||||
<entry name="columnsLayoutInitialRotationAngle" type="String">
|
<entry name="columnsLayoutInitialRotationAngle" type="String">
|
||||||
<label>Columns layout initial rotation angle</label>
|
<label>Columns layout initial rotation angle</label>
|
||||||
<default>0</default>
|
<default>0</default>
|
||||||
</entry>
|
</entry>
|
||||||
|
|
||||||
|
<entry name="columnsBalanced" type="Bool">
|
||||||
|
<label>Enable/disable creating a new window in the shortest column</label>
|
||||||
|
<default>false</default>
|
||||||
|
</entry>
|
||||||
|
|
||||||
<entry name="enableStackedLayout" type="Bool">
|
<entry name="enableStackedLayout" type="Bool">
|
||||||
<label>Enable/disable Stacked layout</label>
|
<label>Enable/disable Stacked layout</label>
|
||||||
<default>false</default>
|
<default>false</default>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>440</width>
|
<width>440</width>
|
||||||
<height>755</height>
|
<height>1109</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
@ -258,6 +258,19 @@
|
|||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_3">
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
|
<item row="0" column="1">
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Orientation::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
<item>
|
<item>
|
||||||
@ -299,18 +312,15 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="1" column="0">
|
||||||
<spacer name="horizontalSpacer">
|
<widget class="QCheckBox" name="kcfg_columnsBalanced">
|
||||||
<property name="orientation">
|
<property name="toolTip">
|
||||||
<enum>Qt::Orientation::Horizontal</enum>
|
<string>Creating a new window in the shortest column</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="text">
|
||||||
<size>
|
<string>Balanced</string>
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"KPackageStructure": "KWin/Script",
|
"KPackageStructure": "KWin/Script",
|
||||||
"KPlugin": {
|
"KPlugin": {
|
||||||
"Name": "Krohnkite",
|
"Name": "Krohnkite",
|
||||||
"Description": "A dynamic tiling script for KWin (96a3502)",
|
"Description": "A dynamic tiling script for KWin (f1ef1cf)",
|
||||||
"Icon": "dialog-tile-clones",
|
"Icon": "dialog-tile-clones",
|
||||||
|
|
||||||
"Authors": [
|
"Authors": [
|
||||||
@ -12,7 +12,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"Id": "krohnkite",
|
"Id": "krohnkite",
|
||||||
"Version": "0.9.8.2",
|
"Version": "0.9.8.3",
|
||||||
"License": "MIT",
|
"License": "MIT",
|
||||||
"Website": "https://github.com/anametologin/krohnkite#readme"
|
"Website": "https://github.com/anametologin/krohnkite#readme"
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user