diff --git a/include/wlr/types/wlr_xdg_shell.h b/include/wlr/types/wlr_xdg_shell.h index f6b3b362..802f03a5 100644 --- a/include/wlr/types/wlr_xdg_shell.h +++ b/include/wlr/types/wlr_xdg_shell.h @@ -83,11 +83,14 @@ struct wlr_xdg_popup_state { bool reactive; }; +enum wlr_xdg_popup_configure_field { + WLR_XDG_POPUP_CONFIGURE_REPOSITION_TOKEN = 1 << 0, +}; + struct wlr_xdg_popup_configure { + uint32_t fields; // enum wlr_xdg_popup_configure_field struct wlr_box geometry; struct wlr_xdg_positioner_rules rules; - - bool has_reposition_token; uint32_t reposition_token; }; diff --git a/types/xdg_shell/wlr_xdg_popup.c b/types/xdg_shell/wlr_xdg_popup.c index 5f8cd454..adf94c03 100644 --- a/types/xdg_shell/wlr_xdg_popup.c +++ b/types/xdg_shell/wlr_xdg_popup.c @@ -21,10 +21,12 @@ struct wlr_xdg_popup_configure *send_xdg_popup_configure( } *configure = popup->scheduled; - if (popup->scheduled.has_reposition_token) { - popup->scheduled.has_reposition_token = false; + uint32_t version = wl_resource_get_version(popup->resource); + + if ((configure->fields & WLR_XDG_POPUP_CONFIGURE_REPOSITION_TOKEN) && + version >= XDG_POPUP_REPOSITIONED_SINCE_VERSION) { xdg_popup_send_repositioned(popup->resource, - popup->scheduled.reposition_token); + configure->reposition_token); } struct wlr_box *geometry = &configure->geometry; @@ -32,6 +34,8 @@ struct wlr_xdg_popup_configure *send_xdg_popup_configure( geometry->x, geometry->y, geometry->width, geometry->height); + popup->scheduled.fields = 0; + return configure; } @@ -315,7 +319,8 @@ static void xdg_popup_handle_reposition( wlr_xdg_positioner_rules_get_geometry( &positioner->rules, &popup->scheduled.geometry); popup->scheduled.rules = positioner->rules; - popup->scheduled.has_reposition_token = true; + + popup->scheduled.fields |= WLR_XDG_POPUP_CONFIGURE_REPOSITION_TOKEN; popup->scheduled.reposition_token = token; wlr_xdg_surface_schedule_configure(popup->base);