refactor: wrap numberScreensChanged signal

This commit is contained in:
Mikhail Zolotukhin 2022-03-26 14:11:06 +03:00 committed by Genda
parent 288d9cf944
commit e8cd561eee
5 changed files with 17 additions and 17 deletions

View File

@ -31,6 +31,7 @@ void Controller::bindEvents()
{ {
auto &workspace = m_plasmaApi.workspace(); auto &workspace = m_plasmaApi.workspace();
connect(&workspace, &PlasmaApi::Workspace::currentDesktopChanged, this, &Controller::onCurrentSurfaceChanged); connect(&workspace, &PlasmaApi::Workspace::currentDesktopChanged, this, &Controller::onCurrentSurfaceChanged);
connect(&workspace, &PlasmaApi::Workspace::numberScreensChanged, this, &Controller::onSurfaceUpdate);
} }
void Controller::registerAction(const Action &data) void Controller::registerAction(const Action &data)
@ -65,6 +66,15 @@ void Controller::onCurrentSurfaceChanged()
} }
} }
void Controller::onSurfaceUpdate()
{
if (m_proxy) {
auto ctl = m_proxy->jsController();
auto func = ctl.property("onSurfaceUpdate");
func.callWithInstance(ctl);
}
}
void Controller::setProxy(TSProxy *proxy) void Controller::setProxy(TSProxy *proxy)
{ {
m_proxy = proxy; m_proxy = proxy;

View File

@ -40,6 +40,7 @@ public:
public Q_SLOTS: public Q_SLOTS:
void onCurrentSurfaceChanged(); void onCurrentSurfaceChanged();
void onSurfaceUpdate();
private: private:
std::vector<QAction *> m_registeredShortcuts{}; std::vector<QAction *> m_registeredShortcuts{};

View File

@ -41,8 +41,8 @@ void Workspace::wrapSignals()
connect(m_kwinImpl, implNormSignature, this, thisNormSignature); connect(m_kwinImpl, implNormSignature, this, thisNormSignature);
}; };
wrapSimpleSignal(SIGNAL(numberScreensChanged(int count))); wrapSimpleSignal(SIGNAL(numberScreensChanged(int)));
wrapSimpleSignal(SIGNAL(screenResized(int screen))); wrapSimpleSignal(SIGNAL(screenResized(int)));
wrapSimpleSignal(SIGNAL(currentActivityChanged(const QString &))); wrapSimpleSignal(SIGNAL(currentActivityChanged(const QString &)));
wrapComplexSignal(SIGNAL(currentDesktopChanged(int, KWin::AbstractClient *)), SLOT(currentDesktopChangedTransformer(int, KWin::AbstractClient *))); wrapComplexSignal(SIGNAL(currentDesktopChanged(int, KWin::AbstractClient *)), SLOT(currentDesktopChangedTransformer(int, KWin::AbstractClient *)));
@ -50,8 +50,7 @@ void Workspace::wrapSignals()
wrapComplexSignal(SIGNAL(clientRemoved(KWin::AbstractClient *)), SLOT(clientRemovedTransformer(KWin::AbstractClient *))); wrapComplexSignal(SIGNAL(clientRemoved(KWin::AbstractClient *)), SLOT(clientRemovedTransformer(KWin::AbstractClient *)));
wrapComplexSignal(SIGNAL(clientMinimized(KWin::AbstractClient *)), SLOT(clientMinimizedTransformer(KWin::AbstractClient *))); wrapComplexSignal(SIGNAL(clientMinimized(KWin::AbstractClient *)), SLOT(clientMinimizedTransformer(KWin::AbstractClient *)));
wrapComplexSignal(SIGNAL(clientUnminimized(KWin::AbstractClient *)), SLOT(clientUnminimizedTransformer(KWin::AbstractClient *))); wrapComplexSignal(SIGNAL(clientUnminimized(KWin::AbstractClient *)), SLOT(clientUnminimizedTransformer(KWin::AbstractClient *)));
wrapComplexSignal(SIGNAL(clientMaximizeSet(KWin::AbstractClient *, bool h, bool v)), wrapComplexSignal(SIGNAL(clientMaximizeSet(KWin::AbstractClient *, bool, bool)), SLOT(clientMaximizeSetTransformer(KWin::AbstractClient *, bool, bool)));
SLOT(clientMaximizeSetTransformer(KWin::AbstractClient *, bool h, bool v)));
}; };
QRect Workspace::clientArea(ClientAreaOption option, int screen, int desktop) QRect Workspace::clientArea(ClientAreaOption option, int screen, int desktop)

View File

@ -54,9 +54,8 @@ export interface Controller {
/** /**
* React to screen update. For example, when the new screen has connected. * React to screen update. For example, when the new screen has connected.
* @param comment the metadata string about the details of what has changed
*/ */
onSurfaceUpdate(comment: string): void; onSurfaceUpdate(): void;
/** /**
* React to window geometry update * React to window geometry update
@ -205,8 +204,7 @@ export class ControllerImpl implements Controller {
this.driver.showNotification(text, icon, hint); this.driver.showNotification(text, icon, hint);
} }
public onSurfaceUpdate(comment: string): void { public onSurfaceUpdate(): void {
this.log.log(["onSurfaceUpdate", { comment }]);
this.engine.arrange(); this.engine.arrange();
} }

View File

@ -167,10 +167,6 @@ export class DriverImpl implements Driver {
} }
public bindEvents(): void { public bindEvents(): void {
const onNumberScreensChanged = (count: number): void => {
this.controller.onSurfaceUpdate(`screens=${count}`);
};
const onScreenResized = (screen: number): void => { const onScreenResized = (screen: number): void => {
const srf = new DriverSurfaceImpl( const srf = new DriverSurfaceImpl(
screen, screen,
@ -180,7 +176,7 @@ export class DriverImpl implements Driver {
this.config, this.config,
this.proxy this.proxy
); );
this.controller.onSurfaceUpdate("resized " + srf.toString()); this.controller.onSurfaceUpdate();
}; };
const onCurrentActivityChanged = (_activity: string): void => { const onCurrentActivityChanged = (_activity: string): void => {
@ -242,10 +238,6 @@ export class DriverImpl implements Driver {
"unminimized" "unminimized"
); );
this.connect(
this.kwinApi.workspace.numberScreensChanged,
onNumberScreensChanged
);
this.connect(this.kwinApi.workspace.screenResized, onScreenResized); this.connect(this.kwinApi.workspace.screenResized, onScreenResized);
this.connect( this.connect(
this.kwinApi.workspace.currentActivityChanged, this.kwinApi.workspace.currentActivityChanged,