diff --git a/keybinding/daemon.go b/keybinding/daemon.go index 02eafc850..5163d3170 100644 --- a/keybinding/daemon.go +++ b/keybinding/daemon.go @@ -76,8 +76,13 @@ func (d *Daemon) Start() error { m.listenSystemPlatformChanged() m.eliminateKeystrokeConflict() - m.shortcutManager.EventLoop() - m.shortcutManager.RecordEventLoop() + + for ch := range m.smInit { + if ch { + go m.shortcutManager.EventLoop() + go m.shortcutManager.RecordEventLoop() + } + } }() return nil diff --git a/keybinding/manager.go b/keybinding/manager.go index 2dbe686ae..6a0f5a322 100644 --- a/keybinding/manager.go +++ b/keybinding/manager.go @@ -151,9 +151,8 @@ type Manager struct { wifiControlEnable bool needXrandrQDevice []string - configManagerPath dbus.ObjectPath - dmiInfo systeminfo.DMIInfo + smInit chan bool //nolint signals *struct { @@ -206,6 +205,8 @@ func newManager(service *dbusutil.Service) (*Manager, error) { m.login1Manager = login1.NewManager(sysBus) } + m.smInit = make(chan bool, 10) + m.init() m.gsKeyboard = gio.NewSettings(gsSchemaKeyboard) @@ -243,6 +244,7 @@ func (m *Manager) init() { m.keyEvent = keyevent.NewKeyEvent(sysBus) m.shortcutManager = shortcuts.NewShortcutManager(m.conn, m.keySymbols, m.handleKeyEvent) + m.smInit <- m.shortcutManager != nil // when session is locked, we need handle some keyboard function event m.lockFront = lockfront.NewLockFront(sessionBus) diff --git a/keybinding/manager_handlers.go b/keybinding/manager_handlers.go index cab0cc5f6..9708edb40 100644 --- a/keybinding/manager_handlers.go +++ b/keybinding/manager_handlers.go @@ -182,6 +182,7 @@ func (m *Manager) initHandlers() { if m.shortcutManager == nil { m.shortcutManager = NewShortcutManager(m.conn, m.keySymbols, m.handleKeyEvent) + m.smInit <- m.shortcutManager != nil } m.shortcutManager.SetAllModKeysReleasedCallback(func() {