Repository navigation
Conversation
Reviewer's GuideData structuresAdd persisted per-display lid-scaling state and a flag that distinguishes confirmed closed-lid configurations from defaults.
ImplementationCoordinate lid-transition display initialization, configuration preservation, and per-display scale saving and restoration.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 7 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="display1/displayconf.go" line_range="60" />
<code_context>
+
+// 缩放仍由 XSettings 生效,这里只保存开合盖切换时各显示器的配置。
+type LidScaleConfig struct {
+ Factors map[string]map[string]float64 // 显示器 UUID -> 原有缩放映射
+ ExternalUUID string `json:",omitempty"` // 尚未切回内屏的外屏
}
</code_context>
<issue_to_address>
**Lid transition crashes on missing factors**
When the user config has a non-nil `LidScale` with omitted or null `Factors`, `applyLidScale` assigns to `state.Factors` without initializing the map, so the lid transition panics and terminates the daemon.
Initialize `LidScale.Factors` when loading or fixing user config, and guard the assignment in `applyLidScale`.
Also at `display1/manager_lid.go:209`, `display1/manager_lid.go:248`.
</issue_to_address>
### Comment 2
<location path="display1/manager_lid.go" line_range="236" />
<code_context>
+ }
+ if state != nil && state.ExternalUUID == external.uuid {
+ // 合盖期间重启服务时,当前值已经属于外屏,不能拿它覆盖内屏记录。
+ m.lidScalePending = false
+ return
+ }
</code_context>
<issue_to_address>
**Failed external scale is not retried**
When the daemon stops before applying the external scale or `SetScreenScaleFactors` fails after `ExternalUUID` is saved, the next `applyLidScale` takes the matching-UUID branch, clears `lidScalePending`, and skips setting the scale; the external display remains at the wrong scale.
Make the matching-UUID path retry `SetScreenScaleFactors` while the scale is pending, and clear the pending flag only after the setting succeeds.
Also at `display1/manager_lid.go:254-263`.
</issue_to_address>
### Comment 3
<location path="display1/manager_lid.go" line_range="202" />
<code_context>
+ m.userCfgMu.Lock()
+ defer m.userCfgMu.Unlock()
+ state := m.userConfig.LidScale
+ if !builtin.lidClosed && builtin.Enabled && state != nil && state.ExternalUUID != "" {
+ // 切回内屏前保存外屏最后使用的值,不能下次合盖又重置为默认值。
+ factors, err := m.xsManager.GetScreenScaleFactors(0)
</code_context>
<issue_to_address>
**Disconnected display loses remembered scale**
When the external display recorded in `ExternalUUID` is disconnected while the lid is closed, `applyLidScale` reads the builtin display’s current factors and stores them under the disconnected external display’s UUID, overwriting its remembered scale.
Verify that the recorded external display is still connected and active before saving current factors under its UUID.
Also at `display1/manager_lid.go:209`.
</issue_to_address>
### Comment 4
<location path="display1/displayconf.go" line_range="60" />
<code_context>
+
+// 缩放仍由 XSettings 生效,这里只保存开合盖切换时各显示器的配置。
+type LidScaleConfig struct {
+ Factors map[string]map[string]float64 // 显示器 UUID -> 原有缩放映射
+ ExternalUUID string `json:",omitempty"` // 尚未切回内屏的外屏
}
</code_context>
<issue_to_address>
**UUID migration loses saved scales**
When a monitor UUID changes while lid-scale state for its previous UUID is persisted, `UserConfig.updateUuid` migrates only `Screens`, leaving `LidScale.Factors` and `ExternalUUID` at the old UUID; `applyLidScale` misses the saved factors and uses the recommended default scale.
Migrate the UUID keys in `LidScale.Factors` and the value of `LidScale.ExternalUUID` along with `Screens`.
Also at `display1/displayconf.go:61`.
</issue_to_address>
### Comment 5
<location path="display1/manager_lid.go" line_range="226" />
<code_context>
+ for _, monitor := range monitorMap {
+ if monitor.ID != builtin.ID && monitor.realConnected && monitor.Enabled {
+ if external != nil {
+ return // 多外屏组合沿用原有逻辑,不擅自套用单外屏的缩放。
+ }
+ external = monitor
</code_context>
<issue_to_address>
**Multiple displays leave scaling pending**
When more than one enabled external display is present during the lid-close apply, `applyLidScale` returns without clearing `lidScalePending`, so later resolution changes are ignored and a subsequent single-external setup can be treated as the original lid transition.
Clear or otherwise reset `lidScalePending` before returning for multiple enabled external displays.
</issue_to_address>
### Comment 6
<location path="display1/manager_lid.go" line_range="249" />
<code_context>
+ m.userConfig.LidScale = state
+ }
+ state.Factors[builtin.uuid] = factors
+ target := state.Factors[external.uuid]
+ if len(target) == 0 {
+ // 仅首次使用该外屏时计算默认值,之后优先恢复用户保存的值。
</code_context>
<issue_to_address>
**External scale changes are forgotten**
When the user changes the external display's scale while the lid is open, then selects builtin-only before closing the lid, `applyLidScale` reads the external target from the cached `state.Factors` map and reapplies that value on lid close, but it only refreshes the cache during the lid-open transition. A later user scale change while the external display is active is therefore overwritten by the older cached value on the next close.
Refresh the per-display factor cache when the active display's scale changes, or read and save the external factors before switching away from that display.
</issue_to_address>
### Comment 7
<location path="display1/manager.go" line_range="2403" />
<code_context>
+ closed := builtin.lidClosed
+ builtin.PropsMu.RUnlock()
+ if closed {
+ screenCfg.LidClosedConfigured = true
+ }
+ }
</code_context>
<issue_to_address>
**Confirmed closed-lid settings are missed**
When the user confirms external-only settings while the builtin display is lid-closed and the daemon restarts before the lid opens, `save` stores the confirmed external-only `Single` config under the active monitor ID, which excludes the closed builtin monitor. After restart, `getLidClosedSingleConfig` looks it up using the physical monitor ID including the builtin, misses both the saved config and its confirmation flag, and applies defaults instead of the user's settings.
Persist and look up the confirmed closed-lid config under the same monitor-set key, or add a fallback that retrieves it from the external-only key.
</issue_to_address>1. Initialize external display defaults when closing a builtin-only setup. 2. Remember per-display scaling and restore builtin scaling on lid open. 3. Preserve confirmed closed-lid settings across cycles and service restarts. Log: Fix external display initialization and closed-lid settings recovery. PMS: BUG-383753 Influence: 1. Close a builtin-only setup and check external resolution, rotation and scale. 2. Save an external resolution, reopen and close the lid, then check recovery. 3. Restart the daemon with the lid closed and verify saved display settings. fix: 修复开合盖时外屏初始化及显示配置恢复 1. 仅内屏模式下合盖时初始化外屏默认显示参数。 2. 按显示器记忆缩放,开盖时恢复内屏原有缩放。 3. 保留合盖时确认保存的配置,避免反复开合盖或重启服务后重置。 Influence: 1. 仅内屏模式下合盖,检查外屏分辨率、方向和缩放初始化。 2. 保存外屏分辨率后反复开合盖,检查配置恢复和内屏状态。 3. 合盖时重启 daemon,检查已保存显示参数是否保持。 Log: 修复合盖外屏初始化异常及已保存显示配置无法恢复的问题。 PMS: BUG-383753
xujin177
force-pushed
the
fix/lid-scale-code-review
branch
from
December 1, 2026 13:01
4c7ecbb to
40db4e6
Compare
mhduiy
approved these changes
Dec 1, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mhduiy, xujin177 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 |
xujin177
merged commit Dec 1, 2026
5bf9eb0
into
linuxdeepin:release/2500u2-pajil
16 of 19 checks passed
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.
Log: Fix external display initialization and closed-lid settings recovery.
PMS: BUG-383753
Influence:
fix: 修复开合盖时外屏初始化及显示配置恢复
Influence:
Log: 修复合盖外屏初始化异常及已保存显示配置无法恢复的问题。
PMS: BUG-383753
Summary by Sourcery
Preserve display configuration when closing and opening the lid, including external display initialization and saved scaling.
Bug Fixes: