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

`Space.windows()` doesn't return all windows accurately #333

Open z20240 opened 1 year ago

z20240 commented 1 year ago

First of all, I'm very thankful that the author provide this powerful library.

I'm trying to using Space.windows() to get all windows' information from Space.windows() bug it seems not return accurate result.

Here is my snip code

const spaces = Space.all();
for (let space of spaces) {
  console.log('Space ---->', space.hash());
  console.log(
    space
      .windows()
      .map((window) => `[${window.hash()}]-${window.app().name()}`)
      .join('\n')
  );
}

And the result of console.log returned is below

2023-04-05 01:54:03.846401+0800 0x1802     Default     0x0                  753    0    Phoenix: Phoenix has loaded!
2023-04-05 01:54:03.846595+0800 0x1802     Default     0x0                  753    0    Phoenix: Space ----> 3
2023-04-05 01:54:03.875760+0800 0x1802     Default     0x0                  753    0    Phoenix:
2023-04-05 01:54:03.875868+0800 0x1802     Default     0x0                  753    0    Phoenix: Space ----> 4
2023-04-05 01:54:03.898515+0800 0x1802     Default     0x0                  753    0    Phoenix:
2023-04-05 01:54:03.898631+0800 0x1802     Default     0x0                  753    0    Phoenix: Space ----> 5
2023-04-05 01:54:03.923203+0800 0x1802     Default     0x0                  753    0    Phoenix: [1668246211]-Code
2023-04-05 01:54:03.923300+0800 0x1802     Default     0x0                  753    0    Phoenix: Space ----> 6
2023-04-05 01:54:04.049655+0800 0x1802     Default     0x0                  753    0    Phoenix:
2023-04-05 01:54:04.049780+0800 0x1802     Default     0x0                  753    0    Phoenix: Space ----> 7
2023-04-05 01:54:04.105358+0800 0x1802     Default     0x0                  753    0    Phoenix:
2023-04-05 01:54:04.105512+0800 0x1802     Default     0x0                  753    0    Phoenix: Space ----> 11
2023-04-05 01:54:04.132246+0800 0x1802     Default     0x0                  753    0    Phoenix: [1668245901]-Microsoft Edge
[1668245944]-System Information
2023-04-05 01:54:04.132420+0800 0x1802     Default     0x0                  753    0    Phoenix: Space ----> 9
2023-04-05 01:54:04.157580+0800 0x1802     Default     0x0                  753    0    Phoenix:
2023-04-05 01:54:04.157708+0800 0x1802     Default     0x0                  753    0    Phoenix: Space ----> 10
2023-04-05 01:54:04.183784+0800 0x1802     Default     0x0                  753    0    Phoenix:
2023-04-05 01:54:04.197950+0800 0x1802     Default     0x0                  753    0    Phoenix: Context loaded.

Here is my actual window distribute.

Screenshot 2023-04-05 at 1 59 59 AM

Screenshot 2023-04-05 at 1 59 59 AM (2)

It seems that some window didn't be detected by phoenix.

Any idea?

kasper commented 1 year ago

Hi! I would need to investigate this more, I’m unsure what could cause this.

z20240 commented 1 year ago

Thank you very much. If you need more info, please let me know. I'll do my best to support it.

kasper commented 1 year ago

@z20240 Thanks! If you check what Window.all() returns, can you find all the windows there?

z20240 commented 1 year ago

@z20240 Thanks! If you check what Window.all() returns, can you find all the windows there?

Yah, it can return all active windows even if the window is not currently displayed.

image

image

btw, I have two monitors in my develop space. I'm not sure if it is related to this situation.

image

image

kasper commented 1 year ago

Great, so what happens if you iterate over all the windows from Window.all() and call Window#spaces() for each window? Do you get better results? Or do some windows return empty spaces?

z20240 commented 1 year ago

Great, so what happens if you iterate over all the windows from Window.all() and call Window#spaces() for each window? Do you get better results? Or do some windows return empty spaces?

It seems a little wired.

I tried to iterate over all the windows from Window.all() and call Window.spaces() for each window.

However it still not shown correct windows distribution in each space.

Here is the code what used to iterate.

image

image

And the testing environment in on desktop 4 and desktop 6 which is Space 4 and Space 7.

It seems if any space doesn't have window, it won't be return by window.spaces().


The figures below is what my actually windows distribution.

desktop 1

image

desktop 2

image

desktop 3

image

desktop 4

image

desktop 5

image

desktop 6

image