desktop-shell: extract view_get_transform, make it reliable
Avoid crashes related to get_shell_surface returning NULL. Surfaces are already allowed to be neither focus nor shell in e.g. focus_state_surface_destroy.
This commit is contained in:
+24
-15
@@ -961,18 +961,31 @@ get_output_height(struct weston_output *output)
|
|||||||
return abs(output->region.extents.y1 - output->region.extents.y2);
|
return abs(output->region.extents.y1 - output->region.extents.y2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct weston_transform *
|
||||||
|
view_get_transform(struct weston_view *view)
|
||||||
|
{
|
||||||
|
struct focus_surface *fsurf = NULL;
|
||||||
|
struct shell_surface *shsurf = NULL;
|
||||||
|
|
||||||
|
if (is_focus_view(view)) {
|
||||||
|
fsurf = get_focus_surface(view->surface);
|
||||||
|
return &fsurf->workspace_transform;
|
||||||
|
}
|
||||||
|
|
||||||
|
shsurf = get_shell_surface(view->surface);
|
||||||
|
if (shsurf)
|
||||||
|
return &shsurf->workspace_transform;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
view_translate(struct workspace *ws, struct weston_view *view, double d)
|
view_translate(struct workspace *ws, struct weston_view *view, double d)
|
||||||
{
|
{
|
||||||
struct weston_transform *transform;
|
struct weston_transform *transform = view_get_transform(view);
|
||||||
|
|
||||||
if (is_focus_view(view)) {
|
if (!transform)
|
||||||
struct focus_surface *fsurf = get_focus_surface(view->surface);
|
return;
|
||||||
transform = &fsurf->workspace_transform;
|
|
||||||
} else {
|
|
||||||
struct shell_surface *shsurf = get_shell_surface(view->surface);
|
|
||||||
transform = &shsurf->workspace_transform;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wl_list_empty(&transform->link))
|
if (wl_list_empty(&transform->link))
|
||||||
wl_list_insert(view->geometry.transformation_list.prev,
|
wl_list_insert(view->geometry.transformation_list.prev,
|
||||||
@@ -1044,13 +1057,9 @@ workspace_deactivate_transforms(struct workspace *ws)
|
|||||||
struct weston_transform *transform;
|
struct weston_transform *transform;
|
||||||
|
|
||||||
wl_list_for_each(view, &ws->layer.view_list.link, layer_link.link) {
|
wl_list_for_each(view, &ws->layer.view_list.link, layer_link.link) {
|
||||||
if (is_focus_view(view)) {
|
transform = view_get_transform(view);
|
||||||
struct focus_surface *fsurf = get_focus_surface(view->surface);
|
if (!transform)
|
||||||
transform = &fsurf->workspace_transform;
|
continue;
|
||||||
} else {
|
|
||||||
struct shell_surface *shsurf = get_shell_surface(view->surface);
|
|
||||||
transform = &shsurf->workspace_transform;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!wl_list_empty(&transform->link)) {
|
if (!wl_list_empty(&transform->link)) {
|
||||||
wl_list_remove(&transform->link);
|
wl_list_remove(&transform->link);
|
||||||
|
|||||||
Reference in New Issue
Block a user