weird windowUnfocused event from window.filter
wd opened this issue · comments
Dong Wang commented
with this code
watcher = function(win, name, event)
logger:i("event: " .. event)
logger:i(win:id())
end
obj.start = function(apps)
for _, v in ipairs(apps) do
app = wf.new{v}
app:subscribe(
{
wf.windowFocused,
wf.windowUnfocused,
}, watcher)
end
end
obj.start({Logseq})
I will get a weird windowUnfocused event. this is the log. After reloading the config, I focused on the application Logseq
and will get the windowFocused
, but just after some seconds, I'll get the windowUnfocused
event. Why does the windowUnfocused
event happen?
2022-04-03 16:04:16: -- Loading ~/.hammerspoon/init.lua
2022-04-03 16:04:16: -- Loading Spoon: RecursiveBinder
2022-04-03 16:04:16: -- Loading Spoon: Win
2022-04-03 16:04:16: -- Loading extension: window
2022-04-03 16:04:16: -- Loading extensions: window.filter
2022-04-03 16:04:16: -- Loading extension: screen
2022-04-03 16:04:16: -- Loading Spoon: IMIndicator
2022-04-03 16:04:16: -- Loading extension: axuielement
2022-04-03 16:04:16: -- Loading extension: keycodes
2022-04-03 16:04:16: -- Loading extension: application
2022-04-03 16:04:16: -- Loading extension: canvas
2022-04-03 16:04:16: -- Loading extension: styledtext
2022-04-03 16:04:16: -- Loading extension: hotkey
2022-04-03 16:04:16: 16:04:16 hotkey: Enabled hotkey ⌘⌃SPACE
2022-04-03 16:04:16: -- Loading Spoon: CopyMarkdownToHtml
2022-04-03 16:04:16: -- Loading extension: logger
2022-04-03 16:04:16: -- Done.
2022-04-03 16:04:17: 16:04:17 CopyMarkdo: table: 0x6000023c3f40 event: windowFocused
2022-04-03 16:04:17: CopyMarkdo: table: 0x6000023c3f40 43490
2022-04-03 16:04:20: 16:04:20 CopyMarkdo: table: 0x6000023c3f40 event: windowUnfocused
2022-04-03 16:04:20: CopyMarkdo: table: 0x6000023c3f40 43490
Dong Wang commented
hammerspoon: Version 0.9.97 (6267)
macOS: 12.3 (21E230)
Dong Wang commented
I also tested with this code, I can get the same window id. I believe this is a bug from the hammerspoon.
watcher = function(win, name, event)
logger:i("event: " .. event)
logger:i(win:id())
curWin = hs.window.focusedWindow()
logger:i(curWin:id())
end