12 Commits

Author SHA1 Message Date
Peter Fajdiga
adc78f11bc bump version to 0.9.4 2024-07-09 21:27:54 +02:00
Peter Fajdiga
f1206b18b1 switch screen on screensChanged 2024-07-09 09:50:16 +02:00
Peter Fajdiga
c6066c354d add action screen-switch (fixes #37) 2024-07-09 09:34:50 +02:00
Peter Fajdiga
914202f091 Desktop: use constructor assignment 2024-07-09 09:05:30 +02:00
Peter Fajdiga
b85c86e7db Column: rename isToTheLeftOf and isToTheRightOf 2024-07-08 12:25:55 +02:00
Peter Fajdiga
fdb4b88333 Column: remove moveAfter 2024-07-08 12:25:50 +02:00
Peter Fajdiga
4e3d924366 Grid: rename moveColumn 2024-07-08 12:25:24 +02:00
Peter Fajdiga
3d3e8cff17 config: adjust default gaps 2024-07-07 23:24:23 +02:00
Peter Fajdiga
a79229da75 bump version to 0.9.3 2024-07-07 12:46:55 +02:00
Peter Fajdiga
53d04c1d33 config: don't tile xwaylandvideobridge (fixes #54) 2024-07-07 12:17:21 +02:00
Peter Fajdiga
a18ff61d9e prevent untiling maximized windows (fixes #51) 2024-07-05 16:12:23 +02:00
Peter Fajdiga
99ffad9223 use inqequality operator with MaximizedMode 2024-07-05 16:00:06 +02:00
13 changed files with 89 additions and 54 deletions

View File

@@ -9,7 +9,7 @@
"Name": "Peter Fajdiga"
}],
"Id": "karousel",
"Version": "0.9.2",
"Version": "0.9.4",
"License": "GPLv3",
"Website": "https://github.com/peterfajdiga/karousel",
"BugReportUrl": "https://github.com/peterfajdiga/karousel/issues"

View File

@@ -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));
}
});
};

View File

@@ -3,6 +3,10 @@ const defaultWindowRules = `[
"class": "ksmserver-logout-greeter",
"tile": false
},
{
"class": "xwaylandvideobridge",
"tile": false
},
{
"class": "(org\\\\.kde\\\\.)?plasmashell",
"tile": false
@@ -62,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",

View File

@@ -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<[]>;

View File

@@ -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[] = [

View File

@@ -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();

View File

@@ -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) {

View File

@@ -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);

View File

@@ -36,7 +36,7 @@ class Window {
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) {
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,
@@ -79,7 +79,7 @@ class Window {
}
public onMaximizedChanged(maximizedMode: MaximizedMode) {
const maximized = maximizedMode > MaximizedMode.Unmaximized;
const maximized = maximizedMode !== MaximizedMode.Unmaximized;
this.skipArrange = maximized;
if (this.column.grid.config.tiledKeepBelow) {
this.client.kwinClient.keepBelow = !maximized;

View File

@@ -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, () => {

View File

@@ -118,6 +118,11 @@ class ClientManager {
if (client === undefined) {
return;
}
if (client.getMaximizedMode() !== MaximizedMode.Unmaximized) {
// the client is not really kwin-tiled, just maximized
kwinClient.tile = null;
return;
}
client.stateManager.setState(() => new ClientState.Pinned(this.world, this.pinManager, this.desktopManager, kwinClient, this.config), false);
this.pinManager.addClient(kwinClient);
for (const desktop of this.desktopManager.getDesktopsForClient(kwinClient)) {

View File

@@ -180,7 +180,7 @@ class ClientWrapper {
const manager = new SignalManager();
manager.connect(client.kwinClient.maximizedAboutToChange, (maximizedMode: MaximizedMode) => {
if (maximizedMode > MaximizedMode.Unmaximized && client.kwinClient.tile !== null) {
if (maximizedMode !== MaximizedMode.Unmaximized && client.kwinClient.tile !== null) {
client.kwinClient.tile = null;
}
client.maximizedMode = maximizedMode;

View File

@@ -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);