forked from Blendman974/faceclaw
feat: separate per-app keep awake from full screen
This commit is contained in:
7 files changed
+105
-21
No files matched your search
@@ -164,6 +164,23 @@ export function appFullscreenSetting(appId: string): ConfigSettingBoolean {
|
||||
return setting;
|
||||
}
|
||||
|
||||
const appKeepAwakeSettings = new Map<string, ConfigSettingBoolean>();
|
||||
|
||||
/** Independent of full screen; applies only while this app is visible. */
|
||||
export function appKeepAwakeSetting(appId: string): ConfigSettingBoolean {
|
||||
let setting = appKeepAwakeSettings.get(appId);
|
||||
if (!setting) {
|
||||
setting = new ConfigSettingBoolean({
|
||||
id: `app-keep-awake-${appId}`, label: "Keep screen awake",
|
||||
description: "Prevent automatic sleep while this app is visible, in any display mode.",
|
||||
storageKey: `display.keepAwake.${appId}`, defaultValue: false,
|
||||
reportInAnalytics: false,
|
||||
});
|
||||
appKeepAwakeSettings.set(appId, setting);
|
||||
}
|
||||
return setting;
|
||||
}
|
||||
|
||||
type ConfigSettingEnumOptions<TValue extends string, TId extends string> = ConfigSettingOptions<TValue, TId> & {
|
||||
values: readonly TValue[];
|
||||
normalize?: (value: string | null | undefined) => TValue;
|
||||
|
||||
+13
-5
@@ -32,6 +32,8 @@ import { SingleNotificationLayer } from "../notifications";
|
||||
import {
|
||||
anthropicApiKeySetting,
|
||||
appFullscreenSetting,
|
||||
appKeepAwakeSetting,
|
||||
toggleSettingMenuItem,
|
||||
assistantHermesKeySetting,
|
||||
assistantHermesUrlSetting,
|
||||
assistantBackendSetting,
|
||||
@@ -74,8 +76,6 @@ import { BrightnessPickerLayer } from "./brightness-picker-layer";
|
||||
import { toolRegistry } from "../../assistant/tool-registry";
|
||||
import {
|
||||
appViewportRect,
|
||||
displayLayout,
|
||||
isImmersive,
|
||||
minWindowTop,
|
||||
sidebarWidth,
|
||||
switcherPosition,
|
||||
@@ -228,7 +228,7 @@ export type ShellConfig = {
|
||||
onSwitcherBarHeightChanged?: () => void;
|
||||
/** A per-app full-screen choice changed the viewport and compositor geometry. */
|
||||
onWindowLayoutChanged?: () => void;
|
||||
/** Full screen must not keep the lock screen awake. */
|
||||
/** An app's keep-awake preference must not keep the lock screen awake. */
|
||||
isLocked?: () => boolean;
|
||||
/**
|
||||
* The Notifications app's window, opened in the background (neither
|
||||
@@ -882,7 +882,7 @@ class Shell {
|
||||
if (this.activeVoiceLayer || this.activeKeyboardLayer || this.assistantSession?.isTurnActive() ||
|
||||
foreground?.isVoiceCapturing?.() || foreground?.keepsScreenOn?.() ||
|
||||
(foreground?.closeable && !this.config.isLocked?.() &&
|
||||
(isImmersive(foreground.appId) || displayLayout(foreground.appId) === "fullscreen"))) {
|
||||
appKeepAwakeSetting(foreground.appId).get())) {
|
||||
this.lastInputAtMs = nowMs;
|
||||
return false;
|
||||
}
|
||||
@@ -1993,7 +1993,7 @@ class Shell {
|
||||
const fullscreen = appFullscreenSetting(foreground.appId);
|
||||
items.push({
|
||||
label: fullscreen.get() ? "Exit full screen" : "Enter full screen",
|
||||
description: "Use the whole display and keep it awake while this app is visible.",
|
||||
description: "Use the whole display for this app.",
|
||||
onSelect: (ctx) => {
|
||||
ctx.stack.pop();
|
||||
if (!this.windows.some(window => window.windowId === foreground.windowId)) return;
|
||||
@@ -2004,6 +2004,14 @@ class Shell {
|
||||
this.config.requestShellRender();
|
||||
},
|
||||
});
|
||||
items.push(toggleSettingMenuItem(appKeepAwakeSetting(foreground.appId), {
|
||||
onChange: (ctx) => {
|
||||
ctx.stack.pop();
|
||||
this.noteUserActivity();
|
||||
this.focusWindow(foreground.windowId);
|
||||
this.config.requestShellRender();
|
||||
},
|
||||
}));
|
||||
}
|
||||
if (brightnessSetting.get() !== "auto") {
|
||||
items.push({
|
||||
|
||||
Reference in new issue
Block a user