2017-08-09 13:33:30 +00:00
|
|
|
#include <assert.h>
|
|
|
|
#include <stdlib.h>
|
2019-07-27 08:53:54 +00:00
|
|
|
#include <wayland-server-core.h>
|
2018-02-12 20:29:23 +00:00
|
|
|
#include <wlr/render/interface.h>
|
2018-06-08 19:06:13 +00:00
|
|
|
#include <wlr/types/wlr_buffer.h>
|
2018-04-21 17:40:25 +00:00
|
|
|
#include <wlr/types/wlr_compositor.h>
|
2018-03-15 08:11:03 +00:00
|
|
|
#include <wlr/types/wlr_matrix.h>
|
2018-02-13 22:48:46 +00:00
|
|
|
#include <wlr/types/wlr_region.h>
|
2018-02-12 20:29:23 +00:00
|
|
|
#include <wlr/types/wlr_surface.h>
|
2018-09-24 14:52:52 +00:00
|
|
|
#include <wlr/types/wlr_output.h>
|
2017-08-09 13:33:30 +00:00
|
|
|
#include <wlr/util/log.h>
|
2018-01-26 21:11:09 +00:00
|
|
|
#include <wlr/util/region.h>
|
2021-03-30 08:17:15 +00:00
|
|
|
#include "types/wlr_surface.h"
|
2018-02-12 18:45:58 +00:00
|
|
|
#include "util/signal.h"
|
2020-06-05 21:50:00 +00:00
|
|
|
#include "util/time.h"
|
2017-08-09 13:33:30 +00:00
|
|
|
|
2018-04-30 21:20:11 +00:00
|
|
|
#define CALLBACK_VERSION 1
|
|
|
|
|
2018-06-01 11:27:10 +00:00
|
|
|
static int min(int fst, int snd) {
|
|
|
|
if (fst < snd) {
|
|
|
|
return fst;
|
|
|
|
} else {
|
|
|
|
return snd;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int max(int fst, int snd) {
|
|
|
|
if (fst > snd) {
|
|
|
|
return fst;
|
|
|
|
} else {
|
|
|
|
return snd;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-27 10:30:41 +00:00
|
|
|
static void surface_handle_destroy(struct wl_client *client,
|
2017-09-24 12:25:53 +00:00
|
|
|
struct wl_resource *resource) {
|
2017-08-09 13:33:30 +00:00
|
|
|
wl_resource_destroy(resource);
|
|
|
|
}
|
|
|
|
|
2021-08-27 10:30:41 +00:00
|
|
|
static void surface_handle_attach(struct wl_client *client,
|
2017-08-09 13:33:30 +00:00
|
|
|
struct wl_resource *resource,
|
2021-08-11 15:34:34 +00:00
|
|
|
struct wl_resource *buffer_resource, int32_t dx, int32_t dy) {
|
2018-02-13 22:48:46 +00:00
|
|
|
struct wlr_surface *surface = wlr_surface_from_resource(resource);
|
2017-09-24 22:24:48 +00:00
|
|
|
|
2021-09-07 06:38:48 +00:00
|
|
|
struct wlr_buffer *buffer = NULL;
|
|
|
|
if (buffer_resource != NULL) {
|
|
|
|
buffer = wlr_buffer_from_resource(buffer_resource);
|
|
|
|
if (buffer == NULL) {
|
|
|
|
wl_resource_post_error(buffer_resource, 0, "unknown buffer type");
|
|
|
|
return;
|
|
|
|
}
|
2021-08-11 15:34:34 +00:00
|
|
|
}
|
|
|
|
|
2018-06-21 21:39:26 +00:00
|
|
|
surface->pending.committed |= WLR_SURFACE_STATE_BUFFER;
|
2018-06-25 21:38:40 +00:00
|
|
|
surface->pending.dx = dx;
|
|
|
|
surface->pending.dy = dy;
|
2021-08-11 15:34:34 +00:00
|
|
|
|
|
|
|
wlr_buffer_unlock(surface->pending.buffer);
|
|
|
|
surface->pending.buffer = buffer;
|
2017-08-09 13:33:30 +00:00
|
|
|
}
|
|
|
|
|
2021-08-27 10:30:41 +00:00
|
|
|
static void surface_handle_damage(struct wl_client *client,
|
2017-08-09 13:33:30 +00:00
|
|
|
struct wl_resource *resource,
|
|
|
|
int32_t x, int32_t y, int32_t width, int32_t height) {
|
2018-02-13 22:48:46 +00:00
|
|
|
struct wlr_surface *surface = wlr_surface_from_resource(resource);
|
2017-08-10 03:34:50 +00:00
|
|
|
if (width < 0 || height < 0) {
|
|
|
|
return;
|
|
|
|
}
|
2018-06-21 21:39:26 +00:00
|
|
|
surface->pending.committed |= WLR_SURFACE_STATE_SURFACE_DAMAGE;
|
|
|
|
pixman_region32_union_rect(&surface->pending.surface_damage,
|
|
|
|
&surface->pending.surface_damage,
|
2017-08-11 15:48:59 +00:00
|
|
|
x, y, width, height);
|
2017-08-09 13:33:30 +00:00
|
|
|
}
|
|
|
|
|
2018-04-30 21:20:11 +00:00
|
|
|
static void callback_handle_resource_destroy(struct wl_resource *resource) {
|
2018-06-20 19:00:23 +00:00
|
|
|
wl_list_remove(wl_resource_get_link(resource));
|
2017-08-09 19:58:41 +00:00
|
|
|
}
|
|
|
|
|
2021-08-27 10:30:41 +00:00
|
|
|
static void surface_handle_frame(struct wl_client *client,
|
2017-08-09 13:33:30 +00:00
|
|
|
struct wl_resource *resource, uint32_t callback) {
|
2018-02-13 22:48:46 +00:00
|
|
|
struct wlr_surface *surface = wlr_surface_from_resource(resource);
|
2017-08-09 19:58:41 +00:00
|
|
|
|
2018-06-20 19:00:23 +00:00
|
|
|
struct wl_resource *callback_resource = wl_resource_create(client,
|
|
|
|
&wl_callback_interface, CALLBACK_VERSION, callback);
|
|
|
|
if (callback_resource == NULL) {
|
2017-08-09 19:58:41 +00:00
|
|
|
wl_resource_post_no_memory(resource);
|
|
|
|
return;
|
|
|
|
}
|
2018-06-20 19:00:23 +00:00
|
|
|
wl_resource_set_implementation(callback_resource, NULL, NULL,
|
2018-04-30 21:20:11 +00:00
|
|
|
callback_handle_resource_destroy);
|
2017-08-09 19:58:41 +00:00
|
|
|
|
2018-06-21 21:39:26 +00:00
|
|
|
wl_list_insert(surface->pending.frame_callback_list.prev,
|
2018-06-20 19:00:23 +00:00
|
|
|
wl_resource_get_link(callback_resource));
|
2017-09-24 22:24:48 +00:00
|
|
|
|
2018-06-21 21:39:26 +00:00
|
|
|
surface->pending.committed |= WLR_SURFACE_STATE_FRAME_CALLBACK_LIST;
|
2017-08-09 13:33:30 +00:00
|
|
|
}
|
|
|
|
|
2021-08-27 10:30:41 +00:00
|
|
|
static void surface_handle_set_opaque_region(struct wl_client *client,
|
2017-08-09 13:33:30 +00:00
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *region_resource) {
|
2018-02-13 22:48:46 +00:00
|
|
|
struct wlr_surface *surface = wlr_surface_from_resource(resource);
|
2018-06-21 21:39:26 +00:00
|
|
|
surface->pending.committed |= WLR_SURFACE_STATE_OPAQUE_REGION;
|
2017-08-10 03:34:50 +00:00
|
|
|
if (region_resource) {
|
2018-02-13 22:48:46 +00:00
|
|
|
pixman_region32_t *region = wlr_region_from_resource(region_resource);
|
2018-06-21 21:39:26 +00:00
|
|
|
pixman_region32_copy(&surface->pending.opaque, region);
|
2017-08-10 03:34:50 +00:00
|
|
|
} else {
|
2018-06-21 21:39:26 +00:00
|
|
|
pixman_region32_clear(&surface->pending.opaque);
|
2017-08-10 03:34:50 +00:00
|
|
|
}
|
2017-08-09 13:33:30 +00:00
|
|
|
}
|
|
|
|
|
2021-08-27 10:30:41 +00:00
|
|
|
static void surface_handle_set_input_region(struct wl_client *client,
|
2018-08-10 16:13:41 +00:00
|
|
|
struct wl_resource *resource,
|
|
|
|
struct wl_resource *region_resource) {
|
2018-02-13 22:48:46 +00:00
|
|
|
struct wlr_surface *surface = wlr_surface_from_resource(resource);
|
2018-06-21 21:39:26 +00:00
|
|
|
surface->pending.committed |= WLR_SURFACE_STATE_INPUT_REGION;
|
2017-08-10 03:34:50 +00:00
|
|
|
if (region_resource) {
|
2018-02-13 22:48:46 +00:00
|
|
|
pixman_region32_t *region = wlr_region_from_resource(region_resource);
|
2018-06-21 21:39:26 +00:00
|
|
|
pixman_region32_copy(&surface->pending.input, region);
|
2017-08-10 03:34:50 +00:00
|
|
|
} else {
|
2018-06-21 21:39:26 +00:00
|
|
|
pixman_region32_fini(&surface->pending.input);
|
|
|
|
pixman_region32_init_rect(&surface->pending.input,
|
2017-08-15 11:40:26 +00:00
|
|
|
INT32_MIN, INT32_MIN, UINT32_MAX, UINT32_MAX);
|
2017-08-10 03:34:50 +00:00
|
|
|
}
|
2017-08-09 13:33:30 +00:00
|
|
|
}
|
|
|
|
|
2021-11-20 10:30:18 +00:00
|
|
|
static void surface_state_transformed_buffer_size(struct wlr_surface_state *state,
|
|
|
|
int *out_width, int *out_height) {
|
|
|
|
int width = state->buffer_width;
|
|
|
|
int height = state->buffer_height;
|
|
|
|
if ((state->transform & WL_OUTPUT_TRANSFORM_90) != 0) {
|
|
|
|
int tmp = width;
|
|
|
|
width = height;
|
|
|
|
height = tmp;
|
|
|
|
}
|
|
|
|
*out_width = width;
|
|
|
|
*out_height = height;
|
|
|
|
}
|
|
|
|
|
2020-03-31 13:18:49 +00:00
|
|
|
/**
|
|
|
|
* Computes the surface viewport source size, ie. the size after applying the
|
|
|
|
* surface's scale, transform and cropping (via the viewport's source
|
|
|
|
* rectangle) but before applying the viewport scaling (via the viewport's
|
|
|
|
* destination rectangle).
|
|
|
|
*/
|
2021-02-15 14:28:04 +00:00
|
|
|
static void surface_state_viewport_src_size(struct wlr_surface_state *state,
|
2020-03-31 13:18:49 +00:00
|
|
|
int *out_width, int *out_height) {
|
2020-06-18 07:55:46 +00:00
|
|
|
if (state->buffer_width == 0 && state->buffer_height == 0) {
|
|
|
|
*out_width = *out_height = 0;
|
2021-02-15 14:28:04 +00:00
|
|
|
return;
|
2020-06-18 07:55:46 +00:00
|
|
|
}
|
|
|
|
|
2020-03-31 13:18:49 +00:00
|
|
|
if (state->viewport.has_src) {
|
|
|
|
*out_width = state->viewport.src.width;
|
|
|
|
*out_height = state->viewport.src.height;
|
|
|
|
} else {
|
2021-11-20 10:30:18 +00:00
|
|
|
surface_state_transformed_buffer_size(state,
|
|
|
|
out_width, out_height);
|
|
|
|
*out_width /= state->scale;
|
|
|
|
*out_height /= state->scale;
|
2020-03-31 13:18:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-26 16:45:25 +00:00
|
|
|
static void surface_finalize_pending(struct wlr_surface *surface) {
|
|
|
|
struct wlr_surface_state *pending = &surface->pending;
|
|
|
|
|
|
|
|
if ((pending->committed & WLR_SURFACE_STATE_BUFFER)) {
|
2021-08-11 15:34:34 +00:00
|
|
|
if (pending->buffer != NULL) {
|
2021-08-26 16:45:25 +00:00
|
|
|
pending->buffer_width = pending->buffer->width;
|
|
|
|
pending->buffer_height = pending->buffer->height;
|
2018-07-01 14:03:55 +00:00
|
|
|
} else {
|
2021-08-26 16:45:25 +00:00
|
|
|
pending->buffer_width = pending->buffer_height = 0;
|
2018-07-01 14:03:55 +00:00
|
|
|
}
|
2018-06-28 22:49:40 +00:00
|
|
|
}
|
|
|
|
|
2021-08-26 16:45:25 +00:00
|
|
|
if (!pending->viewport.has_src &&
|
|
|
|
(pending->buffer_width % pending->scale != 0 ||
|
|
|
|
pending->buffer_height % pending->scale != 0)) {
|
2021-02-15 14:32:11 +00:00
|
|
|
// TODO: send WL_SURFACE_ERROR_INVALID_SIZE error once this issue is
|
|
|
|
// resolved:
|
|
|
|
// https://gitlab.freedesktop.org/wayland/wayland/-/issues/194
|
|
|
|
wlr_log(WLR_DEBUG, "Client bug: submitted a buffer whose size (%dx%d) "
|
2021-08-26 16:45:25 +00:00
|
|
|
"is not divisible by scale (%d)", pending->buffer_width,
|
|
|
|
pending->buffer_height, pending->scale);
|
2021-02-15 14:28:04 +00:00
|
|
|
}
|
|
|
|
|
2021-08-26 16:45:25 +00:00
|
|
|
if (pending->viewport.has_dst) {
|
|
|
|
if (pending->buffer_width == 0 && pending->buffer_height == 0) {
|
|
|
|
pending->width = pending->height = 0;
|
2020-06-18 06:15:34 +00:00
|
|
|
} else {
|
2021-08-26 16:45:25 +00:00
|
|
|
pending->width = pending->viewport.dst_width;
|
|
|
|
pending->height = pending->viewport.dst_height;
|
2020-03-31 13:18:49 +00:00
|
|
|
}
|
|
|
|
} else {
|
2021-08-26 16:45:25 +00:00
|
|
|
surface_state_viewport_src_size(pending, &pending->width, &pending->height);
|
2017-08-14 20:30:53 +00:00
|
|
|
}
|
2018-06-28 22:49:40 +00:00
|
|
|
|
2021-08-26 16:45:25 +00:00
|
|
|
pixman_region32_intersect_rect(&pending->surface_damage,
|
|
|
|
&pending->surface_damage, 0, 0, pending->width, pending->height);
|
2018-06-28 22:49:40 +00:00
|
|
|
|
2021-08-26 16:45:25 +00:00
|
|
|
pixman_region32_intersect_rect(&pending->buffer_damage,
|
|
|
|
&pending->buffer_damage, 0, 0, pending->buffer_width,
|
|
|
|
pending->buffer_height);
|
2018-06-25 22:35:02 +00:00
|
|
|
}
|
|
|
|
|
2018-06-28 22:49:40 +00:00
|
|
|
static void surface_update_damage(pixman_region32_t *buffer_damage,
|
2018-09-24 20:36:02 +00:00
|
|
|
struct wlr_surface_state *current, struct wlr_surface_state *pending) {
|
2018-06-28 22:49:40 +00:00
|
|
|
pixman_region32_clear(buffer_damage);
|
|
|
|
|
2018-09-24 20:36:02 +00:00
|
|
|
if (pending->width != current->width ||
|
2022-01-22 08:35:22 +00:00
|
|
|
pending->height != current->height ||
|
|
|
|
pending->viewport.src.x != current->viewport.src.x ||
|
|
|
|
pending->viewport.src.y != current->viewport.src.y ||
|
|
|
|
pending->viewport.src.width != current->viewport.src.width ||
|
|
|
|
pending->viewport.src.height != current->viewport.src.height) {
|
|
|
|
// Damage the whole buffer on resize or viewport source box change
|
2018-06-28 22:49:40 +00:00
|
|
|
pixman_region32_union_rect(buffer_damage, buffer_damage, 0, 0,
|
2018-10-03 20:31:04 +00:00
|
|
|
pending->buffer_width, pending->buffer_height);
|
2018-06-25 22:35:02 +00:00
|
|
|
} else {
|
|
|
|
// Copy over surface damage + buffer damage
|
|
|
|
pixman_region32_t surface_damage;
|
|
|
|
pixman_region32_init(&surface_damage);
|
2018-10-03 20:31:04 +00:00
|
|
|
|
2018-09-24 20:36:02 +00:00
|
|
|
pixman_region32_copy(&surface_damage, &pending->surface_damage);
|
2020-03-31 13:18:49 +00:00
|
|
|
|
|
|
|
if (pending->viewport.has_dst) {
|
|
|
|
int src_width, src_height;
|
|
|
|
surface_state_viewport_src_size(pending, &src_width, &src_height);
|
|
|
|
float scale_x = (float)pending->viewport.dst_width / src_width;
|
|
|
|
float scale_y = (float)pending->viewport.dst_height / src_height;
|
|
|
|
wlr_region_scale_xy(&surface_damage, &surface_damage,
|
|
|
|
1.0 / scale_x, 1.0 / scale_y);
|
|
|
|
}
|
|
|
|
if (pending->viewport.has_src) {
|
|
|
|
// This is lossy: do a best-effort conversion
|
|
|
|
pixman_region32_translate(&surface_damage,
|
|
|
|
floor(pending->viewport.src.x),
|
|
|
|
floor(pending->viewport.src.y));
|
|
|
|
}
|
|
|
|
|
2021-11-20 10:30:18 +00:00
|
|
|
wlr_region_scale(&surface_damage, &surface_damage, pending->scale);
|
|
|
|
|
|
|
|
int width, height;
|
|
|
|
surface_state_transformed_buffer_size(pending, &width, &height);
|
2018-06-28 22:49:40 +00:00
|
|
|
wlr_region_transform(&surface_damage, &surface_damage,
|
2018-10-03 20:31:04 +00:00
|
|
|
wlr_output_transform_invert(pending->transform),
|
2021-11-20 10:30:18 +00:00
|
|
|
width, height);
|
2018-10-03 20:31:04 +00:00
|
|
|
|
2018-11-04 10:08:06 +00:00
|
|
|
pixman_region32_union(buffer_damage,
|
|
|
|
&pending->buffer_damage, &surface_damage);
|
|
|
|
|
2018-06-25 22:35:02 +00:00
|
|
|
pixman_region32_fini(&surface_damage);
|
|
|
|
}
|
2017-08-14 20:30:53 +00:00
|
|
|
}
|
|
|
|
|
2021-08-11 13:26:38 +00:00
|
|
|
/**
|
|
|
|
* Append pending state to current state and clear pending state.
|
|
|
|
*/
|
|
|
|
static void surface_state_move(struct wlr_surface_state *state,
|
2018-06-28 22:49:40 +00:00
|
|
|
struct wlr_surface_state *next) {
|
2018-06-25 22:35:02 +00:00
|
|
|
state->width = next->width;
|
|
|
|
state->height = next->height;
|
|
|
|
state->buffer_width = next->buffer_width;
|
|
|
|
state->buffer_height = next->buffer_height;
|
2017-09-24 22:24:48 +00:00
|
|
|
|
2018-07-01 11:22:43 +00:00
|
|
|
if (next->committed & WLR_SURFACE_STATE_SCALE) {
|
2017-09-27 12:26:25 +00:00
|
|
|
state->scale = next->scale;
|
2017-09-24 22:24:48 +00:00
|
|
|
}
|
2018-07-01 11:22:43 +00:00
|
|
|
if (next->committed & WLR_SURFACE_STATE_TRANSFORM) {
|
2017-09-27 12:26:25 +00:00
|
|
|
state->transform = next->transform;
|
2017-09-24 22:24:48 +00:00
|
|
|
}
|
2018-07-01 11:22:43 +00:00
|
|
|
if (next->committed & WLR_SURFACE_STATE_BUFFER) {
|
2018-06-25 21:38:40 +00:00
|
|
|
state->dx = next->dx;
|
|
|
|
state->dy = next->dy;
|
2021-08-11 13:26:38 +00:00
|
|
|
next->dx = next->dy = 0;
|
|
|
|
|
2021-08-11 15:42:31 +00:00
|
|
|
wlr_buffer_unlock(state->buffer);
|
|
|
|
state->buffer = NULL;
|
2021-08-11 13:26:38 +00:00
|
|
|
if (next->buffer) {
|
|
|
|
state->buffer = wlr_buffer_lock(next->buffer);
|
|
|
|
}
|
|
|
|
wlr_buffer_unlock(next->buffer);
|
|
|
|
next->buffer = NULL;
|
2018-06-25 21:38:40 +00:00
|
|
|
} else {
|
|
|
|
state->dx = state->dy = 0;
|
2017-09-24 22:24:48 +00:00
|
|
|
}
|
2018-07-01 11:22:43 +00:00
|
|
|
if (next->committed & WLR_SURFACE_STATE_SURFACE_DAMAGE) {
|
2018-06-25 22:35:02 +00:00
|
|
|
pixman_region32_copy(&state->surface_damage, &next->surface_damage);
|
2021-08-11 13:26:38 +00:00
|
|
|
pixman_region32_clear(&next->surface_damage);
|
2018-06-25 22:35:02 +00:00
|
|
|
} else {
|
|
|
|
pixman_region32_clear(&state->surface_damage);
|
2017-09-24 22:24:48 +00:00
|
|
|
}
|
2018-07-01 11:22:43 +00:00
|
|
|
if (next->committed & WLR_SURFACE_STATE_BUFFER_DAMAGE) {
|
2018-06-25 22:35:02 +00:00
|
|
|
pixman_region32_copy(&state->buffer_damage, &next->buffer_damage);
|
2021-08-11 13:26:38 +00:00
|
|
|
pixman_region32_clear(&next->buffer_damage);
|
2018-06-25 22:35:02 +00:00
|
|
|
} else {
|
|
|
|
pixman_region32_clear(&state->buffer_damage);
|
2017-09-24 22:24:48 +00:00
|
|
|
}
|
2018-07-01 11:22:43 +00:00
|
|
|
if (next->committed & WLR_SURFACE_STATE_OPAQUE_REGION) {
|
2018-06-25 22:35:02 +00:00
|
|
|
pixman_region32_copy(&state->opaque, &next->opaque);
|
2017-09-24 22:24:48 +00:00
|
|
|
}
|
2018-07-01 11:22:43 +00:00
|
|
|
if (next->committed & WLR_SURFACE_STATE_INPUT_REGION) {
|
2017-10-08 16:33:39 +00:00
|
|
|
pixman_region32_copy(&state->input, &next->input);
|
2017-09-24 22:24:48 +00:00
|
|
|
}
|
2020-03-31 13:18:49 +00:00
|
|
|
if (next->committed & WLR_SURFACE_STATE_VIEWPORT) {
|
|
|
|
memcpy(&state->viewport, &next->viewport, sizeof(state->viewport));
|
|
|
|
}
|
2021-08-19 10:32:07 +00:00
|
|
|
if (next->committed & WLR_SURFACE_STATE_FRAME_CALLBACK_LIST) {
|
|
|
|
wl_list_insert_list(&state->frame_callback_list,
|
|
|
|
&next->frame_callback_list);
|
|
|
|
wl_list_init(&next->frame_callback_list);
|
|
|
|
}
|
2018-07-01 11:22:43 +00:00
|
|
|
|
|
|
|
state->committed |= next->committed;
|
2021-08-11 13:26:38 +00:00
|
|
|
next->committed = 0;
|
2018-07-01 11:22:43 +00:00
|
|
|
|
2021-08-11 13:26:38 +00:00
|
|
|
state->seq = next->seq;
|
2017-09-24 22:24:48 +00:00
|
|
|
|
2021-08-11 13:26:38 +00:00
|
|
|
state->cached_state_locks = next->cached_state_locks;
|
2021-03-22 18:27:29 +00:00
|
|
|
next->cached_state_locks = 0;
|
2017-09-24 22:24:48 +00:00
|
|
|
}
|
|
|
|
|
2018-06-17 11:49:34 +00:00
|
|
|
static void surface_apply_damage(struct wlr_surface *surface) {
|
2021-08-11 15:34:34 +00:00
|
|
|
if (surface->current.buffer == NULL) {
|
2018-06-08 19:06:13 +00:00
|
|
|
// NULL commit
|
2020-02-28 11:32:43 +00:00
|
|
|
if (surface->buffer != NULL) {
|
2020-02-28 12:25:05 +00:00
|
|
|
wlr_buffer_unlock(&surface->buffer->base);
|
2020-02-28 11:32:43 +00:00
|
|
|
}
|
2018-06-08 19:06:13 +00:00
|
|
|
surface->buffer = NULL;
|
2017-10-10 08:18:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-06-08 17:45:56 +00:00
|
|
|
if (surface->buffer != NULL) {
|
2021-08-11 15:22:11 +00:00
|
|
|
if (wlr_client_buffer_apply_damage(surface->buffer,
|
|
|
|
surface->current.buffer, &surface->buffer_damage)) {
|
2021-07-07 18:28:37 +00:00
|
|
|
wlr_buffer_unlock(surface->current.buffer);
|
|
|
|
surface->current.buffer = NULL;
|
2018-06-08 19:06:13 +00:00
|
|
|
return;
|
2018-03-24 22:30:28 +00:00
|
|
|
}
|
2017-10-10 08:18:38 +00:00
|
|
|
}
|
|
|
|
|
2021-07-06 21:02:04 +00:00
|
|
|
struct wlr_client_buffer *buffer = wlr_client_buffer_create(
|
2021-07-09 21:27:07 +00:00
|
|
|
surface->current.buffer, surface->renderer);
|
2021-07-07 18:28:37 +00:00
|
|
|
|
|
|
|
wlr_buffer_unlock(surface->current.buffer);
|
|
|
|
surface->current.buffer = NULL;
|
|
|
|
|
2018-06-08 19:06:13 +00:00
|
|
|
if (buffer == NULL) {
|
2018-07-09 21:49:54 +00:00
|
|
|
wlr_log(WLR_ERROR, "Failed to upload buffer");
|
2018-06-08 19:06:13 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-02-28 11:32:43 +00:00
|
|
|
if (surface->buffer != NULL) {
|
2020-02-28 12:25:05 +00:00
|
|
|
wlr_buffer_unlock(&surface->buffer->base);
|
2020-02-28 11:32:43 +00:00
|
|
|
}
|
2018-06-08 19:06:13 +00:00
|
|
|
surface->buffer = buffer;
|
2017-10-10 08:18:38 +00:00
|
|
|
}
|
|
|
|
|
2018-07-13 09:54:51 +00:00
|
|
|
static void surface_update_opaque_region(struct wlr_surface *surface) {
|
|
|
|
struct wlr_texture *texture = wlr_surface_get_texture(surface);
|
|
|
|
if (texture == NULL) {
|
|
|
|
pixman_region32_clear(&surface->opaque_region);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wlr_texture_is_opaque(texture)) {
|
|
|
|
pixman_region32_init_rect(&surface->opaque_region,
|
|
|
|
0, 0, surface->current.width, surface->current.height);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pixman_region32_intersect_rect(&surface->opaque_region,
|
2018-08-10 16:13:41 +00:00
|
|
|
&surface->current.opaque,
|
|
|
|
0, 0, surface->current.width, surface->current.height);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void surface_update_input_region(struct wlr_surface *surface) {
|
|
|
|
pixman_region32_intersect_rect(&surface->input_region,
|
|
|
|
&surface->current.input,
|
2018-07-13 09:54:51 +00:00
|
|
|
0, 0, surface->current.width, surface->current.height);
|
|
|
|
}
|
|
|
|
|
2021-03-22 18:27:29 +00:00
|
|
|
static void surface_state_init(struct wlr_surface_state *state);
|
|
|
|
|
2021-12-03 20:14:13 +00:00
|
|
|
static void subsurface_parent_commit(struct wlr_subsurface *subsurface);
|
|
|
|
|
2021-03-22 18:27:29 +00:00
|
|
|
static void surface_cache_pending(struct wlr_surface *surface) {
|
|
|
|
struct wlr_surface_state *cached = calloc(1, sizeof(*cached));
|
|
|
|
if (!cached) {
|
|
|
|
wl_resource_post_no_memory(surface->resource);
|
2020-03-05 15:24:25 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-06-28 22:49:40 +00:00
|
|
|
|
2021-03-22 18:27:29 +00:00
|
|
|
surface_state_init(cached);
|
|
|
|
surface_state_move(cached, &surface->pending);
|
2018-07-09 22:02:03 +00:00
|
|
|
|
2021-03-22 18:27:29 +00:00
|
|
|
wl_list_insert(surface->cached.prev, &cached->cached_state_link);
|
2021-07-02 09:49:53 +00:00
|
|
|
|
|
|
|
surface->pending.seq++;
|
2021-03-22 18:27:29 +00:00
|
|
|
}
|
2018-07-09 22:02:03 +00:00
|
|
|
|
2021-03-22 18:27:29 +00:00
|
|
|
static void surface_commit_state(struct wlr_surface *surface,
|
|
|
|
struct wlr_surface_state *next) {
|
|
|
|
assert(next->cached_state_locks == 0);
|
|
|
|
|
|
|
|
bool invalid_buffer = next->committed & WLR_SURFACE_STATE_BUFFER;
|
|
|
|
|
|
|
|
surface->sx += next->dx;
|
|
|
|
surface->sy += next->dy;
|
|
|
|
surface_update_damage(&surface->buffer_damage, &surface->current, next);
|
2018-06-28 22:49:40 +00:00
|
|
|
|
2021-12-04 17:05:32 +00:00
|
|
|
pixman_region32_clear(&surface->external_damage);
|
|
|
|
if (surface->current.width > next->width ||
|
|
|
|
surface->current.height > next->height ||
|
|
|
|
next->dx != 0 || next->dy != 0) {
|
|
|
|
pixman_region32_union_rect(&surface->external_damage,
|
|
|
|
&surface->external_damage, -next->dx, -next->dy,
|
|
|
|
surface->current.width, surface->current.height);
|
|
|
|
}
|
|
|
|
|
2021-08-11 13:19:26 +00:00
|
|
|
surface->previous.scale = surface->current.scale;
|
|
|
|
surface->previous.transform = surface->current.transform;
|
|
|
|
surface->previous.width = surface->current.width;
|
|
|
|
surface->previous.height = surface->current.height;
|
|
|
|
surface->previous.buffer_width = surface->current.buffer_width;
|
|
|
|
surface->previous.buffer_height = surface->current.buffer_height;
|
|
|
|
|
2021-03-22 18:27:29 +00:00
|
|
|
surface_state_move(&surface->current, next);
|
2017-10-09 21:19:17 +00:00
|
|
|
|
2018-06-17 11:49:34 +00:00
|
|
|
if (invalid_buffer) {
|
|
|
|
surface_apply_damage(surface);
|
|
|
|
}
|
2018-07-13 09:54:51 +00:00
|
|
|
surface_update_opaque_region(surface);
|
2018-08-10 16:13:41 +00:00
|
|
|
surface_update_input_region(surface);
|
2017-10-10 08:18:38 +00:00
|
|
|
|
2017-09-29 12:40:37 +00:00
|
|
|
// commit subsurface order
|
|
|
|
struct wlr_subsurface *subsurface;
|
2021-08-26 17:57:51 +00:00
|
|
|
wl_list_for_each_reverse(subsurface, &surface->pending.subsurfaces_above,
|
2021-08-18 14:11:09 +00:00
|
|
|
pending.link) {
|
|
|
|
wl_list_remove(&subsurface->current.link);
|
2021-08-26 17:57:51 +00:00
|
|
|
wl_list_insert(&surface->current.subsurfaces_above,
|
2021-08-18 14:11:09 +00:00
|
|
|
&subsurface->current.link);
|
2021-06-01 10:18:53 +00:00
|
|
|
|
2021-12-03 20:14:13 +00:00
|
|
|
subsurface_parent_commit(subsurface);
|
2021-06-01 10:18:53 +00:00
|
|
|
}
|
2021-08-26 17:57:51 +00:00
|
|
|
wl_list_for_each_reverse(subsurface, &surface->pending.subsurfaces_below,
|
2021-08-18 14:11:09 +00:00
|
|
|
pending.link) {
|
|
|
|
wl_list_remove(&subsurface->current.link);
|
2021-08-26 17:57:51 +00:00
|
|
|
wl_list_insert(&surface->current.subsurfaces_below,
|
2021-08-18 14:11:09 +00:00
|
|
|
&subsurface->current.link);
|
2017-09-29 12:40:37 +00:00
|
|
|
|
2021-12-03 20:14:13 +00:00
|
|
|
subsurface_parent_commit(subsurface);
|
2017-09-29 12:40:37 +00:00
|
|
|
}
|
|
|
|
|
2021-07-02 09:49:53 +00:00
|
|
|
// If we're committing the pending state, bump the pending sequence number
|
|
|
|
// here, to allow commit listeners to lock the new pending state.
|
|
|
|
if (next == &surface->pending) {
|
|
|
|
surface->pending.seq++;
|
|
|
|
}
|
|
|
|
|
2018-07-07 21:45:16 +00:00
|
|
|
if (surface->role && surface->role->commit) {
|
|
|
|
surface->role->commit(surface);
|
2017-12-27 11:06:29 +00:00
|
|
|
}
|
|
|
|
|
2018-02-12 08:12:31 +00:00
|
|
|
wlr_signal_emit_safe(&surface->events.commit, surface);
|
2017-08-09 13:33:30 +00:00
|
|
|
}
|
|
|
|
|
2018-04-25 22:51:00 +00:00
|
|
|
static bool subsurface_is_synchronized(struct wlr_subsurface *subsurface) {
|
2018-11-26 22:16:40 +00:00
|
|
|
while (subsurface != NULL) {
|
2017-09-24 22:24:48 +00:00
|
|
|
if (subsurface->synchronized) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!subsurface->parent) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-04-21 17:40:25 +00:00
|
|
|
if (!wlr_surface_is_subsurface(subsurface->parent)) {
|
|
|
|
break;
|
|
|
|
}
|
2018-06-30 09:13:30 +00:00
|
|
|
subsurface = wlr_subsurface_from_wlr_surface(subsurface->parent);
|
2017-09-24 22:24:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-12-04 17:05:32 +00:00
|
|
|
static void collect_subsurface_damage_iter(struct wlr_surface *surface,
|
|
|
|
int sx, int sy, void *data) {
|
|
|
|
struct wlr_subsurface *subsurface = data;
|
|
|
|
pixman_region32_t *damage = &subsurface->parent->external_damage;
|
|
|
|
pixman_region32_union_rect(damage, damage,
|
|
|
|
subsurface->current.x + sx,
|
|
|
|
subsurface->current.y + sy,
|
|
|
|
surface->current.width, surface->current.height);
|
|
|
|
}
|
|
|
|
|
2021-12-03 20:14:13 +00:00
|
|
|
static void subsurface_parent_commit(struct wlr_subsurface *subsurface) {
|
2018-06-21 21:15:39 +00:00
|
|
|
struct wlr_surface *surface = subsurface->surface;
|
2022-01-22 08:35:22 +00:00
|
|
|
|
2021-12-04 17:05:32 +00:00
|
|
|
bool moved = subsurface->current.x != subsurface->pending.x ||
|
|
|
|
subsurface->current.y != subsurface->pending.y;
|
|
|
|
if (subsurface->mapped && moved) {
|
|
|
|
wlr_surface_for_each_surface(surface,
|
|
|
|
collect_subsurface_damage_iter, subsurface);
|
|
|
|
}
|
2017-09-24 22:24:48 +00:00
|
|
|
|
2021-12-03 20:14:13 +00:00
|
|
|
if (subsurface->synchronized && subsurface->has_cache) {
|
|
|
|
wlr_surface_unlock_cached(surface, subsurface->cached_seq);
|
|
|
|
subsurface->has_cache = false;
|
2017-09-24 22:24:48 +00:00
|
|
|
}
|
2021-12-03 20:15:55 +00:00
|
|
|
|
2021-12-04 17:05:32 +00:00
|
|
|
subsurface->current.x = subsurface->pending.x;
|
|
|
|
subsurface->current.y = subsurface->pending.y;
|
|
|
|
if (subsurface->mapped && (moved || subsurface->reordered)) {
|
|
|
|
subsurface->reordered = false;
|
|
|
|
wlr_surface_for_each_surface(surface,
|
|
|
|
collect_subsurface_damage_iter, subsurface);
|
2021-12-03 20:15:55 +00:00
|
|
|
}
|
2021-12-06 11:59:00 +00:00
|
|
|
|
|
|
|
if (!subsurface->added) {
|
|
|
|
subsurface->added = true;
|
|
|
|
wlr_signal_emit_safe(&subsurface->parent->events.new_subsurface,
|
|
|
|
subsurface);
|
|
|
|
}
|
2017-09-24 22:24:48 +00:00
|
|
|
}
|
|
|
|
|
2018-04-25 22:51:00 +00:00
|
|
|
static void subsurface_commit(struct wlr_subsurface *subsurface) {
|
2017-09-24 22:24:48 +00:00
|
|
|
struct wlr_surface *surface = subsurface->surface;
|
|
|
|
|
2018-04-25 22:51:00 +00:00
|
|
|
if (subsurface_is_synchronized(subsurface)) {
|
2017-09-24 22:24:48 +00:00
|
|
|
if (subsurface->has_cache) {
|
2021-03-22 18:45:36 +00:00
|
|
|
// We already lock a previous commit. The prevents any future
|
|
|
|
// commit to be applied before we release the previous commit.
|
|
|
|
return;
|
2017-09-24 22:24:48 +00:00
|
|
|
}
|
2021-03-22 18:45:36 +00:00
|
|
|
subsurface->has_cache = true;
|
|
|
|
subsurface->cached_seq = wlr_surface_lock_pending(surface);
|
2022-01-25 19:30:36 +00:00
|
|
|
} else if (subsurface->has_cache) {
|
|
|
|
wlr_surface_unlock_cached(surface, subsurface->cached_seq);
|
|
|
|
subsurface->has_cache = false;
|
2017-09-24 22:24:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-27 10:30:41 +00:00
|
|
|
static void surface_handle_commit(struct wl_client *client,
|
2017-09-24 15:33:37 +00:00
|
|
|
struct wl_resource *resource) {
|
2018-02-13 22:48:46 +00:00
|
|
|
struct wlr_surface *surface = wlr_surface_from_resource(resource);
|
2017-09-24 15:33:37 +00:00
|
|
|
|
2018-11-26 22:16:40 +00:00
|
|
|
struct wlr_subsurface *subsurface = wlr_surface_is_subsurface(surface) ?
|
|
|
|
wlr_subsurface_from_wlr_surface(surface) : NULL;
|
|
|
|
if (subsurface != NULL) {
|
2018-04-25 22:51:00 +00:00
|
|
|
subsurface_commit(subsurface);
|
2017-09-24 22:24:48 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 15:11:33 +00:00
|
|
|
surface_finalize_pending(surface);
|
|
|
|
|
|
|
|
if (surface->role && surface->role->precommit) {
|
|
|
|
surface->role->precommit(surface);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (surface->pending.cached_state_locks > 0 || !wl_list_empty(&surface->cached)) {
|
|
|
|
surface_cache_pending(surface);
|
|
|
|
} else {
|
|
|
|
surface_commit_state(surface, &surface->pending);
|
|
|
|
}
|
2017-09-24 15:33:37 +00:00
|
|
|
}
|
|
|
|
|
2021-08-27 10:30:41 +00:00
|
|
|
static void surface_handle_set_buffer_transform(struct wl_client *client,
|
2019-02-14 23:50:18 +00:00
|
|
|
struct wl_resource *resource, int32_t transform) {
|
|
|
|
if (transform < WL_OUTPUT_TRANSFORM_NORMAL ||
|
|
|
|
transform > WL_OUTPUT_TRANSFORM_FLIPPED_270) {
|
|
|
|
wl_resource_post_error(resource, WL_SURFACE_ERROR_INVALID_TRANSFORM,
|
|
|
|
"Specified transform value (%d) is invalid", transform);
|
|
|
|
return;
|
|
|
|
}
|
2018-02-13 22:48:46 +00:00
|
|
|
struct wlr_surface *surface = wlr_surface_from_resource(resource);
|
2018-06-21 21:39:26 +00:00
|
|
|
surface->pending.committed |= WLR_SURFACE_STATE_TRANSFORM;
|
|
|
|
surface->pending.transform = transform;
|
2017-08-09 13:33:30 +00:00
|
|
|
}
|
|
|
|
|
2021-08-27 10:30:41 +00:00
|
|
|
static void surface_handle_set_buffer_scale(struct wl_client *client,
|
2019-02-14 23:50:18 +00:00
|
|
|
struct wl_resource *resource, int32_t scale) {
|
2019-02-14 23:38:33 +00:00
|
|
|
if (scale <= 0) {
|
|
|
|
wl_resource_post_error(resource, WL_SURFACE_ERROR_INVALID_SCALE,
|
|
|
|
"Specified scale value (%d) is not positive", scale);
|
|
|
|
return;
|
|
|
|
}
|
2018-02-13 22:48:46 +00:00
|
|
|
struct wlr_surface *surface = wlr_surface_from_resource(resource);
|
2018-06-21 21:39:26 +00:00
|
|
|
surface->pending.committed |= WLR_SURFACE_STATE_SCALE;
|
|
|
|
surface->pending.scale = scale;
|
2017-08-09 13:33:30 +00:00
|
|
|
}
|
|
|
|
|
2021-08-27 10:30:41 +00:00
|
|
|
static void surface_handle_damage_buffer(struct wl_client *client,
|
2017-08-09 13:33:30 +00:00
|
|
|
struct wl_resource *resource,
|
|
|
|
int32_t x, int32_t y, int32_t width,
|
|
|
|
int32_t height) {
|
2018-02-13 22:48:46 +00:00
|
|
|
struct wlr_surface *surface = wlr_surface_from_resource(resource);
|
2017-08-10 19:14:41 +00:00
|
|
|
if (width < 0 || height < 0) {
|
|
|
|
return;
|
|
|
|
}
|
2018-06-21 21:39:26 +00:00
|
|
|
surface->pending.committed |= WLR_SURFACE_STATE_BUFFER_DAMAGE;
|
|
|
|
pixman_region32_union_rect(&surface->pending.buffer_damage,
|
|
|
|
&surface->pending.buffer_damage,
|
2017-08-10 19:14:41 +00:00
|
|
|
x, y, width, height);
|
2017-08-09 13:33:30 +00:00
|
|
|
}
|
|
|
|
|
2021-08-27 10:30:41 +00:00
|
|
|
static const struct wl_surface_interface surface_implementation = {
|
|
|
|
.destroy = surface_handle_destroy,
|
|
|
|
.attach = surface_handle_attach,
|
|
|
|
.damage = surface_handle_damage,
|
|
|
|
.frame = surface_handle_frame,
|
|
|
|
.set_opaque_region = surface_handle_set_opaque_region,
|
|
|
|
.set_input_region = surface_handle_set_input_region,
|
|
|
|
.commit = surface_handle_commit,
|
|
|
|
.set_buffer_transform = surface_handle_set_buffer_transform,
|
|
|
|
.set_buffer_scale = surface_handle_set_buffer_scale,
|
|
|
|
.damage_buffer = surface_handle_damage_buffer
|
2017-08-09 13:33:30 +00:00
|
|
|
};
|
|
|
|
|
2018-02-13 22:48:46 +00:00
|
|
|
struct wlr_surface *wlr_surface_from_resource(struct wl_resource *resource) {
|
|
|
|
assert(wl_resource_instance_of(resource, &wl_surface_interface,
|
2021-08-27 10:30:41 +00:00
|
|
|
&surface_implementation));
|
2018-02-13 22:48:46 +00:00
|
|
|
return wl_resource_get_user_data(resource);
|
|
|
|
}
|
|
|
|
|
2018-06-21 21:39:26 +00:00
|
|
|
static void surface_state_init(struct wlr_surface_state *state) {
|
2017-09-24 15:33:37 +00:00
|
|
|
state->scale = 1;
|
|
|
|
state->transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
|
|
|
|
2021-08-26 17:57:51 +00:00
|
|
|
wl_list_init(&state->subsurfaces_above);
|
|
|
|
wl_list_init(&state->subsurfaces_below);
|
|
|
|
|
2017-09-24 22:24:48 +00:00
|
|
|
wl_list_init(&state->frame_callback_list);
|
|
|
|
|
2017-09-24 15:33:37 +00:00
|
|
|
pixman_region32_init(&state->surface_damage);
|
|
|
|
pixman_region32_init(&state->buffer_damage);
|
|
|
|
pixman_region32_init(&state->opaque);
|
2017-10-08 16:33:39 +00:00
|
|
|
pixman_region32_init_rect(&state->input,
|
|
|
|
INT32_MIN, INT32_MIN, UINT32_MAX, UINT32_MAX);
|
2017-09-24 22:24:48 +00:00
|
|
|
}
|
|
|
|
|
2018-06-21 21:39:26 +00:00
|
|
|
static void surface_state_finish(struct wlr_surface_state *state) {
|
2021-07-07 18:28:37 +00:00
|
|
|
wlr_buffer_unlock(state->buffer);
|
2018-06-21 21:39:26 +00:00
|
|
|
|
2018-06-20 19:00:23 +00:00
|
|
|
struct wl_resource *resource, *tmp;
|
|
|
|
wl_resource_for_each_safe(resource, tmp, &state->frame_callback_list) {
|
|
|
|
wl_resource_destroy(resource);
|
2017-09-24 22:24:48 +00:00
|
|
|
}
|
|
|
|
|
2017-09-27 12:26:25 +00:00
|
|
|
pixman_region32_fini(&state->surface_damage);
|
|
|
|
pixman_region32_fini(&state->buffer_damage);
|
|
|
|
pixman_region32_fini(&state->opaque);
|
|
|
|
pixman_region32_fini(&state->input);
|
2017-09-24 22:24:48 +00:00
|
|
|
}
|
|
|
|
|
2021-03-22 18:27:29 +00:00
|
|
|
static void surface_state_destroy_cached(struct wlr_surface_state *state) {
|
|
|
|
surface_state_finish(state);
|
|
|
|
wl_list_remove(&state->cached_state_link);
|
|
|
|
free(state);
|
|
|
|
}
|
|
|
|
|
2019-02-16 16:32:01 +00:00
|
|
|
static void subsurface_unmap(struct wlr_subsurface *subsurface);
|
|
|
|
|
2018-04-21 10:42:18 +00:00
|
|
|
static void subsurface_destroy(struct wlr_subsurface *subsurface) {
|
2018-04-30 21:20:11 +00:00
|
|
|
if (subsurface == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-08-25 17:11:22 +00:00
|
|
|
if (subsurface->has_cache) {
|
|
|
|
wlr_surface_unlock_cached(subsurface->surface,
|
|
|
|
subsurface->cached_seq);
|
|
|
|
}
|
|
|
|
|
2019-02-16 16:32:01 +00:00
|
|
|
subsurface_unmap(subsurface);
|
|
|
|
|
2018-02-12 08:12:31 +00:00
|
|
|
wlr_signal_emit_safe(&subsurface->events.destroy, subsurface);
|
2018-01-21 13:22:33 +00:00
|
|
|
|
2018-04-21 17:40:25 +00:00
|
|
|
wl_list_remove(&subsurface->surface_destroy.link);
|
2017-09-30 17:24:59 +00:00
|
|
|
|
|
|
|
if (subsurface->parent) {
|
2021-08-18 14:11:09 +00:00
|
|
|
wl_list_remove(&subsurface->current.link);
|
|
|
|
wl_list_remove(&subsurface->pending.link);
|
2018-04-21 17:40:25 +00:00
|
|
|
wl_list_remove(&subsurface->parent_destroy.link);
|
2017-09-30 17:24:59 +00:00
|
|
|
}
|
|
|
|
|
2017-09-24 22:24:48 +00:00
|
|
|
wl_resource_set_user_data(subsurface->resource, NULL);
|
|
|
|
if (subsurface->surface) {
|
2018-04-21 17:40:25 +00:00
|
|
|
subsurface->surface->role_data = NULL;
|
2017-09-24 22:24:48 +00:00
|
|
|
}
|
|
|
|
free(subsurface);
|
|
|
|
}
|
|
|
|
|
2020-11-07 21:08:40 +00:00
|
|
|
static void surface_output_destroy(struct wlr_surface_output *surface_output);
|
|
|
|
|
2018-04-25 23:11:36 +00:00
|
|
|
static void surface_handle_resource_destroy(struct wl_resource *resource) {
|
2018-02-13 22:48:46 +00:00
|
|
|
struct wlr_surface *surface = wlr_surface_from_resource(resource);
|
2017-09-24 22:24:48 +00:00
|
|
|
|
2021-03-22 18:27:29 +00:00
|
|
|
struct wlr_surface_output *surface_output, *surface_output_tmp;
|
|
|
|
wl_list_for_each_safe(surface_output, surface_output_tmp,
|
|
|
|
&surface->current_outputs, link) {
|
2020-11-07 21:08:40 +00:00
|
|
|
surface_output_destroy(surface_output);
|
|
|
|
}
|
|
|
|
|
2018-04-21 17:40:25 +00:00
|
|
|
wlr_signal_emit_safe(&surface->events.destroy, surface);
|
2017-09-24 22:24:48 +00:00
|
|
|
|
2021-08-28 09:13:14 +00:00
|
|
|
wlr_addon_set_finish(&surface->addons);
|
|
|
|
|
2021-03-22 18:27:29 +00:00
|
|
|
struct wlr_surface_state *cached, *cached_tmp;
|
|
|
|
wl_list_for_each_safe(cached, cached_tmp, &surface->cached, cached_state_link) {
|
|
|
|
surface_state_destroy_cached(cached);
|
|
|
|
}
|
|
|
|
|
2018-04-26 16:51:06 +00:00
|
|
|
wl_list_remove(&surface->renderer_destroy.link);
|
2018-06-21 21:39:26 +00:00
|
|
|
surface_state_finish(&surface->pending);
|
|
|
|
surface_state_finish(&surface->current);
|
2018-06-28 22:49:40 +00:00
|
|
|
pixman_region32_fini(&surface->buffer_damage);
|
2021-12-04 17:05:32 +00:00
|
|
|
pixman_region32_fini(&surface->external_damage);
|
2018-07-13 09:54:51 +00:00
|
|
|
pixman_region32_fini(&surface->opaque_region);
|
2018-08-10 16:13:41 +00:00
|
|
|
pixman_region32_fini(&surface->input_region);
|
2020-02-28 11:32:43 +00:00
|
|
|
if (surface->buffer != NULL) {
|
2020-02-28 12:25:05 +00:00
|
|
|
wlr_buffer_unlock(&surface->buffer->base);
|
2020-02-28 11:32:43 +00:00
|
|
|
}
|
2017-09-24 22:24:48 +00:00
|
|
|
free(surface);
|
2017-09-24 15:33:37 +00:00
|
|
|
}
|
|
|
|
|
2018-04-25 23:11:36 +00:00
|
|
|
static void surface_handle_renderer_destroy(struct wl_listener *listener,
|
|
|
|
void *data) {
|
|
|
|
struct wlr_surface *surface =
|
|
|
|
wl_container_of(listener, surface, renderer_destroy);
|
|
|
|
wl_resource_destroy(surface->resource);
|
|
|
|
}
|
|
|
|
|
2021-03-30 08:17:15 +00:00
|
|
|
struct wlr_surface *surface_create(struct wl_client *client,
|
2021-03-30 08:19:29 +00:00
|
|
|
uint32_t version, uint32_t id, struct wlr_renderer *renderer) {
|
2017-10-31 10:58:39 +00:00
|
|
|
struct wlr_surface *surface = calloc(1, sizeof(struct wlr_surface));
|
|
|
|
if (!surface) {
|
2018-04-26 16:51:06 +00:00
|
|
|
wl_client_post_no_memory(client);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
surface->resource = wl_resource_create(client, &wl_surface_interface,
|
|
|
|
version, id);
|
|
|
|
if (surface->resource == NULL) {
|
|
|
|
free(surface);
|
|
|
|
wl_client_post_no_memory(client);
|
2017-08-15 05:56:47 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2021-08-27 10:30:41 +00:00
|
|
|
wl_resource_set_implementation(surface->resource, &surface_implementation,
|
2018-04-26 16:51:06 +00:00
|
|
|
surface, surface_handle_resource_destroy);
|
|
|
|
|
2018-07-09 21:49:54 +00:00
|
|
|
wlr_log(WLR_DEBUG, "New wlr_surface %p (res %p)", surface, surface->resource);
|
2018-04-26 16:51:06 +00:00
|
|
|
|
2017-08-11 02:15:37 +00:00
|
|
|
surface->renderer = renderer;
|
2017-09-24 15:33:37 +00:00
|
|
|
|
2018-06-21 21:39:26 +00:00
|
|
|
surface_state_init(&surface->current);
|
|
|
|
surface_state_init(&surface->pending);
|
2021-03-22 17:28:13 +00:00
|
|
|
surface->pending.seq = 1;
|
2017-09-24 15:33:37 +00:00
|
|
|
|
2017-10-08 17:12:28 +00:00
|
|
|
wl_signal_init(&surface->events.commit);
|
|
|
|
wl_signal_init(&surface->events.destroy);
|
2018-01-21 13:22:33 +00:00
|
|
|
wl_signal_init(&surface->events.new_subsurface);
|
2020-11-07 21:08:40 +00:00
|
|
|
wl_list_init(&surface->current_outputs);
|
2021-03-22 18:27:29 +00:00
|
|
|
wl_list_init(&surface->cached);
|
2018-06-28 22:49:40 +00:00
|
|
|
pixman_region32_init(&surface->buffer_damage);
|
2021-12-04 17:05:32 +00:00
|
|
|
pixman_region32_init(&surface->external_damage);
|
2018-07-13 09:54:51 +00:00
|
|
|
pixman_region32_init(&surface->opaque_region);
|
2018-08-10 16:13:41 +00:00
|
|
|
pixman_region32_init(&surface->input_region);
|
2021-08-28 09:13:14 +00:00
|
|
|
wlr_addon_set_init(&surface->addons);
|
2018-04-25 23:11:36 +00:00
|
|
|
|
|
|
|
wl_signal_add(&renderer->events.destroy, &surface->renderer_destroy);
|
|
|
|
surface->renderer_destroy.notify = surface_handle_renderer_destroy;
|
|
|
|
|
2017-08-09 13:33:30 +00:00
|
|
|
return surface;
|
|
|
|
}
|
2017-08-14 17:54:57 +00:00
|
|
|
|
2018-06-13 18:38:10 +00:00
|
|
|
struct wlr_texture *wlr_surface_get_texture(struct wlr_surface *surface) {
|
|
|
|
if (surface->buffer == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return surface->buffer->texture;
|
|
|
|
}
|
|
|
|
|
2017-10-23 01:07:32 +00:00
|
|
|
bool wlr_surface_has_buffer(struct wlr_surface *surface) {
|
2018-06-13 18:38:10 +00:00
|
|
|
return wlr_surface_get_texture(surface) != NULL;
|
2017-10-23 01:07:32 +00:00
|
|
|
}
|
|
|
|
|
2018-07-07 21:45:16 +00:00
|
|
|
bool wlr_surface_set_role(struct wlr_surface *surface,
|
|
|
|
const struct wlr_surface_role *role, void *role_data,
|
2017-09-11 22:06:19 +00:00
|
|
|
struct wl_resource *error_resource, uint32_t error_code) {
|
2018-07-07 21:45:16 +00:00
|
|
|
assert(role != NULL);
|
|
|
|
|
|
|
|
if (surface->role != NULL && surface->role != role) {
|
|
|
|
if (error_resource != NULL) {
|
|
|
|
wl_resource_post_error(error_resource, error_code,
|
2020-06-04 12:33:32 +00:00
|
|
|
"Cannot assign role %s to wl_surface@%" PRIu32 ", already has role %s\n",
|
2018-07-07 21:45:16 +00:00
|
|
|
role->name, wl_resource_get_id(surface->resource),
|
|
|
|
surface->role->name);
|
|
|
|
}
|
|
|
|
return false;
|
2017-09-11 22:06:19 +00:00
|
|
|
}
|
2020-03-21 11:55:54 +00:00
|
|
|
if (surface->role_data != NULL && surface->role_data != role_data) {
|
|
|
|
wl_resource_post_error(error_resource, error_code,
|
2020-06-04 12:33:32 +00:00
|
|
|
"Cannot reassign role %s to wl_surface@%" PRIu32 ","
|
2020-03-21 11:55:54 +00:00
|
|
|
"role object still exists", role->name,
|
|
|
|
wl_resource_get_id(surface->resource));
|
|
|
|
return false;
|
|
|
|
}
|
2017-09-11 22:06:19 +00:00
|
|
|
|
2018-07-07 21:45:16 +00:00
|
|
|
surface->role = role;
|
|
|
|
surface->role_data = role_data;
|
|
|
|
return true;
|
2017-09-11 22:06:19 +00:00
|
|
|
}
|
2017-09-24 12:23:18 +00:00
|
|
|
|
2021-03-22 18:27:29 +00:00
|
|
|
uint32_t wlr_surface_lock_pending(struct wlr_surface *surface) {
|
|
|
|
surface->pending.cached_state_locks++;
|
|
|
|
return surface->pending.seq;
|
|
|
|
}
|
|
|
|
|
|
|
|
void wlr_surface_unlock_cached(struct wlr_surface *surface, uint32_t seq) {
|
|
|
|
if (surface->pending.seq == seq) {
|
|
|
|
assert(surface->pending.cached_state_locks > 0);
|
|
|
|
surface->pending.cached_state_locks--;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool found = false;
|
|
|
|
struct wlr_surface_state *cached;
|
|
|
|
wl_list_for_each(cached, &surface->cached, cached_state_link) {
|
|
|
|
if (cached->seq == seq) {
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
assert(found);
|
|
|
|
|
|
|
|
assert(cached->cached_state_locks > 0);
|
|
|
|
cached->cached_state_locks--;
|
|
|
|
|
|
|
|
if (cached->cached_state_locks != 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cached->cached_state_link.prev != &surface->cached) {
|
|
|
|
// This isn't the first cached state. This means we're blocked on a
|
|
|
|
// previous cached state.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: consider merging all committed states together
|
|
|
|
struct wlr_surface_state *next, *tmp;
|
|
|
|
wl_list_for_each_safe(next, tmp, &surface->cached, cached_state_link) {
|
|
|
|
if (next->cached_state_locks > 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
surface_commit_state(surface, next);
|
|
|
|
surface_state_destroy_cached(next);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-13 22:48:46 +00:00
|
|
|
static const struct wl_subsurface_interface subsurface_implementation;
|
|
|
|
|
|
|
|
static struct wlr_subsurface *subsurface_from_resource(
|
|
|
|
struct wl_resource *resource) {
|
|
|
|
assert(wl_resource_instance_of(resource, &wl_subsurface_interface,
|
|
|
|
&subsurface_implementation));
|
|
|
|
return wl_resource_get_user_data(resource);
|
|
|
|
}
|
|
|
|
|
2017-09-24 12:23:18 +00:00
|
|
|
static void subsurface_resource_destroy(struct wl_resource *resource) {
|
2018-02-13 22:48:46 +00:00
|
|
|
struct wlr_subsurface *subsurface = subsurface_from_resource(resource);
|
2018-04-30 21:20:11 +00:00
|
|
|
subsurface_destroy(subsurface);
|
2017-09-24 12:23:18 +00:00
|
|
|
}
|
|
|
|
|
2018-04-21 10:42:18 +00:00
|
|
|
static void subsurface_handle_destroy(struct wl_client *client,
|
2017-09-24 12:23:18 +00:00
|
|
|
struct wl_resource *resource) {
|
|
|
|
wl_resource_destroy(resource);
|
|
|
|
}
|
|
|
|
|
2018-04-30 21:20:11 +00:00
|
|
|
static void subsurface_handle_set_position(struct wl_client *client,
|
2017-09-24 12:23:18 +00:00
|
|
|
struct wl_resource *resource, int32_t x, int32_t y) {
|
2018-02-13 22:48:46 +00:00
|
|
|
struct wlr_subsurface *subsurface = subsurface_from_resource(resource);
|
2018-04-30 21:20:11 +00:00
|
|
|
if (subsurface == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
2017-09-24 22:24:48 +00:00
|
|
|
|
2018-06-21 21:15:39 +00:00
|
|
|
subsurface->pending.x = x;
|
|
|
|
subsurface->pending.y = y;
|
2017-09-24 12:23:18 +00:00
|
|
|
}
|
|
|
|
|
2017-09-29 12:40:37 +00:00
|
|
|
static struct wlr_subsurface *subsurface_find_sibling(
|
|
|
|
struct wlr_subsurface *subsurface, struct wlr_surface *surface) {
|
|
|
|
struct wlr_surface *parent = subsurface->parent;
|
|
|
|
|
|
|
|
struct wlr_subsurface *sibling;
|
2021-12-06 11:59:00 +00:00
|
|
|
wl_list_for_each(sibling, &parent->pending.subsurfaces_below, pending.link) {
|
2021-06-01 10:18:53 +00:00
|
|
|
if (sibling->surface == surface && sibling != subsurface) {
|
|
|
|
return sibling;
|
|
|
|
}
|
|
|
|
}
|
2021-12-06 11:59:00 +00:00
|
|
|
wl_list_for_each(sibling, &parent->pending.subsurfaces_above, pending.link) {
|
2018-01-21 15:28:21 +00:00
|
|
|
if (sibling->surface == surface && sibling != subsurface) {
|
2017-09-29 12:40:37 +00:00
|
|
|
return sibling;
|
2018-01-21 15:28:21 +00:00
|
|
|
}
|
2017-09-29 12:40:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-04-30 21:20:11 +00:00
|
|
|
static void subsurface_handle_place_above(struct wl_client *client,
|
2017-09-29 12:40:37 +00:00
|
|
|
struct wl_resource *resource, struct wl_resource *sibling_resource) {
|
2018-02-13 22:48:46 +00:00
|
|
|
struct wlr_subsurface *subsurface = subsurface_from_resource(resource);
|
2018-04-30 21:20:11 +00:00
|
|
|
if (subsurface == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
2017-09-29 12:40:37 +00:00
|
|
|
|
|
|
|
struct wlr_surface *sibling_surface =
|
2018-02-13 22:48:46 +00:00
|
|
|
wlr_surface_from_resource(sibling_resource);
|
2021-06-01 10:18:53 +00:00
|
|
|
|
|
|
|
struct wl_list *node;
|
|
|
|
if (sibling_surface == subsurface->parent) {
|
2021-08-26 17:57:51 +00:00
|
|
|
node = &subsurface->parent->pending.subsurfaces_above;
|
2021-06-01 10:18:53 +00:00
|
|
|
} else {
|
|
|
|
struct wlr_subsurface *sibling =
|
|
|
|
subsurface_find_sibling(subsurface, sibling_surface);
|
|
|
|
if (!sibling) {
|
|
|
|
wl_resource_post_error(subsurface->resource,
|
|
|
|
WL_SUBSURFACE_ERROR_BAD_SURFACE,
|
|
|
|
"%s: wl_surface@%" PRIu32 "is not a parent or sibling",
|
|
|
|
"place_above", wl_resource_get_id(sibling_resource));
|
|
|
|
return;
|
|
|
|
}
|
2021-08-18 14:11:09 +00:00
|
|
|
node = &sibling->pending.link;
|
2017-09-29 12:40:37 +00:00
|
|
|
}
|
|
|
|
|
2021-08-18 14:11:09 +00:00
|
|
|
wl_list_remove(&subsurface->pending.link);
|
|
|
|
wl_list_insert(node, &subsurface->pending.link);
|
2017-09-29 12:40:37 +00:00
|
|
|
|
|
|
|
subsurface->reordered = true;
|
2017-09-24 12:23:18 +00:00
|
|
|
}
|
|
|
|
|
2018-04-30 21:20:11 +00:00
|
|
|
static void subsurface_handle_place_below(struct wl_client *client,
|
2017-09-29 12:40:37 +00:00
|
|
|
struct wl_resource *resource, struct wl_resource *sibling_resource) {
|
2018-02-13 22:48:46 +00:00
|
|
|
struct wlr_subsurface *subsurface = subsurface_from_resource(resource);
|
2018-04-30 21:20:11 +00:00
|
|
|
if (subsurface == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
2017-09-29 12:40:37 +00:00
|
|
|
|
|
|
|
struct wlr_surface *sibling_surface =
|
2018-02-13 22:48:46 +00:00
|
|
|
wlr_surface_from_resource(sibling_resource);
|
2021-06-01 10:18:53 +00:00
|
|
|
|
|
|
|
struct wl_list *node;
|
|
|
|
if (sibling_surface == subsurface->parent) {
|
2021-08-26 17:57:51 +00:00
|
|
|
node = &subsurface->parent->pending.subsurfaces_below;
|
2021-06-01 10:18:53 +00:00
|
|
|
} else {
|
|
|
|
struct wlr_subsurface *sibling =
|
|
|
|
subsurface_find_sibling(subsurface, sibling_surface);
|
|
|
|
if (!sibling) {
|
|
|
|
wl_resource_post_error(subsurface->resource,
|
|
|
|
WL_SUBSURFACE_ERROR_BAD_SURFACE,
|
|
|
|
"%s: wl_surface@%" PRIu32 " is not a parent or sibling",
|
|
|
|
"place_below", wl_resource_get_id(sibling_resource));
|
|
|
|
return;
|
|
|
|
}
|
2021-08-18 14:11:09 +00:00
|
|
|
node = &sibling->pending.link;
|
2017-09-29 12:40:37 +00:00
|
|
|
}
|
|
|
|
|
2021-08-18 14:11:09 +00:00
|
|
|
wl_list_remove(&subsurface->pending.link);
|
|
|
|
wl_list_insert(node->prev, &subsurface->pending.link);
|
2017-09-29 12:40:37 +00:00
|
|
|
|
|
|
|
subsurface->reordered = true;
|
2017-09-24 12:23:18 +00:00
|
|
|
}
|
|
|
|
|
2018-04-30 21:20:11 +00:00
|
|
|
static void subsurface_handle_set_sync(struct wl_client *client,
|
2017-09-24 12:23:18 +00:00
|
|
|
struct wl_resource *resource) {
|
2018-02-13 22:48:46 +00:00
|
|
|
struct wlr_subsurface *subsurface = subsurface_from_resource(resource);
|
2018-04-30 21:20:11 +00:00
|
|
|
if (subsurface == NULL) {
|
|
|
|
return;
|
2017-09-24 15:17:17 +00:00
|
|
|
}
|
2018-04-30 21:20:11 +00:00
|
|
|
|
|
|
|
subsurface->synchronized = true;
|
2017-09-24 12:23:18 +00:00
|
|
|
}
|
|
|
|
|
2018-04-30 21:20:11 +00:00
|
|
|
static void subsurface_handle_set_desync(struct wl_client *client,
|
2017-09-24 12:23:18 +00:00
|
|
|
struct wl_resource *resource) {
|
2018-02-13 22:48:46 +00:00
|
|
|
struct wlr_subsurface *subsurface = subsurface_from_resource(resource);
|
2018-04-30 21:20:11 +00:00
|
|
|
if (subsurface == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
2017-09-24 15:17:17 +00:00
|
|
|
|
2018-04-30 21:20:11 +00:00
|
|
|
if (subsurface->synchronized) {
|
2017-09-24 15:17:17 +00:00
|
|
|
subsurface->synchronized = false;
|
|
|
|
|
2021-12-03 20:14:13 +00:00
|
|
|
if (!subsurface_is_synchronized(subsurface) &&
|
|
|
|
subsurface->has_cache) {
|
|
|
|
wlr_surface_unlock_cached(subsurface->surface,
|
|
|
|
subsurface->cached_seq);
|
|
|
|
subsurface->has_cache = false;
|
2017-09-24 15:17:17 +00:00
|
|
|
}
|
|
|
|
}
|
2017-09-24 12:23:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct wl_subsurface_interface subsurface_implementation = {
|
2018-04-21 10:42:18 +00:00
|
|
|
.destroy = subsurface_handle_destroy,
|
2018-04-30 21:20:11 +00:00
|
|
|
.set_position = subsurface_handle_set_position,
|
|
|
|
.place_above = subsurface_handle_place_above,
|
|
|
|
.place_below = subsurface_handle_place_below,
|
|
|
|
.set_sync = subsurface_handle_set_sync,
|
|
|
|
.set_desync = subsurface_handle_set_desync,
|
2017-09-24 12:23:18 +00:00
|
|
|
};
|
|
|
|
|
2019-02-16 16:32:01 +00:00
|
|
|
/**
|
|
|
|
* Checks if this subsurface needs to be marked as mapped. This can happen if:
|
|
|
|
* - The subsurface has a buffer
|
|
|
|
* - Its parent is mapped
|
|
|
|
*/
|
|
|
|
static void subsurface_consider_map(struct wlr_subsurface *subsurface,
|
|
|
|
bool check_parent) {
|
|
|
|
if (subsurface->mapped || !wlr_surface_has_buffer(subsurface->surface)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (check_parent) {
|
|
|
|
if (subsurface->parent == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (wlr_surface_is_subsurface(subsurface->parent)) {
|
|
|
|
struct wlr_subsurface *parent =
|
|
|
|
wlr_subsurface_from_wlr_surface(subsurface->parent);
|
|
|
|
if (parent == NULL || !parent->mapped) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now we can map the subsurface
|
|
|
|
wlr_signal_emit_safe(&subsurface->events.map, subsurface);
|
|
|
|
subsurface->mapped = true;
|
|
|
|
|
|
|
|
// Try mapping all children too
|
|
|
|
struct wlr_subsurface *child;
|
2021-08-26 17:57:51 +00:00
|
|
|
wl_list_for_each(child, &subsurface->surface->current.subsurfaces_below,
|
2021-08-18 14:11:09 +00:00
|
|
|
current.link) {
|
2021-06-01 10:18:53 +00:00
|
|
|
subsurface_consider_map(child, false);
|
|
|
|
}
|
2021-08-26 17:57:51 +00:00
|
|
|
wl_list_for_each(child, &subsurface->surface->current.subsurfaces_above,
|
2021-08-18 14:11:09 +00:00
|
|
|
current.link) {
|
2019-02-16 16:32:01 +00:00
|
|
|
subsurface_consider_map(child, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void subsurface_unmap(struct wlr_subsurface *subsurface) {
|
|
|
|
if (!subsurface->mapped) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wlr_signal_emit_safe(&subsurface->events.unmap, subsurface);
|
|
|
|
subsurface->mapped = false;
|
|
|
|
|
|
|
|
// Unmap all children
|
|
|
|
struct wlr_subsurface *child;
|
2021-08-26 17:57:51 +00:00
|
|
|
wl_list_for_each(child, &subsurface->surface->current.subsurfaces_below,
|
2021-08-18 14:11:09 +00:00
|
|
|
current.link) {
|
2021-06-01 10:18:53 +00:00
|
|
|
subsurface_unmap(child);
|
|
|
|
}
|
2021-08-26 17:57:51 +00:00
|
|
|
wl_list_for_each(child, &subsurface->surface->current.subsurfaces_above,
|
2021-08-18 14:11:09 +00:00
|
|
|
current.link) {
|
2019-02-16 16:32:01 +00:00
|
|
|
subsurface_unmap(child);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-07 21:45:16 +00:00
|
|
|
static void subsurface_role_commit(struct wlr_surface *surface) {
|
|
|
|
struct wlr_subsurface *subsurface =
|
|
|
|
wlr_subsurface_from_wlr_surface(surface);
|
|
|
|
if (subsurface == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
2018-06-21 21:15:39 +00:00
|
|
|
|
2019-02-16 16:32:01 +00:00
|
|
|
subsurface_consider_map(subsurface, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void subsurface_role_precommit(struct wlr_surface *surface) {
|
|
|
|
struct wlr_subsurface *subsurface =
|
|
|
|
wlr_subsurface_from_wlr_surface(surface);
|
|
|
|
if (subsurface == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (surface->pending.committed & WLR_SURFACE_STATE_BUFFER &&
|
2021-08-11 15:34:34 +00:00
|
|
|
surface->pending.buffer == NULL) {
|
2019-02-16 16:32:01 +00:00
|
|
|
// This is a NULL commit
|
|
|
|
subsurface_unmap(subsurface);
|
|
|
|
}
|
2018-06-21 21:15:39 +00:00
|
|
|
}
|
|
|
|
|
2018-07-07 21:45:16 +00:00
|
|
|
const struct wlr_surface_role subsurface_role = {
|
|
|
|
.name = "wl_subsurface",
|
|
|
|
.commit = subsurface_role_commit,
|
2019-02-16 16:32:01 +00:00
|
|
|
.precommit = subsurface_role_precommit,
|
2018-07-07 21:45:16 +00:00
|
|
|
};
|
|
|
|
|
2017-09-30 17:24:59 +00:00
|
|
|
static void subsurface_handle_parent_destroy(struct wl_listener *listener,
|
|
|
|
void *data) {
|
|
|
|
struct wlr_subsurface *subsurface =
|
2018-04-21 17:40:25 +00:00
|
|
|
wl_container_of(listener, subsurface, parent_destroy);
|
2019-02-16 16:32:01 +00:00
|
|
|
subsurface_unmap(subsurface);
|
2021-08-18 14:11:09 +00:00
|
|
|
wl_list_remove(&subsurface->current.link);
|
|
|
|
wl_list_remove(&subsurface->pending.link);
|
2018-04-21 17:40:25 +00:00
|
|
|
wl_list_remove(&subsurface->parent_destroy.link);
|
2017-09-30 17:24:59 +00:00
|
|
|
subsurface->parent = NULL;
|
|
|
|
}
|
|
|
|
|
2018-04-21 17:40:25 +00:00
|
|
|
static void subsurface_handle_surface_destroy(struct wl_listener *listener,
|
|
|
|
void *data) {
|
|
|
|
struct wlr_subsurface *subsurface =
|
|
|
|
wl_container_of(listener, subsurface, surface_destroy);
|
2018-04-21 10:42:18 +00:00
|
|
|
subsurface_destroy(subsurface);
|
2018-04-21 17:40:25 +00:00
|
|
|
}
|
|
|
|
|
2021-06-29 11:41:47 +00:00
|
|
|
struct wlr_subsurface *subsurface_create(struct wlr_surface *surface,
|
|
|
|
struct wlr_surface *parent, uint32_t version, uint32_t id) {
|
2017-11-02 22:14:24 +00:00
|
|
|
struct wl_client *client = wl_resource_get_client(surface->resource);
|
2017-09-24 12:23:18 +00:00
|
|
|
|
|
|
|
struct wlr_subsurface *subsurface =
|
|
|
|
calloc(1, sizeof(struct wlr_subsurface));
|
|
|
|
if (!subsurface) {
|
2017-11-02 22:14:24 +00:00
|
|
|
wl_client_post_no_memory(client);
|
2018-04-24 22:31:58 +00:00
|
|
|
return NULL;
|
2017-09-24 12:23:18 +00:00
|
|
|
}
|
2017-09-30 17:24:59 +00:00
|
|
|
subsurface->synchronized = true;
|
2017-09-24 12:23:18 +00:00
|
|
|
subsurface->surface = surface;
|
2018-04-26 16:51:06 +00:00
|
|
|
subsurface->resource =
|
|
|
|
wl_resource_create(client, &wl_subsurface_interface, version, id);
|
|
|
|
if (subsurface->resource == NULL) {
|
|
|
|
free(subsurface);
|
|
|
|
wl_client_post_no_memory(client);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
wl_resource_set_implementation(subsurface->resource,
|
2021-06-29 11:41:47 +00:00
|
|
|
&subsurface_implementation, subsurface, subsurface_resource_destroy);
|
2018-04-26 16:51:06 +00:00
|
|
|
|
2018-01-21 13:22:33 +00:00
|
|
|
wl_signal_init(&subsurface->events.destroy);
|
2019-02-16 16:32:01 +00:00
|
|
|
wl_signal_init(&subsurface->events.map);
|
|
|
|
wl_signal_init(&subsurface->events.unmap);
|
2018-04-26 16:51:06 +00:00
|
|
|
|
2018-04-21 17:40:25 +00:00
|
|
|
wl_signal_add(&surface->events.destroy, &subsurface->surface_destroy);
|
|
|
|
subsurface->surface_destroy.notify = subsurface_handle_surface_destroy;
|
2017-09-30 17:24:59 +00:00
|
|
|
|
|
|
|
// link parent
|
2017-09-24 12:23:18 +00:00
|
|
|
subsurface->parent = parent;
|
2018-04-21 17:40:25 +00:00
|
|
|
wl_signal_add(&parent->events.destroy, &subsurface->parent_destroy);
|
|
|
|
subsurface->parent_destroy.notify = subsurface_handle_parent_destroy;
|
2021-12-06 11:59:00 +00:00
|
|
|
|
|
|
|
wl_list_init(&subsurface->current.link);
|
2021-08-26 17:57:51 +00:00
|
|
|
wl_list_insert(parent->pending.subsurfaces_above.prev,
|
2021-08-18 14:11:09 +00:00
|
|
|
&subsurface->pending.link);
|
2017-09-24 12:23:18 +00:00
|
|
|
|
2018-07-07 21:45:16 +00:00
|
|
|
surface->role_data = subsurface;
|
2018-01-21 13:22:33 +00:00
|
|
|
|
2018-04-24 22:31:58 +00:00
|
|
|
return subsurface;
|
2017-09-24 12:23:18 +00:00
|
|
|
}
|
2017-09-29 12:58:17 +00:00
|
|
|
|
2018-02-19 23:01:27 +00:00
|
|
|
|
2018-04-04 20:48:23 +00:00
|
|
|
struct wlr_surface *wlr_surface_get_root_surface(struct wlr_surface *surface) {
|
2018-04-21 17:40:25 +00:00
|
|
|
while (wlr_surface_is_subsurface(surface)) {
|
|
|
|
struct wlr_subsurface *subsurface =
|
2018-06-30 09:13:30 +00:00
|
|
|
wlr_subsurface_from_wlr_surface(surface);
|
2018-11-26 22:16:40 +00:00
|
|
|
if (subsurface == NULL) {
|
|
|
|
break;
|
|
|
|
}
|
2020-12-13 15:07:31 +00:00
|
|
|
if (subsurface->parent == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2018-06-04 15:17:01 +00:00
|
|
|
surface = subsurface->parent;
|
2017-09-29 12:58:17 +00:00
|
|
|
}
|
2018-04-21 17:40:25 +00:00
|
|
|
return surface;
|
2017-09-29 12:58:17 +00:00
|
|
|
}
|
2017-10-09 20:51:55 +00:00
|
|
|
|
2018-04-04 21:16:35 +00:00
|
|
|
bool wlr_surface_point_accepts_input(struct wlr_surface *surface,
|
|
|
|
double sx, double sy) {
|
2018-06-21 21:39:26 +00:00
|
|
|
return sx >= 0 && sx < surface->current.width &&
|
|
|
|
sy >= 0 && sy < surface->current.height &&
|
2018-09-18 11:05:44 +00:00
|
|
|
pixman_region32_contains_point(&surface->current.input, floor(sx), floor(sy), NULL);
|
2018-04-04 21:16:35 +00:00
|
|
|
}
|
|
|
|
|
2018-04-04 20:48:23 +00:00
|
|
|
struct wlr_surface *wlr_surface_surface_at(struct wlr_surface *surface,
|
2017-10-09 20:51:55 +00:00
|
|
|
double sx, double sy, double *sub_x, double *sub_y) {
|
|
|
|
struct wlr_subsurface *subsurface;
|
2021-08-26 17:57:51 +00:00
|
|
|
wl_list_for_each_reverse(subsurface, &surface->current.subsurfaces_above,
|
2021-08-18 14:11:09 +00:00
|
|
|
current.link) {
|
2021-09-28 10:51:10 +00:00
|
|
|
if (!subsurface->mapped) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-06-21 21:15:39 +00:00
|
|
|
double _sub_x = subsurface->current.x;
|
|
|
|
double _sub_y = subsurface->current.y;
|
2018-04-04 20:48:23 +00:00
|
|
|
struct wlr_surface *sub = wlr_surface_surface_at(subsurface->surface,
|
|
|
|
sx - _sub_x, sy - _sub_y, sub_x, sub_y);
|
|
|
|
if (sub != NULL) {
|
2017-10-09 20:51:55 +00:00
|
|
|
return sub;
|
|
|
|
}
|
2018-04-04 20:48:23 +00:00
|
|
|
}
|
2017-10-09 20:51:55 +00:00
|
|
|
|
2018-04-04 20:48:23 +00:00
|
|
|
if (wlr_surface_point_accepts_input(surface, sx, sy)) {
|
2019-11-08 07:10:43 +00:00
|
|
|
if (sub_x) {
|
|
|
|
*sub_x = sx;
|
|
|
|
}
|
|
|
|
if (sub_y) {
|
|
|
|
*sub_y = sy;
|
|
|
|
}
|
2018-04-04 20:48:23 +00:00
|
|
|
return surface;
|
2017-10-09 20:51:55 +00:00
|
|
|
}
|
|
|
|
|
2021-08-26 17:57:51 +00:00
|
|
|
wl_list_for_each_reverse(subsurface, &surface->current.subsurfaces_below,
|
2021-08-18 14:11:09 +00:00
|
|
|
current.link) {
|
2021-09-28 10:51:10 +00:00
|
|
|
if (!subsurface->mapped) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2021-06-01 10:18:53 +00:00
|
|
|
double _sub_x = subsurface->current.x;
|
|
|
|
double _sub_y = subsurface->current.y;
|
|
|
|
struct wlr_surface *sub = wlr_surface_surface_at(subsurface->surface,
|
|
|
|
sx - _sub_x, sy - _sub_y, sub_x, sub_y);
|
|
|
|
if (sub != NULL) {
|
|
|
|
return sub;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-09 20:51:55 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2017-10-23 03:19:21 +00:00
|
|
|
|
2020-11-07 21:08:40 +00:00
|
|
|
static void surface_output_destroy(struct wlr_surface_output *surface_output) {
|
|
|
|
wl_list_remove(&surface_output->bind.link);
|
|
|
|
wl_list_remove(&surface_output->destroy.link);
|
|
|
|
wl_list_remove(&surface_output->link);
|
|
|
|
|
|
|
|
free(surface_output);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void surface_handle_output_bind(struct wl_listener *listener,
|
|
|
|
void *data) {
|
|
|
|
struct wlr_output_event_bind *evt = data;
|
|
|
|
struct wlr_surface_output *surface_output =
|
|
|
|
wl_container_of(listener, surface_output, bind);
|
|
|
|
struct wl_client *client = wl_resource_get_client(
|
|
|
|
surface_output->surface->resource);
|
|
|
|
if (client == wl_resource_get_client(evt->resource)) {
|
|
|
|
wl_surface_send_enter(surface_output->surface->resource, evt->resource);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void surface_handle_output_destroy(struct wl_listener *listener,
|
|
|
|
void *data) {
|
|
|
|
struct wlr_surface_output *surface_output =
|
|
|
|
wl_container_of(listener, surface_output, destroy);
|
|
|
|
surface_output_destroy(surface_output);
|
|
|
|
}
|
|
|
|
|
2017-10-23 03:19:21 +00:00
|
|
|
void wlr_surface_send_enter(struct wlr_surface *surface,
|
|
|
|
struct wlr_output *output) {
|
|
|
|
struct wl_client *client = wl_resource_get_client(surface->resource);
|
2020-11-07 21:08:40 +00:00
|
|
|
struct wlr_surface_output *surface_output;
|
2017-10-23 03:19:21 +00:00
|
|
|
struct wl_resource *resource;
|
2020-11-07 21:08:40 +00:00
|
|
|
|
|
|
|
wl_list_for_each(surface_output, &surface->current_outputs, link) {
|
|
|
|
if (surface_output->output == output) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
surface_output = calloc(1, sizeof(struct wlr_surface_output));
|
|
|
|
if (surface_output == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
surface_output->bind.notify = surface_handle_output_bind;
|
|
|
|
surface_output->destroy.notify = surface_handle_output_destroy;
|
|
|
|
|
|
|
|
wl_signal_add(&output->events.bind, &surface_output->bind);
|
|
|
|
wl_signal_add(&output->events.destroy, &surface_output->destroy);
|
|
|
|
|
|
|
|
surface_output->surface = surface;
|
|
|
|
surface_output->output = output;
|
|
|
|
wl_list_insert(&surface->current_outputs, &surface_output->link);
|
|
|
|
|
2018-07-08 18:21:31 +00:00
|
|
|
wl_resource_for_each(resource, &output->resources) {
|
2017-10-23 03:19:21 +00:00
|
|
|
if (client == wl_resource_get_client(resource)) {
|
|
|
|
wl_surface_send_enter(surface->resource, resource);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-10-26 02:37:02 +00:00
|
|
|
|
|
|
|
void wlr_surface_send_leave(struct wlr_surface *surface,
|
|
|
|
struct wlr_output *output) {
|
|
|
|
struct wl_client *client = wl_resource_get_client(surface->resource);
|
2020-11-07 21:08:40 +00:00
|
|
|
struct wlr_surface_output *surface_output, *tmp;
|
2017-10-26 02:37:02 +00:00
|
|
|
struct wl_resource *resource;
|
2020-11-07 21:08:40 +00:00
|
|
|
|
|
|
|
wl_list_for_each_safe(surface_output, tmp,
|
|
|
|
&surface->current_outputs, link) {
|
|
|
|
if (surface_output->output == output) {
|
|
|
|
surface_output_destroy(surface_output);
|
|
|
|
wl_resource_for_each(resource, &output->resources) {
|
|
|
|
if (client == wl_resource_get_client(resource)) {
|
|
|
|
wl_surface_send_leave(surface->resource, resource);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2017-10-26 02:37:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-11-20 19:53:13 +00:00
|
|
|
|
|
|
|
void wlr_surface_send_frame_done(struct wlr_surface *surface,
|
|
|
|
const struct timespec *when) {
|
2018-06-20 19:00:23 +00:00
|
|
|
struct wl_resource *resource, *tmp;
|
|
|
|
wl_resource_for_each_safe(resource, tmp,
|
2018-06-21 21:39:26 +00:00
|
|
|
&surface->current.frame_callback_list) {
|
2018-06-20 19:00:23 +00:00
|
|
|
wl_callback_send_done(resource, timespec_to_msec(when));
|
|
|
|
wl_resource_destroy(resource);
|
2017-11-20 19:53:13 +00:00
|
|
|
}
|
|
|
|
}
|
2017-12-27 11:06:29 +00:00
|
|
|
|
2018-04-05 00:10:47 +00:00
|
|
|
static void surface_for_each_surface(struct wlr_surface *surface, int x, int y,
|
|
|
|
wlr_surface_iterator_func_t iterator, void *user_data) {
|
2021-06-01 10:18:53 +00:00
|
|
|
struct wlr_subsurface *subsurface;
|
2021-08-26 17:57:51 +00:00
|
|
|
wl_list_for_each(subsurface, &surface->current.subsurfaces_below, current.link) {
|
2021-09-25 16:40:12 +00:00
|
|
|
if (!subsurface->mapped) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2021-08-18 14:40:54 +00:00
|
|
|
struct wlr_subsurface_parent_state *state = &subsurface->current;
|
2021-06-01 10:18:53 +00:00
|
|
|
int sx = state->x;
|
|
|
|
int sy = state->y;
|
|
|
|
|
|
|
|
surface_for_each_surface(subsurface->surface, x + sx, y + sy,
|
|
|
|
iterator, user_data);
|
|
|
|
}
|
|
|
|
|
2018-04-05 00:10:47 +00:00
|
|
|
iterator(surface, x, y, user_data);
|
|
|
|
|
2021-08-26 17:57:51 +00:00
|
|
|
wl_list_for_each(subsurface, &surface->current.subsurfaces_above, current.link) {
|
2021-09-25 16:40:12 +00:00
|
|
|
if (!subsurface->mapped) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2021-08-18 14:40:54 +00:00
|
|
|
struct wlr_subsurface_parent_state *state = &subsurface->current;
|
2018-06-21 21:15:39 +00:00
|
|
|
int sx = state->x;
|
|
|
|
int sy = state->y;
|
2018-04-05 00:10:47 +00:00
|
|
|
|
|
|
|
surface_for_each_surface(subsurface->surface, x + sx, y + sy,
|
|
|
|
iterator, user_data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void wlr_surface_for_each_surface(struct wlr_surface *surface,
|
|
|
|
wlr_surface_iterator_func_t iterator, void *user_data) {
|
|
|
|
surface_for_each_surface(surface, 0, 0, iterator, user_data);
|
|
|
|
}
|
2018-06-01 11:27:10 +00:00
|
|
|
|
|
|
|
struct bound_acc {
|
|
|
|
int32_t min_x, min_y;
|
|
|
|
int32_t max_x, max_y;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void handle_bounding_box_surface(struct wlr_surface *surface,
|
|
|
|
int x, int y, void *data) {
|
|
|
|
struct bound_acc *acc = data;
|
|
|
|
|
|
|
|
acc->min_x = min(x, acc->min_x);
|
2018-06-01 14:36:04 +00:00
|
|
|
acc->min_y = min(y, acc->min_y);
|
2018-06-01 11:27:10 +00:00
|
|
|
|
2018-06-21 21:39:26 +00:00
|
|
|
acc->max_x = max(x + surface->current.width, acc->max_x);
|
|
|
|
acc->max_y = max(y + surface->current.height, acc->max_y);
|
2018-06-01 11:27:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void wlr_surface_get_extends(struct wlr_surface *surface, struct wlr_box *box) {
|
|
|
|
struct bound_acc acc = {
|
|
|
|
.min_x = 0,
|
|
|
|
.min_y = 0,
|
2018-06-21 21:39:26 +00:00
|
|
|
.max_x = surface->current.width,
|
|
|
|
.max_y = surface->current.height,
|
2018-06-01 11:27:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
wlr_surface_for_each_surface(surface, handle_bounding_box_surface, &acc);
|
|
|
|
|
|
|
|
box->x = acc.min_x;
|
|
|
|
box->y = acc.min_y;
|
|
|
|
box->width = acc.max_x - acc.min_x;
|
|
|
|
box->height = acc.max_y - acc.min_y;
|
|
|
|
}
|
2018-10-03 20:31:04 +00:00
|
|
|
|
2020-03-31 13:18:49 +00:00
|
|
|
static void crop_region(pixman_region32_t *dst, pixman_region32_t *src,
|
|
|
|
const struct wlr_box *box) {
|
|
|
|
pixman_region32_intersect_rect(dst, src,
|
|
|
|
box->x, box->y, box->width, box->height);
|
|
|
|
pixman_region32_translate(dst, -box->x, -box->y);
|
|
|
|
}
|
|
|
|
|
2018-10-03 20:31:04 +00:00
|
|
|
void wlr_surface_get_effective_damage(struct wlr_surface *surface,
|
|
|
|
pixman_region32_t *damage) {
|
|
|
|
pixman_region32_clear(damage);
|
|
|
|
|
|
|
|
// Transform and copy the buffer damage in terms of surface coordinates.
|
|
|
|
wlr_region_transform(damage, &surface->buffer_damage,
|
|
|
|
surface->current.transform, surface->current.buffer_width,
|
|
|
|
surface->current.buffer_height);
|
2018-11-04 10:08:06 +00:00
|
|
|
wlr_region_scale(damage, damage, 1.0 / (float)surface->current.scale);
|
2018-10-03 20:31:04 +00:00
|
|
|
|
2020-03-31 13:18:49 +00:00
|
|
|
if (surface->current.viewport.has_src) {
|
|
|
|
struct wlr_box src_box = {
|
|
|
|
.x = floor(surface->current.viewport.src.x),
|
|
|
|
.y = floor(surface->current.viewport.src.y),
|
|
|
|
.width = ceil(surface->current.viewport.src.width),
|
|
|
|
.height = ceil(surface->current.viewport.src.height),
|
|
|
|
};
|
|
|
|
crop_region(damage, damage, &src_box);
|
|
|
|
}
|
|
|
|
if (surface->current.viewport.has_dst) {
|
|
|
|
int src_width, src_height;
|
|
|
|
surface_state_viewport_src_size(&surface->current,
|
|
|
|
&src_width, &src_height);
|
|
|
|
float scale_x = (float)surface->current.viewport.dst_width / src_width;
|
|
|
|
float scale_y = (float)surface->current.viewport.dst_height / src_height;
|
|
|
|
wlr_region_scale_xy(damage, damage, scale_x, scale_y);
|
|
|
|
}
|
|
|
|
|
2021-12-04 17:05:32 +00:00
|
|
|
pixman_region32_union(damage, damage, &surface->external_damage);
|
2018-10-03 20:31:04 +00:00
|
|
|
}
|
2020-06-08 15:35:21 +00:00
|
|
|
|
|
|
|
void wlr_surface_get_buffer_source_box(struct wlr_surface *surface,
|
|
|
|
struct wlr_fbox *box) {
|
|
|
|
box->x = box->y = 0;
|
|
|
|
box->width = surface->current.buffer_width;
|
|
|
|
box->height = surface->current.buffer_height;
|
|
|
|
|
|
|
|
if (surface->current.viewport.has_src) {
|
|
|
|
box->x = surface->current.viewport.src.x * surface->current.scale;
|
|
|
|
box->y = surface->current.viewport.src.y * surface->current.scale;
|
|
|
|
box->width = surface->current.viewport.src.width * surface->current.scale;
|
|
|
|
box->height = surface->current.viewport.src.height * surface->current.scale;
|
2021-11-20 10:30:18 +00:00
|
|
|
|
|
|
|
int width, height;
|
|
|
|
surface_state_transformed_buffer_size(&surface->current, &width, &height);
|
|
|
|
wlr_fbox_transform(box, box,
|
|
|
|
wlr_output_transform_invert(surface->current.transform),
|
|
|
|
width, height);
|
2020-06-08 15:35:21 +00:00
|
|
|
}
|
|
|
|
}
|