refactor: wrap currentActivity Property

This commit is contained in:
Mikhail Zolotukhin 2022-03-23 18:26:12 +03:00 committed by Genda
parent eb9d989a3a
commit 91a277ea1e
4 changed files with 14 additions and 6 deletions

View File

@ -42,6 +42,7 @@ void Workspace::wrapSignals()
}; };
wrapComplexSignal(SIGNAL(currentDesktopChanged(int, KWin::AbstractClient *)), SLOT(currentDesktopChangedTransformer(int, KWin::AbstractClient *))); 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) QRect Workspace::clientArea(ClientAreaOption option, int screen, int desktop)

View File

@ -38,6 +38,7 @@ public:
Workspace(const Workspace &); Workspace(const Workspace &);
BI_PROPERTY(int, currentDesktop, setCurrentDesktop); BI_PROPERTY(int, currentDesktop, setCurrentDesktop);
BI_PROPERTY(QString, currentActivity, setCurrentActivity);
/** /**
* Returns the geometry a Client can use with the specified option. * Returns the geometry a Client can use with the specified option.
@ -57,6 +58,12 @@ private Q_SLOTS:
Q_SIGNALS: Q_SIGNALS:
void currentDesktopChanged(int desktop, PlasmaApi::Client kwinClient); 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: private:
void wrapSignals(); void wrapSignals();

View File

@ -67,7 +67,7 @@ export class DriverImpl implements Driver {
this.kwinApi.workspace.activeClient this.kwinApi.workspace.activeClient
? this.kwinApi.workspace.activeClient.screen ? this.kwinApi.workspace.activeClient.screen
: 0, : 0,
this.kwinApi.workspace.currentActivity, this.proxy.workspace().currentActivity,
this.proxy.workspace().currentDesktop, this.proxy.workspace().currentDesktop,
this.qml.activityInfo, this.qml.activityInfo,
this.kwinApi, this.kwinApi,
@ -107,7 +107,7 @@ export class DriverImpl implements Driver {
screensArr.push( screensArr.push(
new DriverSurfaceImpl( new DriverSurfaceImpl(
screen, screen,
this.kwinApi.workspace.currentActivity, this.proxy.workspace().currentActivity,
this.proxy.workspace().currentDesktop, this.proxy.workspace().currentDesktop,
this.qml.activityInfo, this.qml.activityInfo,
this.kwinApi, this.kwinApi,
@ -179,7 +179,7 @@ export class DriverImpl implements Driver {
const onScreenResized = (screen: number): void => { const onScreenResized = (screen: number): void => {
const srf = new DriverSurfaceImpl( const srf = new DriverSurfaceImpl(
screen, screen,
this.kwinApi.workspace.currentActivity, this.proxy.workspace().currentActivity,
this.proxy.workspace().currentDesktop, this.proxy.workspace().currentDesktop,
this.qml.activityInfo, this.qml.activityInfo,
this.kwinApi, this.kwinApi,

View File

@ -161,12 +161,12 @@ export class DriverWindowImpl implements DriverWindow {
public get surface(): DriverSurface { public get surface(): DriverSurface {
let activity; let activity;
if (this.client.activities.length === 0) { if (this.client.activities.length === 0) {
activity = this.kwinApi.workspace.currentActivity; activity = this.proxy.workspace().currentActivity;
} else if ( } else if (
this.client.activities.indexOf(this.kwinApi.workspace.currentActivity) >= this.client.activities.indexOf(this.proxy.workspace().currentActivity) >=
0 0
) { ) {
activity = this.kwinApi.workspace.currentActivity; activity = this.proxy.workspace().currentActivity;
} else { } else {
activity = this.client.activities[0]; activity = this.client.activities[0];
} }