-
Notifications
You must be signed in to change notification settings - Fork 127
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
App#windows() does not include windows that are not in the current space #131
Comments
Hmm, interesting. |
Oh, and a quick hint. |
I think this is again caused by the “Displays have separate Spaces” option being disabled. If that is the case, I’m not sure what we can do about it. Could you again test this theory? |
Yeah, that is what i thought that it might be too, but I double checked it and verified that the behavior is the same when the option is both enabled & disabled. Hard to believe, right? Does it do the same for you? |
Did you log out between enabling / disabling the separate spaces option? On Sun, 14 Aug 2016, 11:58 p.m. Robert Lasko, notifications@github.com
|
Yes, i did logout. I've triple verified that it isn't just some wacky user (me) error. Am I the only person that is experiencing this? |
this should be really easy to replicate. here is the code i am using to indicate the problem in Console:
open up your app with two windows in separate spaces, and then Alt+3 |
@rjlasko I haven’t encountered this before and definitely have been able to get windows from different Spaces. (For example Could this be a behaviour related to a certain app? Have you verified this behaviour with multiple apps? |
@rjlasko Ok, sorry I retract my previous comment — I probably have only tried fetching windows from different but active spaces. I actually can reproduce this and guess what, unfortunately this is how Apple seems to have implemented it! You only get the windows for the active space. I wonder why this hasn’t come up before! Other window managers seem to hack this by listening to window events (open and close). 👎 |
Sorry for the delayed reply... So there are actually two related issues here.
That is a bummer, however I guess that not all is lost. My final goal was to be able to reorganize all active apps onto different predefined spaces on a single-display system. Maybe there is still a workaround available for this involving navigating to all spaces, and performing operations while the active space has been altered. I will report my success after I have tested it out. |
Actually, i don't think that a workaround is possible, is it? I was thinking about moving a window to a different space and then focusing on it to transition, but that is not enough if i cannot add/delete a space. There is no API that allows the creation or deletion of a space, correct? If so, then spaces support is ultimately limited to what is already within the set of active (visible) spaces. =( Please prove me wrong. |
@rjlasko Well the Spaces support is minimal, because Apple simply doesn’t give public APIs for the feature. To limit issues, we only use the private APIs that make sense. Creating and removing spaces with the private APIs require you to kill the Dock with every change. Not really practical. So you need to preset the Spaces with the UI. You can however switch to a Space easily by focusing to an app/window that is located there. Obviously this is made harder by the fact that you can’t get windows from different Spaces if they are there to start with (but if you move a window to a different Space, you already have the reference to it). To improve this, I guess we would need to start with the windows returned by the Accessibility API and then listen to events to add windows created and deleted in other Spaces than the current (you could try this yourself). Hammerspoon seems to do this in the filter extension. Not sure if this would work, since you could already have windows in different Spaces. I’m confused why Apple has implemented this how it is. I would expect if I ask the Accessibility API to “return me all windows”, it would return all windows. Since it returns windows from different screens anyway (and screens can have different Spaces). |
I guess the main idea is that you cannot create windows in other Spaces than the current one (for every screen). Not even from the UI, new windows open to the current Space for the active screen. You could have your Spaces preset in the way you prefer. Open the windows in the current Space and then add/move them to an other one. This should work just fine. |
FYI, |
A quick update on this: I noted that function moveAppToCurrentSpace(name) {
let app = App.get(name)
if (!app) return
const space = Space.active()
while(app.mainWindow() !== undefined) {
app.mainWindow().minimize()
}
space.moveWindows(app.windows())
app.windows().forEach(w => w.unminimize())
app.focus()
} This isn't without some wonkiness. The minimize animation, for instance, will occur on the new space. Some apps (WezTerm, for instance) seem to destroy their windows rather than minimize them. I don't actually recommend using the snippet above, but it does point to something smelly, in my opinion. |
Let's say that I am in laptop only mode, with two spaces open, and an application having a window in each space.
I don't believe this applies in this case, but note that in Mission Control, I have the following settings:
if i run the following code:
For the following cases I get the following output in Console:
A. The app has both windows (visible) in the first (currently active) space
B. The app has one window in the first space (which is currently active), and a second window in the second (non-visible) space:
C. Same as B, but If switch to the second space, and rerun:
The text was updated successfully, but these errors were encountered: