From eb9d989a3a505f3695ede1735e3bfc927695e19a Mon Sep 17 00:00:00 2001 From: Mikhail Zolotukhin Date: Mon, 21 Mar 2022 21:21:14 +0300 Subject: [PATCH] refactor: put currentDesktop API into use --- src/core/plasma-api/utils.hpp | 11 ++++++----- src/kwinscript/driver/index.ts | 12 ++++++------ src/kwinscript/driver/window.ts | 4 ++-- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/core/plasma-api/utils.hpp b/src/core/plasma-api/utils.hpp index fb822e0b..9d9d4ade 100644 --- a/src/core/plasma-api/utils.hpp +++ b/src/core/plasma-api/utils.hpp @@ -3,14 +3,15 @@ #pragma once -#define BI_READ_ONLY_PROPERTY(TYPE, NAME) \ +#include + +#define BI_PROPERTY(TYPE, NAME, SETTER_NAME) \ + Q_PROPERTY(TYPE NAME READ NAME WRITE SETTER_NAME); \ + \ TYPE NAME() const \ { \ return m_kwinImpl->property(#NAME).value(); \ - } - -#define BI_PROPERTY(TYPE, NAME, SETTER_NAME) \ - BI_READ_ONLY_PROPERTY(TYPE, NAME) \ + } \ \ void SETTER_NAME(const TYPE &value) \ { \ diff --git a/src/kwinscript/driver/index.ts b/src/kwinscript/driver/index.ts index cb7f24b7..0b61ab3e 100644 --- a/src/kwinscript/driver/index.ts +++ b/src/kwinscript/driver/index.ts @@ -68,7 +68,7 @@ export class DriverImpl implements Driver { ? this.kwinApi.workspace.activeClient.screen : 0, this.kwinApi.workspace.currentActivity, - this.kwinApi.workspace.currentDesktop, + this.proxy.workspace().currentDesktop, this.qml.activityInfo, this.kwinApi, this.config, @@ -83,8 +83,8 @@ export class DriverImpl implements Driver { // TODO: focusing window on other screen? // TODO: find a way to change activity - if (this.kwinApi.workspace.currentDesktop !== kwinSurface.desktop) { - this.kwinApi.workspace.currentDesktop = kwinSurface.desktop; + if (this.proxy.workspace().currentDesktop !== kwinSurface.desktop) { + this.proxy.workspace().currentDesktop = kwinSurface.desktop; } } @@ -108,7 +108,7 @@ export class DriverImpl implements Driver { new DriverSurfaceImpl( screen, this.kwinApi.workspace.currentActivity, - this.kwinApi.workspace.currentDesktop, + this.proxy.workspace().currentDesktop, this.qml.activityInfo, this.kwinApi, this.config, @@ -180,7 +180,7 @@ export class DriverImpl implements Driver { const srf = new DriverSurfaceImpl( screen, this.kwinApi.workspace.currentActivity, - this.kwinApi.workspace.currentDesktop, + this.proxy.workspace().currentDesktop, this.qml.activityInfo, this.kwinApi, this.config, @@ -276,7 +276,7 @@ export class DriverImpl implements Driver { onCurrentActivityChanged ); this.connect( - this.kwinApi.workspace.currentDesktopChanged, + this.proxy.workspace().currentDesktopChanged, onCurrentDesktopChanged ); this.connect(this.kwinApi.workspace.clientAdded, onClientAdded); diff --git a/src/kwinscript/driver/window.ts b/src/kwinscript/driver/window.ts index 06d726bf..2a694028 100644 --- a/src/kwinscript/driver/window.ts +++ b/src/kwinscript/driver/window.ts @@ -174,7 +174,7 @@ export class DriverWindowImpl implements DriverWindow { const desktop = this.client.desktop >= 0 ? this.client.desktop - : this.kwinApi.workspace.currentDesktop; + : this.proxy.workspace().currentDesktop; return new DriverSurfaceImpl( this.client.screen, @@ -281,7 +281,7 @@ export class DriverWindowImpl implements DriverWindow { .clientArea( this.kwinApi.KWin.PlacementArea, this.client.screen, - this.kwinApi.workspace.currentDesktop + this.proxy.workspace().currentDesktop ) ); if (!area.includes(geometry)) {