Allow resizing fullscreen windows

cf81044e6132133cf277bc19ead9d5dd9354659a
Alexis Sellier committed ago 1 parent 116a58f9
swm.c +9 -1
1142 1142
    if (client_is_x11(c))
1143 1143
        return c->surface.xwayland->override_redirect;
1144 1144
    return false;
1145 1145
}
1146 1146
1147 +
/* Return whether the client supports the requested pointer operation. */
1148 +
static inline bool client_allows_move_resize(client_t *c, uint32_t mode) {
1149 +
    return !client_is_unmanaged(c) && (!c->is_fullscreen || mode == CURSOR_RESIZE);
1150 +
}
1151 +
1147 1152
/* Send keyboard focus to a client surface. */
1148 1153
static inline void client_notify_enter(struct wlr_surface *s, struct wlr_keyboard *kb) {
1149 1154
    if (kb)
1150 1155
        wlr_seat_keyboard_notify_enter(seat, s, kb->keycodes, kb->num_keycodes, &kb->modifiers);
1151 1156
    else
4269 4274
void move_resize(const arg_t *arg) {
4270 4275
    if (cursor_mode != CURSOR_NORMAL && cursor_mode != CURSOR_PRESSED)
4271 4276
        return;
4272 4277
    point_to_node(cursor->x, cursor->y, nullptr, &grabc, nullptr, nullptr, nullptr);
4273 4278
4274 -
    if (!grabc || client_is_unmanaged(grabc) || grabc->is_fullscreen)
4279 +
    if (!grabc || !client_allows_move_resize(grabc, arg->u))
4275 4280
        return;
4276 4281
4282 +
    if (grabc->is_fullscreen)
4283 +
        set_fullscreen(grabc, 0);
4284 +
4277 4285
    /* Float the window and let pointer motion move or resize it. */
4278 4286
    grabc->persist_float = 1;
4279 4287
    set_floating(grabc, 1);
4280 4288
4281 4289
    switch (cursor_mode = arg->u) {
test/unit.c +5 -0
530 530
531 531
    init_xdg_client(&client, &xdg, &toplevel, "xdg-app", "XDG title");
532 532
    xdg.geometry = (struct wlr_box){ 3, 4, 50, 60 };
533 533
    client.geom  = (struct wlr_box){ 1, 2, 70, 80 };
534 534
    client.bw    = 2;
535 +
    client.is_fullscreen = true;
536 +
    assert(!client_allows_move_resize(&client, CURSOR_MOVE));
537 +
    assert(client_allows_move_resize(&client, CURSOR_RESIZE));
538 +
    client.is_fullscreen = false;
539 +
    assert(client_allows_move_resize(&client, CURSOR_MOVE));
535 540
    assert(!strcmp(client_get_appid(&client), "xdg-app"));
536 541
    assert(!strcmp(client_get_title(&client), "XDG title"));
537 542
    client_get_clip(&client, &box);
538 543
    assert(box.x == 3 && box.y == 4 && box.width == 68 && box.height == 78);
539 544
    client_get_geometry(&client, &box);