Dim the screen underneath when a context menu is open

This commit is contained in:
James Babcock committed 2026-09-03 01:25:10 -07:00
1 parent 83c3732ba7
commit 9234458dd6
13 files changed
+211 -14

No files matched your search

+17
View File
@@ -120,6 +120,11 @@ function nonNegativeNumber(value: number): number {
return Number.isFinite(numeric) ? Math.max(0, numeric) : 0;
}
/** A 0..1 brightness factor as the compositor's 0..256 fixed-point form. */
export function dimFactor256(factor: number): number {
return Math.round(Math.max(0, Math.min(1, factor)) * 256);
}
export class FaceclawCommunicatorBridge {
private readonly communicator: any;
private readonly listenerProxy: any;
@@ -524,6 +529,18 @@ export class FaceclawCommunicatorBridge {
});
}
/**
* Dim every compositor surface whose zOrder is below `belowZOrder` to
* `factor` (0..1; 1 = no dimming) of its brightness; takes effect at the
* next composite. How a shell overlay's Layer.dimUnderneath reaches the
* window surfaces beneath the shell surface.
*/
async setUnderlayDim(belowZOrder: number, factor: number): Promise<void> {
await this.enqueueJavaCall(() => {
this.communicator.setUnderlayDim(Math.round(belowZOrder), dimFactor256(factor));
});
}
/** Show or hide a compositor surface; takes effect at the next composite. */
async setSurfaceVisible(id: string, visible: boolean): Promise<void> {
await this.enqueueJavaCall(() => {
+6 -1
View File
@@ -1,5 +1,5 @@
import { ImageSource, Utils } from "@nativescript/core";
import type { FaceclawCommunicatorBridge, SurfaceOptions } from "./faceclaw-communicator";
import { dimFactor256, type FaceclawCommunicatorBridge, type SurfaceOptions } from "./faceclaw-communicator";
declare const com: any;
declare const java: any;
@@ -19,6 +19,7 @@ export type DisplayTarget = Pick<
| "configureSurface"
| "removeSurface"
| "setSurfaceVisible"
| "setUnderlayDim"
| "setScreenBlanked"
| "submitSurfaceFrame"
| "waitForFrameFinished"
@@ -96,6 +97,10 @@ export class PreviewDisplayTarget implements DisplayTarget {
this.compositor.setSurfaceVisible(id, Boolean(visible));
}
async setUnderlayDim(belowZOrder: number, factor: number): Promise<void> {
this.compositor.setUnderlayDim(Math.round(belowZOrder), dimFactor256(factor));
}
async setScreenBlanked(blanked: boolean): Promise<void> {
this.compositor.setScreenBlanked(Boolean(blanked));
}