From a64761d6a482b6b17e0193ea319e9ed5a2fc57f1 Mon Sep 17 00:00:00 2001 From: fuleyi Date: Thu, 9 Jan 2025 13:43:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=AE=BE=E7=BD=AE=E6=89=8B=E5=8A=BF?= =?UTF-8?q?=E7=9A=84=E5=8A=A8=E4=BD=9C=E5=90=8E=EF=BC=8C=E5=8F=91=E9=80=81?= =?UTF-8?q?infos=E5=8F=98=E5=8C=96=E7=9A=84=E4=BF=A1=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 设置手势的动作后,发送infos变化的信号 Log: 设置手势的动作后,发送infos变化的信号 pms: TASK-362119 --- gesture1/daemon.go | 5 ++--- gesture1/gesture1_dbusutil.go | 16 ++++++++++++++++ gesture1/manager.go | 4 +++- gesture1/manager_ifc.go | 4 ++++ 4 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 gesture1/gesture1_dbusutil.go 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 }