func initDBusIFC() error { var err error dspObj, err = libdsp.NewDisplay("com.deepin.daemon.Display", "/com/deepin/daemon/Display") if err != nil { finalizeDBusIFC() return err } areaObj, err = libarea.NewXMouseArea("com.deepin.api.XMouseArea", "/com/deepin/api/XMouseArea") if err != nil { finalizeDBusIFC() return err } launchObj, err = launcher.NewLauncher("com.deepin.dde.launcher", "/com/deepin/dde/launcher") if err != nil { finalizeDBusIFC() return err } return nil }
func initDisplay() bool { var err error dpy, err = display.NewDisplay( "com.deepin.daemon.Display", "/com/deepin/daemon/Display", ) if err != nil { logger.Error("connect to display failed:", err) return false } // to avoid get PrimaryRect failed defer func() { if r := recover(); r != nil { logger.Warning("Recovered in initDisplay:", r) } }() setDisplayRect(dpy.PrimaryRect.Get()) dpy.ConnectPrimaryChanged(func(rect []interface{}) { setDisplayRect(rect) for _, app := range ENTRY_MANAGER.runtimeApps { for _, winInfo := range app.xids { winInfo.OverlapDock = isWindowOverlapDock(winInfo.Xid) } } hideModemanager.UpdateState() }) return true }
func doIdleAction() { dp, _ := display.NewDisplay("com.deepin.daemon.Display", "/com/deepin/daemon/Display") stoper := make(chan bool) stopAnimation = append(stopAnimation, stoper) for _, p := range dp.Monitors.Get() { m, err := display.NewMonitor("com.deepin.daemon.Display", p) if err != nil { logger.Warningf("create monitor %v failed:%v", p, err) continue } go func() { outputs := m.Outputs.Get() for v := 0.8; v > 0.1; v -= 0.05 { <-time.After(time.Millisecond * time.Duration(float64(400)*(v))) select { case <-stoper: for _, name := range outputs { dp.ResetBrightness(name) } dpmsOn() return default: for _, name := range outputs { dp.ChangeBrightness(name, v) } } } }() } dpmsOff() if suspendDelta != 0 { for { select { case <-time.After(time.Second * time.Duration(suspendDelta)): doSuspend() return case <-stoper: return } } } }
func (*Power) handleIdleOff() { for _, c := range stopAnimation { close(c) } stopAnimation = nil dpmsOn() dp, _ := display.NewDisplay("com.deepin.daemon.Display", "/com/deepin/daemon/Display") defer display.DestroyDisplay(dp) for _, p := range dp.Monitors.Get() { m, _ := display.NewMonitor("com.deepin.daemon.Display", p) defer display.DestroyMonitor(m) for _, name := range m.Outputs.Get() { dp.ResetBrightness(name) } } }
func isMultihead() bool { if dp, err := display.NewDisplay("com.deepin.daemon.Display", "/com/deepin/daemon/Display"); err != nil { logger.Error("Can't build com.deepin.daemon.Display Object:", err) return false } else { paths := dp.Monitors.Get() if len(paths) > 1 { return true } else if len(paths) == 1 { if m, err := display.NewMonitor("com.deepin.daemon.Display", paths[0]); err != nil { return false } else if m.IsComposited.Get() { return true } else { return false } } } return false }