forked from Blendman974/faceclaw
Merge per-app full screen and keep-awake behavior
This commit is contained in:
11 files changed
+162
-6
No files matched your search
@@ -267,6 +267,7 @@ function shellEnv({ wakeAction = 'voice-input', skipConfirmation = false } = {})
|
||||
}
|
||||
const voiceDialogs = [];
|
||||
const settings = { wakeWordActionSetting: { get: () => wakeAction }, brightnessSetting: { get: () => 'auto' },
|
||||
appFullscreenSetting: () => ({ get: () => false }),
|
||||
assistantSkipConfirmationSetting: { get: () => skipConfirmation } };
|
||||
const { shell, rawInputEventToInputEvent } = load('app/ui/shell/shell.ts', {
|
||||
'../../graphics/shell-scene': { encodeShellScene: () => new Uint8Array([0, 0]) },
|
||||
|
||||
@@ -15,6 +15,8 @@ function geometry() {
|
||||
appSwitcherPositionSetting: 'left', uiDepthSetting: '0', statusBarPositionSetting: 'top',
|
||||
statusBarVisibilitySetting: 'always', windowBorderSetting: true,
|
||||
}).map(([name, value]) => [name, { value, get() { return this.value; } }]));
|
||||
const fullscreen = new Map();
|
||||
settings.appFullscreenSetting = id => ({ get: () => fullscreen.get(id) ?? false, set: value => fullscreen.set(id, value) });
|
||||
const context = { exports: {}, require: (name) => {
|
||||
if (name === '../../graphics/image') return { G2_LENS_WIDTH: 640, G2_LENS_HEIGHT: 480 };
|
||||
assert.equal(name, '../dashboard-settings');
|
||||
@@ -27,6 +29,25 @@ function geometry() {
|
||||
|
||||
const LAYOUTS = ['band-top', 'band-high', 'band-middle', 'band-low', 'band-bottom', 'tall', 'fullscreen'];
|
||||
|
||||
test('user full screen spans the panel with any switcher and survives app immersive cleanup', () => {
|
||||
const g = geometry();
|
||||
const previous = g.rect('min', 'test');
|
||||
for (const position of ['left', 'right', 'bottom', 'popup']) {
|
||||
g.settings.appSwitcherPositionSetting.value = position;
|
||||
g.settings.appFullscreenSetting('test').set(true);
|
||||
assert.deepEqual(g.rect('min', 'test'), { x: 0, y: 0, width: 640, height: 480 });
|
||||
assert.equal(g.sidebarStripVisible('window', 'test'), false);
|
||||
assert.equal(g.sidebarStripVisible('sidebar', 'test'), true);
|
||||
g.setAppImmersive('test', true);
|
||||
g.setAppImmersive('test', false);
|
||||
assert.equal(g.isImmersive('test'), true);
|
||||
assert.equal(g.isImmersive('other'), false);
|
||||
}
|
||||
g.settings.appSwitcherPositionSetting.value = 'left';
|
||||
g.settings.appFullscreenSetting('test').set(false);
|
||||
assert.deepEqual(g.rect('min', 'test'), previous);
|
||||
});
|
||||
|
||||
test('defaults preserve normal windows, EvenHub height and tall terminal sessions', () => {
|
||||
const g = geometry();
|
||||
assert.deepEqual(g.rect('min', 'navigate'), { x: 64, y: 124, width: 576, height: 260 });
|
||||
|
||||
@@ -9,7 +9,7 @@ function fixture(options = {}) {
|
||||
const source = ts.createSourceFile('shell.ts', fs.readFileSync(path.join(__dirname, '../app/ui/shell/shell.ts'), 'utf8'), ts.ScriptTarget.Latest, true);
|
||||
const shellClass = source.statements.find(node => ts.isClassDeclaration(node) && node.name.text === 'Shell');
|
||||
const names = new Set(['routeInput', 'openEscapeMenu', 'closeAllWindows', 'closeWindow', 'removeWindow',
|
||||
'foregroundWindow', 'noteWindowVisible', 'mostRecentWindowIndex', 'yieldFocusToSidebar']);
|
||||
'foregroundWindow', 'noteWindowVisible', 'mostRecentWindowIndex', 'yieldFocusToSidebar', 'applyScreenTimeout']);
|
||||
const methods = shellClass.members.filter(node => names.has(node.name?.getText(source)));
|
||||
assert.equal(methods.length, names.size);
|
||||
const overlay = source.statements.find(node => ts.isClassDeclaration(node) && node.name.text === 'ShellOverlayMenuLayer');
|
||||
@@ -17,12 +17,15 @@ function fixture(options = {}) {
|
||||
constructor(title, items) { this.title = title; this.items = items; }
|
||||
selectItem(index) { this.selectedIndex = index; }
|
||||
}
|
||||
const fullscreen = new Map();
|
||||
const context = {
|
||||
exports: {}, MenuLayer, console: { warn: () => {} },
|
||||
appViewportRect: () => ({ x: 0, y: 0, width: 576 }), CONTEXT_MENU_DIM: 0.5,
|
||||
brightnessSetting: { get: () => 'auto' }, gestureHints: () => 'App menu',
|
||||
GESTURE_SHORT_THEN_LONG_PRESS: 'tap-hold', makeInputEvent: event => event,
|
||||
isWatchInput: event => event.source === 'watch', isDirectionalInput: () => false,
|
||||
appFullscreenSetting: id => ({ get: () => fullscreen.get(id) ?? false, set: value => fullscreen.set(id, value) }),
|
||||
isImmersive: id => fullscreen.get(id) ?? false, displayLayout: () => 'band-middle',
|
||||
};
|
||||
vm.runInNewContext(ts.transpileModule(`${overlay.getText(source)}\nexport class Shell { ${methods.map(node => node.getText(source)).join('\n')} }`, {
|
||||
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
|
||||
@@ -54,6 +57,10 @@ function fixture(options = {}) {
|
||||
config: { voiceInputEnabled: false, requestShellRender() {}, onWindowsChanged() {} },
|
||||
cancelEscapeMenuTimer() {}, startEscapeMenuTimer() { s.escapeStarted = true; },
|
||||
lastInput: null,
|
||||
lastInputAtMs: 0,
|
||||
noteUserActivity() { this.lastInputAtMs = 100; },
|
||||
focusWindow(id) { this.selectedIndex = this.windows.findIndex(w => w.windowId === id); this.focus = 'window'; },
|
||||
sleep() { this.screenOn = false; },
|
||||
});
|
||||
const input = type => s.routeInput({ type, source: 'ring', timestampMs: 100 }, 1);
|
||||
const menu = () => layers.at(-1);
|
||||
@@ -62,9 +69,50 @@ function fixture(options = {}) {
|
||||
assert.ok(item, label);
|
||||
item.onSelect({ stack: s.stack });
|
||||
};
|
||||
return { s, input, menu, choose, closed, delivered, warnings, renders, launcher, app, background, window };
|
||||
return { s, input, menu, choose, closed, delivered, warnings, renders, launcher, app, background, window, fullscreen };
|
||||
}
|
||||
|
||||
test('full screen targets the captured app and keeps only the visible app awake', async () => {
|
||||
const h = fixture();
|
||||
h.s.config.getScreenTimeoutMs = () => 1000;
|
||||
let relayouts = 0;
|
||||
h.s.config.onWindowLayoutChanged = () => relayouts++;
|
||||
await h.input('long-press');
|
||||
h.s.selectedIndex = 2;
|
||||
h.choose('Enter full screen');
|
||||
assert.equal(h.fullscreen.get('current'), true);
|
||||
assert.equal(h.s.foregroundWindow().windowId, 'current');
|
||||
assert.equal(h.s.focus, 'window');
|
||||
assert.equal(relayouts, 1);
|
||||
assert.equal(h.s.applyScreenTimeout(5000), false);
|
||||
h.s.focusWindow('background');
|
||||
assert.equal(h.s.applyScreenTimeout(5500), false);
|
||||
assert.equal(h.s.applyScreenTimeout(6000), true);
|
||||
h.s.screenOn = true;
|
||||
h.s.focusWindow('current');
|
||||
await h.input('long-press');
|
||||
h.choose('Exit full screen');
|
||||
assert.equal(h.fullscreen.get('current'), false);
|
||||
assert.equal(relayouts, 2);
|
||||
assert.equal(h.s.applyScreenTimeout(7000), true);
|
||||
});
|
||||
|
||||
test('full screen does not suppress lock timeout or manual sleep, and is absent for the launcher', async () => {
|
||||
const h = fixture();
|
||||
h.fullscreen.set('current', true);
|
||||
h.s.config.getScreenTimeoutMs = () => 1000;
|
||||
h.s.config.isLocked = () => true;
|
||||
assert.equal(h.s.applyScreenTimeout(5000), true);
|
||||
h.s.screenOn = true;
|
||||
h.s.config.isLocked = () => false;
|
||||
h.s.sleep();
|
||||
assert.equal(h.s.screenOn, false);
|
||||
h.s.screenOn = true;
|
||||
h.s.selectedIndex = 0;
|
||||
await h.input('long-press');
|
||||
assert.ok(!h.menu().items.some(item => /full screen/.test(item.label)));
|
||||
});
|
||||
|
||||
test('switcher opens its menu on hold or tap-hold even for an app claiming holds or hold-to-talk', async () => {
|
||||
for (const type of ['long-press', 'short-then-long-press']) {
|
||||
for (const app of [{}, { claimsLongPress: () => true }, { holdToTalk: true }]) {
|
||||
|
||||
@@ -39,6 +39,7 @@ const menu = load('app/ui/menu.ts', {
|
||||
function fixture(initial = '50', viewport = { x: 64, y: 124, width: 576, height: 260 }) {
|
||||
let value = initial, writes = 0, closed = 0;
|
||||
const settings = {
|
||||
appFullscreenSetting: () => ({ get: () => false }),
|
||||
brightnessSetting: { get: () => value, set: (next) => { value = next; writes++; } },
|
||||
brightnessSettingToLevel: (value) => value === 'auto' ? null : Number(value),
|
||||
};
|
||||
@@ -120,13 +121,14 @@ test('system menu hides brightness in Auto and opens its picker between Voice in
|
||||
shell.openSystemMenu('test');
|
||||
let opened = shell.stack.layers.at(-1);
|
||||
assert.deepEqual(Array.from(opened.items, (item) => item.label),
|
||||
['Close current app', 'Focus app switcher', 'Voice input', 'Close all apps', 'Debug']);
|
||||
['Close current app', 'Focus app switcher', 'Voice input', 'Close all apps', 'Enter full screen', 'Debug']);
|
||||
shell.stack.clearToBase();
|
||||
f.settings.brightnessSetting.set('40');
|
||||
shell.openSystemMenu('test');
|
||||
opened = shell.stack.layers.at(-1);
|
||||
assert.deepEqual(Array.from(opened.items, (item) => item.label),
|
||||
['Close current app', 'Focus app switcher', 'Voice input', 'Close all apps', 'Brightness', 'Debug']);
|
||||
['Close current app', 'Focus app switcher', 'Voice input', 'Close all apps', 'Enter full screen', 'Brightness', 'Debug']);
|
||||
await shell.stack.handleInput(gestures.makeInputEvent({ type: 'scroll-down' }));
|
||||
await shell.stack.handleInput(gestures.makeInputEvent({ type: 'scroll-down' }));
|
||||
await shell.stack.handleInput(gestures.makeInputEvent({ type: 'scroll-down' }));
|
||||
await shell.stack.handleInput(gestures.makeInputEvent({ type: 'scroll-down' }));
|
||||
|
||||
@@ -65,3 +65,16 @@ test('Full Screen is offered only with a bottom or popup app switcher', () => {
|
||||
assert.deepEqual(Array.from(api.DISPLAY_LAYOUT_VALUES, (value) => api.displayLayoutLabel(value)),
|
||||
['Band · Top', 'Band · High', 'Band · Middle', 'Band · Low', 'Band · Bottom', 'Tall', 'Full Screen']);
|
||||
});
|
||||
|
||||
test('per-app full screen defaults off, persists across restart and preserves display preferences', () => {
|
||||
const store = new Map([['display.layout', 'band-low'], ['terminal.displayLayout', 'tall']]);
|
||||
const prefs = settingsFixture(store);
|
||||
assert.equal(prefs.appFullscreenSetting('terminal').get(), false);
|
||||
prefs.appFullscreenSetting('terminal').set(true);
|
||||
const restarted = settingsFixture(store);
|
||||
assert.equal(restarted.appFullscreenSetting('terminal').get(), true);
|
||||
assert.equal(restarted.appFullscreenSetting('other').get(), false);
|
||||
restarted.appFullscreenSetting('terminal').set(false);
|
||||
assert.equal(restarted.displayLayoutSetting.get(), 'band-low');
|
||||
assert.equal(store.get('terminal.displayLayout'), 'tall');
|
||||
});
|
||||
Reference in new issue
Block a user