tests: make mocks more accurately mimic kwin behaviour
This commit is contained in:
@@ -61,3 +61,10 @@ function getClientManager(world: World): ClientManager {
|
||||
world.do((cm, dm) => clientManager = cm);
|
||||
return clientManager!;
|
||||
}
|
||||
|
||||
function activateRandomWindowOnDesktop(desktop: KwinDesktop) {
|
||||
const windows = Workspace.windows.filter(w => w.desktops.includes(desktop));
|
||||
if (windows.length > 0) {
|
||||
Workspace.activeWindow = randomItem(windows);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,6 +198,10 @@ class MockKwinClient {
|
||||
this.desktopsChanged.fire();
|
||||
if (Workspace.activeWindow === this && !desktops.includes(Workspace.currentDesktop)) {
|
||||
Workspace.activeWindow = null;
|
||||
runMaybe(() => Workspace.activeWindow = null); // fired again for some reason
|
||||
if (Workspace.activeWindow === null) {
|
||||
activateRandomWindowOnDesktop(Workspace.currentDesktop);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -58,10 +58,7 @@ class MockWorkspace {
|
||||
() => this.windowRemoved.fire(window),
|
||||
);
|
||||
if (window === this.activeWindow) {
|
||||
const windows = this.windows.filter(w => w.desktops.includes(this.currentDesktop));
|
||||
if (Workspace.activeWindow === null && windows.length > 0) {
|
||||
Workspace.activeWindow = randomItem(windows);
|
||||
}
|
||||
activateRandomWindowOnDesktop(this.currentDesktop);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user