You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In short, hs.keycodes.inputSourceChanged events aren't delivered until the next one comes in.
To reproduce, you'll need more than one input source, of course. The code is as follows:
math.randomseed(os.time())
localcharset= {}
-- qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890fori=48, 57dotable.insert(charset, string.char(i)) endfori=65, 90dotable.insert(charset, string.char(i)) endfori=97, 122dotable.insert(charset, string.char(i)) end-- this is used only to see new console messages easilyfunctionrandomString(length)
iflength>0thenreturnrandomString(length-1) ..charset[math.random(1, #charset)]
elsereturn""endend-----------------------------foo=hs.distributednotifications.new(
function(name, object, userInfo)
print("notification: " ..name.."\n")
end,
-- or 'AppleSelectedInputSourcesChangedNotification''com.apple.Carbon.TISNotifySelectedKeyboardInputSourceChanged'
)
foo:start()
hs.keycodes.inputSourceChanged(function()
print("changed the layout to " ..hs.keycodes.currentSourceID() .."; " ..randomString(6) .."\n")
end)
Now, when the focused window is Hammerspoon, both system notification and inputSourceChanged are delivered at once when the input source is changed, with inputSourceChanged coming in after the system notifications. However, if you switch to another application and change the input source, the first inputSourceChanged event is not delivered, and then new events fire before the system notification. Finally, if you switch back to Hammerspoon, one inputSourceChanged is fired immediately out of nowhere. All of this suggests that inputSourceChanged events are delayed until the next one comes.
I've tried hiding Hammerspoon altogether and using alerts instead of the console, nothing changes. The last event is delivered when I click the menu icon.
The obvious workaround is obvious: subscribe to the system notifications instead of inputSourceChanged. So I guess it's not a pressing issue, but hs.keycodes.inputSourceChanged is still pretty much broken.
The text was updated successfully, but these errors were encountered:
I'm using Hammerspoon 0.9.55 on OSX El Capitan.
In short, hs.keycodes.inputSourceChanged events aren't delivered until the next one comes in.
To reproduce, you'll need more than one input source, of course. The code is as follows:
Now, when the focused window is Hammerspoon, both system notification and inputSourceChanged are delivered at once when the input source is changed, with inputSourceChanged coming in after the system notifications. However, if you switch to another application and change the input source, the first inputSourceChanged event is not delivered, and then new events fire before the system notification. Finally, if you switch back to Hammerspoon, one inputSourceChanged is fired immediately out of nowhere. All of this suggests that inputSourceChanged events are delayed until the next one comes.
I've tried hiding Hammerspoon altogether and using alerts instead of the console, nothing changes. The last event is delivered when I click the menu icon.
The obvious workaround is obvious: subscribe to the system notifications instead of inputSourceChanged. So I guess it's not a pressing issue, but hs.keycodes.inputSourceChanged is still pretty much broken.
The text was updated successfully, but these errors were encountered: