Skip to content

fix: dual-screen extension mode primary migration and window-output binding#1027

Open
deepin-wm wants to merge 1 commit into
linuxdeepin:masterfrom
deepin-wm:fix/dual-screen-primary-migration
Open

fix: dual-screen extension mode primary migration and window-output binding#1027
deepin-wm wants to merge 1 commit into
linuxdeepin:masterfrom
deepin-wm:fix/dual-screen-primary-migration

Conversation

@deepin-wm

@deepin-wm deepin-wm commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

修复内容

  1. 修复 onScreenRemoved 主屏迁移条件:使用 isCurrentPrimary || wasPrimaryBeforeRemoval 替代 !isCurrentPrimary && !wasPrimaryBeforeRemoval,正确处理主屏移除时窗口迁移
  2. 新增窗口-输出绑定记录与恢复机制:
    • SurfaceBinding 存储最大化/全屏状态的 surfaceState
    • getAllOutputSurfaces 收集所有工作区的 surface
    • 在 onScreenRemoved 中直接使用 primaryOutput() 避免与 removeOutput 的主屏选择冲突
    • 覆盖策略处理重复 recordSurfaceBinding 调用
    • 跳过用户手动移动的窗口(positionAutomatic)
    • restoreSurfaceBindings 中使用 qBound 边界约束
    • cleanupStaleBindings 处理永久移除的输出

Fixes: #1002

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @deepin-wm, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: deepin-wm

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

1. Fix onScreenRemoved primary migration condition: use
   isCurrentPrimary || wasPrimaryBeforeRemoval instead of
   !isCurrentPrimary && !wasPrimaryBeforeRemoval to
   correctly migrate windows when primary output is removed
2. Add window-output binding record and restore mechanism:
   SurfaceBinding stores surfaceState, getAllOutputSurfaces
   collects surfaces across all workspaces, use primaryOutput()
   directly in onScreenRemoved to avoid conflict with
   removeOutput's primary selection, overwrite strategy for
   duplicate recordSurfaceBinding calls, skip restore for
   user-moved windows (positionAutomatic), qBound boundary
   constraint in restoreSurfaceBindings

Log: Fixed windows not migrating to remaining screen when
primary output is unplugged in dual-screen extension mode,
and windows not returning to original screen when reconnected

Influence:
1. Test unplugging primary screen in extension mode, verify
   windows migrate to remaining screen
2. Test unplugging secondary screen, verify windows migrate
   to primary screen
3. Test reconnecting screens, verify windows return to
   original positions
4. Test maximized and fullscreen window migration
5. Test minimized window restoration after screen reconnect

fix: 扩展模式主屏迁移和窗口-输出绑定

1. 修复 onScreenRemoved 主屏迁移条件:使用
   isCurrentPrimary || wasPrimaryBeforeRemoval 替代
   !isCurrentPrimary && !wasPrimaryBeforeRemoval,
   正确处理主屏移除时窗口迁移
2. 新增窗口-输出绑定记录与恢复机制:
   SurfaceBinding 存储 surfaceState,
   getAllOutputSurfaces 收集所有工作区的 surface,
   在 onScreenRemoved 中直接使用 primaryOutput()
   避免与 removeOutput 的主屏选择冲突,
   覆盖策略处理重复 recordSurfaceBinding 调用,
   跳过用户手动移动的窗口(positionAutomatic),
   restoreSurfaceBindings 中使用 qBound 边界约束

Log: 修复扩展模式拔掉主屏后窗口未迁移到剩余屏幕,
以及重新连接后窗口未回到原屏幕的问题

Influence:
1. 测试扩展模式拔掉主屏,验证窗口迁移到剩余屏幕
2. 测试拔掉副屏,验证窗口迁移到主屏
3. 测试重新连接屏幕,验证窗口回到原位置
4. 测试最大化和全屏窗口的迁移
5. 测试最小化窗口在重新连接屏幕后的恢复
@deepin-wm deepin-wm force-pushed the fix/dual-screen-primary-migration branch 5 times, most recently from e1e3253 to 060fad4 Compare June 18, 2026 15:37
@deepin-wm deepin-wm marked this pull request as ready for review June 18, 2026 15:38

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @deepin-wm, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-wm deepin-wm force-pushed the fix/dual-screen-primary-migration branch from 060fad4 to e2762a9 Compare June 18, 2026 16:01
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.

2 participants