kishorviswanathan / window-state-manager

GNOME-shell extension to automatically save/restore window state
GNU General Public License v2.0
22 stars 4 forks source link

Windows being moved to the wrong workspace #9

Open neilbags opened 8 months ago

neilbags commented 8 months ago

Hi, this seems to work great at putting windows back on the correct workspace

However when docking it also seems to put all windows on the current workspace. Am I the only one having this problem?

FloFaber commented 7 months ago

@neilbags No, you are not the only one. Why did you close this issue? Did you find another solution?

neilbags commented 7 months ago

Hi @FloFaber I realized that it was also happening without the extension enabled. I didn't have time to investigate further so I closed the issue for now

FloFaber commented 7 months ago

Yes, it's the same for me when I disable the extension: Everything goes on the same workspace on the same monitor when undocking. I assume this is default gnome behaviour then? Nevertheless it would be nice for this extension to also remember a window's workspace.

@kishorviswanathan Would it be possible to implement this feature?

P.S.: I have enabled the option to only switch workspaces on my primary monitor. The behaviour I described only exists if this option is enabled. When selecting "Workspaces on all monitors", the window's workspaces are remembered when undocking. I assume this is more of a gnome issue then, isn't it?

kishorviswanathan commented 7 months ago

@FloFaber From what you have described, I think your primary monitor jumps between your laptop display and external monitor when you dock and undock. In that case the workspace that previously existed on the monitor no longer exists. That could be the reason why all windows end up on the same workspace.

If I remember correctly, this extension won't modify anything related to the workspace. But anyway I will try to debug the reason for this behaviour.

neilbags commented 7 months ago

Here's what I am seeing:

With Multi Monitor set to Workspaces on Primary Display only, when I dock, all my windows end up on one workspace. When docking one of my external monitors becomes primary.

With Multi Monitor set to Workspaces on all displays, when I dock, windows stay on the correct workspace, but all end up on my left-most output, which isn't my primary monitor. Also annoying.

I don't have any issues when I un-dock. I'm on GNOME 43 from Debian bookworm, and haven't tried on a newer version.

Thanks for your great work @kishorviswanathan

FloFaber commented 7 months ago

@kishorviswanathan Exactly, my primary monitor is an external one when docked.

In that case the workspace that previously existed on the monitor no longer exists.

That makes sense. However my guess is that it won't be as easy to add that workaround/feature in the extension, right?

qdrop17 commented 7 months ago

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/1046 - these two issues are probably linked together.

I resolved this issue by enabling Workspaces on all displays:

image

Now everything works as expected. Great work @kishorviswanathan!

kishorviswanathan commented 7 months ago

I have added some changes to the extension to monitor the workspace index as well. If you are on Gnome 45 or later, can you test by installing from the main branch and see if this change fixes your issue ?

neilbags commented 7 months ago

Hi, thanks for looking into it. Is there a hard requirement for Gnome 45? Any way to make it work on 43? I'm on Debian Bookworm so probably won't see a newer version for over a year

kishorviswanathan commented 7 months ago

@neilbags In gnome 45, ES modules were introduced and I had to rewrite the entire extension to make it compatible. Previously the extension used to save and restore states periodically and now it does so based on events. Back porting the changes to Gnome 43 would be time consuming and I don't have a way to test it.

However I will try to backport just this change if I get a chance.

neilbags commented 7 months ago

Hi thanks @kishorviswanathan I understand.

I just tested this on a fresh Ubuntu 23.10 (Gnome 45) with Multi Monitor set to 'Workspaces on Primary Display only' and I'm still seeing the same issue

kishorviswanathan commented 7 months ago

@neilbags It is weird. I just tried on my machine running gnome 46 and workspace enabled only on the primary display. I have 3 monitors, out of which one of the external monitor is the primary one. When docked, I have 3 workspaces on the primary monitor. Once undocked, everything goes to my laptop's monitor and to the first workspace. When I dock it again, windows are back to their old workspaces on the external monitor.

I believe this is the behavior you are also expecting to see. Are you testing it the same way as I am testing or are you doing something different ?

neilbags commented 6 months ago

Sorry I have been a bit tied up moving house and haven't been able to test this properly.

In testing I'm usually starting un-docked and creating windows on multiple workspaces. Upon docking, I'm expecting each window to stay same workspace even though the primary display has changed. E.g I always have my web browser on workspace 1 and my email client on workspace 2. I want this to persist whether I'm docked or undocked

kishorviswanathan commented 3 months ago

Based on how the code is written, this is how it should work:

Example:

Docked (2 monitors):

Workspace 1:
  Monitor 1: Chrome
  Monitor 2: Spotify
Workspace 2:
  Monitor 1: Terminal
  Monitor 2: Empty

Undocked:

Workspace 1:
  Monitor 1: Chrome, Spotify
Workspace 2:
  Monitor 1: Terminal

Added "VS Code" to Workspace 2 and moved "Terminal" to Workspace 3 while in undocked state. Now the new layout is:

Undocked:

Workspace 1:
  Monitor 1: Chrome, Spotify
Workspace 2:
  Monitor 1: VS Code
Workspace 3:
  Monitor 1: Terminal

Now when you dock it again, extension has no idea where to put the "VS Code" window. It was not present before. So it will not modify state of that window. New layout would be:

Docked (2 monitors):

Workspace 1:
  Monitor 1: Chrome
  Monitor 2: Spotify
Workspace 2:
  Monitor 1: Terminal
  Monitor 2: VS Code (probably, but it is up to gnome to decide)

If it is working like that, then there are no bugs. This extension only aims to save and restore the state before and after layout changes. It cannot handle mappings. Probably use a different extension like smart-auto-move.