levnikmyskin / hyprland-virtual-desktops

A plugin for the Hyprland compositor, implementing virtual-desktop functionality.
BSD 3-Clause "New" or "Revised" License
104 stars 9 forks source link

Window pulling focus breaks vdesk sync? #55

Open vgmethod opened 2 months ago

vgmethod commented 2 months ago

Great plugin! Works quite well overall.

Was curious if I've missed a config option in the plugin or otherwise that could help with this.

If a window pulls focus, (clicking on an app in the waybar systray, a mako notifcation, or even opening an app that is dedicated to a certain workspace) it changes the workspace on one monitor, but not the full vdesk (not changing the secondary monitor in sync) - this then breaks the sync until i manually change the workspace of the monitors individually to sync back up. Sometimes have to close all my apps to reset properly.

Thanks again!

levnikmyskin commented 2 months ago

hmm interesting issue, never had it...albeit, I only have thunderbird stealing focus usually. Could you provide the hyprland logs?

What you can try in the meantime is setting the rememberlayout = none in the plugin settings, e.g.:

plugin {
    virtual-desktops {
        rememberlayout = none
    }
}

Also, in such situations the command hyprctl dispatch vdeskreset might come in handy

vgmethod commented 2 months ago

Thanks for the tips. Here's a output from the log. Hard to make sense of for me, I tried to contain it to what I think was the trigger for the break, and then a final command where i ran vdeskreset - It happened when I clicked a link in slack, which opened up my browser (cachy-browser), that was on a separate workspace. It switched workspaces on on monitor, but not the whole vdesk, and then everything got out of whack. Hopefully this helps, and appreciate your time in debugging. hyprland.log

levnikmyskin commented 2 months ago

Have you also tried with the plugin settings I mentioned? Does that still happen? For the logs, I'll have to take a better look into it as soon as I find some more time :)

PS: also please add this to the config:

plugin {
    virtual-desktops {
        rememberlayout = none
        verbose_logging=1
    }
}
vgmethod commented 2 months ago

Thanks, yeah I've tried with the "none" setting. Still happens when I click a link that opens another window, or another window pulls focus. Here is the log reposted with verbose enabled. Same flow. Slack open, click a link, opens cachy-browser on separate workspace, doesn't switch synced workspace on secondary monitor, vdesk out of whack.

hyprland-verbose.log

Plugin settings:

plugin { virtual-desktops { names = 1:general, 2:ai, 3:work, 4:other cycleworkspaces = 0 rememberlayout = none notifyinit = 0 verbose_logging = 1 } }

Workspaces config:

-- Workspaces ------------------------------------------------

bind = SUPER, 1, vdesk, 1 bind = SUPER, 2, vdesk, 2 bind = SUPER, 3, vdesk, 3 bind = SUPER, 4, vdesk, 4 bind = SUPER, 5, vdesk, 5

bind = SUPER, KP_End, vdesk, 1 bind = SUPER, KP_Down, vdesk, 2 bind = SUPER, KP_Next, vdesk, 3 bind = SUPER, KP_Left, vdesk, 4 bind = SUPER, KP_Begin, vdesk, 5

workspace=1, monitor:DP-2, default:true, persistent:true workspace=2, monitor:DP-3, default:true, persistent:true workspace=3, monitor:DP-2, persistent:true, layoutopt:orientation:bottom workspace=4, monitor:DP-3, persistent:true workspace=5, monitor:DP-2, persistent:true, layoutopt:orientation:bottom workspace=6, monitor:DP-3, persistent:true workspace=7, monitor:DP-2, persistent:true, layoutopt:orientation:bottom workspace=8, monitor:DP-3, persistent:true workspace=9, monitor:DP-2, persistent:true, layoutopt:orientation:bottom workspace=10,monitor:DP-3, persistent:true

levnikmyskin commented 2 months ago

Hi! So, I've looked into your logs. It doesn't give me the reasons why this is happening, but at least I can see that it is happening. Specifically, here:

[INFO] [virtual-desktops] applying vdeskwork
[INFO] [virtual-desktops] workspace changed: workspace id 5; on monitor 0
[LOG] [WLDataDevice] New offer 64f23d8b6d50 for data source 64f23e142650
[LOG] [WLDataDevice]  | offer 64f23d8b6d50 supports mime SAVE_TARGETS
[LOG] [WLDataDevice]  | offer 64f23d8b6d50 supports mime text/plain;charset=utf-8
[LOG] [WLDataDevice]  | offer 64f23d8b6d50 supports mime text/plain;charset=utf-8
[LOG] [WLDataDevice]  | offer 64f23d8b6d50 supports mime text/plain;charset=UTF-8
[LOG] Set keyboard focus to surface 1, with [Window 64f23d8ca420: title: "A Document - Google Docs — Cachy Browser"]
[LOG] Searching for matching rules for cachy-browser (title: A Document - Google Docs — Cachy Browser)
[LOG] Window rule opacity 1 0.85 ->     class:^(cachy-browser)$ matched [Window 64f23d8ca420: title: "A Document - Google Docs — Cachy Browser"]
[ERR] Regex error at  class:^(*)$ (Mismatched '(' and ')' in regular expression)
[ERR] Regex error at  title:^(*)$ (Mismatched '(' and ')' in regular expression)
[LOG] Callback 64f239134a40 -> 64f239134a38, CPointerManager removed.
[INFO] [virtual-desktops] workspace changed: workspace id 2; on monitor 1

This shows that:

  1. the plugin is incorrectly applying your work vdesk. It seems like workspace 5 is set on monitor 0, but it seems like the other monitor does not receive a new workspace;
  2. at some point, the workspace for monitor 1 (the one that was not set before!) changes to workspace 2.

I would look into a couple of things:

  1. remove your workspace rules. That's probably what's causing this issue.
  2. you have a LOT of these [ERR] Regex error... -> look into those;
  3. do you have window rules, mapping specific apps to workspaces or similar?
vgmethod commented 2 months ago

Removed workspace= rules, fixed regex error, and removed a couple stickyrules i had for apps - issue still persists unfortunately.

Here's my general hyprland config, maybe something to do with a generic hyprland setting could be causing it. I'm also running waybar although not sure why this would effect anything.

Appreciate your time in trying to help debug the issue. If you want to write this off to an edge case we can't figure out, totally fine. I can keep trying to work through it on my own :)

settings.txt

vgmethod commented 2 months ago

Just tried removing all settings in the settings.txt file, no help. Although I can turn off focus_on_activate and atleast then it doesn't push me to a new workspace automatically

levnikmyskin commented 2 months ago

why is your file called settings.txt? Did you rename it for this purpose? It should be hyprland.conf right?

Anyway, what about your setup (could see this in the logs but faster if you tell me): do you have a laptop connecting to multiple monitors? or just a desktop pc?

levnikmyskin commented 2 months ago

Ah, I guess I'm stupid. I just realized that your problem is expected. This plugin does not manage this, thus the focus is handled by hyprland.

I'm not really planning to add this functionality, but of course nothing against PRs

vgmethod commented 2 months ago

Gotchya, thanks for letting me know!

levnikmyskin commented 2 months ago

I would actually leave this open, in case somebody at some point wants to implement this