Closed AlaxJI closed 1 month ago
@AlaxJI Hey, thanks for reporting! I’m going to presume you get the coordinates for the window again after moving to the new space?
Sounds like it’s a regression created by #350 for multi-monitor setups. Also reported in: https://github.com/kasper/phoenix/issues/348#issuecomment-2182162242
Unfortunately, I’m unsure how to fix it at the moment. @metakirby5 would you have any thoughts?
Not really sure, I haven't experienced the issue with my multi-monitor setup 🤔
In System Settings > Desktop & Dock > Mission Control
, do you have Displays have separate spaces
on or off? I wonder if a difference in settings there is related.
Otherwise, it would help to have a minimal config to reproduce the issue.
(To be honest, I don't fully understand how the API I used in #350 works, since it's totally undocumented. I mostly just observed how other tools were using it and verified it worked on my end.)
In
System Settings > Desktop & Dock > Mission Control
, do you haveDisplays have separate spaces
on or off? I wonder if a difference in settings there is related.
I have it on.
Otherwise, it would help to have a minimal config to reproduce the issue.
My javascript is poor, but this is my config:
const applicationMapToSpace = {
"NetBeans": 6,
"DBeaver": 7,
"Telegram": 11,
"Slack": 11,
"WhatsApp": 11,
};
var getMainWindow = async function (app) {
return new Promise((resolve, reject) => {
if (typeof app.mainWindow() !== "undefined") {
resolve(app.mainWindow());
} else {
setTimeout(() => {
getMainWindow(app).then((resolveApp) => {resolve(resolveApp);});
}, 1000);
}
});
};
var moveAppToSpace = function (app) {
var entry = Object.entries(applicationMapToSpace).find(([key, value]) => app.name().indexOf(key) >= 0);
if (typeof entry !== 'undefined') {
var name = entry[0];
var spaceNumber = entry[1];
getMainWindow(app).then((window) => {
var spaces = Space.all();
var i = 0;
for (let index = 0; index < spaces.length; index++) {
if (!spaces[index].isFullScreen()) {
i++;
}
if (i === spaceNumber) {
var space = spaces[index];
if (!window.spaces()[0].isEqual(space)) {
space.moveWindows([window]);
setTimeout(() => {
window.focus();
window.maximize();
}, 500)
}
}
}
});
}
}
const moverOnLaunch = Event.on('appDidLaunch', (app) => {
moveAppToSpace(app);
});
const moverOnActivate = Event.on('appDidActivate', (app) => {
moveAppToSpace(app);
});
This is my "Arrange Displays". Each display have five spaces.
@AlaxJI Thanks! I found that in my config, I had been updating the window via setTopLeft
and setSize
after moving it to a new screen, using values from the new screen's flippedVisibleFrame
. Would you mind giving it a try too? It would probably go right after the call to space.moveWindows([window])
.
@metakirby5 Thanks!
updating the window via
setTopLeft
andsetSize
after moving it
It's work!!!
Glad to hear! Thanks @metakirby5 for assisting on this one. ❤️
@dan-phantom Hey! Could you also confirm your code and post a snippet of the logic that was not working for you?
I'm on holiday, will reply next week 🤗 On Jul 21, 2024, at 8:21 AM, Kasper Hirvikoski @.***> wrote: @dan-phantom Hey! Could you also confirm your code and post a snippet of the logic that was not working for you?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>
More details, sorry for the delay @kasper
I have 3 screens, MBP + 2 externals, each of them has 4 spaces on it
This is the code
const loadConfig = () => {
_.each(screens, (screen) => {
const screenConfig = screenMap[screen.id];
if (screenConfig && screen.raw.identifier() === screen.id) {
_.each(screen.raw.spaces(), (space, idx) => {
wait(1000);
_.each(
screenConfig.config?.[screens.length].spaces[idx]?.apps,
(app) => {
const appWins = App.get(app)?.windows() || [];
console.log(
`app space: ${app} ${idx} ${space.hash()} ${appWins?.length}`
);
space.moveWindows(appWins);
_.each(appWins, (win) => {
wait(1000);
win.maximize();
});
}
);
});
}
});
};
and screenMap
is something like
const screenMap = {
"37D8832A-2D66-02CA-blah": {
name: "Macbook",
config: {
3: {
spaces: [{ apps: ["Warp"] }],
},
},
},
"B19F092B-DEA3-422F-blah": {
name: "Left",
config: {
3: {
spaces: [
{ apps: ["Code"] },
{ apps: ["Linear"] },
{ apps: ["Notion"] },
{ apps: ["Rive", "ForkLift"] },
],
},
},
},
"CBFD144E-D4D8-4FF5-blah": {
name: "Right",
config: {
3: {
spaces: [
{
apps: [
"Microsoft Edge",
"Google Chrome",
"Firefox",
"Safari",
"Brave Browser",
],
},
{
apps: ["com.apple.iphonesimulator", "Vysor"],
},
{ apps: ["Slack", "Gmail", "Google Calendar"] },
{ apps: ["Spotify"] },
],
},
},
},
};
@metakirby5 @kasper I can also confirm the setTopLeft
works for me too , I call it before maximise ❤️
@dan-phantom Perfect, great to hear! Thanks!
Incorrect (out of screen) window TopLeft coordinates after moving it at another space.
Moving window to space 11