xdg-shell: introduce wlr_xdg_surface.current

This holds the current state, and avoids having ad-hoc fields in
wlr_xdg_surface.
master
Simon Ser 3 years ago committed by Kirill Primak
parent db4afc2408
commit 0e34208344

@ -191,14 +191,11 @@ struct wlr_xdg_surface {
struct wl_list popups; // wlr_xdg_popup::link struct wl_list popups; // wlr_xdg_popup::link
bool added, configured, mapped; bool added, configured, mapped;
uint32_t configure_serial;
struct wl_event_source *configure_idle; struct wl_event_source *configure_idle;
uint32_t configure_next_serial; uint32_t configure_next_serial;
struct wl_list configure_list; struct wl_list configure_list;
struct wlr_box geometry; struct wlr_xdg_surface_state current, pending;
struct wlr_xdg_surface_state pending;
struct wl_listener surface_destroy; struct wl_listener surface_destroy;
struct wl_listener surface_commit; struct wl_listener surface_commit;

@ -511,8 +511,8 @@ void wlr_layer_surface_v1_for_each_popup_surface(struct wlr_layer_surface_v1 *su
} }
double popup_sx, popup_sy; double popup_sx, popup_sy;
popup_sx = popup->popup->geometry.x - popup->geometry.x; popup_sx = popup->popup->geometry.x - popup->current.geometry.x;
popup_sy = popup->popup->geometry.y - popup->geometry.y; popup_sy = popup->popup->geometry.y - popup->current.geometry.y;
struct layer_surface_iterator_data data = { struct layer_surface_iterator_data data = {
.user_iterator = iterator, .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) { wl_list_for_each(popup_state, &surface->popups, link) {
struct wlr_xdg_surface *popup = popup_state->base; struct wlr_xdg_surface *popup = popup_state->base;
double popup_sx = popup_state->geometry.x - popup->geometry.x; double popup_sx = popup_state->geometry.x - popup->current.geometry.x;
double popup_sy = popup_state->geometry.y - popup->geometry.y; double popup_sy = popup_state->geometry.y - popup->current.geometry.y;
struct wlr_surface *sub = wlr_xdg_surface_surface_at(popup, struct wlr_surface *sub = wlr_xdg_surface_surface_at(popup,
sx - popup_sx, sx - popup_sx,

@ -408,8 +408,8 @@ void wlr_xdg_popup_get_toplevel_coords(struct wlr_xdg_popup *popup,
popup_sy += xdg_surface->popup->geometry.y; popup_sy += xdg_surface->popup->geometry.y;
parent = xdg_surface->popup->parent; parent = xdg_surface->popup->parent;
} else { } else {
popup_sx += xdg_surface->geometry.x; popup_sx += xdg_surface->current.geometry.x;
popup_sy += xdg_surface->geometry.y; popup_sy += xdg_surface->current.geometry.y;
break; break;
} }
} }

@ -81,14 +81,13 @@ void unmap_xdg_surface(struct wlr_xdg_surface *surface) {
} }
surface->configured = surface->mapped = false; surface->configured = surface->mapped = false;
surface->configure_serial = 0;
if (surface->configure_idle) { if (surface->configure_idle) {
wl_event_source_remove(surface->configure_idle); wl_event_source_remove(surface->configure_idle);
surface->configure_idle = NULL; surface->configure_idle = NULL;
} }
surface->configure_next_serial = 0; 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)); 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) { void handle_xdg_surface_commit(struct wlr_surface *wlr_surface) {
struct wlr_xdg_surface *surface = struct wlr_xdg_surface *surface =
wlr_xdg_surface_from_wlr_surface(wlr_surface); wlr_xdg_surface_from_wlr_surface(wlr_surface);
@ -325,7 +316,7 @@ void handle_xdg_surface_commit(struct wlr_surface *wlr_surface) {
return; return;
} }
surface_commit_state(surface, &surface->pending); surface->current = surface->pending;
switch (surface->role) { switch (surface->role) {
case WLR_XDG_SURFACE_ROLE_NONE: 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; struct wlr_box parent_geo;
wlr_xdg_surface_get_geometry(parent, &parent_geo); wlr_xdg_surface_get_geometry(parent, &parent_geo);
*popup_sx = parent_geo.x + popup->geometry.x - *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_sy = parent_geo.y + popup->geometry.y -
popup->base->geometry.y; popup->base->current.geometry.y;
} }
struct wlr_surface *wlr_xdg_surface_surface_at( 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, void wlr_xdg_surface_get_geometry(struct wlr_xdg_surface *surface,
struct wlr_box *box) { struct wlr_box *box) {
wlr_surface_get_extends(surface->surface, box); wlr_surface_get_extends(surface->surface, box);
/* The client never set the geometry */ /* The client never set the geometry */
if (!surface->geometry.width) { if (wlr_box_empty(&surface->current.geometry)) {
return; return;
} }
wlr_box_intersection(box, &surface->geometry, box); wlr_box_intersection(box, &surface->current.geometry, box);
} }

Loading…
Cancel
Save