Skip to content
This repository has been archived by the owner on Jan 26, 2024. It is now read-only.

Clients on external monitor in monocle layout don't all come off monitor on disconnect #326

Closed
BenJarg opened this issue Oct 28, 2022 · 4 comments
Labels
A: bug Something isn't working

Comments

@BenJarg
Copy link
Contributor

BenJarg commented Oct 28, 2022

Info

dwl's commit: e9826de
wlroots version: 0.15.1

Description

It there are 2 clients in a monocle layout on an external monitor, when the monitor is unplugged, only one of them jumps to the remaining monitor, where the other can't be seen. When the monitor is plugged back in, the left behind client is still there, but often in some kind of weird state that can trigger a segfault somethings.

I've found it's caused by the line added in 06d9230. cleanupmon() calls focusclient() just before closemon() to set selmon to the remaining monitor. In the wl_list_for_each loop in closemon(), the first client on the dying monitor is moved correctly, but setmon() changes selmon back to the dying monitor in the process while calling monocle() (from arrange() ). Then, the next round of the loop, selmon is back on the dying monitor, so the remaining client is setmoned to that, which does nothing, and it doesn't move.

For fixes, fixing monocle() to not change selmon, such as by calling only wlr_scene_node_raise_to_top to move the focused client to the top of monocle without all the other things in focusclient fixes this. I don't know if there are other things focusclient does that are necessary in some cases though.

Things could also be changed in closemon(), such that selmon is restored to the new monitor at the top of the loop, or maybe not rely on selmon completely and copy the target monitor to a distinct variable before the loop and setmon to that instead.

@BenJarg BenJarg added the A: bug Something isn't working label Oct 28, 2022
@sevz17
Copy link
Collaborator

sevz17 commented Oct 29, 2022

Please can you try #294?

@BenJarg
Copy link
Contributor Author

BenJarg commented Oct 29, 2022

@sevz17 No change in this behavior it seems

@sevz17
Copy link
Collaborator

sevz17 commented Oct 29, 2022

Then this should work:

diff --git a/dwl.c b/dwl.c
index a80de05..8c7644e 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1495,7 +1495,8 @@ monocle(Monitor *m)
 			continue;
 		resize(c, m->w, 0);
 	}
-	focusclient(focustop(m), 1);
+	if ((c = focustop(m)))
+		wlr_scene_node_raise_to_top(c->scene);
 }
 
 void

@BenJarg
Copy link
Contributor Author

BenJarg commented Oct 29, 2022

@sevz17 yep that works

@sevz17 sevz17 closed this as completed in 9588b46 Oct 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants