mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 21:05:58 +01:00
output-layer: add cropping support
Add a src_box state field. Use the SRC_* KMS props in the DRM backend, reject the layers in the Wayland backend (for now, we can support it later via viewporter).
This commit is contained in:
parent
d795824346
commit
44069dfd5e
4 changed files with 23 additions and 4 deletions
|
@ -201,10 +201,18 @@ static bool set_layer_props(struct wlr_drm_backend *drm,
|
||||||
uint64_t crtc_w = (uint64_t)state->dst_box.width;
|
uint64_t crtc_w = (uint64_t)state->dst_box.width;
|
||||||
uint64_t crtc_h = (uint64_t)state->dst_box.height;
|
uint64_t crtc_h = (uint64_t)state->dst_box.height;
|
||||||
|
|
||||||
uint64_t src_x = to_fp16(0);
|
struct wlr_fbox src_box = state->src_box;
|
||||||
uint64_t src_y = to_fp16(0);
|
if (wlr_fbox_empty(&src_box)) {
|
||||||
uint64_t src_w = to_fp16(width);
|
src_box = (struct wlr_fbox){
|
||||||
uint64_t src_h = to_fp16(height);
|
.width = width,
|
||||||
|
.height = height,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t src_x = to_fp16(src_box.x);
|
||||||
|
uint64_t src_y = to_fp16(src_box.y);
|
||||||
|
uint64_t src_w = to_fp16(src_box.width);
|
||||||
|
uint64_t src_h = to_fp16(src_box.height);
|
||||||
|
|
||||||
return
|
return
|
||||||
liftoff_layer_set_property(layer->liftoff, "zpos", zpos) == 0 &&
|
liftoff_layer_set_property(layer->liftoff, "zpos", zpos) == 0 &&
|
||||||
|
|
|
@ -294,6 +294,13 @@ static bool output_test(struct wlr_output *wlr_output,
|
||||||
height != layer_state->dst_box.height) {
|
height != layer_state->dst_box.height) {
|
||||||
supported = false;
|
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 &&
|
supported = supported &&
|
||||||
test_buffer(output->backend, layer_state->buffer);
|
test_buffer(output->backend, layer_state->buffer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,7 @@ struct wlr_output_layer {
|
||||||
|
|
||||||
// private state
|
// private state
|
||||||
|
|
||||||
|
struct wlr_fbox src_box;
|
||||||
struct wlr_box dst_box;
|
struct wlr_box dst_box;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -63,6 +64,8 @@ struct wlr_output_layer_state {
|
||||||
|
|
||||||
// Buffer to display, or NULL to disable the layer
|
// Buffer to display, or NULL to disable the layer
|
||||||
struct wlr_buffer *buffer;
|
struct wlr_buffer *buffer;
|
||||||
|
// Source box, leave empty to use the whole buffer
|
||||||
|
struct wlr_fbox src_box;
|
||||||
// Destination box in output-buffer-local coordinates
|
// Destination box in output-buffer-local coordinates
|
||||||
struct wlr_box dst_box;
|
struct wlr_box dst_box;
|
||||||
|
|
||||||
|
|
|
@ -832,6 +832,7 @@ bool wlr_output_commit_state(struct wlr_output *output,
|
||||||
wl_list_insert(output->layers.prev, &layer->link);
|
wl_list_insert(output->layers.prev, &layer->link);
|
||||||
|
|
||||||
// Commit layer state
|
// Commit layer state
|
||||||
|
layer->src_box = layer_state->src_box;
|
||||||
layer->dst_box = layer_state->dst_box;
|
layer->dst_box = layer_state->dst_box;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue