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