diff options
author | Devin J. Pohly <djpohly@gmail.com> | 2021-01-18 14:12:00 -0600 |
---|---|---|
committer | Devin J. Pohly <djpohly@gmail.com> | 2021-01-18 14:12:00 -0600 |
commit | a5210f7d77a4849a09eec13e7cf3f9d5c844cf4b (patch) | |
tree | 88f93c4eaab31f42cd02f905d9afc21ed7366941 /dwl.c | |
parent | 48ef5e8bd2f89e9b8775f2908eaeab97e28c0aeb (diff) |
cleanup on aisle createmon()
Diffstat (limited to 'dwl.c')
-rw-r--r-- | dwl.c | 27 |
1 files changed, 12 insertions, 15 deletions
@@ -818,18 +818,12 @@ createmon(struct wl_listener *listener, void *data) * monitor) becomes available. */ struct wlr_output *wlr_output = data; const MonitorRule *r; - size_t nlayers; - Monitor *m, *moni, *insertmon = NULL; - - /* The mode is a tuple of (width, height, refresh rate), and each - * monitor supports only a specific set of modes. We just pick the - * monitor's preferred mode; a more sophisticated compositor would let - * the user configure it. */ - wlr_output_set_mode(wlr_output, wlr_output_preferred_mode(wlr_output)); - - /* Allocates and configures monitor state using configured rules */ - m = wlr_output->data = calloc(1, sizeof(*m)); + Monitor *m = wlr_output->data = calloc(1, sizeof(*m)); m->wlr_output = wlr_output; + + /* Initialize monitor state using configured rules */ + for (size_t i = 0; i < LENGTH(m->layers); ++i) + wl_list_init(&m->layers[i]); m->tagset[0] = m->tagset[1] = 1; for (r = monrules; r < END(monrules); r++) { if (!r->name || strstr(wlr_output->name, r->name)) { @@ -842,7 +836,14 @@ createmon(struct wl_listener *listener, void *data) break; } } + + /* The mode is a tuple of (width, height, refresh rate), and each + * monitor supports only a specific set of modes. We just pick the + * monitor's preferred mode; a more sophisticated compositor would let + * the user configure it. */ + wlr_output_set_mode(wlr_output, wlr_output_preferred_mode(wlr_output)); wlr_output_enable_adaptive_sync(wlr_output, 1); + /* Set up event listeners */ LISTEN(&wlr_output->events.frame, &m->frame, rendermon); LISTEN(&wlr_output->events.destroy, &m->destroy, cleanupmon); @@ -861,10 +862,6 @@ createmon(struct wl_listener *listener, void *data) wlr_output_layout_add(output_layout, wlr_output, r->x, r->y); sgeom = *wlr_output_layout_get_box(output_layout, NULL); - nlayers = LENGTH(m->layers); - for (size_t i = 0; i < nlayers; ++i) - wl_list_init(&m->layers[i]); - /* When adding monitors, the geometries of all monitors must be updated */ updatemons(); wl_list_for_each(m, &mons, link) { |