RecordingTip 2회차 안 보임 수정: 2-phase 리사이즈 제거, 즉시 show 방식

This commit is contained in:
Yun Chan 2026-04-05 11:09:55 +09:00
parent c079f335c1
commit 67a6ee242a

View file

@ -126,71 +126,39 @@ export function getRecordingTipWindow(): BrowserWindow {
* Phase 1: prepare * Phase 1: prepare
* Phase 2: resize show * Phase 2: resize show
*/ */
// RecordingTip 측정 리스너 관리 (race condition 방지) // RecordingTip 기본 크기 (고정 — 2-phase 복잡도 제거)
let _tipMeasuredHandler: ((_event: Electron.IpcMainEvent, data: { width: number; height: number }) => void) | null = null const TIP_WIDTH = 280
let _tipHidden = false const TIP_HEIGHT = 80
export function showRecordingTip( export function showRecordingTip(
state: string, state: string,
params?: { text?: string; errorMessage?: string } params?: { text?: string; errorMessage?: string }
): void { ): void {
const win = getRecordingTipWindow() const win = getRecordingTipWindow()
_tipHidden = false
// 이전 측정 리스너 제거 (중복 방지) // 커서 위치에 배치
if (_tipMeasuredHandler) {
ipcMain.removeListener('window:tipMeasured', _tipMeasuredHandler)
_tipMeasuredHandler = null
}
// Phase 1: prepare (크기 측정)
win.webContents.send('window:tipPrepare', { state, ...params })
// tipMeasured 이벤트를 한번만 처리
_tipMeasuredHandler = (_event: Electron.IpcMainEvent, data: { width: number; height: number }) => {
if (_tipMeasuredHandler) {
ipcMain.removeListener('window:tipMeasured', _tipMeasuredHandler)
_tipMeasuredHandler = null
}
// hide가 이미 호출되었으면 show하지 않음
if (_tipHidden) return
// 커서 위치에 표시
const cursorPos = screen.getCursorScreenPoint() const cursorPos = screen.getCursorScreenPoint()
const display = screen.getDisplayNearestPoint(cursorPos) const display = screen.getDisplayNearestPoint(cursorPos)
let x = cursorPos.x - Math.round(data.width / 2) let x = cursorPos.x - Math.round(TIP_WIDTH / 2)
let y = cursorPos.y - data.height - 20 let y = cursorPos.y - TIP_HEIGHT - 20
// 화면 밖 보정 // 화면 밖 보정
x = Math.max(display.workArea.x, Math.min(x, display.workArea.x + display.workArea.width - data.width)) x = Math.max(display.workArea.x, Math.min(x, display.workArea.x + display.workArea.width - TIP_WIDTH))
if (y < display.workArea.y) { if (y < display.workArea.y) {
y = cursorPos.y + 20 y = cursorPos.y + 20
} }
win.setBounds({ x, y, width: data.width, height: data.height }) win.setBounds({ x, y, width: TIP_WIDTH, height: TIP_HEIGHT })
// 상태 전송 후 즉시 show (2-phase 제거 — 숨겨진 윈도우의 렌더러 비활성 문제 방지)
win.webContents.send('window:tipStateChanged', { state, ...params })
if (!win.isVisible()) { if (!win.isVisible()) {
win.showInactive() win.showInactive()
} }
// Phase 2: show
win.webContents.send('window:tipShow', { state })
}
ipcMain.on('window:tipMeasured', _tipMeasuredHandler)
} }
export function hideRecordingTip(): void { export function hideRecordingTip(): void {
_tipHidden = true
// pending 측정 리스너 제거 (늦게 도착하면 다시 show되는 버그 방지)
if (_tipMeasuredHandler) {
ipcMain.removeListener('window:tipMeasured', _tipMeasuredHandler)
_tipMeasuredHandler = null
}
if (recordingTipWindow && !recordingTipWindow.isDestroyed()) { if (recordingTipWindow && !recordingTipWindow.isDestroyed()) {
recordingTipWindow.hide() recordingTipWindow.hide()
} }