chore: don't use proxy for KWinAPI

This commit is contained in:
Mikhail Zolotukhin 2022-09-17 21:57:04 +03:00
parent 8fd8a0f95e
commit 2b8b78be15
4 changed files with 23 additions and 31 deletions

View File

@ -64,12 +64,12 @@ export interface Driver {
export class DriverImpl implements Driver {
public get currentSurface(): DriverSurface {
return new DriverSurfaceImpl(
this.proxy.workspace().activeScreen,
this.proxy.workspace().currentActivity,
this.proxy.workspace().currentDesktop,
this.kwinApi.workspace.activeScreen,
this.kwinApi.workspace.currentActivity,
this.kwinApi.workspace.currentDesktop,
this.qml.activityInfo,
this.config,
this.proxy
this.kwinApi
);
}
@ -80,8 +80,8 @@ export class DriverImpl implements Driver {
// TODO: focusing window on other screen?
// TODO: find a way to change activity
if (this.proxy.workspace().currentDesktop !== kwinSurface.desktop) {
this.proxy.workspace().currentDesktop = kwinSurface.desktop;
if (this.kwinApi.workspace.currentDesktop !== kwinSurface.desktop) {
this.kwinApi.workspace.currentDesktop = kwinSurface.desktop;
}
}
@ -100,15 +100,15 @@ export class DriverImpl implements Driver {
public get screens(): DriverSurface[] {
const screensArr = [];
for (let screen = 0; screen < this.proxy.workspace().numScreens; screen++) {
for (let screen = 0; screen < this.kwinApi.workspace.numScreens; screen++) {
screensArr.push(
new DriverSurfaceImpl(
screen,
this.proxy.workspace().currentActivity,
this.proxy.workspace().currentDesktop,
this.kwinApi.workspace.currentActivity,
this.kwinApi.workspace.currentDesktop,
this.qml.activityInfo,
this.config,
this.proxy
this.kwinApi
)
);
}
@ -150,13 +150,7 @@ export class DriverImpl implements Driver {
(client: KWin.Client) => DriverWindowImpl.generateID(client),
(client: KWin.Client) =>
new EngineWindowImpl(
new DriverWindowImpl(
client,
this.qml,
this.config,
this.log,
this.proxy
),
new DriverWindowImpl(client, this.qml, this.config, this.kwinApi),
this.config,
this.log
)

View File

@ -45,7 +45,7 @@ export class DriverSurfaceImpl implements DriverSurface {
public readonly desktop: number,
private activityInfo: Plasma.TaskManager.ActivityInfo,
private config: Config,
private proxy: TSProxy
private kwinApi: KWin.Api
) {
this.id = this.generateId();
@ -55,7 +55,7 @@ export class DriverSurfaceImpl implements DriverSurface {
this.config.ignoreScreen.indexOf(screen) >= 0;
this.workingArea = Rect.fromQRect(
this.proxy.workspace().clientArea(
this.kwinApi.workspace.clientArea(
0, // This is PlacementArea
screen,
desktop
@ -65,7 +65,7 @@ export class DriverSurfaceImpl implements DriverSurface {
public next(): DriverSurface | null {
// This is the last virtual desktop
if (this.desktop === this.proxy.workspace().desktops) {
if (this.desktop === this.kwinApi.workspace.desktops) {
return null;
}
@ -75,7 +75,7 @@ export class DriverSurfaceImpl implements DriverSurface {
this.desktop + 1,
this.activityInfo,
this.config,
this.proxy
this.kwinApi
);
}

View File

@ -161,12 +161,12 @@ export class DriverWindowImpl implements DriverWindow {
public get surface(): DriverSurface {
let activity;
if (this.client.activities.length === 0) {
activity = this.proxy.workspace().currentActivity;
activity = this.kwinApi.workspace.currentActivity;
} else if (
this.client.activities.indexOf(this.proxy.workspace().currentActivity) >=
this.client.activities.indexOf(this.kwinApi.workspace.currentActivity) >=
0
) {
activity = this.proxy.workspace().currentActivity;
activity = this.kwinApi.workspace.currentActivity;
} else {
activity = this.client.activities[0];
}
@ -174,7 +174,7 @@ export class DriverWindowImpl implements DriverWindow {
const desktop =
this.client.desktop >= 0
? this.client.desktop
: this.proxy.workspace().currentDesktop;
: this.kwinApi.workspace.currentDesktop;
return new DriverSurfaceImpl(
this.client.screen,
@ -182,7 +182,7 @@ export class DriverWindowImpl implements DriverWindow {
desktop,
this.qml.activityInfo,
this.config,
this.proxy
this.kwinApi
);
}
@ -211,8 +211,7 @@ export class DriverWindowImpl implements DriverWindow {
public readonly client: KWin.Client,
private qml: Bismuth.Qml.Main,
private config: Config,
private log: Log,
private proxy: TSProxy
private kwinApi: KWin.Api
) {
this.id = DriverWindowImpl.generateID(client);
this.maximized = false;
@ -273,10 +272,10 @@ export class DriverWindowImpl implements DriverWindow {
geometry = this.adjustGeometry(geometry);
if (this.config.preventProtrusion) {
const area = Rect.fromQRect(
this.proxy.workspace().clientArea(
this.kwinApi.workspace.clientArea(
0, // This is placement area
this.client.screen,
this.proxy.workspace().currentDesktop
this.kwinApi.workspace.currentDesktop
)
);
if (!area.includes(geometry)) {

View File

@ -5,7 +5,6 @@ import { Config } from "../config";
import { Action } from "../controller/action";
export interface TSProxy {
workspace(): KWin.WorkspaceWrapper;
jsConfig(): Config;
registerShortcut(data: Action): void;
log(value: any): void;