diff options
author | Simon Ser <contact@emersion.fr> | 2023-04-20 12:04:01 +0200 |
---|---|---|
committer | Alexander Orzechowski <alex@ozal.ski> | 2023-06-05 18:29:55 +0000 |
commit | 4e513c93bd834bfe694c382cfe32108fbb8c8b33 (patch) | |
tree | 98dd905523a608a3c2e767f0616735da5f99636d /backend | |
parent | 4c5eadecce4fce6956c8e8f9fb5f2ae0e48a2e81 (diff) |
backend/wayland: add support for cropping output layers
Diffstat (limited to 'backend')
-rw-r--r-- | backend/wayland/output.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/backend/wayland/output.c b/backend/wayland/output.c index 986ee23d..d16b0dbc 100644 --- a/backend/wayland/output.c +++ b/backend/wayland/output.c @@ -290,19 +290,19 @@ static bool output_test(struct wlr_output *wlr_output, int height = layer_state->dst_box.height; bool needs_viewport = width != layer_state->buffer->width || height != layer_state->buffer->height; + if (!wlr_fbox_empty(&layer_state->src_box)) { + needs_viewport = needs_viewport || + layer_state->src_box.x != 0 || + layer_state->src_box.y != 0 || + layer_state->src_box.width != width || + layer_state->src_box.height != height; + } if (x < 0 || y < 0 || x + width > wlr_output->width || y + height > wlr_output->height || (output->backend->viewporter == NULL && needs_viewport)) { supported = false; } - if (!wlr_fbox_empty(&layer_state->src_box)) { - supported = supported && - layer_state->src_box.x == 0 && - layer_state->src_box.y == 0 && - layer_state->src_box.width == width && - layer_state->src_box.height == height; - } supported = supported && test_buffer(output->backend, layer_state->buffer); } @@ -419,6 +419,23 @@ static bool output_layer_commit(struct wlr_wl_output *output, state->layer->dst_box.height != state->dst_box.height)) { wp_viewport_set_destination(layer->viewport, state->dst_box.width, state->dst_box.height); } + if (layer->viewport != NULL && !wlr_fbox_equal(&state->layer->src_box, &state->src_box)) { + struct wlr_fbox src_box = state->src_box; + if (wlr_fbox_empty(&src_box)) { + // -1 resets the box + src_box = (struct wlr_fbox){ + .x = -1, + .y = -1, + .width = -1, + .height = -1, + }; + } + wp_viewport_set_source(layer->viewport, + wl_fixed_from_double(src_box.x), + wl_fixed_from_double(src_box.y), + wl_fixed_from_double(src_box.width), + wl_fixed_from_double(src_box.height)); + } wl_surface_attach(layer->surface, buffer->wl_buffer, 0, 0); wl_surface_damage_buffer(layer->surface, 0, 0, INT32_MAX, INT32_MAX); |