Skip to content

Commit 97407f8

Browse files
Seeker04Seeker04
authored andcommitted
Fixed crash when unplugging focused monitor (#108)
1 parent 95cb12a commit 97407f8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/plwm.pl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,11 +1113,16 @@
11131113
monitors(Mons),
11141114
(Mons \= [_] -> % keep logic of final monitor even if it's disconnected
11151115
(nextto(Mon, NMon, Mons) -> NextMon = NMon ; Mons = [NextMon|_]),
1116-
nb_getval(workspaces, Wss),
1116+
1117+
nb_getval(workspaces, Wss), % move windows to next monitor
11171118
forall(member(Ws, Wss), (
11181119
forall(global_key_value(windows, Mon-Ws, Wins), (
11191120
forall(member(Win, Wins), win_tomon_toworkspace_top(Win, NextMon, Ws, false))
11201121
)))),
1122+
1123+
nb_getval(active_mon, ActMon), % focus next monitor if this was the focused one
1124+
(ActMon == Mon -> switch_monitor(NextMon) ; true),
1125+
11211126
nb_getval(monitor_geom, AMonGeom), nb_getval(free_win_space, AFreeWinSpace),
11221127
nb_getval(active_ws, AActiveWs), nb_getval(prev_ws, APrevWs),
11231128
del_assoc(Mon, AMonGeom, _, NewAMonGeom), del_assoc(Mon, AFreeWinSpace, _, NewAFreeWinSpace),
@@ -1127,9 +1132,6 @@
11271132

11281133
forall(member(Ws, Wss), delete_ws_assocs(Mon, Ws)),
11291134

1130-
nb_getval(active_mon, ActMon),
1131-
(ActMon == Mon -> switch_monitor(NextMon) ; true),
1132-
11331135
format(string(Msg), "Monitor \"~s\" unmanaged", [Mon]),
11341136
writeln(Msg)
11351137
; true)

0 commit comments

Comments
 (0)