forked from Blendman974/faceclaw
[verified] fix: hide notification background only on screen wake
This commit is contained in:
1 parent
22df4d76d9
commit
9ddc864b0d
6 files changed
+75
-20
No files matched your search
@@ -6,7 +6,7 @@ import { Layer, LayerActions, LayerContext, LayerStack, PaintBelow } from "../la
|
||||
import { appViewportRect, appViewportSize, SHELL_OPAQUE_BLACK } from "./geometry";
|
||||
|
||||
// The modal box covers most of the min-height app viewport. Retained vector
|
||||
// clears hide the app outside its opaque rect. Size and position are
|
||||
// clears optionally hide the app outside its opaque rect. Size and position are
|
||||
// computed per paint: the display-mode setting changes the viewport size at
|
||||
// runtime, and the vertical position setting moves the band.
|
||||
const MODAL_MARGIN = 14;
|
||||
@@ -34,10 +34,10 @@ export function modalRect(): { x: number; y: number; width: number; height: numb
|
||||
|
||||
/**
|
||||
* A shell overlay hosting an inner layer stack in a bordered box over the
|
||||
* app viewport (used for new-notification popups). It replaces the shell's
|
||||
* lower layers. Only the box is opaque, so its cropped image fits the 64 KiB
|
||||
* resource limit; a resource-free retained list clears the outside margins
|
||||
* over separate app surfaces. The inner stack paints at the modal's interior
|
||||
* app viewport (used for new-notification popups). Normally the shell's lower
|
||||
* layers stay visible. For a wake popup, only the box is opaque (keeping its
|
||||
* image within 64 KiB), and a resource-free retained list clears the outside
|
||||
* margins over separate app surfaces. The inner stack paints at the modal's interior
|
||||
* size; inner value-0 pixels read as black, not transparent.
|
||||
*/
|
||||
export class ShellModalLayer implements Layer {
|
||||
@@ -47,6 +47,8 @@ export class ShellModalLayer implements Layer {
|
||||
baseLayer: Layer,
|
||||
actions: LayerActions,
|
||||
private readonly hooks: {
|
||||
/** Arrival-time screen state: mask the background only for a wake popup. */
|
||||
hideBackground?: boolean;
|
||||
/** The modal left the shell stack, however it went. */
|
||||
removed?: () => void;
|
||||
/** Input reached the modal (before its inner stack handles it). */
|
||||
@@ -60,9 +62,10 @@ export class ShellModalLayer implements Layer {
|
||||
this.hooks.removed?.();
|
||||
}
|
||||
|
||||
paint(ctx: LayerContext, _paintBelow: PaintBelow): GrayImage {
|
||||
// Do not call paintBelow: retained chrome/menu animations must not remain
|
||||
// beneath the notification. Leave the outer margins transparent so the
|
||||
paint(ctx: LayerContext, paintBelow: PaintBelow): GrayImage {
|
||||
// Wake popups omit lower chrome, but ordinary popups keep the usual overlay.
|
||||
if (!this.hooks.hideBackground) paintBelow();
|
||||
// Leave the outer margins transparent so the
|
||||
// scene encoder crops to the resource-sized modal, not the whole display.
|
||||
// Native dim=0 still preserves a 1/0 halftone; clipped CLEAR calls below
|
||||
// instead produce literal black without changing shared dimming semantics.
|
||||
@@ -87,6 +90,7 @@ export class ShellModalLayer implements Layer {
|
||||
image.drawRect(rect.x, rect.y, rect.width, rect.height, 110);
|
||||
image.bitBlt(inner, innerX, innerY, { transparentZero: true });
|
||||
top.image.copyPresentationsInto(image, innerX + top.x, innerY + top.y);
|
||||
if (!this.hooks.hideBackground) return image;
|
||||
// ShellScene replays retained calls after the opaque box. Clear only the
|
||||
// complement of that box, keeping the inner menu's presentation order.
|
||||
// These are vector clips, not tiled image resources; no full-screen image
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*/
|
||||
export interface NotificationModalHost<M> {
|
||||
/** Create and stack a modal showing this notification. */
|
||||
open(notificationKey: string): M;
|
||||
open(notificationKey: string, hideBackground: boolean): M;
|
||||
/** Whether a queued notification is still worth opening (not dismissed, popups still on). */
|
||||
isAvailable(notificationKey: string): boolean;
|
||||
/** Put the screen back to sleep. */
|
||||
@@ -20,6 +20,8 @@ interface Entry {
|
||||
readonly notificationKey: string;
|
||||
/** Whether this notification woke the screen, so closing the last modal sleeps again. */
|
||||
readonly wokeScreen: boolean;
|
||||
/** Arrival-time state, independent of the inherited return-to-sleep flag. */
|
||||
readonly hideBackground: boolean;
|
||||
}
|
||||
|
||||
export class NotificationModalQueue<M> {
|
||||
@@ -37,11 +39,14 @@ export class NotificationModalQueue<M> {
|
||||
if (this.current) {
|
||||
if (this.current.notificationKey !== notificationKey
|
||||
&& !this.queued.some((entry) => entry.notificationKey === notificationKey)) {
|
||||
this.queued.push({ notificationKey, wokeScreen });
|
||||
this.queued.push({ notificationKey, wokeScreen, hideBackground: wokeScreen });
|
||||
}
|
||||
return;
|
||||
}
|
||||
this.current = { modal: this.host.open(notificationKey), notificationKey, wokeScreen };
|
||||
this.current = {
|
||||
modal: this.host.open(notificationKey, wokeScreen),
|
||||
notificationKey, wokeScreen, hideBackground: wokeScreen,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,7 +99,11 @@ export class NotificationModalQueue<M> {
|
||||
while (this.queued.length > 0) {
|
||||
const next = this.queued.shift()!;
|
||||
if (!this.host.isAvailable(next.notificationKey)) continue;
|
||||
this.post(next.notificationKey, wokeScreen || next.wokeScreen);
|
||||
this.current = {
|
||||
...next,
|
||||
wokeScreen: wokeScreen || next.wokeScreen,
|
||||
modal: this.host.open(next.notificationKey, next.hideBackground),
|
||||
};
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -482,7 +482,7 @@ class Shell {
|
||||
// App-posted notifications that are open or queued, by key.
|
||||
private readonly appNotifications = new Map<string, AppNotification>();
|
||||
private readonly notificationModals = new NotificationModalQueue<NotificationPopup>({
|
||||
open: (notificationKey) => this.pushNotificationModal(notificationKey),
|
||||
open: (notificationKey, hideBackground) => this.pushNotificationModal(notificationKey, hideBackground),
|
||||
isAvailable: (notificationKey) => {
|
||||
if (this.appNotifications.has(notificationKey)) return true;
|
||||
const notification = readActiveNotifications(ALL_NOTIFICATIONS).find((item) => item.key === notificationKey);
|
||||
@@ -926,7 +926,7 @@ class Shell {
|
||||
this.openNotificationModal(notification.key, wokeScreen);
|
||||
}
|
||||
|
||||
private pushNotificationModal(notificationKey: string): NotificationPopup {
|
||||
private pushNotificationModal(notificationKey: string, hideBackground: boolean): NotificationPopup {
|
||||
const appNotification = this.appNotifications.get(notificationKey);
|
||||
const close = () => this.closeNotificationModal(popup, notificationKey);
|
||||
const content = appNotification
|
||||
@@ -951,6 +951,7 @@ class Shell {
|
||||
appNotification ? appNotification.createLayer(close) : content!,
|
||||
this.config.actions,
|
||||
{
|
||||
hideBackground,
|
||||
removed: () => {
|
||||
timeout.stop();
|
||||
this.appNotifications.delete(notificationKey);
|
||||
|
||||
Reference in new issue
Block a user