mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-23 02:19:49 +01:00
surface: implement wl_surface.offset
References: https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/123
This commit is contained in:
parent
42d68d7532
commit
c2359d0321
1 changed files with 27 additions and 6 deletions
|
@ -15,7 +15,7 @@
|
|||
#include "util/signal.h"
|
||||
#include "util/time.h"
|
||||
|
||||
#define COMPOSITOR_VERSION 4
|
||||
#define COMPOSITOR_VERSION 5
|
||||
#define CALLBACK_VERSION 1
|
||||
|
||||
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 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;
|
||||
if (buffer_resource != NULL) {
|
||||
buffer = wlr_buffer_from_resource(buffer_resource);
|
||||
|
@ -53,13 +61,16 @@ static void surface_handle_attach(struct wl_client *client,
|
|||
}
|
||||
}
|
||||
|
||||
surface->pending.committed |=
|
||||
WLR_SURFACE_STATE_BUFFER | WLR_SURFACE_STATE_OFFSET;
|
||||
surface->pending.dx = dx;
|
||||
surface->pending.dy = dy;
|
||||
surface->pending.committed |= WLR_SURFACE_STATE_BUFFER;
|
||||
|
||||
wlr_buffer_unlock(surface->pending.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,
|
||||
|
@ -578,6 +589,15 @@ static void surface_handle_damage_buffer(struct wl_client *client,
|
|||
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 = {
|
||||
.destroy = surface_handle_destroy,
|
||||
.attach = surface_handle_attach,
|
||||
|
@ -588,7 +608,8 @@ static const struct wl_surface_interface surface_implementation = {
|
|||
.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
|
||||
.damage_buffer = surface_handle_damage_buffer,
|
||||
.offset = surface_handle_offset,
|
||||
};
|
||||
|
||||
struct wlr_surface *wlr_surface_from_resource(struct wl_resource *resource) {
|
||||
|
|
Loading…
Reference in a new issue