feat(editor): настройки экрана презентации при запуске сессии

Выбор монитора и полноэкранного режима в настройках; при «Запустить» окно презентации открывается на выбранном дисплее автоматически.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Ivan Fontosh
2026-09-02 13:05:50 +08:00
parent 8b28a9b11a
commit 746b862cb9
13 changed files with 437 additions and 13 deletions
+26 -6
View File
@@ -2,8 +2,12 @@ import path from 'node:path';
import { app, BrowserWindow, screen } from 'electron';
import type { PresentationSettings } from '../../shared/types/presentationSettings';
import { readPresentationSettings } from '../preferences/appPreferences';
import { windowChromeTitle, type AppWindowKind } from '../../shared/appBranding';
import { ipcChannels } from '../../shared/ipc/contracts';
import { resolvePresentationDisplay } from './presentationDisplay';
import { safeConsoleError } from '../safeConsole';
@@ -517,20 +521,36 @@ export function focusEditorWindow(): void {
}
}
export function openMultiWindow() {
export function openMultiWindow(presentationSettings?: PresentationSettings) {
const settings = presentationSettings ?? readPresentationSettings(app.getPath('userData'));
let presentation = windows.get('presentation');
if (!presentation) {
const display = screen.getPrimaryDisplay();
const display = resolvePresentationDisplay(settings.displayId);
const { x, y, width, height } = display.bounds;
presentation = createWindow('presentation');
presentation.setBounds({ x, y, width, height });
presentation.setMenuBarVisibility(false);
presentation.maximize();
if (settings.fullScreen) {
presentation.setFullScreen(true);
} else {
presentation.maximize();
}
}
if (!windows.has('control')) {
// macOS: parent-child window binding moves child with the parent (unlike Windows behavior we want).
// Keep control window independent on darwin.
createWindow('control', process.platform === 'darwin' ? undefined : { parent: presentation });
const editor = windows.get('editor');
const editorDisplay = editor
? screen.getDisplayMatching(editor.getBounds())
: screen.getPrimaryDisplay();
const control = createWindow('control');
const area = editorDisplay.workArea;
const cw = Math.min(1200, Math.max(640, area.width - 80));
const ch = Math.min(800, Math.max(480, area.height - 80));
control.setBounds({
x: area.x + Math.max(0, Math.round((area.width - cw) / 2)),
y: area.y + Math.max(0, Math.round((area.height - ch) / 2)),
width: cw,
height: ch,
});
}
broadcastMultiWindowStateChanged(true);
broadcastPresentationContentSize();