Evacuate unmanaged Xwayland views properly

Unmanaged views currently do not get evacuated at all. This means they are still
referring to a deallocated output if they happen to be have been there during
deallocation. We now evacuate them alongside regular views on workspace merging.
This commit is contained in:
raichoo 2020-08-31 09:09:53 +00:00
parent dfd72dea7d
commit b345399d7d
3 changed files with 44 additions and 0 deletions

View File

@ -36,4 +36,9 @@ hikari_xwayland_unmanaged_view_init(
struct wlr_xwayland_surface *xwayland_surface,
struct hikari_workspace *workspace);
void
hikari_xwayland_unmanaged_evacuate(
struct hikari_xwayland_unmanaged_view *xwayland_unmanaged_view,
struct hikari_workspace *workspace);
#endif

View File

@ -25,6 +25,7 @@
#include <hikari/sheet.h>
#include <hikari/xdg_view.h>
#ifdef HAVE_XWAYLAND
#include <hikari/xwayland_unmanaged_view.h>
#include <hikari/xwayland_view.h>
#endif
@ -96,6 +97,17 @@ hikari_workspace_merge(
hikari_view_evacuate(view, to);
}
}
#ifdef HAVE_XWAYLAND
struct hikari_xwayland_unmanaged_view *unmanaged_xwayland_view,
*unmanaged_xwayland_view_temp;
wl_list_for_each_reverse_safe (unmanaged_xwayland_view,
unmanaged_xwayland_view_temp,
&workspace->output->unmanaged_xwayland_views,
unmanaged_server_views) {
hikari_xwayland_unmanaged_evacuate(unmanaged_xwayland_view, into);
}
#endif
}
void

View File

@ -19,6 +19,17 @@ was_updated(struct wlr_xwayland_surface *surface,
(surface->height == geometry->height));
}
static void
recalculate_geometry(struct wlr_box *geometry,
struct wlr_xwayland_surface *surface,
struct hikari_output *output)
{
geometry->x = surface->x - output->geometry.x;
geometry->y = surface->y - output->geometry.y;
geometry->width = surface->width;
geometry->height = surface->height;
}
static void
commit_handler(struct wl_listener *listener, void *data)
{
@ -200,4 +211,20 @@ hikari_xwayland_unmanaged_view_init(
wl_signal_add(&xwayland_surface->events.request_configure,
&xwayland_unmanaged_view->request_configure);
}
void
hikari_xwayland_unmanaged_evacuate(
struct hikari_xwayland_unmanaged_view *xwayland_unmanaged_view,
struct hikari_workspace *workspace)
{
struct hikari_output *output = workspace->output;
struct wlr_xwayland_surface *surface = xwayland_unmanaged_view->surface;
struct wlr_box *geometry = &xwayland_unmanaged_view->geometry;
xwayland_unmanaged_view->workspace = workspace;
recalculate_geometry(geometry, surface, output);
hikari_output_add_damage(output, &xwayland_unmanaged_view->geometry);
}
#endif