Prevent updatemons() from removing monitors that have been put to sleep from the layout

This commit is contained in:
David Donahue 2024-04-06 11:29:14 -06:00 committed by Leonardo Hernández Hernández
parent 9b1f35e42b
commit 2902df94d6
No known key found for this signature in database
GPG key ID: E538897EE11B9624

8
dwl.c
View file

@ -207,6 +207,7 @@ struct Monitor {
int gamma_lut_changed;
int nmaster;
char ltsymbol[16];
int asleep;
};
typedef struct {
@ -962,6 +963,8 @@ createmon(struct wl_listener *listener, void *data)
LISTEN(&wlr_output->events.destroy, &m->destroy, cleanupmon);
LISTEN(&wlr_output->events.request_state, &m->request_state, requestmonstate);
m->asleep = 0;
wlr_output_state_set_enabled(&state, 1);
wlr_output_commit_state(wlr_output, &state);
wlr_output_state_finish(&state);
@ -2018,8 +2021,11 @@ void
powermgrsetmodenotify(struct wl_listener *listener, void *data)
{
struct wlr_output_power_v1_set_mode_event *event = data;
wlr_output_enable(event->output, event->mode);
wlr_output_commit(event->output);
((Monitor *)(event->output->data))->asleep = !event->mode;
}
void
@ -2755,7 +2761,7 @@ updatemons(struct wl_listener *listener, void *data)
/* First remove from the layout the disabled monitors */
wl_list_for_each(m, &mons, link) {
if (m->wlr_output->enabled)
if (m->wlr_output->enabled || m->asleep)
continue;
config_head = wlr_output_configuration_head_v1_create(config, m->wlr_output);
config_head->state.enabled = 0;