Simon Ser 3 years ago
parent 42d68d7532
commit c2359d0321

@ -15,7 +15,7 @@
#include "util/signal.h" #include "util/signal.h"
#include "util/time.h" #include "util/time.h"
#define COMPOSITOR_VERSION 4 #define COMPOSITOR_VERSION 5
#define CALLBACK_VERSION 1 #define CALLBACK_VERSION 1
static int min(int fst, int snd) { static int min(int fst, int snd) {
@ -44,6 +44,14 @@ static void surface_handle_attach(struct wl_client *client,
struct wl_resource *buffer_resource, int32_t dx, int32_t dy) { struct wl_resource *buffer_resource, int32_t dx, int32_t dy) {
struct wlr_surface *surface = wlr_surface_from_resource(resource); struct wlr_surface *surface = wlr_surface_from_resource(resource);
if (wl_resource_get_version(resource) >= WL_SURFACE_OFFSET_SINCE_VERSION &&
(dx != 0 || dy != 0)) {
wl_resource_post_error(resource, WL_SURFACE_ERROR_INVALID_OFFSET,
"Offset must be zero on wl_surface.attach version >= %"PRIu32,
WL_SURFACE_OFFSET_SINCE_VERSION);
return;
}
struct wlr_buffer *buffer = NULL; struct wlr_buffer *buffer = NULL;
if (buffer_resource != NULL) { if (buffer_resource != NULL) {
buffer = wlr_buffer_from_resource(buffer_resource); buffer = wlr_buffer_from_resource(buffer_resource);
@ -53,13 +61,16 @@ static void surface_handle_attach(struct wl_client *client,
} }
} }
surface->pending.committed |= surface->pending.committed |= WLR_SURFACE_STATE_BUFFER;
WLR_SURFACE_STATE_BUFFER | WLR_SURFACE_STATE_OFFSET;
surface->pending.dx = dx;
surface->pending.dy = dy;
wlr_buffer_unlock(surface->pending.buffer); wlr_buffer_unlock(surface->pending.buffer);
surface->pending.buffer = buffer; surface->pending.buffer = buffer;
if (wl_resource_get_version(resource) < WL_SURFACE_OFFSET_SINCE_VERSION) {
surface->pending.committed |= WLR_SURFACE_STATE_OFFSET;
surface->pending.dx = dx;
surface->pending.dy = dy;
}
} }
static void surface_handle_damage(struct wl_client *client, static void surface_handle_damage(struct wl_client *client,
@ -578,6 +589,15 @@ static void surface_handle_damage_buffer(struct wl_client *client,
x, y, width, height); x, y, width, height);
} }
static void surface_handle_offset(struct wl_client *client,
struct wl_resource *resource, int32_t x, int32_t y) {
struct wlr_surface *surface = wlr_surface_from_resource(resource);
surface->pending.committed |= WLR_SURFACE_STATE_OFFSET;
surface->pending.dx = x;
surface->pending.dy = y;
}
static const struct wl_surface_interface surface_implementation = { static const struct wl_surface_interface surface_implementation = {
.destroy = surface_handle_destroy, .destroy = surface_handle_destroy,
.attach = surface_handle_attach, .attach = surface_handle_attach,
@ -588,7 +608,8 @@ static const struct wl_surface_interface surface_implementation = {
.commit = surface_handle_commit, .commit = surface_handle_commit,
.set_buffer_transform = surface_handle_set_buffer_transform, .set_buffer_transform = surface_handle_set_buffer_transform,
.set_buffer_scale = surface_handle_set_buffer_scale, .set_buffer_scale = surface_handle_set_buffer_scale,
.damage_buffer = surface_handle_damage_buffer .damage_buffer = surface_handle_damage_buffer,
.offset = surface_handle_offset,
}; };
struct wlr_surface *wlr_surface_from_resource(struct wl_resource *resource) { struct wlr_surface *wlr_surface_from_resource(struct wl_resource *resource) {

Loading…
Cancel
Save