Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] unable to focus window after movetonextdesk (ends up on wrong workspace) #57

Open
timon-schelling opened this issue Aug 16, 2024 · 6 comments

Comments

@timon-schelling
Copy link

I really appreciate this plugin, thanks for the effort.

When I move windows between virtual desktops I'm unable to focus the moved windows and some artifacts appear on other monitors. After some time and jumping between desktops, I am once again able to focus the window, but on a different monitor without moving it there.

The simplest case I was able to reproduce consistently is with three monitors with one window each. Than I open a new window one of the monitors and move it via movetonextdesk.

Further down is some console output that was captured while testing this.

For me it seems like the the window was moved to the wrong workspace (from 2 to 6 instead of from 2 to 5) and somehow the output of the workspace that the window landed on got displayed on the monitor the window came from.

Output of hyprctl workspaces & hyprctl clients before running movetonextdesk with window "Window 3ecf7e00 -> Rio" focused

❯ hyprctl workspaces; hyprctl clients
workspace ID 1 (1) on monitor DP-1:
	monitorID: 0
	windows: 1
	hasfullscreen: 0
	lastwindow: 0x0
	lastwindowtitle:

workspace ID 2 (2) on monitor DP-2:
	monitorID: 1
	windows: 2
	hasfullscreen: 0
	lastwindow: 0x3ec6ca60
	lastwindowtitle: Rio

workspace ID 3 (3) on monitor DP-3:
	monitorID: 2
	windows: 1
	hasfullscreen: 0
	lastwindow: 0x3ecacd30
	lastwindowtitle: Visual Studio Code


Window 3ecacd30 -> Visual Studio Code:
	mapped: 1
	hidden: 0
	at: 1211,285
	size: 2538,1394
	workspace: 3 (3)
	floating: 0
	pseudo: 0
	monitor: 2
	class: code-url-handler
	title: Visual Studio Code
	initialClass: code-url-handler
	initialTitle: Visual Studio Code
	pid: 21627
	xwayland: 0
	pinned: 0
	fullscreen: 0
	fullscreenmode: 0
	fakefullscreen: 0
	grouped: 0
	tags:
	swallowing: 0
	focusHistoryID: 3

Window 3ecc8190 -> Mozilla Firefox:
	mapped: 1
	hidden: 0
	at: 3771,35
	size: 1178,1874
	workspace: 1 (1)
	floating: 0
	pseudo: 0
	monitor: 0
	class: firefox
	title: Mozilla Firefox
	initialClass: firefox
	initialTitle: Mozilla Firefox
	pid: 21781
	xwayland: 0
	pinned: 0
	fullscreen: 0
	fullscreenmode: 0
	fakefullscreen: 0
	grouped: 0
	tags:
	swallowing: 0
	focusHistoryID: 2

Window 3ecf7e00 -> Rio:
	mapped: 1
	hidden: 0
	at: 11,981
	size: 1178,928
	workspace: 2 (2)
	floating: 0
	pseudo: 0
	monitor: 1
	class: rio
	title: Rio
	initialClass: rio
	initialTitle: Rio
	pid: 22329
	xwayland: 0
	pinned: 0
	fullscreen: 0
	fullscreenmode: 0
	fakefullscreen: 0
	grouped: 0
	tags:
	swallowing: 0
	focusHistoryID: 1

Window 3ec6ca60 -> Rio:
	mapped: 1
	hidden: 0
	at: 11,35
	size: 1178,928
	workspace: 2 (2)
	floating: 0
	pseudo: 0
	monitor: 1
	class: rio
	title: Rio
	initialClass: rio
	initialTitle: Rio
	pid: 21629
	xwayland: 0
	pinned: 0
	fullscreen: 0
	fullscreenmode: 0
	fakefullscreen: 0
	grouped: 0
	tags:
	swallowing: 0
	focusHistoryID: 0

after movetonextdesk

workspace ID 1 (1) on monitor DP-1:
	monitorID: 0
	windows: 1
	hasfullscreen: 0
	lastwindow: 0x3ecc8190
	lastwindowtitle: Mozilla Firefox

workspace ID 2 (2) on monitor DP-2:
	monitorID: 1
	windows: 1
	hasfullscreen: 0
	lastwindow: 0x3ec6ca60
	lastwindowtitle: Rio

workspace ID 3 (3) on monitor DP-3:
	monitorID: 2
	windows: 1
	hasfullscreen: 0
	lastwindow: 0x3ecacd30
	lastwindowtitle: Visual Studio Code

workspace ID 6 (6) on monitor DP-2:
	monitorID: 1
	windows: 1
	hasfullscreen: 0
	lastwindow: 0x3ecf7e00
	lastwindowtitle: Rio

workspace ID 5 (5) on monitor DP-2:
	monitorID: 1
	windows: 0
	hasfullscreen: 0
	lastwindow: 0x0
	lastwindowtitle:

workspace ID 4 (4) on monitor DP-1:
	monitorID: 0
	windows: 1
	hasfullscreen: 0
	lastwindow:
	lastwindowtitle:


Window 3ecacd30 -> Visual Studio Code:
	mapped: 1
	hidden: 0
	at: 1211,285
	size: 2538,1394
	workspace: 3 (3)
	floating: 0
	pseudo: 0
	monitor: 2
	class: code-url-handler
	title: Visual Studio Code
	initialClass: code-url-handler
	initialTitle: Visual Studio Code
	pid: 21627
	xwayland: 0
	pinned: 0
	fullscreen: 0
	fullscreenmode: 0
	fakefullscreen: 0
	grouped: 0
	tags:
	swallowing: 0
	focusHistoryID: 3

Window 3ecc8190 -> Mozilla Firefox:
	mapped: 1
	hidden: 0
	at: 3771,35
	size: 1178,1874
	workspace: 1 (1)
	floating: 0
	pseudo: 0
	monitor: 0
	class: firefox
	title: Mozilla Firefox
	initialClass: firefox
	initialTitle: Mozilla Firefox
	pid: 21781
	xwayland: 0
	pinned: 0
	fullscreen: 0
	fullscreenmode: 0
	fakefullscreen: 0
	grouped: 0
	tags:
	swallowing: 0
	focusHistoryID: 4

Window 3ec6ca60 -> Rio:
	mapped: 1
	hidden: 0
	at: 11,35
	size: 1178,1874
	workspace: 2 (2)
	floating: 0
	pseudo: 0
	monitor: 1
	class: rio
	title: Rio
	initialClass: rio
	initialTitle: Rio
	pid: 21629
	xwayland: 0
	pinned: 0
	fullscreen: 0
	fullscreenmode: 0
	fakefullscreen: 0
	grouped: 0
	tags:
	swallowing: 0
	focusHistoryID: 1

 Window 3ecf7e00 -> Rio:
	mapped: 1
	hidden: 0
	at: 11,35
	size: 1178,1874
	workspace: 6 (6)
	floating: 0
	pseudo: 0
	monitor: 1
	class: rio
	title: Rio
	initialClass: rio
	initialTitle: Rio
	pid: 23202
	xwayland: 0
	pinned: 0
	fullscreen: 0
	fullscreenmode: 0
	fakefullscreen: 0
	grouped: 0
	tags:
	swallowing: 0
	focusHistoryID: 2

after moving back to desktop 1

❯ hyprctl workspaces; hyprctl clients
workspace ID 1 (1) on monitor DP-1:
	monitorID: 0
	windows: 1
	hasfullscreen: 0
	lastwindow: 0x3ecc8190
	lastwindowtitle: Mozilla Firefox

workspace ID 2 (2) on monitor DP-2:
	monitorID: 1
	windows: 1
	hasfullscreen: 0
	lastwindow: 0x3ec6ca60
	lastwindowtitle: Rio

workspace ID 3 (3) on monitor DP-3:
	monitorID: 2
	windows: 1
	hasfullscreen: 0
	lastwindow: 0x3ecacd30
	lastwindowtitle: Visual Studio Code

workspace ID 6 (6) on monitor DP-2:
	monitorID: 1
	windows: 1
	hasfullscreen: 0
	lastwindow: 0x3ecf7e00
	lastwindowtitle: Rio


Window 3ecacd30 ->  Visual Studio Code:
	mapped: 1
	hidden: 0
	at: 1211,285
	size: 2538,1394
	workspace: 3 (3)
	floating: 0
	pseudo: 0
	monitor: 2
	class: code-url-handler
	title: Visual Studio Code
	initialClass: code-url-handler
	initialTitle: Visual Studio Code
	pid: 21627
	xwayland: 0
	pinned: 0
	fullscreen: 0
	fullscreenmode: 0
	fakefullscreen: 0
	grouped: 0
	tags:
	swallowing: 0
	focusHistoryID: 2

Window 3ecc8190 -> Mozilla Firefox:
	mapped: 1
	hidden: 0
	at: 3771,35
	size: 1178,1874
	workspace: 1 (1)
	floating: 0
	pseudo: 0
	monitor: 0
	class: firefox
	title: Mozilla Firefox
	initialClass: firefox
	initialTitle: Mozilla Firefox
	pid: 21781
	xwayland: 0
	pinned: 0
	fullscreen: 0
	fullscreenmode: 0
	fakefullscreen: 0
	grouped: 0
	tags:
	swallowing: 0
	focusHistoryID: 1

Window 3ecf7e00 -> Rio:
	mapped: 1
	hidden: 0
	at: 11,35
	size: 1178,1874
	workspace: 6 (6)
	floating: 0
	pseudo: 0
	monitor: 1
	class: rio
	title: Rio
	initialClass: rio
	initialTitle: Rio
	pid: 22329
	xwayland: 0
	pinned: 0
	fullscreen: 0
	fullscreenmode: 0
	fakefullscreen: 0
	grouped: 0
	tags:
	swallowing: 0
	focusHistoryID: 3

Window 3ec6ca60 -> Rio:
	mapped: 1
	hidden: 0
	at: 11,35
	size: 1178,1874
	workspace: 2 (2)
	floating: 0
	pseudo: 0
	monitor: 1
	class: rio
	title: Rio
	initialClass: rio
	initialTitle: Rio
	pid: 21629
	xwayland: 0
	pinned: 0
	fullscreen: 0
	fullscreenmode: 0
	fakefullscreen: 0
	grouped: 0
	tags:
	swallowing: 0
	focusHistoryID: 0
@levnikmyskin
Copy link
Owner

hi! It looks to me that in the second console output the window was not moved at all...also it seems you have two instances of Rio, instead of 1? The fact that it is moved to workspace 6 instead of 5 is not important: if you have 3 monitors, by default on vdesk 2 there will be workspaces 4,5,6, and the window will just be placed wherever on one of these workspaces IIRC.

Just wondering, does this happen if you move back and forth once between vdesk 1 and 2, before moving the window?
What if instead you use hyprctl dispatch vdeskreset before moving the window?

@timon-schelling
Copy link
Author

timon-schelling commented Aug 18, 2024

hi! It looks to me that in the second console output the window was not moved at all...also it seems you have two instances of Rio, instead of 1?

To reproduce my issue I need 3 windows that stay on each of the 3 monitors on vdesk, one of them is a second rio window in the logs I provided.
The second 3ecf7e00 moved from monitor 2 to monitor 3 and from workspace 2 to workspace 6. This happened between log 1 and 2. I don't know why you would think it did not move at all. I could redo it with other windows maybe 3 Firefox and one vscode that I move around, would that make it clearer?

The fact that it is moved to workspace 6 instead of 5 is not important: if you have 3 monitors, by default on vdesk 2 there will be workspaces 4,5,6, and the window will just be placed wherever on one of these workspaces IIRC.

I think it matters for me, there are different dispatchers to move windows around between visible monitors. I think the behavior of KDE or GNOME is what users would expect.

Just wondering, does this happen if you move back and forth once between vdesk 1 and 2, before moving the window?

I have never tested this specifically. But also happened after using the vdesk 1 and 2 for some time, moving between them but leaving every window on the vdesk it was created on, and then moving a window from vdesk 1 to 2. the behavior is identical in that case.

What if instead you use hyprctl dispatch vdeskreset before moving the window?

This did not change anything.
The logs I provided where recorded after rebooting, than creating the windows and than calling vdeskreset. I get the same results regardless if I call vdeskreset before or not.

Thanks for investigating this. Tell me if I can help in any way.

@levnikmyskin
Copy link
Owner

The second 3ecf7e00 moved from monitor 2 to monitor 3 and from workspace 2 to workspace 6. This happened between log 1 and 2.

Misunderstood the logs, thought you also tried to move it back to first vdesk.

I think it matters for me, there are different dispatchers to move windows around between visible monitors. I think the behavior of KDE or GNOME is what users would expect.

Yes, but this is not implemented in the plugin yet, so what you're seeing is not technically a bug, but a missing feature.

So, given this, I think the actual bug in your situation is the artifacts, and the fact that the window cannot be focused. Do you use any software that manages monitors, like kanshi, shikane, way-displays or similar? These kind of problems are usually related to the fact that both Hyprland and the plugin are trying to move windows and workspaces around when monitors get connected/disconnected. I've been meaning to add a plugin event to avoid this to Hyprland, but never really got around to actually doing it

@timon-schelling
Copy link
Author

So, given this, I think the actual bug in your situation is the artifacts, and the fact that the window cannot be focused.

Feel free to change this issue represent that.

Do you use any software that manages monitors, like kanshi, shikane, way-displays or similar?

No just hyprland and this plugin, with a static monitor configuration.

Yes, but this is not implemented in the plugin yet, so what you're seeing is not technically a bug, but a missing feature.

Thus I should open a separate feature request?

@levnikmyskin
Copy link
Owner

Yes, you can open a feature request :)
For the bug, I think this might be related to #44 . I hope these issues will be fixed once I finally will take the time to push some additional events to hyprland plugin events

@jarek102
Copy link

jarek102 commented Dec 18, 2024

I also experienced same bug, for now I've set up permanent workspaces:

workspace = 1, monitor:DP-1, persistent:true 
workspace = 3, monitor:DP-2, persistent:true
workspace = 2, monitor:HDMI-A-1, persistent:true 
workspace = 4, monitor:DP-1, persistent:true
workspace = 6, monitor:DP-2, persistent:true
workspace = 5, monitor:HDMI-A-1, persistent:true 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants