Skip to content

fix: 修复部分场景下窗口超出显示器边界的问题#903

Merged
ayangweb merged 6 commits intomasterfrom
fix-window-pos
Apr 13, 2026
Merged

fix: 修复部分场景下窗口超出显示器边界的问题#903
ayangweb merged 6 commits intomasterfrom
fix-window-pos

Conversation

@ayangweb
Copy link
Copy Markdown
Owner

No description provided.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

该 PR 旨在修复 Tauri 桌面端在部分情况下窗口位置超出显示器可视范围的问题,通过在窗口移动时对位置进行“夹紧”(clamp) 来保证窗口留在当前显示器边界内。

Changes:

  • useWindowState 中新增基于 getCursorMonitor() 的窗口位置边界夹紧逻辑,并使用 useDebounceFn 做防抖处理
  • 在窗口移动事件触发时,尝试自动将窗口位置限制在鼠标所在显示器的范围内
  • 调整 onChange 中对事件 payload 的处理方式(解构后复用)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/composables/useWindowState.ts
Comment thread src/composables/useWindowState.ts Outdated
…rdinate space

Agent-Logs-Url: https://github.com/ayangweb/BongoCat/sessions/c4c8647c-d80a-4f6f-9351-8acca82b21d0

Co-authored-by: ayangweb <75017711+ayangweb@users.noreply.github.com>
@ayangweb
Copy link
Copy Markdown
Owner Author

@copilot If the window becomes out-of-bounds due to resize (manual resize, restoring a saved size after monitor resolution/DPI changes, etc.), this code won’t clamp it back onto the monitor.

Copy link
Copy Markdown

Copilot AI commented Apr 13, 2026

@copilot If the window becomes out-of-bounds due to resize (manual resize, restoring a saved size after monitor resolution/DPI changes, etc.), this code won’t clamp it back onto the monitor.

This was already addressed in 69045b5. clampToMonitor() is now called unconditionally in onChange (covering both onMoved and onResized events) and also at the end of restoreState after the saved size/position are applied.

@ayangweb
Copy link
Copy Markdown
Owner Author

@copilot If the window becomes out-of-bounds due to resize (manual resize, restoring a saved size after monitor resolution/DPI changes, etc.), this code won’t clamp it back onto the monitor.

This was already addressed in 69045b5. clampToMonitor() is now called unconditionally in onChange (covering both onMoved and onResized events) and also at the end of restoreState after the saved size/position are applied.

但是显示器的分辨率变化的问题,你并没有解决啊?不是有 appWIndow.onScaleChanged 吗?我不知道 dpi 是什么方法

@ayangweb
Copy link
Copy Markdown
Owner Author

@copilot 但是显示器的分辨率变化的问题,你并没有解决啊?不是有 appWindow.onScaleChanged 吗?我不知道 dpi 是什么方法

Copy link
Copy Markdown

Copilot AI commented Apr 13, 2026

@copilot 但是显示器的分辨率变化的问题,你并没有解决啊?不是有 appWindow.onScaleChanged 吗?我不知道 dpi 是什么方法

Fixed in 23f4093. Added appWindow.onScaleChanged(() => clampToMonitor()) in onMounted, so whenever the monitor's DPI/scale changes, the window position is automatically clamped back within the monitor bounds.

@ayangweb ayangweb merged commit f0c1250 into master Apr 13, 2026
@ayangweb ayangweb deleted the fix-window-pos branch April 13, 2026 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants