Resize every fullscreen client after output changes

6fed400cd2a40178cac003ed94e056b25830c27d
Alexis Sellier committed ago 1 parent 4c9a1f13
swm.c +9 -2
6535 6535
6536 6536
    if (m->lock_surface)
6537 6537
        client_set_scale(m->lock_surface->surface, m->wlr_output->scale);
6538 6538
}
6539 6539
6540 +
/* Return whether a fullscreen client must follow an output geometry change. */
6541 +
static bool client_follows_output_geometry(client_t *c, monitor_t *m) {
6542 +
    return c->mon == m && c->is_fullscreen;
6543 +
}
6544 +
6540 6545
/* Reconcile display layout changes with workspaces, windows, focus, and color state. */
6541 6546
void update_monitors(struct wl_listener *listener, void *data) {
6542 6547
    /*
6543 6548
6544 6549
     * Called whenever the output layout changes: adding or removing a
6616 6621
         * hidden or shown elsewhere before this display appeared). */
6617 6622
        monitor_set_scale(m);
6618 6623
        /* Keep windows on their workspace when displays are connected. */
6619 6624
        arrange(m);
6620 6625
        /* Resize fullscreen windows to fill their display. */
6621 -
        if ((c = focus_top(m)) && c->is_fullscreen)
6622 -
            resize(c, m->m, 0);
6626 +
        wl_list_for_each(c, &clients, link) {
6627 +
            if (client_follows_output_geometry(c, m))
6628 +
                resize(c, m->m, 0);
6629 +
        }
6623 6630
6624 6631
        /* Reapply color correction in case this display was just re-enabled. */
6625 6632
        m->gamma_lut_changed = 1;
6626 6633
6627 6634
        config_head->state.x = m->m.x;
test/unit.c +2 -0
454 454
    wl_list_insert(clients.prev, &hidden.link);
455 455
    wl_list_insert(&fstack, &hidden.flink);
456 456
    wl_list_insert(&fstack, &first.flink);
457 457
    wl_list_insert(&fstack, &second.flink);
458 458
    assert(focus_top(&monitor) == &second);
459 +
    first.is_fullscreen = second.is_fullscreen = true;
460 +
    assert(client_follows_output_geometry(&first, &monitor));
459 461
    assert(focus_top(nullptr) == nullptr);
460 462
    assert(focus_close(&second) == &first);
461 463
    assert(focus_close(nullptr) == nullptr);
462 464
    assert(focus_close(&hidden) == nullptr);
463 465
    assert(client_main(nullptr) == nullptr);