Skip to content

Commit 449eb22

Browse files
lichangzeKT-lcz
authored andcommitted
fix: 修复usb手写屏热插拔不生效问题
usb手写屏接入时,会新增monitor,需要增加对该monitor的处理 Log: 修复usb手写屏热插拔不生效问题 Bug: https://pms.uniontech.com/bug-view-135213.html Influence: 显示设备热插拔 Change-Id: Ifab669a06e5ea9afb3cbf12d17ab1df9b70d70e9
1 parent 1ed617e commit 449eb22

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

display/xorg.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,28 @@ func (mm *xMonitorManager) doDiff() {
379379
}
380380
}
381381
} else {
382-
logger.Warning("can not handle new monitor")
382+
logger.Info("need add new monitor")
383+
if mm.monitorChangedCbEnabled {
384+
if mm.hooks != nil {
385+
mm.mu.Unlock()
386+
mm.hooks.handleMonitorChanged(monitor)
387+
mm.mu.Lock()
388+
}
389+
} else {
390+
logger.Debug("monitorChangedCb disabled")
391+
}
392+
}
393+
}
394+
newMap := toMonitorInfoMap(newMonitors)
395+
if len(newMonitors) < len(oldMonitors) {
396+
for k, monitor := range oldMonitors {
397+
_, ok := newMap[k]
398+
if !ok {
399+
// 需要移除的monitor
400+
mm.mu.Unlock()
401+
mm.hooks.handleMonitorRemoved(monitor.ID)
402+
mm.mu.Lock()
403+
}
383404
}
384405
}
385406
}
@@ -1171,6 +1192,7 @@ func (mm *xMonitorManager) handleOutputChanged(e *randr.OutputChangeNotifyEvent)
11711192
reply, err := mm.getOutputInfo(e.Output)
11721193
if err != nil {
11731194
logger.Warningf("get output %v info failed: %v", e.Output, err)
1195+
delete(mm.outputs, e.Output)
11741196
return
11751197
}
11761198
mm.outputs[e.Output] = (*OutputInfo)(reply)

0 commit comments

Comments
 (0)