mirror of
https://github.com/Bismuth-Forge/bismuth.git
synced 2024-09-11 00:15:37 +03:00
refactor: docs and cleanup at driver surface
This commit is contained in:
parent
cb97128cf0
commit
13e202e10e
@ -6,65 +6,53 @@
|
|||||||
import Config from "../config";
|
import Config from "../config";
|
||||||
import { Rect } from "../util/rect";
|
import { Rect } from "../util/rect";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Surface provided by KWin. Surface is essentially a screen space, but
|
||||||
|
* it can represent a surface, that is not currently displayed, e.g. a
|
||||||
|
* virtual desktop.
|
||||||
|
*/
|
||||||
export interface DriverSurface {
|
export interface DriverSurface {
|
||||||
|
/**
|
||||||
|
* Surface unique id
|
||||||
|
*/
|
||||||
readonly id: string;
|
readonly id: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should the surface be completely ignored by the script.
|
||||||
|
*/
|
||||||
readonly ignore: boolean;
|
readonly ignore: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The area in which windows are placed.
|
||||||
|
*/
|
||||||
readonly workingArea: Readonly<Rect>;
|
readonly workingArea: Readonly<Rect>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The next surface. The next surface is a virtual desktop, that comes after current one.
|
||||||
|
*/
|
||||||
next(): DriverSurface | null;
|
next(): DriverSurface | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DriverSurfaceImpl implements DriverSurface {
|
export class DriverSurfaceImpl implements DriverSurface {
|
||||||
public static generateId(
|
|
||||||
screen: number,
|
|
||||||
activity: string,
|
|
||||||
desktop: number,
|
|
||||||
config: Config
|
|
||||||
): string {
|
|
||||||
let path = String(screen);
|
|
||||||
if (config.layoutPerActivity) {
|
|
||||||
path += `@${activity}`;
|
|
||||||
}
|
|
||||||
if (config.layoutPerDesktop) {
|
|
||||||
path += `"#${desktop}`;
|
|
||||||
}
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
public readonly id: string;
|
public readonly id: string;
|
||||||
public readonly ignore: boolean;
|
public readonly ignore: boolean;
|
||||||
public readonly workingArea: Rect;
|
public readonly workingArea: Rect;
|
||||||
|
|
||||||
public readonly screen: number;
|
|
||||||
public readonly activity: string;
|
|
||||||
public readonly desktop: number;
|
|
||||||
|
|
||||||
private activityInfo: Plasma.TaskManager.ActivityInfo;
|
|
||||||
private kwinApi: KWin.Api;
|
|
||||||
private config: Config;
|
|
||||||
constructor(
|
constructor(
|
||||||
screen: number,
|
public readonly screen: number,
|
||||||
activity: string,
|
public readonly activity: string,
|
||||||
desktop: number,
|
public readonly desktop: number,
|
||||||
activityInfo: Plasma.TaskManager.ActivityInfo,
|
private activityInfo: Plasma.TaskManager.ActivityInfo,
|
||||||
kwinApi: KWin.Api,
|
private kwinApi: KWin.Api,
|
||||||
config: Config
|
private config: Config
|
||||||
) {
|
) {
|
||||||
|
this.id = this.generateId();
|
||||||
|
|
||||||
const activityName = activityInfo.activityName(activity);
|
const activityName = activityInfo.activityName(activity);
|
||||||
|
|
||||||
this.activityInfo = activityInfo;
|
|
||||||
this.kwinApi = kwinApi;
|
|
||||||
this.config = config;
|
|
||||||
|
|
||||||
this.id = DriverSurfaceImpl.generateId(
|
|
||||||
screen,
|
|
||||||
activity,
|
|
||||||
desktop,
|
|
||||||
this.config
|
|
||||||
);
|
|
||||||
this.ignore =
|
this.ignore =
|
||||||
this.config.ignoreActivity.indexOf(activityName) >= 0 ||
|
this.config.ignoreActivity.indexOf(activityName) >= 0 ||
|
||||||
this.config.ignoreScreen.indexOf(screen) >= 0;
|
this.config.ignoreScreen.indexOf(screen) >= 0;
|
||||||
|
|
||||||
this.workingArea = Rect.fromQRect(
|
this.workingArea = Rect.fromQRect(
|
||||||
this.kwinApi.workspace.clientArea(
|
this.kwinApi.workspace.clientArea(
|
||||||
this.kwinApi.KWin.PlacementArea,
|
this.kwinApi.KWin.PlacementArea,
|
||||||
@ -72,16 +60,11 @@ export class DriverSurfaceImpl implements DriverSurface {
|
|||||||
desktop
|
desktop
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
this.screen = screen;
|
|
||||||
this.activity = activity;
|
|
||||||
this.desktop = desktop;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public next(): DriverSurface | null {
|
public next(): DriverSurface | null {
|
||||||
|
// This is the last virtual desktop
|
||||||
if (this.desktop === this.kwinApi.workspace.desktops) {
|
if (this.desktop === this.kwinApi.workspace.desktops) {
|
||||||
/* this is the last virtual desktop */
|
|
||||||
/* TODO: option to create additional desktop */
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,14 +79,18 @@ export class DriverSurfaceImpl implements DriverSurface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public toString(): string {
|
public toString(): string {
|
||||||
return (
|
const activityName = this.activityInfo.activityName(this.activity);
|
||||||
"KWinSurface(" +
|
return `DriverSurface(${this.screen}, ${activityName}, ${this.desktop})`;
|
||||||
[
|
}
|
||||||
this.screen,
|
|
||||||
this.activityInfo.activityName(this.activity),
|
private generateId(): string {
|
||||||
this.desktop,
|
let path = String(this.screen);
|
||||||
].join(", ") +
|
if (this.config.layoutPerActivity) {
|
||||||
")"
|
path += `@${this.activity}`;
|
||||||
);
|
}
|
||||||
|
if (this.config.layoutPerDesktop) {
|
||||||
|
path += `"#${this.desktop}`;
|
||||||
|
}
|
||||||
|
return path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user