GnomeSnapExtensions / gSnap

Gnome-shell extension that allows you to move windows into specific regions similiar to FancyZones on windows.
https://extensions.gnome.org/extension/4442/gsnap/
Other
166 stars 23 forks source link

Third display getting lost of display position #77

Closed jwdotpark closed 5 months ago

jwdotpark commented 1 year ago

Hi, thank you for the great extension!

I have a bug regarding third display not being recognized after a while(not sure what event cause losing the display setup). It only happens on third display, I assume this code is related to it.

If I manually designate the value to monitor3, it does work as intended a while but like I said above, it lose its position value as soon as there is an event such as changing focus, triggering application grid or some kind of fullscreen event it seems.

I'll try making the fix but guess it's worth reporting. Again, thank you for the great extension!

meronz commented 11 months ago

So you mean that hotplugging a 3rd monitor does not trigger the extension to refresh and recognize the monitor. Did I get that correctly? Logs would be helpful in this case to better assess whats happening. Anyway I don't have access to a physical 3-monitor setup. I just have 1 monitor and I typically use a virtual machine with N-displays. I'm not sure if I am able to reproduce the same behaviour with that setup.

iirc the primary/secondary monitor category just differentiates the primary monitor from the other ones (the primary monitor being the one with the title bar!). I maybe wrong on this, so I'll check it.

thomas-rooty commented 9 months ago

Hi,

I also have this bug, I have 3 monitors and the middle one which is number 3 on the gSnap point of view doesnt remember its grid layout.

jwdotpark commented 9 months ago

@meronz Hey I'm so sorry for late response, I completely forgot about the bug report!

My description went wrong a bit - what I meant was the extension doesn't recognize the display more than 2 basically.

image

To be precise, the extension does recognize every display but only 2 displays are ready for tiling, more than 2 display are ignored regardless of display array in below setup.

image

Apologize for this frankenstein but with the setup above for an example, again only 2 display can be tiled no matter what. Also the order is random so I have to do the enable/disable puzzle in the Settings for designated display being able to be tiled (in my case 1 and 3) but that's rather gnome display array management thing than this extension(Sorry I can't be sure).

I tried logging using journalctl --follow /usr/bin/gnome-shell | grep "gSnap" but I can't see any log while tiling, not sure what went wrong. I haven't been involved in gnome env development before, any cursor for debugging would be very much appreciated.

All in all it works as intended once I get it right for 2 displays and I don't have much problem for now, priority for this one is pretty low tbh. Thanks for the great extension!

meronz commented 9 months ago

Don't worry! To enable the logs you need to go in the extensions settings and click on the "debug" checkbox. If you can provide the logs I could try to fix it :)

KF-AK commented 9 months ago

It's unclear to me if I'm experiencing the same issue as @jwdotpark , maybe they can confirm:

Sometimes my third monitor (labelled as monitor 2) will have the set layout removed, when this happens holding control while dragging results in no zones appearing and no snapping on this monitor until a layout is selected from the tray icon again. The behavior on the other two monitors is unaffected. I first noticed this issue after having my monitors turned off for a long period (multiple hours) while the machine was still powered on (no sleep/hibernate used)

I have found a way to reliably reproduce this issue as well:

  1. Have 3 monitors connected
  2. Set a layout for each of the monitors
  3. Open gSnap settings
  4. Toggle "Show tabs"
  5. Attempt to tile

Result should be monitor 0 + monitor 1 still have layouts set, while monitor 2 has no layout set.

This is on Gnome 42.9 in x11, if it matters

Logs: gsnap-log.txt

jwdotpark commented 9 months ago

In the process of logging, tiling is only applied to display 1 and 3. If I change the layout of display array in the Settings, tiling applied display is changed randomly.

Here's the log.txt when I enabled Display 2. All the log is generated from the process of enabling the display except last line which is just moving window from A to B.

I'm not sure this is appropriate way to reproduce the bug. If you want any different way situation to try, please let me know I'd happy to provide more.

KF-AK commented 8 months ago

Is there anything I or another member of the community can offer to help resolve this? Be it more debug/troubleshooting, a bounty, a third monitor for your use, etc? This the only real issue I've had with gSnap and it will perfectly fit my needs once this is resolved, so I'm happy to help in any way I am able, I unfortunately just don't have the experience necessary to fix it myself

warelock2 commented 5 months ago

@meronz As currently written, this plugin only supports saving configuration for two monitors.

$ jq -r '.workspaces[0]' ~/.config/gSnap/layouts.json
[
  {
    "current": 1
  },
  {
    "current": 1
  }
]

A user is free to assign a layout to the third monitor, but if they make any change in Settings, the plugin restarts itself, reloading configuration from the json file. Since no settings were saved for the third monitor, the third monitor loses its configuration and must be manually set again by the user.

To watch this plugin save your changes to disk, live as you change per-monitor layouts in the plugin:

$ watch jq -r '.workspaces[0]' ~/.config/gSnap/layouts.json
warelock2 commented 5 months ago

I use Ubuntu 22.04, have three monitors, and any time I made a change to anything in gSnap, it would lose the settings for only my third monitor. Here's a one-time workaround hack you can do live to fix this:

This a three-monitor fix, setting layout "0" or "None" for all three monitors. You can just copy/paste the code into your non-root shell:

json_file=~/.config/gSnap/layouts.json
content=$(cat $json_file | jq -r ".workspaces =
    [
      [
        {"current": 0},
        {"current": 0},
        {"current": 0}
      ],
      [
        {"current": 0},
        {"current": 0},
        {"current": 0}
      ]
    ]"
)
echo $content | jq -r . > $json_file

Once this is done, just go into the extension drop down menu and set your monitors to the layouts you want, as you normally would. Since this code does an in-line edit your existing "layouts.json" file, any custom layouts you may have created shouldn't be altered at all.

You can extend this fix to get gSnap to save settings for n monitors, by adding another "current" line two both code blocks, for each additional monitor you have. For example, here's a four monitor fix:

json_file=~/.config/gSnap/layouts.json
content=$(cat $json_file | jq -r ".workspaces =
    [
      [
        {"current": 0},
        {"current": 0},
        {"current": 0},
        {"current": 0}
      ],
      [
        {"current": 0},
        {"current": 0},
        {"current": 0},
        {"current": 0}
      ]
    ]"
)
echo $content | jq -r . > $json_file

As to the original problem, my investigations have shown me that the code that creates the default "layouts.json" file assume you have two monitors, rather than probe what you do have (ie. three monitors) and create the initial "layouts.json" file properly. If you actually have three monitors and the "layouts.json" file only is set up for two monitors, the settings for your third monitor will be lost whenever you make any changes in the extension per-monitor layout assignments or settings.

@meronz Please fix this. Thanks.

meronz commented 5 months ago

Fixed, please wait for the extension to be released on EGO.