fix: correct display mode in event log for single screen / 修复单屏时事件日志显…#1123
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts display event logging so that when only one screen is connected, the logged display_mode is forced to single-screen mode instead of an extended display mode value. Flow diagram for updated display_mode logging in logDisplayScreenEventflowchart TD
A[logDisplayScreenEvent called] --> B[Read screenCount]
B --> C{screenCount == 1?}
C -- Yes --> D[Set displayMode = DisplayModeOnlyOne]
C -- No --> E[Use displayMode = m.DisplayMode]
D --> F[Get primaryMonitor]
E --> F[Get primaryMonitor]
F --> G[Write event log with displayMode and primaryMonitor]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Instead of overriding
displayModewhenscreenCount == 1, consider deriving the mode directly from the current layout/state (e.g., actual active outputs and primary assignment) so the logged value always reflects the real configuration rather than relying on a forced constant.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Instead of overriding `displayMode` when `screenCount == 1`, consider deriving the mode directly from the current layout/state (e.g., actual active outputs and primary assignment) so the logged value always reflects the real configuration rather than relying on a forced constant.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
…示模式错误 When a user unplugs an external monitor and logs in again with only one screen, the event log incorrectly shows display_mode as "EXTEND" instead of the monitor name. This fix ensures the display mode in event logs reflects the actual screen state. 当用户拔掉外接显示器后重新登录只有一个屏幕时,事件日志错误地显示 display_mode 为 "EXTEND" 而不是显示器名称。 此修复确保事件日志中的显示模式反映实际的屏幕状态。 PMS: BUG-361115
8c7db96 to
e0720dd
Compare
deepin pr auto review你好!我是智能编程助手 CodeGeeX。我已仔细审查了你提供的 Git Diff 代码。 这段代码的意图是:在记录显示器屏幕事件日志时,如果检测到只有一个屏幕,则强制将显示模式覆盖为 以下是我从语法逻辑、代码质量、代码性能和代码安全四个维度提出的审查意见和改进建议: 1. 语法与逻辑
2. 代码质量
3. 代码性能
4. 代码安全
改进建议代码综合以上分析,我为你提供了一份改进后的代码示例(假设 // 建议将魔法数字定义为常量,提高可读性
const MinScreenCountForMultiDisplay = 2
func (m *Manager) logDisplayScreenEvent() {
// TODO: 确保 screenCount 的获取是线程安全的,且性能良好
// 例如: screenCount := m.getScreenCount()
// 暂时假设你已有 screenCount 变量
// 获取当前显示模式 (局部变量,仅用于日志记录,不修改原状态)
displayMode := m.DisplayMode
// 如果屏幕数量少于多屏的最小要求,强制使用单屏模式
// 这里使用 <= 1 可以同时处理 screenCount 为 1 或 0 的边界情况
if screenCount < MinScreenCountForMultiDisplay {
displayMode = DisplayModeOnlyOne
}
// 获取主显示器名称
primaryMonitor := m.Primary
// ... 后续逻辑
}重点修改说明:
请根据你的实际项目结构,确认 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: fly602, Ivy233 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 |
…示模式错误
When a user unplugs an external monitor and logs in again with only one screen, the event log incorrectly shows display_mode as "EXTEND" instead of the monitor name. This fix ensures the display mode in event logs reflects the actual screen state.
当用户拔掉外接显示器后重新登录只有一个屏幕时,事件日志错误地显示 display_mode 为 "EXTEND" 而不是显示器名称。 此修复确保事件日志中的显示模式反映实际的屏幕状态。
PMS: BUG-361115
Summary by Sourcery
Bug Fixes: