xdg-surface: fix window geometry handling

It was completely wrong: according to the protocol, the effective
geometry is only updated on commit time if there pending state has
new state from xdg_surface.set_window_geometry or
xdg_surface.set_window_geometry has never been sent at all.

This commit adds wlr_xdg_surface.geometry which correctly matches the
effective window geometry and removes now-useless
wlr_xdg_surface_get_geometry().
This commit is contained in:
Kirill Primak 2024-08-14 18:25:03 +03:00 committed by Alexander Orzechowski
parent a1298580cc
commit 5c98d1a04a
6 changed files with 62 additions and 52 deletions

View file

@ -427,10 +427,9 @@ static void process_cursor_resize(struct tinywl_server *server, uint32_t time) {
}
}
struct wlr_box geo_box;
wlr_xdg_surface_get_geometry(toplevel->xdg_toplevel->base, &geo_box);
struct wlr_box *geo_box = &toplevel->xdg_toplevel->base->geometry;
wlr_scene_node_set_position(&toplevel->scene_tree->node,
new_left - geo_box.x, new_top - geo_box.y);
new_left - geo_box->x, new_top - geo_box->y);
int new_width = new_right - new_left;
int new_height = new_bottom - new_top;
@ -727,17 +726,16 @@ static void begin_interactive(struct tinywl_toplevel *toplevel,
server->grab_x = server->cursor->x - toplevel->scene_tree->node.x;
server->grab_y = server->cursor->y - toplevel->scene_tree->node.y;
} else {
struct wlr_box geo_box;
wlr_xdg_surface_get_geometry(toplevel->xdg_toplevel->base, &geo_box);
struct wlr_box *geo_box = &toplevel->xdg_toplevel->base->geometry;
double border_x = (toplevel->scene_tree->node.x + geo_box.x) +
((edges & WLR_EDGE_RIGHT) ? geo_box.width : 0);
double border_y = (toplevel->scene_tree->node.y + geo_box.y) +
((edges & WLR_EDGE_BOTTOM) ? geo_box.height : 0);
double border_x = (toplevel->scene_tree->node.x + geo_box->x) +
((edges & WLR_EDGE_RIGHT) ? geo_box->width : 0);
double border_y = (toplevel->scene_tree->node.y + geo_box->y) +
((edges & WLR_EDGE_BOTTOM) ? geo_box->height : 0);
server->grab_x = server->cursor->x - border_x;
server->grab_y = server->cursor->y - border_y;
server->grab_geobox = geo_box;
server->grab_geobox = *geo_box;
server->grab_geobox.x += toplevel->scene_tree->node.x;
server->grab_geobox.y += toplevel->scene_tree->node.y;