Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
adc78f11bc | ||
|
|
f1206b18b1 | ||
|
|
c6066c354d | ||
|
|
914202f091 | ||
|
|
b85c86e7db | ||
|
|
fdb4b88333 | ||
|
|
4e3d924366 | ||
|
|
3d3e8cff17 |
@@ -9,7 +9,7 @@
|
||||
"Name": "Peter Fajdiga"
|
||||
}],
|
||||
"Id": "karousel",
|
||||
"Version": "0.9.3",
|
||||
"Version": "0.9.4",
|
||||
"License": "GPLv3",
|
||||
"Website": "https://github.com/peterfajdiga/karousel",
|
||||
"BugReportUrl": "https://github.com/peterfajdiga/karousel/issues"
|
||||
|
||||
@@ -148,13 +148,13 @@ namespace Actions {
|
||||
|
||||
case "column-move-start": return () => {
|
||||
world.doIfTiledFocused(true, (clientManager, desktopManager, window, column, grid) => {
|
||||
column.moveAfter(null);
|
||||
grid.moveColumn(column, null);
|
||||
});
|
||||
};
|
||||
|
||||
case "column-move-end": return () => {
|
||||
world.doIfTiledFocused(true, (clientManager, desktopManager, window, column, grid) => {
|
||||
column.moveAfter(grid.getLastColumn());
|
||||
grid.moveColumn(column, grid.getLastColumn());
|
||||
});
|
||||
};
|
||||
|
||||
@@ -252,6 +252,12 @@ namespace Actions {
|
||||
});
|
||||
};
|
||||
|
||||
case "screen-switch": return () => {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
desktopManager.selectScreen(Workspace.activeScreen);
|
||||
});
|
||||
};
|
||||
|
||||
default: throw new Error("unknown action: " + name);
|
||||
}
|
||||
}
|
||||
@@ -286,10 +292,10 @@ namespace Actions {
|
||||
if (targetColumn === null || targetColumn === column) {
|
||||
return;
|
||||
}
|
||||
if (targetColumn.isAfter(column)) {
|
||||
column.moveAfter(targetColumn);
|
||||
if (targetColumn.isToTheRightOf(column)) {
|
||||
grid.moveColumn(column, targetColumn);
|
||||
} else {
|
||||
column.moveAfter(grid.getPrevColumn(targetColumn));
|
||||
grid.moveColumn(column, grid.getPrevColumn(targetColumn));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -66,32 +66,32 @@ const configDef = [
|
||||
{
|
||||
name: "gapsOuterTop",
|
||||
type: "UInt",
|
||||
default: 18,
|
||||
default: 16,
|
||||
},
|
||||
{
|
||||
name: "gapsOuterBottom",
|
||||
type: "UInt",
|
||||
default: 18,
|
||||
default: 16,
|
||||
},
|
||||
{
|
||||
name: "gapsOuterLeft",
|
||||
type: "UInt",
|
||||
default: 18,
|
||||
default: 16,
|
||||
},
|
||||
{
|
||||
name: "gapsOuterRight",
|
||||
type: "UInt",
|
||||
default: 18,
|
||||
default: 16,
|
||||
},
|
||||
{
|
||||
name: "gapsInnerHorizontal",
|
||||
type: "UInt",
|
||||
default: 18,
|
||||
default: 8,
|
||||
},
|
||||
{
|
||||
name: "gapsInnerVertical",
|
||||
type: "UInt",
|
||||
default: 18,
|
||||
default: 8,
|
||||
},
|
||||
{
|
||||
name: "manualScrollStep",
|
||||
|
||||
3
src/lib/extern/kwin.ts
vendored
3
src/lib/extern/kwin.ts
vendored
@@ -17,8 +17,9 @@ type Workspace = {
|
||||
readonly windowAdded: QSignal<[KwinClient]>;
|
||||
readonly windowRemoved: QSignal<[KwinClient]>;
|
||||
readonly windowActivated: QSignal<[KwinClient]>;
|
||||
readonly desktopsChanged: QSignal<[]>;
|
||||
readonly screensChanged: QSignal<[]>;
|
||||
readonly activitiesChanged: QSignal<[]>;
|
||||
readonly desktopsChanged: QSignal<[]>;
|
||||
readonly currentActivityChanged: QSignal<[]>;
|
||||
readonly virtualScreenSizeChanged: QSignal<[]>;
|
||||
|
||||
|
||||
@@ -146,6 +146,11 @@ const keyBindings: KeyBinding[] = [
|
||||
description: "Scroll to end",
|
||||
defaultKeySequence: "Meta+Alt+End",
|
||||
},
|
||||
{
|
||||
name: "screen-switch",
|
||||
description: "Move Karousel grid to the current screen",
|
||||
defaultKeySequence: "Meta+Ctrl+Return",
|
||||
}
|
||||
];
|
||||
|
||||
const numKeyBindings: NumKeyBinding[] = [
|
||||
|
||||
@@ -19,7 +19,7 @@ class Column {
|
||||
|
||||
public moveToGrid(targetGrid: Grid, prevColumn: Column|null) {
|
||||
if (targetGrid === this.grid) {
|
||||
this.grid.onColumnMoved(this, prevColumn);
|
||||
this.grid.moveColumn(this, prevColumn);
|
||||
} else {
|
||||
this.grid.onColumnRemoved(this, false);
|
||||
this.grid = targetGrid;
|
||||
@@ -30,21 +30,14 @@ class Column {
|
||||
}
|
||||
}
|
||||
|
||||
public moveAfter(prevColumn: Column|null) {
|
||||
if (prevColumn === this) {
|
||||
return;
|
||||
}
|
||||
this.grid.onColumnMoved(this, prevColumn);
|
||||
}
|
||||
|
||||
public isAfter(other: Column) {
|
||||
return this.gridX > other.gridX;
|
||||
}
|
||||
|
||||
public isBefore(other: Column) {
|
||||
public isToTheLeftOf(other: Column) {
|
||||
return this.gridX < other.gridX;
|
||||
}
|
||||
|
||||
public isToTheRightOf(other: Column) {
|
||||
return this.gridX > other.gridX;
|
||||
}
|
||||
|
||||
public moveWindowUp(window: Window) {
|
||||
this.windows.moveBack(window);
|
||||
this.grid.desktop.onLayoutChanged();
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
class Desktop {
|
||||
public readonly grid: Grid;
|
||||
public readonly kwinDesktop: KwinDesktop;
|
||||
private readonly pinManager: PinManager;
|
||||
private readonly config: Desktop.Config;
|
||||
private scrollX: number;
|
||||
private dirty: boolean;
|
||||
private dirtyScroll: boolean;
|
||||
@@ -10,21 +7,24 @@ class Desktop {
|
||||
public clientArea: QmlRect;
|
||||
public tilingArea: QmlRect;
|
||||
|
||||
constructor(kwinDesktop: KwinDesktop, pinManager: PinManager, config: Desktop.Config, layoutConfig: LayoutConfig) {
|
||||
this.pinManager = pinManager;
|
||||
this.config = config;
|
||||
constructor(
|
||||
public readonly kwinDesktop: KwinDesktop,
|
||||
private readonly pinManager: PinManager,
|
||||
private readonly config: Desktop.Config,
|
||||
private readonly getScreen: () => Output,
|
||||
layoutConfig: LayoutConfig,
|
||||
) {
|
||||
this.scrollX = 0;
|
||||
this.dirty = true;
|
||||
this.dirtyScroll = true;
|
||||
this.dirtyPins = true;
|
||||
this.kwinDesktop = kwinDesktop;
|
||||
this.grid = new Grid(this, layoutConfig);
|
||||
this.clientArea = Desktop.getClientArea(kwinDesktop);
|
||||
this.clientArea = Desktop.getClientArea(this.getScreen(), kwinDesktop);
|
||||
this.tilingArea = Desktop.getTilingArea(this.clientArea, kwinDesktop, pinManager, config);
|
||||
}
|
||||
|
||||
private updateArea() {
|
||||
const newClientArea = Desktop.getClientArea(this.kwinDesktop);
|
||||
const newClientArea = Desktop.getClientArea(this.getScreen(), this.kwinDesktop);
|
||||
if (newClientArea === this.clientArea && !this.dirtyPins) {
|
||||
return;
|
||||
}
|
||||
@@ -37,8 +37,8 @@ class Desktop {
|
||||
this.autoAdjustScroll();
|
||||
}
|
||||
|
||||
private static getClientArea(kwinDesktop: KwinDesktop) {
|
||||
return Workspace.clientArea(ClientAreaOption.PlacementArea, Workspace.activeScreen, kwinDesktop);
|
||||
private static getClientArea(screen: Output, kwinDesktop: KwinDesktop) {
|
||||
return Workspace.clientArea(ClientAreaOption.PlacementArea, screen, kwinDesktop);
|
||||
}
|
||||
|
||||
private static getTilingArea(clientArea: QmlRect, kwinDesktop: KwinDesktop, pinManager: PinManager, config: Desktop.Config) {
|
||||
|
||||
@@ -24,6 +24,18 @@ class Grid {
|
||||
});
|
||||
}
|
||||
|
||||
public moveColumn(column: Column, prevColumn: Column|null) {
|
||||
if (column === prevColumn) {
|
||||
return;
|
||||
}
|
||||
const movedLeft = prevColumn === null ? true : column.isToTheRightOf(prevColumn);
|
||||
const firstMovedColumn = movedLeft ? column : this.getNextColumn(column);
|
||||
this.columns.move(column, prevColumn);
|
||||
this.columnsSetX(firstMovedColumn);
|
||||
this.desktop.onLayoutChanged();
|
||||
this.desktop.autoAdjustScroll();
|
||||
}
|
||||
|
||||
public moveColumnLeft(column: Column) {
|
||||
this.columns.moveBack(column);
|
||||
this.columnsSetX(column);
|
||||
@@ -180,15 +192,6 @@ class Grid {
|
||||
}
|
||||
}
|
||||
|
||||
public onColumnMoved(column: Column, prevColumn: Column|null) {
|
||||
const movedLeft = prevColumn === null ? true : column.isAfter(prevColumn);
|
||||
const firstMovedColumn = movedLeft ? column : this.getNextColumn(column);
|
||||
this.columns.move(column, prevColumn);
|
||||
this.columnsSetX(firstMovedColumn);
|
||||
this.desktop.onLayoutChanged();
|
||||
this.desktop.autoAdjustScroll();
|
||||
}
|
||||
|
||||
public onColumnWidthChanged(column: Column) {
|
||||
const nextColumn = this.columns.getNext(column);
|
||||
this.columnsSetX(nextColumn);
|
||||
|
||||
@@ -34,16 +34,22 @@ function initWorkspaceSignalHandlers(world: World) {
|
||||
world.do(() => {}); // re-arrange desktop
|
||||
});
|
||||
|
||||
manager.connect(Workspace.desktopsChanged, () => {
|
||||
manager.connect(Workspace.screensChanged, () => {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
desktopManager.updateDesktops();
|
||||
})
|
||||
desktopManager.selectScreen(Workspace.activeScreen);
|
||||
});
|
||||
});
|
||||
|
||||
manager.connect(Workspace.activitiesChanged, () => {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
desktopManager.updateActivities();
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
manager.connect(Workspace.desktopsChanged, () => {
|
||||
world.do((clientManager, desktopManager) => {
|
||||
desktopManager.updateDesktops();
|
||||
});
|
||||
});
|
||||
|
||||
manager.connect(Workspace.virtualScreenSizeChanged, () => {
|
||||
|
||||
@@ -3,6 +3,7 @@ class DesktopManager {
|
||||
private readonly config: Desktop.Config;
|
||||
public readonly layoutConfig: LayoutConfig;
|
||||
private readonly desktops: Map<string, Desktop>; // key is activityId|desktopId
|
||||
private selectedScreen: Output;
|
||||
private kwinActivities: Set<string>;
|
||||
private kwinDesktops: Set<KwinDesktop>;
|
||||
|
||||
@@ -11,6 +12,7 @@ class DesktopManager {
|
||||
this.config = config;
|
||||
this.layoutConfig = layoutConfig;
|
||||
this.desktops = new Map();
|
||||
this.selectedScreen = Workspace.activeScreen;
|
||||
this.kwinActivities = new Set(Workspace.activities);
|
||||
this.kwinDesktops = new Set(Workspace.desktops);
|
||||
this.addDesktop(currentActivity, currentDesktop);
|
||||
@@ -43,7 +45,13 @@ class DesktopManager {
|
||||
|
||||
private addDesktop(activity: string, kwinDesktop: KwinDesktop) {
|
||||
const desktopKey = DesktopManager.getDesktopKey(activity, kwinDesktop);
|
||||
const desktop = new Desktop(kwinDesktop, this.pinManager, this.config, this.layoutConfig);
|
||||
const desktop = new Desktop(
|
||||
kwinDesktop,
|
||||
this.pinManager,
|
||||
this.config,
|
||||
() => this.selectedScreen,
|
||||
this.layoutConfig,
|
||||
);
|
||||
this.desktops.set(desktopKey, desktop);
|
||||
return desktop;
|
||||
}
|
||||
@@ -72,6 +80,10 @@ class DesktopManager {
|
||||
this.kwinDesktops = newDesktops;
|
||||
}
|
||||
|
||||
public selectScreen(screen: Output) {
|
||||
this.selectedScreen = screen;
|
||||
}
|
||||
|
||||
private removeActivity(activity: string) {
|
||||
for (const kwinDesktop of this.kwinDesktops) {
|
||||
this.destroyDesktop(activity, kwinDesktop);
|
||||
|
||||
Reference in New Issue
Block a user