Repository navigation
fix(surface): restore keyboard focus after minimizing the focused window - #1498
Merged
wineee merged 1 commit intoOct 29, 2026
Merged
Conversation
|
Skipping CI for Draft Pull Request. |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideRestores activation and keyboard-focus fallback when minimizing the focused window by correcting capability-update ordering and hardening inactivation cleanup against non-primary seats and refused fallback activation. Sequence diagram for keyboard focus fallback when minimizing a focused windowsequenceDiagram
participant SurfaceWrapper
participant ShellHandler
participant SeatSurfaceManager
participant Server
participant PreviousWindow
SurfaceWrapper->>SurfaceWrapper: minimize(false)
SurfaceWrapper->>ShellHandler: updateHasActiveCapability(UnMinimized, false)
ShellHandler->>ShellHandler: onSurfaceInactivationRequested(wrapper)
ShellHandler->>Server: setActivatedSurface(nullptr, seat)
ShellHandler->>Server: activateSurface(PreviousWindow, seat)
Server-->>PreviousWindow: set activated and keyboard focus
SurfaceWrapper->>SeatSurfaceManager: updateFocusControlState(UnMinimized, false)
SeatSurfaceManager->>Server: requestKeyboardFocus(nullptr, OtherFocusReason, seat)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Groveer
marked this pull request as ready for review
October 23, 2026 08:09
Groveer
force-pushed
the
fix/wm633-minimize-focus-fallback
branch
from
October 23, 2026 08:09
d982c0d to
f6d41c9
Compare
minimize() dropped the focus capability before the active capability, so SeatSurfaceManager cleared the seat keyboard focus first. When ShellHandler handled the inactivation it no longer saw this surface as the focus owner and only cleared the activated state, leaving no window focused. Drop the active capability first so the fallback still sees this surface as the focus owner, and harden onSurfaceInactivationRequested to clear the activated state up front and to clear the keyboard focus when the fallback is refused. Log: 修复最小化当前焦点窗口后焦点没有回落到上一个窗口的问题 Influence: 1. Open A, B, C and minimize C: B becomes activated and focused. 2. Minimize every window: no window stays activated or focused. 3. Restore a minimized window: it becomes activated and focused. 4. Minimize a window while a layer surface holds focus: the layer surface keeps focus and the window no longer stays activated. 5. Minimize a window whose modal is minimized: no window stays activated or keyboard-focused. Multica Issue: WM-633
Groveer
force-pushed
the
fix/wm633-minimize-focus-fallback
branch
from
October 29, 2026 06:13
f6d41c9 to
efb6b32
Compare
wineee
approved these changes
Oct 29, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: deepin-wm, wineee The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
最小化当前持有键盘焦点的窗口后,焦点没有回落到上一个窗口。复现:依次打开 A、B、C(C 激活并持焦),最小化 C 后 B 既没有被激活、也没有拿到键盘焦点。
原因
SurfaceWrapper::minimize()里两个能力位的更新顺序有问题:updateFocusControlState(UnMinimized, false)→SeatSurfaceManager::onActivatedSurfaceFocusCapabilityChanged()无条件把该 seat 的键盘焦点清成nullptr;updateHasActiveCapability(UnMinimized, false)→ShellHandler::onSurfaceInactivationRequested()。第 2 步用
seatContainer->keyboardFocusSurface() == wrapper判断"要不要回退焦点",而此时焦点已在第 1 步被清空,判断为 false,于是只清了激活态,回退分支被跳过 —— 结果没有任何窗口获得焦点。改动
src/surface/surfacewrapper.cpp(minimize()):交换两处能力位更新的顺序,先丢 active capability(触发焦点回退,此时本窗口仍是焦点所有者),再丢 focus capability。这是治本的一步。src/core/shellhandler.cpp(onSurfaceInactivationRequested()):让 handler 不再依赖能力位顺序 —— 进入"焦点所有者"分支时先setActivatedSurface(nullptr, seat),同时覆盖非主 seat(原本只清焦点、会残留"已最小化但仍激活")和回退被拒(activateSurface提前 return,例如候选窗口带最小化模态)两种情况;回退被拒后再兜底清一次键盘焦点,保证最小化的窗口不会残留激活态或键盘焦点。验证
测试机 10.20.33.125(treeland 0.10.0 源码等价回移 + Debug 构建,全量 1414/1414 通过),判定依据是
treeland-debug读合成器状态:GET /api/windows的active/state、GET /api/focused,不看像素。focused=C,Cactive=truefocused=B,Bactive=true,Cstate=2 active=falsefocused=A,Aactive=truefocused=0,三个窗口state=2 active=falsefocused=C,Cactive=true state=0master 上的构建验证在 10.20.33.81:/tmp/wm633 完成,全量 1961/1961 通过。
未覆盖项
treeland-debug activate对 layer surface 是空操作,指针注入在该机也不会激活窗口,因此isActivatedOwner且非焦点所有者的既有分支没有被真实跑到。xmessage设不了 transient parent)。/usr是只读 overlay)。Cannot map device ... to output),属测试机 seat/设备映射问题,与本改动无关。相关 issue
WM-633
Summary by Sourcery
Restore reliable focus fallback when minimizing the focused window.
Bug Fixes:
Enhancements: