-
Notifications
You must be signed in to change notification settings - Fork 594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
windowfilter returns windows ordered by spaces #1460
Comments
I wonder if @lowne might come out of retirement to assist here :D |
Sounds like (unfortunate but) expected behaviour at script (re)load, due to the usual Spaces limitations. However as you jump through spaces and focus different windows the correct order should be maintained; this may or may not be complicated by the "raise all windows" behaviour when switching to certain applications (not sure if/when that would trigger a "transient" focus event on all current-space windows). |
I cannot see that script reload would trigger this. If I keep the script stable and don't trigger a reload, then move between all spaces to make sure that all windows are picked up, I still see the behavior where window are consistently ordered in space order. |
Just switching to all spaces (so that windowfilter "picks up" all the windows) isn't enough: windowfilter initially populates the per-window "timeFocused" field with os-provided (and spaces-unreliable) data; the field then gets updated (with correct data) as each window gets focused. |
To be clear: to get the correct state you have to 1) switch to all spaces to pick up all the windows and then 2) focus each window once. |
Here's a way to reproduce what I see. I have this in my init.lua:
I put Safari on Space 2, and the other browsers on Space 1. I visit each application with regular command-tab. Then I visit Safari (in Space 2), and then select Firefox (in Space 1). Then I hit ctrl-., and see the browsers in this order: Firefox, Chrome, Safari. Chrome is the selected one, since Firefox is current application. I would have expected Safari to be number 2 in this list, but instead it is placed last, which I assume is because it is on another space. |
I tested the exact same windowfilter in same scenario (Safari and Chrome on space 1, Firefox on space 2), and |
I should also note that I'm not in the best position to test, as running my local build (which is my "production" environment and cannot be touched as it's a mess of long forgotten symlinks) and release builds together makes Accessibility go insane. @strindberg can you check if .49 and/or earlier/later releases work for you? |
I see the same problem in 0.9.49, and in 0.9.46 as well, which seemed to be the first release with window.switcher included. In other words, the older releases also present the windows in the wrong order. |
Hmm... try with |
Yes, that solved the problem for me. Setting 'keepActive()' on the windowfilter now makes the windows show up in the right order. Thank you! Do you want me to close the issue? In other words: is this how it is supposed to work, or should something change in the way Hammerspoon sets up filter by default? I can't find the documentation for 'keepActive()' method anywhere, and I noticed that #1260 seems to be about the same problem. |
Yeah, this is the "documentation" for
So 1. I didn't think of this particular use (maintaining inter-Spaces ordering) as it seems an edge case (but apparently not entirely uncommon since #1260 is an exact dupe) and 2. |
I would argue that this is not really an edge case: if I create a window switcher for switching between applications in recently-used order, is it not reasonable to expect that spaces have nothing to do with the order? |
Yes, but that's a (separate) problem with |
I see. I misunderstood your meaning. Out of curiosity: what is the disadvantage of keeping all window filters active? Is it expensive resource-wise? |
@strindberg It looks like setting this causes Hammerspoon to freeze for 5-10 seconds after switching spaces once in a while–I guess it's trying to get a list of all the windows. |
If I have a windows filter which matches windows on several spaces, and then calls it as follows:
the result is that the windows from the current space are returned (in reverse focus order) first, and then windows from other spaces.
This is quite unexpected and I have not found a way to work around it.
The text was updated successfully, but these errors were encountered: