nlpsuge/gnome-shell-extension-another-window-session-manager

Problem in multi-monitor mode with two horizontal rows of screens

victor-lipin opened this issue · 11 comments

Hello!
There is a problem with moving windows to the top row of monitors (monitor 1 in the screenshot)

As far as I understand, this is due to the fact that the origin point for windows "x_offset": 0, "y_offset": 0, is the upper left corner of monitor 2.

I can move windows horizontally using "x_offset" in the config file.
But I can't raise the window vertically because "y_offset": 0 this is the highest point of the monitors 2 and 3.

Perhaps using negative "y_offset" values could help, but it didn't work for me.

Screenshot from 2022-11-15 18-35-51

I use Manjaro Linux 22.0.0 with GNOME Shell 42.5

What is the x_offset, y_offset of the app in the monitor 1? Please show me the window_position part in the session file related to this app.

Can you move the app from monitor 2 to monitor 1 by hand?

What is the x_offset, y_offset of the app in the monitor 1?

"x_offset": 1777, "y_offset": 24

The parameters look correct, but when the window is restored, it falls on the 3rd monitor. As if y_offset is not on monitor 1 but on monitor 2.

Put Gedit on 1 monitor in the upper left corner and saved the settings
Screenshot from 2022-11-16 21-52-55

Restored the Gedit window and it fell on the 3rd monitor
Screenshot from 2022-11-16 21-54-11

Can you move the app from monitor 2 to monitor 1 by hand?

No, i can move app only from 3 monitor.

But I tested on two monitors

Put Gedit on 1 monitor in the upper left corner and saved the settings
Screenshot from 2022-11-16 21-36-58

Restored the Gedit window and it fell on the second monitor
Screenshot from 2022-11-16 21-38-38

Looks somehow the app just falls on the primary monitor.

I'm not sure why, but we probably can find some clue in the logs.

First, please enable the Debugging mode in the extension Settings:
image

Second, watch the logs in the terminal via journalctl -o short-precise -r /usr/bin/{gjs,gjs-console,gnome-shell} .

Third, reproduce the above steps again and there should be some logs, like Moving gedit - a title to the primary monitor x from y.

Please attach those logs.

I don't even have a physical monitor, I can't test this issue properly. :(


Related code:

/**
* We need to move the window before changing the workspace, because
* the move itself could cause a workspace change if the window enters
* the primary monitor
*
* @see https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/gnome-41/js/ui/workspace.js#L1483
*/
_restoreMonitor(metaWindow, saved_window_session) {
const currentMonitorNumber = metaWindow.get_monitor();
// -1 if the window has been recently unmanaged and does not have a monitor
if (currentMonitorNumber === -1) {
return;
}
const primaryMonitorIndex = global.display.get_primary_monitor()
const toMonitorNumber = saved_window_session.monitor_number;
if (toMonitorNumber === undefined) {
if (currentMonitorNumber !== primaryMonitorIndex) {
this._log.info(`${shellApp.get_name()} - ${metaWindow.get_title()} doesn't have the monitor number data, click the save open windows button to save it. Moving it to the primary monitor ${primaryMonitorIndex} from ${currentMonitorNumber}`);
metaWindow.move_to_monitor(primaryMonitorIndex);
}
return;
}
const shellApp = this._windowTracker.get_window_app(metaWindow);
// It's possible to save the unmanaged windows
if (toMonitorNumber === -1) {
if (currentMonitorNumber !== primaryMonitorIndex) {
this._log.info(`${shellApp.get_name()} - ${metaWindow.get_title()} is unmanaged when saving, moving it to the primary monitor ${primaryMonitorIndex} from ${currentMonitorNumber}`);
metaWindow.move_to_monitor(primaryMonitorIndex);
}
return;
}
const is_on_primary_monitor = saved_window_session.is_on_primary_monitor;
if (is_on_primary_monitor) {
if (currentMonitorNumber !== primaryMonitorIndex) {
this._log.info(`Moving ${shellApp.get_name()} - ${metaWindow.get_title()} to the primary monitor ${primaryMonitorIndex} from ${currentMonitorNumber}`);
metaWindow.move_to_monitor(primaryMonitorIndex);
}
return;
}
// It causes Gnome shell to crash, if we move a monitor to a non-existing monitor on X11 and Wayland!
// We move all windows on non-existing monitors to the primary monitor
const totalMonitors = global.display.get_n_monitors()
if (toMonitorNumber > totalMonitors - 1) {
if (currentMonitorNumber !== primaryMonitorIndex) {
this._log.info(`Monitor ${toMonitorNumber} doesn't exist. Moving ${shellApp.get_name()} - ${metaWindow.get_title()} to the primary monitor ${primaryMonitorIndex} from ${currentMonitorNumber}`);
metaWindow.move_to_monitor(primaryMonitorIndex);
}
return;
}
if (currentMonitorNumber !== toMonitorNumber) {
this._log.debug(`Moving ${shellApp.get_name()} - ${metaWindow.get_title()} to monitor ${toMonitorNumber} from ${currentMonitorNumber}`);
// So, you don't want to unplug the monitor, which we are moving the window in to, at this moment. 🤣
metaWindow.move_to_monitor(toMonitorNumber);
return;
}
}

This is a bug, tested with another virtual screen.

Related code:

this._restoreMonitor(open_window, saved_window_session);
this._restoreWindowGeometry(open_window, saved_window_session);

L81 does move the window to the monitor that it's supposed to be in. But L82 moves it to the primary monitor while L82 restores the size and geometry using metaWindow.move_resize_frame .

I'll fix it later.

@RebelSon84
Hi, did you have this issue on the older GNOME Shells?

This issue had been committed to https://gitlab.gnome.org/GNOME/mutter/-/issues/2340 4 months ago.

did you have this issue on the older GNOME Shells?
Hello!
I'll check it out.
But I didn't seem to notice it before.

Looks like it's a bug of mutter and I have reported it: https://gitlab.gnome.org/GNOME/mutter/-/issues/2521

@RebelSon84

Hi, could you please test this branch https://github.com/nlpsuge/gnome-shell-extension-another-window-session-manager/compare/bugfix-multi-monitor?

You can download it from the release page: https://github.com/nlpsuge/gnome-shell-extension-another-window-session-manager/releases/tag/29.1

After downloading, copy the contents to extension folder:
cp -rp gnome-shell-extension-another-window-session-manager-29.1/* ~/.local/share/gnome-shell/extensions/another-window-session-manager@gmail.com/

Then restart gnome shell (using alt+f2 type r for X11 or logout and login for Wayland).

Hi, could you please test this branch

Hello!
Everything works great!
Thank you very much