diff --git a/display/displayconf.go b/display/displayconf.go index 2aa688d6..b8d29f4d 100644 --- a/display/displayconf.go +++ b/display/displayconf.go @@ -674,17 +674,33 @@ func (s *SysScreenConfig) setMonitorConfigsOnlyOne(uuid string, configs SysMonit s.OnlyOneMap[uuid] = &SysMonitorModeConfig{} } + logger.Debug("OnlyOneConfig lenth:", len(configs)) + // 如果多个屏幕的UUID一样,则保存所有配置,根据屏幕名称区分应该点亮哪一个 if len(configs) > 1 { - // 去除非使能的 monitor - var tmpCfg *SysMonitorConfig + isRepeat := false + mapCfg := make(map[string]bool) for _, config := range configs { - if config.Enabled { - tmpCfg = config + _, ok := mapCfg[config.UUID] + if ok { + logger.Debug("config uuid is repeat") + isRepeat = true break + } else { + mapCfg[config.UUID] = true } } - if tmpCfg != nil { - configs = SysMonitorConfigs{tmpCfg} + if !isRepeat { + // 去除非使能的 monitor + var tmpCfg *SysMonitorConfig + for _, config := range configs { + if config.Enabled { + tmpCfg = config + break + } + } + if tmpCfg != nil { + configs = SysMonitorConfigs{tmpCfg} + } } } diff --git a/display/manager.go b/display/manager.go index 9e4a2c51..cdfae1b8 100644 --- a/display/manager.go +++ b/display/manager.go @@ -1748,7 +1748,6 @@ func (m *Manager) buildConfigForModeOnlyOne(monitors Monitors, uuid string) (mon //cfg.Reflect = 0 cfg.Brightness = 1 monitorCfgs = append(monitorCfgs, cfg) - return } } return @@ -1806,6 +1805,13 @@ func (m *Manager) applyModeOnlyOne(monitorsId monitorsId, monitorMap map[uint32] } } + if len(m.Monitors) > 1 && len(configs) > 1 && name != "" { + for _, config := range configs { + config.Enabled = config.Name == name + logger.Debug("update OnlyOneConfig", config) + } + } + err = m.applySysMonitorConfigs(DisplayModeOnlyOne, monitorsId, monitorMap, configs, options) if err != nil { return