desktop/view: fix segfault in damage_surface_iterator

This function can get called on a surface that is not actually a view.
We need the view for the output, but we can pass that as user_data
instead when the iterator gets called for all surfaces in a view.
This commit is contained in:
Jente Hidskes 2020-10-18 23:01:58 +02:00
parent 8c1028e2de
commit f5a7ab0167
No known key found for this signature in database
GPG key ID: 04BE5A29F32D91EA

View file

@ -68,8 +68,8 @@ cage_view_position(struct cg_view *view)
static void static void
damage_surface_iterator(struct wlr_surface *surface, int sx, int sy, void *user_data) damage_surface_iterator(struct wlr_surface *surface, int sx, int sy, void *user_data)
{ {
struct cg_view *view = (struct cg_view *) surface->data; struct cg_output *output = (struct cg_output *) user_data;
cage_output_damage_surface(view->output, surface, sx, sy); cage_output_damage_surface(output, surface, sx, sy);
} }
void void
@ -109,7 +109,7 @@ void
cage_view_damage_part(struct cg_view *view) cage_view_damage_part(struct cg_view *view)
{ {
assert(view != NULL); assert(view != NULL);
cage_view_for_each_surface(view, damage_surface_iterator, NULL); cage_view_for_each_surface(view, damage_surface_iterator, (void *) view->output);
} }
struct wlr_surface * struct wlr_surface *