From: Johan Malm Date: Tue, 22 Dec 2020 21:08:17 +0000 (+0000) Subject: xdg-shell: await configure serial before moving (issue #11) X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=7c29bcb45ed7b8309b87f0a02d41eed387486228;p=proto%2Flabwc.git xdg-shell: await configure serial before moving (issue #11) --- diff --git a/include/labwc.h b/include/labwc.h index 0c9993c7..0760bec6 100644 --- a/include/labwc.h +++ b/include/labwc.h @@ -181,6 +181,13 @@ struct view { */ struct border margin; + struct { + bool update_x, update_y; + double x, y; + uint32_t width, height; + uint32_t configure_serial; + } pending_move_resize; + int xdg_grab_offset; bool server_side_deco; diff --git a/src/xdg.c b/src/xdg.c index 81a296d1..62c3f365 100644 --- a/src/xdg.c +++ b/src/xdg.c @@ -75,8 +75,26 @@ handle_commit(struct wl_listener *listener, void *data) { struct view *view = wl_container_of(listener, view, commit); assert(view->surface); - view->w = view->surface->current.width; - view->h = view->surface->current.height; + struct wlr_box size; + wlr_xdg_surface_get_geometry(view->xdg_surface, &size); + + view->w = size.width; + view->h = size.height; + + uint32_t serial = view->pending_move_resize.configure_serial; + if (serial > 0 && serial >= view->xdg_surface->configure_serial) { + if (view->pending_move_resize.update_x) { + view->x = view->pending_move_resize.x + + view->pending_move_resize.width - size.width; + } + if (view->pending_move_resize.update_y) { + view->y = view->pending_move_resize.y + + view->pending_move_resize.height - size.height; + } + if (serial == view->xdg_surface->configure_serial) { + view->pending_move_resize.configure_serial = 0; + } + } } static void @@ -133,10 +151,21 @@ handle_request_resize(struct wl_listener *listener, void *data) static void xdg_toplevel_view_configure(struct view *view, struct wlr_box geo) { - view->x = geo.x; - view->y = geo.y; - wlr_xdg_toplevel_set_size(view->xdg_surface, (uint32_t)geo.width, - (uint32_t)geo.height); + view->pending_move_resize.update_x = geo.x != view->x; + view->pending_move_resize.update_y = geo.y != view->y; + view->pending_move_resize.x = geo.x; + view->pending_move_resize.y = geo.y; + view->pending_move_resize.width = geo.width; + view->pending_move_resize.height = geo.height; + + uint32_t serial = wlr_xdg_toplevel_set_size(view->xdg_surface, + (uint32_t)geo.width, (uint32_t)geo.height); + if (serial > 0) { + view->pending_move_resize.configure_serial = serial; + } else if (view->pending_move_resize.configure_serial == 0) { + view->x = geo.x; + view->y = geo.y; + } } static void