forked from Blendman974/faceclaw
Fix double-dimming when app menu submenus are open
This commit is contained in:
1 parent
a82184316e
commit
79ea7858ca
4 files changed
+43
-5
No files matched your search
+12
-1
@@ -102,6 +102,15 @@ export interface Layer {
|
||||
readonly depth?: number;
|
||||
paintParts?(): Plane[];
|
||||
readonly paintOverBase?: boolean;
|
||||
/**
|
||||
* True when this layer stands in for `below`, a stacked layer directly
|
||||
* beneath it (or beneath another layer it stands in for): when this layer
|
||||
* calls paintBelow, the stack skips `below` and paints what is under it
|
||||
* instead. A submenu replacing the menu it opened from uses this, so the
|
||||
* hidden menu costs no plane and its dimUnderneath doesn't dim the content
|
||||
* a second time; popping the submenu still returns to it.
|
||||
*/
|
||||
replacesLayerBelow?(below: Layer): boolean;
|
||||
/**
|
||||
* Dim everything painted beneath this layer: a 0..1 brightness factor
|
||||
* applied to the pixels and glyphs of every plane below it in the stack
|
||||
@@ -326,7 +335,9 @@ export class LayerStack {
|
||||
return [ownPlane];
|
||||
}
|
||||
const dim = layer.dimUnderneath || 1;
|
||||
const below = this.paintLayer(layer.paintOverBase ? 0 : index - 1, dimSoFar * dim, raw);
|
||||
let belowIndex = layer.paintOverBase ? 0 : index - 1;
|
||||
while (belowIndex > 0 && layer.replacesLayerBelow?.(this.layers[belowIndex]!)) belowIndex--;
|
||||
const below = this.paintLayer(belowIndex, dimSoFar * dim, raw);
|
||||
return [...(!raw && dim < 1 ? dimPlanes(below, dim) : below), ownPlane];
|
||||
}
|
||||
}
|
||||
@@ -192,12 +192,13 @@ export function createInProcessWindow(options: InProcessWindowOptions): InProces
|
||||
drawIcon: options.drawIcon ?? windowIcon(options.icon, options.iconLetter),
|
||||
handleInput: async (event, frameId) => {
|
||||
// The shell opened its system menu over this window; close our own
|
||||
// context menu so the two never stack. Never forwarded to app layers.
|
||||
// context menu (and any window submenus open from it) so the two never
|
||||
// stack. Never forwarded to app layers.
|
||||
if (event.type === "system-menu-opened") {
|
||||
options.onSystemMenuOpened?.();
|
||||
if (stack.popIfTop((layer) => layer instanceof WindowMenuLayer)) {
|
||||
requestRender();
|
||||
}
|
||||
let closedMenu = false;
|
||||
while (stack.popIfTop((layer) => layer instanceof WindowMenuLayer)) closedMenu = true;
|
||||
if (closedMenu) requestRender();
|
||||
return;
|
||||
}
|
||||
// The default tap-then-hold response: the window menu (or the system
|
||||
|
||||
@@ -33,6 +33,16 @@ export class WindowMenuLayer extends MenuLayer {
|
||||
? { ...WINDOW_MENU_LAYOUT, footer: gestureHints([[GESTURE_SHORT_THEN_LONG_PRESS, "system menu"]]) }
|
||||
: WINDOW_MENU_LAYOUT);
|
||||
}
|
||||
|
||||
/**
|
||||
* A window submenu (Settings, Spotify, ...) opens in place of the window
|
||||
* menu it came from, which it would mostly cover anyway: the window content
|
||||
* shows beneath it, dimmed once, rather than the parent menu dimming it a
|
||||
* second time and costing a plane of its own.
|
||||
*/
|
||||
replacesLayerBelow(below: Layer): boolean {
|
||||
return below instanceof WindowMenuLayer;
|
||||
}
|
||||
}
|
||||
|
||||
export type WindowMenuOptions = {
|
||||
|
||||
Reference in new issue
Block a user