wayland/surface: Add support for wl_surface.offset

This aims to replace the x,y arguments in wl_surface.attach(); meaning
it can be used more sanely together with EGL, and at all when using
Vulkan.

The most common use case for the offset is setting the hotspot of DND
surfaces.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1905>
This commit is contained in:
Jonas Ådahl 2021-03-22 11:49:11 +01:00
parent fadffe3fad
commit 370de58868
4 changed files with 35 additions and 5 deletions

View File

@ -17,7 +17,7 @@ variables:
.mutter.fedora:35@common:
variables:
FDO_DISTRIBUTION_VERSION: 35
BASE_TAG: '2022-03-04.0'
BASE_TAG: '2022-03-04.1'
FDO_DISTRIBUTION_PACKAGES:
asciidoc
clang
@ -39,6 +39,7 @@ variables:
dnf builddep -y mutter --setopt=install_weak_deps=False &&
dnf builddep -y gnome-shell --setopt=install_weak_deps=False &&
dnf builddep -y libinput --setopt=install_weak_deps=False &&
dnf builddep -y wayland --setopt=install_weak_deps=False &&
dnf builddep -y wayland-protocols --setopt=install_weak_deps=False &&
# For Xwayland
@ -68,6 +69,10 @@ variables:
https://gitlab.gnome.org/GNOME/gsettings-desktop-schemas.git \
42.beta . &&
./.gitlab-ci/install-meson-project.sh \
https://gitlab.freedesktop.org/wayland/wayland.git \
1.20.0 . &&
./.gitlab-ci/install-meson-project.sh \
https://gitlab.freedesktop.org/wayland/wayland-protocols.git \
1.25 . &&

View File

@ -40,7 +40,7 @@ udev_req = '>= 228'
gudev_req = '>= 232'
# wayland version requirements
wayland_server_req = '>= 1.18'
wayland_server_req = '>= 1.20'
wayland_protocols_req = '>= 1.25'
# native backend version requirements

View File

@ -553,10 +553,11 @@ meta_wayland_surface_state_merge_into (MetaWaylandSurfaceState *from,
to->newly_attached = TRUE;
to->buffer = from->buffer;
to->dx = from->dx;
to->dy = from->dy;
}
to->dx += from->dx;
to->dy += from->dy;
wl_list_insert_list (&to->frame_callback_list, &from->frame_callback_list);
wl_list_init (&from->frame_callback_list);
@ -1055,6 +1056,16 @@ wl_surface_attach (struct wl_client *client,
pending->buffer);
}
if (wl_resource_get_version (surface_resource) >=
WL_SURFACE_OFFSET_SINCE_VERSION &&
(dx != 0 || dy != 0))
{
wl_resource_post_error (surface_resource,
WL_SURFACE_ERROR_INVALID_OFFSET,
"Attaching with an offset is no longer allowed");
return;
}
pending->newly_attached = TRUE;
pending->buffer = buffer;
pending->dx = dx;
@ -1259,6 +1270,19 @@ wl_surface_damage_buffer (struct wl_client *client,
cairo_region_union_rectangle (pending->buffer_damage, &rectangle);
}
static void
wl_surface_offset (struct wl_client *client,
struct wl_resource *surface_resource,
int32_t dx,
int32_t dy)
{
MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource);
MetaWaylandSurfaceState *pending = surface->pending_state;
pending->dx = dx;
pending->dy = dy;
}
static const struct wl_surface_interface meta_wayland_wl_surface_interface = {
wl_surface_destroy,
wl_surface_attach,
@ -1270,6 +1294,7 @@ static const struct wl_surface_interface meta_wayland_wl_surface_interface = {
wl_surface_set_buffer_transform,
wl_surface_set_buffer_scale,
wl_surface_damage_buffer,
wl_surface_offset,
};
static void

View File

@ -35,7 +35,7 @@
/* #define META_WL_BUFFER_VERSION 1 */
/* Global/master objects (version exported by wl_registry and negotiated through bind) */
#define META_WL_COMPOSITOR_VERSION 4
#define META_WL_COMPOSITOR_VERSION 5
#define META_WL_DATA_DEVICE_MANAGER_VERSION 3
#define META_XDG_WM_BASE_VERSION 4
#define META_ZXDG_SHELL_V6_VERSION 1