diff options
author | emersion <contact@emersion.fr> | 2018-05-12 22:53:11 +0100 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2018-05-12 22:53:11 +0100 |
commit | b28f06eca07b7b4e869940c08c255f7246927b93 (patch) | |
tree | 7f9ae2d2240603325f32b0b77ed724304ce3e4e6 | |
parent | 059e5f6690c5d7b084517df87537ec16463d470c (diff) |
Don't use unsafe casts in wlr_xdg_popup_get_toplevel_coords
-rw-r--r-- | types/wlr_xdg_shell.c | 9 | ||||
-rw-r--r-- | types/wlr_xdg_shell_v6.c | 2 |
2 files changed, 3 insertions, 8 deletions
diff --git a/types/wlr_xdg_shell.c b/types/wlr_xdg_shell.c index b626b772..17c227e3 100644 --- a/types/wlr_xdg_shell.c +++ b/types/wlr_xdg_shell.c @@ -1656,20 +1656,17 @@ void wlr_xdg_popup_get_anchor_point(struct wlr_xdg_popup *popup, void wlr_xdg_popup_get_toplevel_coords(struct wlr_xdg_popup *popup, int popup_sx, int popup_sy, int *toplevel_sx, int *toplevel_sy) { - assert(strcmp(popup->parent->role, wlr_desktop_xdg_toplevel_role) == 0 - || strcmp(popup->parent->role, wlr_desktop_xdg_popup_role) == 0); - struct wlr_xdg_surface *parent = popup->parent->role_data; + struct wlr_xdg_surface *parent = + wlr_xdg_surface_from_wlr_surface(popup->parent); while (parent != NULL && parent->role == WLR_XDG_SURFACE_ROLE_POPUP) { popup_sx += parent->popup->geometry.x; popup_sy += parent->popup->geometry.y; - parent = parent->popup->parent->role_data; + parent = wlr_xdg_surface_from_wlr_surface(parent->popup->parent); } - assert(parent); *toplevel_sx = popup_sx + parent->geometry.x; *toplevel_sy = popup_sy + parent->geometry.y; - } static void xdg_popup_box_constraints(struct wlr_xdg_popup *popup, diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c index 29e4e605..41655767 100644 --- a/types/wlr_xdg_shell_v6.c +++ b/types/wlr_xdg_shell_v6.c @@ -1673,12 +1673,10 @@ void wlr_xdg_popup_v6_get_toplevel_coords(struct wlr_xdg_popup_v6 *popup, popup_sy += parent->popup->geometry.y; parent = parent->popup->parent; } - assert(parent); *toplevel_sx = popup_sx + parent->geometry.x; *toplevel_sy = popup_sy + parent->geometry.y; - } static void xdg_popup_v6_box_constraints(struct wlr_xdg_popup_v6 *popup, |