view: Move xdg_surface + xwayland_surface to derived structs

Add xdg_surface_from_view() + xwayland_surface_from_view() accessors
that assert() the view is of the expected type before returning.

Fix a real bug in xdg.c parent_of() that dereferenced
`view->xdg_surface->toplevel` without first checking `view->type`.

The goal of the new accessors is to catch similar bugs in future.
This commit is contained in:
John Lindgren 2022-11-25 13:41:12 -05:00 committed by Johan Malm
parent df7276345f
commit 4da37c6532
7 changed files with 147 additions and 106 deletions

View file

@ -186,7 +186,8 @@ view_adjust_size(struct view *view, int *w, int *h)
int min_height = MIN_VIEW_HEIGHT;
#if HAVE_XWAYLAND
if (view->type == LAB_XWAYLAND_VIEW) {
xcb_size_hints_t *hints = view->xwayland_surface->size_hints;
xcb_size_hints_t *hints =
xwayland_surface_from_view(view)->size_hints;
/*
* Honor size increments from WM_SIZE_HINTS. Typically, X11