forked from Blendman974/faceclaw
Windows: decide a surface's visibility when the call is queued, not before
connect() registers window surfaces in a loop that reads the foreground window once, before the loop, then awaits each surface's configure call before queuing its visibility. On a fresh process restoreOpenApps runs at the same time and focuses windows as it relaunches them. The bridge runs Java calls in order, so a visibility decided before the await lands after the focus change's own calls and undoes them: the old foreground can stay visible and cover the new one, and a later window switch doesn't clear it, because a switch only hides the window being left. configureWindowSurface now also accepts visibility as a function, asked after the configure call, when the visibility call is queued. The display- attach loops (glasses and preview), the display-mode, per-app layout and vertical-position changes, and an in-process window's height-mode change pass one. Launch paths that pass a literal false are unchanged. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
54eae0c6b9
commit
8cdee83ff4
1 file changed
+25
-13
@@ -510,7 +510,7 @@ class DashboardController {
|
|||||||
window.relayout();
|
window.relayout();
|
||||||
await this.configureWindowSurface(
|
await this.configureWindowSurface(
|
||||||
window.surfaceId,
|
window.surfaceId,
|
||||||
window.windowId === foregroundWindowId,
|
this.isForegroundWindow(window.windowId),
|
||||||
window.heightMode,
|
window.heightMode,
|
||||||
);
|
);
|
||||||
} else if (window.closeable) {
|
} else if (window.closeable) {
|
||||||
@@ -548,7 +548,7 @@ class DashboardController {
|
|||||||
void (async () => {
|
void (async () => {
|
||||||
for (const window of Array.from(shell.getWindows())) {
|
for (const window of Array.from(shell.getWindows())) {
|
||||||
if (!changed.includes(window.appId)) continue;
|
if (!changed.includes(window.appId)) continue;
|
||||||
await this.configureWindowSurface(window.surfaceId, window.windowId === shell.foregroundWindow()?.windowId, window.heightMode);
|
await this.configureWindowSurface(window.surfaceId, this.isForegroundWindow(window.windowId), window.heightMode);
|
||||||
window.relayout?.();
|
window.relayout?.();
|
||||||
}
|
}
|
||||||
shell.foregroundWindow()?.requestRender();
|
shell.foregroundWindow()?.requestRender();
|
||||||
@@ -560,12 +560,11 @@ class DashboardController {
|
|||||||
const position = verticalPositionSetting.get();
|
const position = verticalPositionSetting.get();
|
||||||
if (position === this.lastVerticalPosition) return;
|
if (position === this.lastVerticalPosition) return;
|
||||||
this.lastVerticalPosition = position;
|
this.lastVerticalPosition = position;
|
||||||
const foregroundWindowId = shell.foregroundWindow()?.windowId;
|
|
||||||
void (async () => {
|
void (async () => {
|
||||||
for (const window of shell.getWindows()) {
|
for (const window of shell.getWindows()) {
|
||||||
await this.configureWindowSurface(
|
await this.configureWindowSurface(
|
||||||
window.surfaceId,
|
window.surfaceId,
|
||||||
window.windowId === foregroundWindowId,
|
this.isForegroundWindow(window.windowId),
|
||||||
window.heightMode,
|
window.heightMode,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1249,11 +1248,10 @@ class DashboardController {
|
|||||||
// loop re-applies the current dim from here.
|
// loop re-applies the current dim from here.
|
||||||
await target.setUnderlayDim(SHELL_SURFACE_Z_ORDER, 1);
|
await target.setUnderlayDim(SHELL_SURFACE_Z_ORDER, 1);
|
||||||
this.appliedUnderlayDim = 1;
|
this.appliedUnderlayDim = 1;
|
||||||
const foregroundWindowId = shell.foregroundWindow()?.windowId;
|
|
||||||
for (const window of shell.getWindows()) {
|
for (const window of shell.getWindows()) {
|
||||||
await this.configureWindowSurface(
|
await this.configureWindowSurface(
|
||||||
window.surfaceId,
|
window.surfaceId,
|
||||||
window.windowId === foregroundWindowId,
|
this.isForegroundWindow(window.windowId),
|
||||||
window.heightMode,
|
window.heightMode,
|
||||||
target,
|
target,
|
||||||
);
|
);
|
||||||
@@ -1538,11 +1536,10 @@ class DashboardController {
|
|||||||
await communicator.setUnderlayDim(SHELL_SURFACE_Z_ORDER, 1);
|
await communicator.setUnderlayDim(SHELL_SURFACE_Z_ORDER, 1);
|
||||||
this.appliedUnderlayDim = 1;
|
this.appliedUnderlayDim = 1;
|
||||||
await this.configureLockSurface(communicator);
|
await this.configureLockSurface(communicator);
|
||||||
const foregroundWindowId = shell.foregroundWindow()?.windowId;
|
|
||||||
for (const window of shell.getWindows()) {
|
for (const window of shell.getWindows()) {
|
||||||
await this.configureWindowSurface(
|
await this.configureWindowSurface(
|
||||||
window.surfaceId,
|
window.surfaceId,
|
||||||
window.windowId === foregroundWindowId,
|
this.isForegroundWindow(window.windowId),
|
||||||
window.heightMode,
|
window.heightMode,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -2276,8 +2273,7 @@ class DashboardController {
|
|||||||
reconfigureSurface: (heightMode) => {
|
reconfigureSurface: (heightMode) => {
|
||||||
// Resize the surface rect to the new band; a foreground window stays
|
// Resize the surface rect to the new band; a foreground window stays
|
||||||
// visible. The shell re-renders so the chrome (top bar) follows.
|
// visible. The shell re-renders so the chrome (top bar) follows.
|
||||||
const visible = shell.foregroundWindow()?.windowId === windowId;
|
void this.configureWindowSurface(surfaceId, this.isForegroundWindow(windowId), heightMode);
|
||||||
void this.configureWindowSurface(surfaceId, visible, heightMode);
|
|
||||||
this.requestShellRender();
|
this.requestShellRender();
|
||||||
},
|
},
|
||||||
onClosed: () => {
|
onClosed: () => {
|
||||||
@@ -2430,10 +2426,21 @@ class DashboardController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Create/refresh a window surface on the compositor, if a display target exists. */
|
/**
|
||||||
|
* Create/refresh a window surface on the compositor, if a display target exists.
|
||||||
|
*
|
||||||
|
* `visible` may be a function, asked only after the surface is configured,
|
||||||
|
* right when the visibility call is queued. Callers that loop over windows
|
||||||
|
* or resize one in place must pass one (isForegroundWindow): the configure
|
||||||
|
* call yields, the foreground can change meanwhile, and a visibility decided
|
||||||
|
* before the await then lands AFTER the focus change's own calls, since the
|
||||||
|
* bridge runs Java calls in order. At startup, restoreOpenApps focuses
|
||||||
|
* windows while connect() registers surfaces, so a foreground read before
|
||||||
|
* that loop left the old window visible and the new foreground hidden.
|
||||||
|
*/
|
||||||
private async configureWindowSurface(
|
private async configureWindowSurface(
|
||||||
surfaceId: string,
|
surfaceId: string,
|
||||||
visible: boolean,
|
visible: boolean | (() => boolean),
|
||||||
heightMode: WindowHeightMode = "min",
|
heightMode: WindowHeightMode = "min",
|
||||||
// ensurePreviewDisplay passes its not-yet-published target explicitly.
|
// ensurePreviewDisplay passes its not-yet-published target explicitly.
|
||||||
target: DisplayTarget | null = this.display,
|
target: DisplayTarget | null = this.display,
|
||||||
@@ -2444,7 +2451,12 @@ class DashboardController {
|
|||||||
zOrder: 0,
|
zOrder: 0,
|
||||||
transparency: "opaque",
|
transparency: "opaque",
|
||||||
});
|
});
|
||||||
await target.setSurfaceVisible(surfaceId, visible);
|
await target.setSurfaceVisible(surfaceId, typeof visible === "function" ? visible() : visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A late answer to "is this window in front?", for configureWindowSurface. */
|
||||||
|
private isForegroundWindow(windowId: string): () => boolean {
|
||||||
|
return () => shell.foregroundWindow()?.windowId === windowId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private removeWindowSurface(surfaceId: string): void {
|
private removeWindowSurface(surfaceId: string): void {
|
||||||
|
|||||||
Reference in new issue
Block a user