mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-05 13:29:47 -05:00
Merge branch 'master' into screencontent
This commit is contained in:
commit
21928cbe61
39 changed files with 163 additions and 144 deletions
|
|
@ -61,8 +61,8 @@ bool wlr_box_contains_point(const struct wlr_box *box, double x, double y) {
|
|||
if (wlr_box_empty(box)) {
|
||||
return false;
|
||||
} else {
|
||||
return x >= box->x && x <= box->x + box->width &&
|
||||
y >= box->y && y <= box->y + box->height;
|
||||
return x >= box->x && x < box->x + box->width &&
|
||||
y >= box->y && y < box->y + box->height;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ struct wlr_cursor_state {
|
|||
struct wl_listener layout_destroy;
|
||||
};
|
||||
|
||||
struct wlr_cursor *wlr_cursor_create() {
|
||||
struct wlr_cursor *wlr_cursor_create(void) {
|
||||
struct wlr_cursor *cur = calloc(1, sizeof(struct wlr_cursor));
|
||||
if (!cur) {
|
||||
wlr_log(L_ERROR, "Failed to allocate wlr_cursor");
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ static void frame_handle_resource_destroy(struct wl_resource *resource) {
|
|||
struct wlr_export_dmabuf_frame_v1 *frame = frame_from_resource(resource);
|
||||
wl_list_remove(&frame->link);
|
||||
wl_list_remove(&frame->output_swap_buffers.link);
|
||||
wlr_dmabuf_buffer_attribs_finish(&frame->attribs);
|
||||
wlr_dmabuf_attributes_finish(&frame->attribs);
|
||||
free(frame);
|
||||
}
|
||||
|
||||
|
|
@ -97,17 +97,16 @@ static void manager_handle_capture_output(struct wl_client *client,
|
|||
return;
|
||||
}
|
||||
|
||||
struct wlr_dmabuf_buffer_attribs *attribs = &frame->attribs;
|
||||
struct wlr_dmabuf_attributes *attribs = &frame->attribs;
|
||||
if (!wlr_output_export_dmabuf(output, attribs)) {
|
||||
zwlr_export_dmabuf_frame_v1_send_cancel(frame->resource,
|
||||
ZWLR_EXPORT_DMABUF_FRAME_V1_CANCEL_REASON_TEMPORARY);
|
||||
return;
|
||||
}
|
||||
assert(attribs->n_planes > 0);
|
||||
|
||||
uint32_t frame_flags = ZWLR_EXPORT_DMABUF_FRAME_V1_FLAGS_TRANSIENT;
|
||||
uint32_t mod_high = attribs->modifier[0] >> 32;
|
||||
uint32_t mod_low = attribs->modifier[0] & 0xFFFFFFFF;
|
||||
uint32_t mod_high = attribs->modifier >> 32;
|
||||
uint32_t mod_low = attribs->modifier & 0xFFFFFFFF;
|
||||
|
||||
zwlr_export_dmabuf_frame_v1_send_frame(frame->resource,
|
||||
output->width, output->height, 0, 0, attribs->flags, frame_flags,
|
||||
|
|
|
|||
|
|
@ -51,17 +51,8 @@ struct wlr_dmabuf_buffer *wlr_dmabuf_buffer_from_buffer_resource(
|
|||
return buffer;
|
||||
}
|
||||
|
||||
void wlr_dmabuf_buffer_attribs_finish(
|
||||
struct wlr_dmabuf_buffer_attribs *attribs) {
|
||||
for (int i = 0; i < attribs->n_planes; ++i) {
|
||||
close(attribs->fd[i]);
|
||||
attribs->fd[i] = -1;
|
||||
}
|
||||
attribs->n_planes = 0;
|
||||
}
|
||||
|
||||
static void linux_dmabuf_buffer_destroy(struct wlr_dmabuf_buffer *buffer) {
|
||||
wlr_dmabuf_buffer_attribs_finish(&buffer->attributes);
|
||||
wlr_dmabuf_attributes_finish(&buffer->attributes);
|
||||
free(buffer);
|
||||
}
|
||||
|
||||
|
|
@ -71,7 +62,7 @@ static void params_destroy(struct wl_client *client,
|
|||
}
|
||||
|
||||
static void params_add(struct wl_client *client,
|
||||
struct wl_resource *params_resource, int32_t name_fd,
|
||||
struct wl_resource *params_resource, int32_t fd,
|
||||
uint32_t plane_idx, uint32_t offset, uint32_t stride,
|
||||
uint32_t modifier_hi, uint32_t modifier_lo) {
|
||||
struct wlr_dmabuf_buffer *buffer =
|
||||
|
|
@ -81,33 +72,42 @@ static void params_add(struct wl_client *client,
|
|||
wl_resource_post_error(params_resource,
|
||||
ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_ALREADY_USED,
|
||||
"params was already used to create a wl_buffer");
|
||||
close(name_fd);
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
if (plane_idx >= WLR_LINUX_DMABUF_MAX_PLANES) {
|
||||
if (plane_idx >= WLR_DMABUF_MAX_PLANES) {
|
||||
wl_resource_post_error(params_resource,
|
||||
ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_PLANE_IDX,
|
||||
"plane index %u > %u", plane_idx, WLR_LINUX_DMABUF_MAX_PLANES);
|
||||
close(name_fd);
|
||||
"plane index %u > %u", plane_idx, WLR_DMABUF_MAX_PLANES);
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
if (buffer->attributes.fd[plane_idx] != -1) {
|
||||
wl_resource_post_error(params_resource,
|
||||
ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_PLANE_SET,
|
||||
"a dmabuf with id %d has already been added for plane %u",
|
||||
buffer->attributes.fd[plane_idx],
|
||||
plane_idx);
|
||||
close(name_fd);
|
||||
"a dmabuf with FD %d has already been added for plane %u",
|
||||
buffer->attributes.fd[plane_idx], plane_idx);
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
||||
buffer->attributes.fd[plane_idx] = name_fd;
|
||||
uint64_t modifier = ((uint64_t)modifier_hi << 32) | modifier_lo;
|
||||
if (buffer->has_modifier && modifier != buffer->attributes.modifier) {
|
||||
wl_resource_post_error(params_resource,
|
||||
ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_INVALID_FORMAT,
|
||||
"sent modifier %lu for plane %u, expected modifier %lu like other planes",
|
||||
modifier, plane_idx, buffer->attributes.modifier);
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
buffer->attributes.modifier = modifier;
|
||||
buffer->has_modifier = true;
|
||||
|
||||
buffer->attributes.fd[plane_idx] = fd;
|
||||
buffer->attributes.offset[plane_idx] = offset;
|
||||
buffer->attributes.stride[plane_idx] = stride;
|
||||
buffer->attributes.modifier[plane_idx] =
|
||||
((uint64_t)modifier_hi << 32) | modifier_lo;
|
||||
buffer->attributes.n_planes++;
|
||||
}
|
||||
|
||||
|
|
@ -186,7 +186,8 @@ static void params_create_common(struct wl_client *client,
|
|||
}
|
||||
|
||||
off_t size = lseek(buffer->attributes.fd[i], 0, SEEK_END);
|
||||
if (size == -1) { /* Skip checks if kernel does no support seek on buffer */
|
||||
if (size == -1) {
|
||||
// Skip checks if kernel does no support seek on buffer
|
||||
continue;
|
||||
}
|
||||
if (buffer->attributes.offset[i] >= size) {
|
||||
|
|
@ -205,8 +206,9 @@ static void params_create_common(struct wl_client *client,
|
|||
goto err_out;
|
||||
}
|
||||
|
||||
if (i == 0 && /* planes > 0 might be subsampled according to fourcc format */
|
||||
buffer->attributes.offset[i] + buffer->attributes.stride[i] * height > size) {
|
||||
// planes > 0 might be subsampled according to fourcc format
|
||||
if (i == 0 && buffer->attributes.offset[i] +
|
||||
buffer->attributes.stride[i] * height >= size) {
|
||||
wl_resource_post_error(params_resource,
|
||||
ZWP_LINUX_BUFFER_PARAMS_V1_ERROR_OUT_OF_BOUNDS,
|
||||
"invalid buffer stride or height for plane %d", i);
|
||||
|
|
@ -223,7 +225,8 @@ static void params_create_common(struct wl_client *client,
|
|||
}
|
||||
|
||||
/* Check if dmabuf is usable */
|
||||
if (!wlr_renderer_check_import_dmabuf(buffer->renderer, buffer)) {
|
||||
if (!wlr_renderer_check_import_dmabuf(buffer->renderer,
|
||||
&buffer->attributes)) {
|
||||
goto err_failed;
|
||||
}
|
||||
|
||||
|
|
@ -324,7 +327,7 @@ static void linux_dmabuf_create_params(struct wl_client *client,
|
|||
goto err;
|
||||
}
|
||||
|
||||
for (int i = 0; i < WLR_LINUX_DMABUF_MAX_PLANES; i++) {
|
||||
for (int i = 0; i < WLR_DMABUF_MAX_PLANES; i++) {
|
||||
buffer->attributes.fd[i] = -1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -566,7 +566,7 @@ uint32_t wlr_output_get_gamma_size(struct wlr_output *output) {
|
|||
}
|
||||
|
||||
bool wlr_output_export_dmabuf(struct wlr_output *output,
|
||||
struct wlr_dmabuf_buffer_attribs *attribs) {
|
||||
struct wlr_dmabuf_attributes *attribs) {
|
||||
if (!output->impl->export_dmabuf) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ struct wlr_output_layout_output_state {
|
|||
struct wl_listener output_destroy;
|
||||
};
|
||||
|
||||
struct wlr_output_layout *wlr_output_layout_create() {
|
||||
struct wlr_output_layout *wlr_output_layout_create(void) {
|
||||
struct wlr_output_layout *layout =
|
||||
calloc(1, sizeof(struct wlr_output_layout));
|
||||
if (layout == NULL) {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include <wlr/render/egl.h>
|
||||
#include <wlr/render/interface.h>
|
||||
#include <wlr/types/wlr_compositor.h>
|
||||
#include <wlr/types/wlr_linux_dmabuf.h>
|
||||
#include <wlr/types/wlr_matrix.h>
|
||||
#include <wlr/types/wlr_region.h>
|
||||
#include <wlr/types/wlr_surface.h>
|
||||
|
|
@ -569,7 +570,7 @@ struct wlr_surface *wlr_surface_from_resource(struct wl_resource *resource) {
|
|||
return wl_resource_get_user_data(resource);
|
||||
}
|
||||
|
||||
static struct wlr_surface_state *surface_state_create() {
|
||||
static struct wlr_surface_state *surface_state_create(void) {
|
||||
struct wlr_surface_state *state =
|
||||
calloc(1, sizeof(struct wlr_surface_state));
|
||||
if (state == NULL) {
|
||||
|
|
|
|||
|
|
@ -231,6 +231,16 @@ struct wlr_virtual_keyboard_manager_v1*
|
|||
|
||||
void wlr_virtual_keyboard_manager_v1_destroy(
|
||||
struct wlr_virtual_keyboard_manager_v1 *manager) {
|
||||
wl_list_remove(&manager->display_destroy.link);
|
||||
wl_global_destroy(manager->global);
|
||||
struct wl_resource *resource, *resource_tmp;
|
||||
wl_resource_for_each_safe(resource, resource_tmp, &manager->resources) {
|
||||
wl_resource_destroy(resource);
|
||||
}
|
||||
struct wlr_virtual_keyboard_v1 *keyboard, *keyboard_tmp;
|
||||
wl_list_for_each_safe(keyboard, keyboard_tmp, &manager->virtual_keyboards,
|
||||
link) {
|
||||
wl_resource_destroy(keyboard->resource);
|
||||
}
|
||||
free(manager);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue