summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStivvo <stivvo01@gmail.com>2020-10-31 12:43:07 +0100
committerStivvo <stivvo01@gmail.com>2020-10-31 12:52:22 +0100
commit25671d79051e9054f64de88e77e089a2daf7008f (patch)
treeab409cd59aa97e7c8d82fbe5e88c217027ddfb84
parent60a63b637c094d4c55aaf3bafc00df0e46ca3d15 (diff)
Fix crash when disabling focused mon
m->link.next leads to errors if the monitor to disable doesn't have a "next" (right) monitor and is currently focused. dirtmon() does more checks. In some previous commits m->link.next is told to be left monitor, which is wrong Also focusclient() explicitly checks for disabled monitors (this fixes in case of more than one disabled monitor)
-rw-r--r--dwl.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/dwl.c b/dwl.c
index a2d5092..ab17546 100644
--- a/dwl.c
+++ b/dwl.c
@@ -1459,16 +1459,26 @@ outputmgrapplyortest(struct wlr_output_configuration_v1 *config, bool test)
{
struct wlr_output_configuration_head_v1 *config_head;
bool ok = true;
+ Arg ar = {.i = -1};
wl_list_for_each(config_head, &config->heads, link) {
struct wlr_output *wlr_output = config_head->state.output;
Monitor *m, *newmon;
+ if (!config_head->state.enabled) {
+ wl_list_for_each(m, &mons, link) {
+ if (m->wlr_output->name == wlr_output->name) {
+ // make sure that the monitor to clean is focused
+ selmon = m;
+ focusclient(selclient(), focustop(selmon), 1);
+
+ // focus the left monitor (relative to the current focus)
+ focusmon(&ar);
+ closemon(m, wl_container_of(&selmon->link, newmon, link));
+ }
+ }
+ }
wlr_output_enable(wlr_output, config_head->state.enabled);
- if (!config_head->state.enabled)
- wl_list_for_each(m, &mons, link)
- if (m->wlr_output->name == wlr_output->name)
- closemon(m, wl_container_of(m->link.next, newmon, link));
if (config_head->state.enabled) {
if (config_head->state.mode)