From 91a277ea1e8e90d96bedd09a018eb6d2411fa094 Mon Sep 17 00:00:00 2001 From: Mikhail Zolotukhin Date: Wed, 23 Mar 2022 18:26:12 +0300 Subject: [PATCH] refactor: wrap currentActivity Property --- src/core/plasma-api/workspace.cpp | 1 + src/core/plasma-api/workspace.hpp | 7 +++++++ src/kwinscript/driver/index.ts | 6 +++--- src/kwinscript/driver/window.ts | 6 +++--- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/core/plasma-api/workspace.cpp b/src/core/plasma-api/workspace.cpp index 90cc8cac..b01ef375 100644 --- a/src/core/plasma-api/workspace.cpp +++ b/src/core/plasma-api/workspace.cpp @@ -42,6 +42,7 @@ void Workspace::wrapSignals() }; wrapComplexSignal(SIGNAL(currentDesktopChanged(int, KWin::AbstractClient *)), SLOT(currentDesktopChangedTransformer(int, KWin::AbstractClient *))); + wrapSimpleSignal(SIGNAL(currentActivityChanged(const QString &))); }; QRect Workspace::clientArea(ClientAreaOption option, int screen, int desktop) diff --git a/src/core/plasma-api/workspace.hpp b/src/core/plasma-api/workspace.hpp index 763f8ee5..b3f2d7c0 100644 --- a/src/core/plasma-api/workspace.hpp +++ b/src/core/plasma-api/workspace.hpp @@ -38,6 +38,7 @@ public: Workspace(const Workspace &); BI_PROPERTY(int, currentDesktop, setCurrentDesktop); + BI_PROPERTY(QString, currentActivity, setCurrentActivity); /** * Returns the geometry a Client can use with the specified option. @@ -57,6 +58,12 @@ private Q_SLOTS: Q_SIGNALS: void currentDesktopChanged(int desktop, PlasmaApi::Client kwinClient); + /** + * Signal emitted whenever the current activity changed. + * @param id id of the new activity + */ + void currentActivityChanged(const QString &id); + private: void wrapSignals(); diff --git a/src/kwinscript/driver/index.ts b/src/kwinscript/driver/index.ts index 0b61ab3e..416db17f 100644 --- a/src/kwinscript/driver/index.ts +++ b/src/kwinscript/driver/index.ts @@ -67,7 +67,7 @@ export class DriverImpl implements Driver { this.kwinApi.workspace.activeClient ? this.kwinApi.workspace.activeClient.screen : 0, - this.kwinApi.workspace.currentActivity, + this.proxy.workspace().currentActivity, this.proxy.workspace().currentDesktop, this.qml.activityInfo, this.kwinApi, @@ -107,7 +107,7 @@ export class DriverImpl implements Driver { screensArr.push( new DriverSurfaceImpl( screen, - this.kwinApi.workspace.currentActivity, + this.proxy.workspace().currentActivity, this.proxy.workspace().currentDesktop, this.qml.activityInfo, this.kwinApi, @@ -179,7 +179,7 @@ export class DriverImpl implements Driver { const onScreenResized = (screen: number): void => { const srf = new DriverSurfaceImpl( screen, - this.kwinApi.workspace.currentActivity, + this.proxy.workspace().currentActivity, this.proxy.workspace().currentDesktop, this.qml.activityInfo, this.kwinApi, diff --git a/src/kwinscript/driver/window.ts b/src/kwinscript/driver/window.ts index 2a694028..6ae385f3 100644 --- a/src/kwinscript/driver/window.ts +++ b/src/kwinscript/driver/window.ts @@ -161,12 +161,12 @@ export class DriverWindowImpl implements DriverWindow { public get surface(): DriverSurface { let activity; if (this.client.activities.length === 0) { - activity = this.kwinApi.workspace.currentActivity; + activity = this.proxy.workspace().currentActivity; } else if ( - this.client.activities.indexOf(this.kwinApi.workspace.currentActivity) >= + this.client.activities.indexOf(this.proxy.workspace().currentActivity) >= 0 ) { - activity = this.kwinApi.workspace.currentActivity; + activity = this.proxy.workspace().currentActivity; } else { activity = this.client.activities[0]; }