diff --git a/gesture1/daemon.go b/gesture1/daemon.go index b2021008b..58e0998c9 100644 --- a/gesture1/daemon.go +++ b/gesture1/daemon.go @@ -42,15 +42,14 @@ func (d *Daemon) Start() error { if d.manager != nil { return nil } - + service := loader.GetService() var err error - d.manager, err = newManager() + d.manager, err = newManager(service) if err != nil { logger.Error("failed to initialize gesture manager:", err) return err } - service := loader.GetService() err = service.Export(dbusServicePath, d.manager) if err != nil { logger.Error("failed to export gesture:", err) diff --git a/gesture1/gesture1_dbusutil.go b/gesture1/gesture1_dbusutil.go new file mode 100644 index 000000000..9f956157e --- /dev/null +++ b/gesture1/gesture1_dbusutil.go @@ -0,0 +1,16 @@ +// Code generated by "dbusutil-gen -type Manager -import github.com/godbus/dbus/v5 manager.go"; DO NOT EDIT. + +package gesture1 + +func (v *Manager) setPropInfos(value GestureInfos) (changed bool) { + if value != nil { + v.Infos = value + v.emitPropChangedInfos(value) + return true + } + return false +} + +func (v *Manager) emitPropChangedInfos(value GestureInfos) error { + return v.service.EmitPropertyChanged(v, "Infos", value) +} diff --git a/gesture1/manager.go b/gesture1/manager.go index fa9b86f92..c54be4c5f 100644 --- a/gesture1/manager.go +++ b/gesture1/manager.go @@ -63,6 +63,7 @@ func setUseWayland(value bool) { type Manager struct { wm wm.Wm + service *dbusutil.Service sysDaemon daemon.Daemon systemSigLoop *dbusutil.SignalLoop mu sync.RWMutex @@ -91,7 +92,7 @@ type Manager struct { availableGestures map[string][]string } -func newManager() (*Manager, error) { +func newManager(service *dbusutil.Service) (*Manager, error) { setUseWayland(len(os.Getenv("WAYLAND_DISPLAY")) != 0) sessionConn, err := dbus.SessionBus() if err != nil { @@ -127,6 +128,7 @@ func newManager() (*Manager, error) { notification: notification.NewNotification(sessionConn), launchpad: launchpad.NewLauncher(sessionConn), availableGestures: make(map[string][]string), + service: service, } dsg := configManager.NewConfigManager(systemConn) powerConfigManagerPath, err := dsg.AcquireManager(0, "org.deepin.dde.daemon", "org.deepin.dde.daemon.gesture", "") diff --git a/gesture1/manager_ifc.go b/gesture1/manager_ifc.go index a1c79ad42..177c90f3c 100644 --- a/gesture1/manager_ifc.go +++ b/gesture1/manager_ifc.go @@ -116,6 +116,10 @@ func (m *Manager) SetGesture(name string, direction string, fingers int32, actio gesture.Direction == direction && gesture.Fingers == fingers { gesture.ActionName = action + err := m.emitPropChangedInfos(m.Infos) + if err != nil { + logger.Warning(err) + } m.saveGestureConfig() break }