Properly track mapping and unmapping

We shouldn't render a window before it is mapped (obviously), but we
render all windows in the view list. Hence, only insert the window once
it is mapped.

We could run into the case where a window is destroyed without being in
the window list, so we now track unmapping again and remove windows from
the list when they get unmapped.
This commit is contained in:
Jente Hidskes 2018-12-31 19:52:47 +01:00
parent a9818c0df1
commit 786e28bdac
No known key found for this signature in database
GPG key ID: 04BE5A29F32D91EA
3 changed files with 19 additions and 6 deletions

View file

@ -41,6 +41,13 @@ is_primary(struct cg_view *view)
return parent == NULL; /*&& role == WLR_XDG_SURFACE_ROLE_TOPLEVEL */
}
static void
handle_xdg_shell_surface_unmap(struct wl_listener *listener, void *data)
{
struct cg_view *view = wl_container_of(listener, view, unmap);
view_unmap(view);
}
static void
handle_xdg_shell_surface_map(struct wl_listener *listener, void *data)
{
@ -61,16 +68,14 @@ handle_xdg_shell_surface_new(struct wl_listener *listener, void *data)
struct cg_server *server = wl_container_of(listener, server, new_xdg_shell_surface);
struct wlr_xdg_surface *xdg_surface = data;
if (xdg_surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
return;
}
struct cg_view *view = cg_view_create(server);
view->type = CAGE_XDG_SHELL_VIEW;
view->xdg_surface = xdg_surface;
view->map.notify = handle_xdg_shell_surface_map;
wl_signal_add(&xdg_surface->events.map, &view->map);
view->unmap.notify = handle_xdg_shell_surface_unmap;
wl_signal_add(&xdg_surface->events.unmap, &view->unmap);
view->destroy.notify = handle_xdg_shell_surface_destroy;
wl_signal_add(&xdg_surface->events.destroy, &view->destroy);