fix(window): don't steal focus when the app starts at login
The login item now passes --autostart (also used when querying it, which Windows needs to match the registration). On such a launch the main window is shown inactive instead of focused, flashed and pinned on top for a second, so typing that already started in another app is not interrupted. Existing registrations migrate on the next startup sync.
This commit is contained in:
parent
e7937c877f
commit
ddd734fd30
3 changed files with 67 additions and 15 deletions
|
|
@ -41,6 +41,7 @@ vi.mock('electron', () => {
|
|||
center = vi.fn()
|
||||
restore = vi.fn()
|
||||
show = vi.fn()
|
||||
showInactive = vi.fn()
|
||||
focus = vi.fn()
|
||||
hide = vi.fn()
|
||||
setAlwaysOnTop = vi.fn()
|
||||
|
|
@ -96,6 +97,35 @@ beforeEach(async () => {
|
|||
lifecycle.setIsQuitting(false)
|
||||
})
|
||||
|
||||
describe('main window launch', () => {
|
||||
it('로그인 자동 실행(--autostart)이면 포커스를 뺏지 않고 띄운다', async () => {
|
||||
vi.resetModules()
|
||||
const argv = process.argv
|
||||
process.argv = [...argv, '--autostart']
|
||||
try {
|
||||
const { createMainWindow } = await import('../../../src/main/windows/WindowManager')
|
||||
createMainWindow()
|
||||
const win = state.windows[0] as unknown as Record<string, ReturnType<typeof vi.fn>> & {
|
||||
listeners: Map<string, Listener>
|
||||
}
|
||||
win.listeners.get('ready-to-show')?.()
|
||||
expect(win.showInactive).toHaveBeenCalled()
|
||||
expect(win.focus).not.toHaveBeenCalled()
|
||||
expect(win.setAlwaysOnTop).not.toHaveBeenCalled()
|
||||
} finally {
|
||||
process.argv = argv
|
||||
}
|
||||
})
|
||||
|
||||
it('직접 실행하면 앞으로 띄우고 포커스를 준다', async () => {
|
||||
vi.resetModules()
|
||||
const { createMainWindow } = await import('../../../src/main/windows/WindowManager')
|
||||
createMainWindow()
|
||||
const win = state.windows[0] as unknown as Record<string, ReturnType<typeof vi.fn>>
|
||||
expect(win.focus).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
describe('main window close', () => {
|
||||
it('closeToTray=false 이면 창 닫기가 앱 종료로 이어진다', async () => {
|
||||
config.closeToTray = false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue