Update panel and lock surface scales

ba77c16e3bde3235155bc737abe64d96aed1a71d
Alexis Sellier committed ago 1 parent 9b10a627
swm.c +20 -2
2580 2580
    }
2581 2581
    m->lock_surface = lock_surface;
2582 2582
2583 2583
    wlr_scene_node_set_position(&scene_tree->node, m->m.x, m->m.y);
2584 2584
    wlr_session_lock_surface_v1_configure(lock_surface, m->m.width, m->m.height);
2585 +
    client_set_scale(lock_surface->surface, m->wlr_output->scale);
2585 2586
2586 2587
    LISTEN(&lock_surface->events.destroy, &m->destroy_lock_surface, destroy_lock_surface);
2587 2588
2588 2589
    if (m == selmon)
2589 2590
        client_notify_enter(lock_surface->surface, wlr_seat_get_keyboard(seat));
6420 6421
    memset(c->border, 0, sizeof(c->border));
6421 6422
    print_status();
6422 6423
    motion_notify(0, nullptr, 0, 0, 0, 0, 1);
6423 6424
}
6424 6425
6426 +
/* Publish an output's scale to every client surface assigned to it. */
6427 +
static void monitor_set_scale(monitor_t *m) {
6428 +
    layer_surface_t *l;
6429 +
    size_t           i;
6430 +
6431 +
    if (m->ws)
6432 +
        assign_workspace(m->ws, m);
6433 +
6434 +
    for (i = 0; i < LENGTH(m->layers); i++)
6435 +
        wl_list_for_each(l, &m->layers[i], link) {
6436 +
            client_set_scale(l->layer_surface->surface, m->wlr_output->scale);
6437 +
        }
6438 +
6439 +
    if (m->lock_surface)
6440 +
        client_set_scale(m->lock_surface->surface, m->wlr_output->scale);
6441 +
}
6442 +
6425 6443
/* Reconcile display layout changes with workspaces, windows, focus, and color state. */
6426 6444
void update_monitors(struct wl_listener *listener, void *data) {
6427 6445
    /*
6446 +
6428 6447
     * Called whenever the output layout changes: adding or removing a
6429 6448
     * monitor, changing an output's mode or position, etc. This is where
6430 6449
     * the change officially happens and we update geometry, window
6431 6450
     * positions, focus, and the stored configuration in wlroots'
6432 6451
     * output-manager implementation.
6496 6515
        }
6497 6516
        /* Reserve panel space before arranging regular windows. */
6498 6517
        arrange_layers(m);
6499 6518
        /* Sync clients of this output's workspace (it may have been
6500 6519
         * hidden or shown elsewhere before this display appeared). */
6501 -
        if (m->ws)
6502 -
            assign_workspace(m->ws, m);
6520 +
        monitor_set_scale(m);
6503 6521
        /* Keep windows on their workspace when displays are connected. */
6504 6522
        arrange(m);
6505 6523
        /* Resize fullscreen windows to fill their display. */
6506 6524
        if ((c = focus_top(m)) && c->is_fullscreen)
6507 6525
            resize(c, m->m, 0);
test/unit.c +25 -0
361 361
    layer.current.layer   = ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND;
362 362
    layer.pending.layer   = ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY;
363 363
    assert(layer_popup_parent(&layer) == &overlay);
364 364
}
365 365
366 +
/* Verify output scale changes reach layer-shell and session-lock surfaces. */
367 +
static void test_output_role_scale_change(void) {
368 +
    struct wlr_surface                 surface       = {};
369 +
    struct wlr_output                  output        = { .scale = 2.0f };
370 +
    struct wlr_layer_surface_v1        layer_surface = { .surface = &surface };
371 +
    struct wlr_session_lock_surface_v1 lock_surface  = { .surface = &surface };
372 +
    layer_surface_t                    layer         = { .layer_surface = &layer_surface };
373 +
    monitor_t                          monitor       = { .wlr_output = &output };
374 +
    size_t                             i;
375 +
376 +
    for (i = 0; i < LENGTH(monitor.layers); i++)
377 +
        wl_list_init(&monitor.layers[i]);
378 +
    wl_list_insert(&monitor.layers[ZWLR_LAYER_SHELL_V1_LAYER_TOP], &layer.link);
379 +
    scaled_surface = nullptr;
380 +
    monitor_set_scale(&monitor);
381 +
    assert(scaled_surface == &surface);
382 +
383 +
    wl_list_remove(&layer.link);
384 +
    monitor.lock_surface = &lock_surface;
385 +
    scaled_surface       = nullptr;
386 +
    monitor_set_scale(&monitor);
387 +
    assert(scaled_surface == &surface);
388 +
}
389 +
366 390
/* Verify matching rules update client state and workspace assignment. */
367 391
static void test_rule_application(void) {
368 392
    client_t                client;
369 393
    struct wlr_xdg_surface  surface;
370 394
    struct wlr_xdg_toplevel toplevel;
1077 1101
        { "client-accessors", test_client_accessors },
1078 1102
        { "autostart", test_autostart_execution },
1079 1103
        { "pointer-gestures", test_pointer_gestures },
1080 1104
        { "shortcut-release", test_shortcut_release },
1081 1105
        { "input-method", test_input_method_lifecycle },
1106 +
        { "output-role-scale-change", test_output_role_scale_change },
1082 1107
        { "input-early-paths", test_input_early_paths },
1083 1108
        { "command-line", test_command_line_errors },
1084 1109
        { "pointer-and-decoration", test_pointer_and_decoration_lifecycle },
1085 1110
        { "keybindings-and-repeat", test_keybindings_and_repeat },
1086 1111
    };