diff options
author | Kirill Primak <vyivel@eclair.cafe> | 2022-06-21 07:42:58 +0300 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2022-06-21 15:14:37 +0000 |
commit | 5c4384a1330faedf975c8b8644881d50390f3613 (patch) | |
tree | 60e2dc295580a7f1bc017ec6bbc9c92771735120 | |
parent | 8d2fa15e9d7c07f9230f20deffd6ca4ba1078853 (diff) |
xdg-popup: use configure fields
-rw-r--r-- | include/wlr/types/wlr_xdg_shell.h | 7 | ||||
-rw-r--r-- | types/xdg_shell/wlr_xdg_popup.c | 13 |
2 files changed, 14 insertions, 6 deletions
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); |