Reclaim space after implicit-output panels close

c8cc6a7b222754a418773d880672dac920a956a5
Alexis Sellier committed ago 1 parent cfe3258e
swm.c +7 -2
6280 6280
    print_status();
6281 6281
}
6282 6282
6283 6283
/* Remove the active session lock after the locker authenticates the user. */
6284 6284
void unlock_session(struct wl_listener *listener, void *data) {
6285 +
6285 6286
    session_lock_t *lock = wl_container_of(listener, lock, unlock);
6286 6287
    destroy_lock(lock, 1);
6287 6288
}
6289 +
/* Resolve the output affected by a layer surface's removal. Implicit-output
6290 +
 * surfaces retain the output selected when they were created. */
6291 +
static monitor_t *layer_surface_output_monitor(layer_surface_t *l) {
6292 +
    return l->layer_surface->output ? l->layer_surface->output->data : l->mon;
6293 +
}
6288 6294
6289 6295
/* Hide an unmapped desktop-layer surface and reclaim its reserved space. */
6290 6296
void layer_surface_unmap_notify(struct wl_listener *listener, void *data) {
6291 6297
    layer_surface_t *l = wl_container_of(listener, l, unmap);
6292 6298
6293 6299
    l->mapped = 0;
6294 6300
    wlr_scene_node_set_enabled(&l->scene->node, 0);
6295 6301
6296 6302
    if (l->dim)
6297 6303
        wlr_scene_node_set_enabled(&l->dim->node, 0);
6298 -
6299 6304
    if (l == exclusive_focus)
6300 6305
        exclusive_focus = nullptr;
6301 6306
6302 -
    if (l->layer_surface->output && (l->mon = l->layer_surface->output->data))
6307 +
    if ((l->mon = layer_surface_output_monitor(l)))
6303 6308
        arrange_layers(l->mon);
6304 6309
6305 6310
    if (l->layer_surface->surface == seat->keyboard_state.focused_surface)
6306 6311
        focus_client(focus_top(selmon), 1);
6307 6312
    motion_notify(0, nullptr, 0, 0, 0, 0, 1);
test/unit.c +13 -0
789 789
    client.type   = XDG_SHELL;
790 790
    client.mon    = nullptr;
791 791
    client.ws     = nullptr;
792 792
    client.persist_float = 0;
793 793
    button_press(nullptr, &event);
794 +
794 795
    assert(cursor_mode == CURSOR_MOVE);
795 796
    assert(grabc == &client);
796 797
}
798 +
/* Verify an implicit-output panel keeps its assigned output when it unmaps. */
799 +
static void test_layer_unmap_monitor(void) {
800 +
    struct wlr_layer_surface_v1 layer = {};
801 +
    monitor_t                   monitor = {};
802 +
    layer_surface_t             wrapper = {
803 +
                    .mon           = &monitor,
804 +
                    .layer_surface = &layer,
805 +
    };
806 +
807 +
    assert(layer_surface_output_monitor(&wrapper) == &monitor);
808 +
}
797 809
798 810
/* Verify text-input and input-method wrappers are created and released. */
799 811
static void test_input_method_lifecycle(void) {
800 812
    struct wlr_seat                  fake_seat       = {};
801 813
    struct wlr_text_input_manager_v3 fake_ti_manager = {};
1007 1019
        { "focus", test_focus_queries },
1008 1020
        { "workspace-scale", test_workspace_scale },
1009 1021
        { "window-state", test_window_state_storage },
1010 1022
        { "child-reaping", test_child_reaping },
1011 1023
        { "spawn-tracking", test_spawn_tracking },
1024 +
        { "layer-unmap-monitor", test_layer_unmap_monitor },
1012 1025
        { "command-failure-notification", test_command_failure_notification },
1013 1026
        { "commands-without-clients", test_commands_without_clients },
1014 1027
        { "small-helpers", test_small_helpers },
1015 1028
        { "pointer-grab-button", test_pointer_grab_button },
1016 1029
        { "client-accessors", test_client_accessors },