Skip to content

Commit

Permalink
fix: special keybinding is not effective
Browse files Browse the repository at this point in the history
event loop must be in different coroutine

Log:
  • Loading branch information
dengbo11 committed Nov 6, 2023
1 parent 457ab4a commit ddacae5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
9 changes: 7 additions & 2 deletions keybinding/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions keybinding/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,8 @@ type Manager struct {
wifiControlEnable bool
needXrandrQDevice []string

configManagerPath dbus.ObjectPath

dmiInfo systeminfo.DMIInfo
smInit chan bool

//nolint
signals *struct {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions keybinding/manager_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit ddacae5

Please sign in to comment.