Skip to content

hs.window.filter not listing windows from another space on v1.0.0 #3822

@YeaminSarder

Description

@YeaminSarder

Recreating

open 2 chrome windows in one space
and 2 chrome windows in another space
switch to a third space
repeatedly press cmd-alt-ctrl-c within 1 seconds

Expected

on first press focuses first chrome window.
successive presses cycles all 4 windows showing the alert
switching to window i/4

Got

on first press focuses last focused chrome window. does not show alert.
successive presses cycles windows in that particular space showing switching to window i/2

things tried

looked through the filter documentation. seems like this is not expected behaviour.
couldn't find similar issues.

hs.loadSpoon("EmmyLua")
function notify(text)
  hs.notify.new({title="Hammerspoon", informativeText=text}):send()
end


hs.hotkey.bind({"cmd", "alt", "ctrl"}, "R", function()
      hs.reload()
end)

local hotswitch = {
   c = "Google Chrome",
   d = "Discord",
   m = "Messenger",
   t = "kitty",
   w = "WhatsApp",
   p = "Python",
   f = "Finder"
}
for key, app in pairs(hotswitch) do
    hs.hotkey.bind({ "cmd", "alt", "ctrl" }, key, function()
        focusWindow(app)
    end)
end

hs.hotkey.bind({"cmd", "alt", "ctrl"}, "h",function ()
      local fwin = hs.window.focusedWindow()
      -- hs.alert.show(fwin:application())
      hs.alert.show(fwin:application())
end)
nextfocus = 1
nextfocuscanceltimer = hs.timer.doAfter(1,function () nextfocus = 1 end)
function focusWindow(hint)
   local wf = hs.window.filter.new({hint})
   -- wf = wf:allowApp("chrome")
   local wins = wf:getWindows()
   if (#wins) > 1 then
      hs.alert.show('switching to window '..nextfocus..'/' .. #wins)
      wins[nextfocus]:focus()
      nextfocus = math.min(nextfocus+1, #wins)
      nextfocuscanceltimer:setNextTrigger(1)
   elseif (#wins) == 1 then
      wins[1]:focus()
   else
      hs.alert.show(hint .. " not found")
   end
   -- hs.alert.show(wins[1])
   -- for _, w in pairs(wf:getWindows()) do
   --   hs.alert.show(w)
   -- end
end
-- focusWindow("act")
hs.alert.show("config loaded", nil, nil, 0.5)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions