From 258bf9be1e44d8a2fb953d727ff4ffcf9ebd6503 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 15 Nov 2022 11:56:45 +0100 Subject: compositor: drop wlr_surface.{sx,sy} The concept of a persistent accumulated surface offset is wrong from a protocol point-of-view. wl_surface.offset is tied to a commit, its interpretation depends on the surface role. For example, with the following sequence: wl_surface@1.offset(1, 1) wl_surface@1.commit() wl_pointer@2.set_cursor(wl_surface@1, 42, 42) The final cursor hotspot is (42, 42): the commit which happened before the set_cursor request has no impact on the hotspot computation. The wlr_output_cursor logic already uses wlr_surface.current.{dx,dy}. wlr_scene's drag icon doesn't, update it accordingly. --- include/wlr/types/wlr_compositor.h | 4 ---- types/scene/drag_icon.c | 7 +++---- types/wlr_compositor.c | 2 -- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/include/wlr/types/wlr_compositor.h b/include/wlr/types/wlr_compositor.h index f3da622b..194c4e37 100644 --- a/include/wlr/types/wlr_compositor.h +++ b/include/wlr/types/wlr_compositor.h @@ -98,10 +98,6 @@ struct wlr_surface { * or something went wrong with uploading the buffer. */ struct wlr_client_buffer *buffer; - /** - * The buffer position, in surface-local units. - */ - int sx, sy; /** * The last commit's buffer damage, in buffer-local coordinates. This * contains both the damage accumulated by the client via diff --git a/types/scene/drag_icon.c b/types/scene/drag_icon.c index 8c28e1a0..15b6b45b 100644 --- a/types/scene/drag_icon.c +++ b/types/scene/drag_icon.c @@ -18,8 +18,9 @@ static void drag_icon_handle_surface_commit(struct wl_listener *listener, void * struct wlr_scene_drag_icon *icon = wl_container_of(listener, icon, drag_icon_surface_commit); struct wlr_surface *surface = icon->drag_icon->surface; - wlr_scene_node_set_position(&icon->surface_tree->node, - surface->sx, surface->sy); + struct wlr_scene_node *node = &icon->surface_tree->node; + wlr_scene_node_set_position(node, + node->x + surface->current.dx, node->y + surface->current.dy); } static void drag_icon_handle_map(struct wl_listener *listener, void *data) { @@ -74,8 +75,6 @@ struct wlr_scene_tree *wlr_scene_drag_icon_create( return NULL; } - wlr_scene_node_set_position(&icon->surface_tree->node, - drag_icon->surface->sx, drag_icon->surface->sy); wlr_scene_node_set_enabled(&icon->tree->node, drag_icon->mapped); icon->tree_destroy.notify = drag_icon_handle_tree_destroy; diff --git a/types/wlr_compositor.c b/types/wlr_compositor.c index d5e5fd0e..3362777f 100644 --- a/types/wlr_compositor.c +++ b/types/wlr_compositor.c @@ -439,8 +439,6 @@ static void surface_commit_state(struct wlr_surface *surface, 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); pixman_region32_clear(&surface->external_damage); -- cgit v1.2.3