diff --git a/src/main/runtime/rpc/methods/host-management/desktop-window.ts b/src/main/runtime/rpc/methods/host-management/desktop-window.ts index cb5e92f623a..f1e7a27af5c 100644 --- a/src/main/runtime/rpc/methods/host-management/desktop-window.ts +++ b/src/main/runtime/rpc/methods/host-management/desktop-window.ts @@ -5,7 +5,7 @@ export const DESKTOP_WINDOW_METHODS = [ // `orca open` asks the running app instead of relaunching it, which would hand it the foreground. defineMethod({ name: 'desktop.openWindowInBackground', - permission: 'workspace', + permission: 'desktop-control', params: null, handler: async () => ({ requested: requestBackgroundWindowOpen() }) }) diff --git a/src/main/window/main-window/main-window-state-lifecycle.ts b/src/main/window/main-window/main-window-state-lifecycle.ts index 78b2cfafbb9..bb86be1c48f 100644 --- a/src/main/window/main-window/main-window-state-lifecycle.ts +++ b/src/main/window/main-window/main-window-state-lifecycle.ts @@ -75,13 +75,16 @@ export function installMainWindowStateLifecycle(args: { if (isWindowlessLaunch()) { return } - // Windows can only maximize by activating (SW_MAXIMIZE), so a background reveal skips it there. - if (savedMaximized && !(revealInBackground && process.platform === 'win32')) { - mainWindow.maximize() - } if (revealInBackground) { + // Maximizing a hidden window shows it active; Windows activates on any maximize, so it stays restored there. mainWindow.showInactive() + if (savedMaximized && process.platform !== 'win32') { + mainWindow.maximize() + } } else { + if (savedMaximized) { + mainWindow.maximize() + } showWindowWithoutStealingFocus(mainWindow) } // Fullscreen needs a shown window; after maximize so leaving it returns there. Background launches must not take a Space. diff --git a/src/main/windows/windows-administrator-restart.ts b/src/main/windows/windows-administrator-restart.ts index 4c1d9d75763..9985d2fc31b 100644 --- a/src/main/windows/windows-administrator-restart.ts +++ b/src/main/windows/windows-administrator-restart.ts @@ -4,6 +4,7 @@ import { app } from 'electron' import { quoteWindowsArgument } from '@orca/process-host/windows-command-line' import { getBundledLauncherPath } from '../cli/packaged-assets/bundled-cli-launcher-path' import { getWindowsAdministratorStatus } from './windows-administrator-status' +import { BACKGROUND_OPEN_ARG } from '../../shared/background-open-argv' const RESTART_LOCAL_TERMINALS_ARG = '--orca-restart-local-terminals-as-administrator' @@ -28,7 +29,10 @@ export function prepareWindowsAdministratorRestart(): Electron.RelaunchOptions { if (!launcher || !existsSync(launcher)) { throw new Error('The Windows administrator launcher is unavailable.') } - const args = process.argv.slice(1).filter((arg) => arg !== RESTART_LOCAL_TERMINALS_ARG) + // The user asked for this restart, so the elevated window comes forward even when `orca open` started this one. + const args = process.argv + .slice(1) + .filter((arg) => arg !== RESTART_LOCAL_TERMINALS_ARG && arg !== BACKGROUND_OPEN_ARG) return { execPath: launcher, args: [