diff --git a/include/wlr/types/wlr_xdg_shell.h b/include/wlr/types/wlr_xdg_shell.h index c214769a..3df2aa96 100644 --- a/include/wlr/types/wlr_xdg_shell.h +++ b/include/wlr/types/wlr_xdg_shell.h @@ -191,14 +191,11 @@ struct wlr_xdg_surface { struct wl_list popups; // wlr_xdg_popup::link bool added, configured, mapped; - uint32_t configure_serial; struct wl_event_source *configure_idle; uint32_t configure_next_serial; struct wl_list configure_list; - struct wlr_box geometry; - - struct wlr_xdg_surface_state pending; + struct wlr_xdg_surface_state current, pending; struct wl_listener surface_destroy; struct wl_listener surface_commit; diff --git a/types/wlr_layer_shell_v1.c b/types/wlr_layer_shell_v1.c index 3d4ecf16..e10be5d3 100644 --- a/types/wlr_layer_shell_v1.c +++ b/types/wlr_layer_shell_v1.c @@ -511,8 +511,8 @@ void wlr_layer_surface_v1_for_each_popup_surface(struct wlr_layer_surface_v1 *su } double popup_sx, popup_sy; - popup_sx = popup->popup->geometry.x - popup->geometry.x; - popup_sy = popup->popup->geometry.y - popup->geometry.y; + popup_sx = popup->popup->geometry.x - popup->current.geometry.x; + popup_sy = popup->popup->geometry.y - popup->current.geometry.y; struct layer_surface_iterator_data data = { .user_iterator = iterator, @@ -542,8 +542,8 @@ struct wlr_surface *wlr_layer_surface_v1_popup_surface_at( wl_list_for_each(popup_state, &surface->popups, link) { struct wlr_xdg_surface *popup = popup_state->base; - double popup_sx = popup_state->geometry.x - popup->geometry.x; - double popup_sy = popup_state->geometry.y - popup->geometry.y; + double popup_sx = popup_state->geometry.x - popup->current.geometry.x; + double popup_sy = popup_state->geometry.y - popup->current.geometry.y; struct wlr_surface *sub = wlr_xdg_surface_surface_at(popup, sx - popup_sx, diff --git a/types/xdg_shell/wlr_xdg_popup.c b/types/xdg_shell/wlr_xdg_popup.c index 9e5c2ced..3718ef74 100644 --- a/types/xdg_shell/wlr_xdg_popup.c +++ b/types/xdg_shell/wlr_xdg_popup.c @@ -408,8 +408,8 @@ void wlr_xdg_popup_get_toplevel_coords(struct wlr_xdg_popup *popup, popup_sy += xdg_surface->popup->geometry.y; parent = xdg_surface->popup->parent; } else { - popup_sx += xdg_surface->geometry.x; - popup_sy += xdg_surface->geometry.y; + popup_sx += xdg_surface->current.geometry.x; + popup_sy += xdg_surface->current.geometry.y; break; } } diff --git a/types/xdg_shell/wlr_xdg_surface.c b/types/xdg_shell/wlr_xdg_surface.c index c2ef7658..4f7d6e24 100644 --- a/types/xdg_shell/wlr_xdg_surface.c +++ b/types/xdg_shell/wlr_xdg_surface.c @@ -81,14 +81,13 @@ void unmap_xdg_surface(struct wlr_xdg_surface *surface) { } surface->configured = surface->mapped = false; - surface->configure_serial = 0; if (surface->configure_idle) { wl_event_source_remove(surface->configure_idle); surface->configure_idle = NULL; } surface->configure_next_serial = 0; - memset(&surface->geometry, 0, sizeof(struct wlr_box)); + memset(&surface->current, 0, sizeof(struct wlr_xdg_surface_state)); memset(&surface->pending, 0, sizeof(struct wlr_xdg_surface_state)); } @@ -310,14 +309,6 @@ static void xdg_surface_handle_surface_commit(struct wl_listener *listener, } } -static void surface_commit_state(struct wlr_xdg_surface *surface, - struct wlr_xdg_surface_state *state) { - surface->configure_serial = state->configure_serial; - if (!wlr_box_empty(&state->geometry)) { - surface->geometry = state->geometry; - } -} - void handle_xdg_surface_commit(struct wlr_surface *wlr_surface) { struct wlr_xdg_surface *surface = wlr_xdg_surface_from_wlr_surface(wlr_surface); @@ -325,7 +316,7 @@ void handle_xdg_surface_commit(struct wlr_surface *wlr_surface) { return; } - surface_commit_state(surface, &surface->pending); + surface->current = surface->pending; switch (surface->role) { case WLR_XDG_SURFACE_ROLE_NONE: @@ -540,9 +531,9 @@ void wlr_xdg_popup_get_position(struct wlr_xdg_popup *popup, struct wlr_box parent_geo; wlr_xdg_surface_get_geometry(parent, &parent_geo); *popup_sx = parent_geo.x + popup->geometry.x - - popup->base->geometry.x; + popup->base->current.geometry.x; *popup_sy = parent_geo.y + popup->geometry.y - - popup->base->geometry.y; + popup->base->current.geometry.y; } struct wlr_surface *wlr_xdg_surface_surface_at( @@ -632,10 +623,11 @@ void wlr_xdg_surface_for_each_popup_surface(struct wlr_xdg_surface *surface, void wlr_xdg_surface_get_geometry(struct wlr_xdg_surface *surface, struct wlr_box *box) { wlr_surface_get_extends(surface->surface, box); + /* The client never set the geometry */ - if (!surface->geometry.width) { + if (wlr_box_empty(&surface->current.geometry)) { return; } - wlr_box_intersection(box, &surface->geometry, box); + wlr_box_intersection(box, &surface->current.geometry, box); }