view: check view->impl functions exist before using

Avoids segfault when using disappearing notification in Thunderbird
This commit is contained in:
Johan Malm 2021-10-18 19:35:41 +01:00
parent 846ccb9eb9
commit 40da2f34a5
2 changed files with 20 additions and 13 deletions

View file

@ -79,7 +79,7 @@ process_cursor_move(struct server *server, uint32_t time)
struct view *view = server->grabbed_view;
/* Move the grabbed view to the new position. */
view->impl->move(view, server->grab_box.x + dx, server->grab_box.y + dy);
view_move(view, server->grab_box.x + dx, server->grab_box.y + dy);
}
static void

View file

@ -19,14 +19,18 @@ view_set_activated(struct view *view, bool activated)
void
view_move_resize(struct view *view, struct wlr_box geo)
{
view->impl->configure(view, geo);
if (view->impl->configure) {
view->impl->configure(view, geo);
}
ssd_update_title(view);
}
void
view_move(struct view *view, double x, double y)
{
view->impl->move(view, x, y);
if (view->impl->move) {
view->impl->move(view, x, y);
}
}
#define MIN_VIEW_WIDTH (100)
@ -112,7 +116,9 @@ view_maximize(struct view *view, bool maximize)
if (view->maximized == maximize) {
return;
}
view->impl->maximize(view, maximize);
if (view->impl->maximize) {
view->impl->maximize(view, maximize);
}
if (view->toplevel_handle) {
wlr_foreign_toplevel_handle_v1_set_maximized(view->toplevel_handle,
maximize);
@ -207,17 +213,18 @@ void
view_for_each_surface(struct view *view, wlr_surface_iterator_func_t iterator,
void *user_data)
{
view->impl->for_each_surface(view, iterator, user_data);
if (view->impl->for_each_surface) {
view->impl->for_each_surface(view, iterator, user_data);
}
}
void
view_for_each_popup_surface(struct view *view, wlr_surface_iterator_func_t iterator,
void *data)
view_for_each_popup_surface(struct view *view,
wlr_surface_iterator_func_t iterator, void *data)
{
if (!view->impl->for_each_popup_surface) {
return;
if (view->impl->for_each_popup_surface) {
view->impl->for_each_popup_surface(view, iterator, data);
}
view->impl->for_each_popup_surface(view, iterator, data);
}
static struct border