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