kasper / phoenix

A lightweight macOS window and app manager scriptable with JavaScript
https://kasper.github.io/phoenix/
Other
4.36k stars 128 forks source link

app.windows() is empty when not an the same space as the application #290

Open ckruse opened 2 years ago

ckruse commented 2 years ago

In my config I iterate over a set of applications and move them to spaces when a second monitor attaches or detaches. This worked really nice before macOS 12.2, but now app.windows() seems to be empty when I am not on the same space as the application. Given this config:

const singleScreenConfig = [
  ["iTerm2", 2],
  ["Element", 3],
  ["Signal", 3],
  ["Nachrichten", 3],
  ["Google Chat", 3],
  ["Mastonaut", 3],
  ["Tweetbot", 3],
  ["MailMate", 4],
  ["Things", 4],
];

function setSingleScreenConfig() {
  const spaces = Space.all();

  singleScreenConfig.forEach(([appName, spaceIdx]) => {
    const app = App.get(appName);
    if (!app) {
      Phoenix.log("app not found", appName);
      return;
    }

    console.log(app.name(), app.windows().length);
    spaces[spaceIdx].moveWindows(app.windows());
  });
}

Key.on("p", ["control", "alt", "cmd"], setSingleScreenConfig);

In this scenario app.windows().length is 0 for e.g. iTerm when I am on the first space and iTerm is on space 2, and thus the window doesn't get moved to space 3. It doesn't matter if I set {visible: true} or {visible: false} or neither.

Am I doing something wrong?

ckruse commented 2 years ago

Ping? :-)

ckruse commented 2 years ago

No need to „thumbs down.“ Just trying to be constructive, no reaction normally means there is important information missing in the report. Am I missing something important?

mafredri commented 2 years ago

I can't speak for Kasper but as an open-source developer that gives away his time for free I have to strongly disagree with both your statements. A ping is not constructive, nor is "no reaction" indicative of missing information. No response simply means that e.g. Kasper has a life outside of this project and hasn't had time to respond to you. If you look at past issues in this repo you will see that he pretty much responds to all issues, he's a really nice guy. Not sure how you think you were being constructive with the ping...

In my view, a ping is very disrespectful, hence the thumb down. I would advice you not to do it in the future.

kasper commented 2 years ago

@ckruse Hey! Not sure what this might be caused by, but it’s likely that Apple has been changing some other private Spaces APIs as well. I will need to investigate more.

@mafredri Indeed, life has been quite hectic lately with personal stuff and work. 😄 I’m really happy to keep this project going, nothing better than doing something that helps other people at the same time.

ckruse commented 2 years ago

@mafredri Look, I am an OSS developer myself, I write and maintain OSS since 1998 or 1999, don't really remember. As such I absolutely know that life happens, and thats exactly why I appreciate a ping. I more than often just forgot that there is an open issue waiting, and a friendly ping reminds me. I'm sorry if it bothered you, it was not meant to be pushy. If you want to take an advice from an old fart like me: don't assume that people's intents are malicious.

@kasper no hurry :-) If I can help you, just say so; I don't really have much knowledge about macOS internals, but when I can help I will!

kasper commented 2 years ago

By all means, if you find the cause it makes fixing much more faster for me. 😄

ckruse commented 2 years ago

I just found this issue form 2016: https://github.com/kasper/phoenix/issues/131

By the comments it looks like it is a known problem with spaces and application windows. I will create a PR later documenting this limitation.

mafredri commented 2 years ago

@ckruse two days isn’t really enough for an issue to be forgotten 😅. That’s hasty no matter how you turn the cake. Not making any assumptions about your intent, just calling it as I see it.

But enough about that. An issue tracker is not the right place to be discussing such “issues” (pun intended).

ckruse commented 2 years ago

@mafredri I forget issues at the same day they‘re opened… 🤷‍♂️ I always need an unread email or an entry in my todo list, otherwise I won‘t remember.

mafredri commented 2 years ago

@ckruse why are you applying your own workflow on others?

Edit: This can be surmised in one sentence. Respect other peoples inboxes.

Edit 2: Would advice you to read https://blog.sindresorhus.com/issue-bumping-e3b9740e2a0.

ckruse commented 2 years ago

@mafredri I don't? I was trying to give you a different perspective.