xwayland: split out xwayland_view constructor

...and make it public in preparation for supporting override-redirect
requests from unmanaged xwayland surfaces.
This commit is contained in:
Johan Malm 2023-04-17 17:02:11 +01:00 committed by Johan Malm
parent 130da3c803
commit 9d08a452a3
2 changed files with 35 additions and 32 deletions

View file

@ -43,6 +43,9 @@ struct xwayland_view {
void xwayland_unmanaged_create(struct server *server, void xwayland_unmanaged_create(struct server *server,
struct wlr_xwayland_surface *xsurface, bool mapped); struct wlr_xwayland_surface *xsurface, bool mapped);
struct xwayland_view *xwayland_view_create(struct server *server,
struct wlr_xwayland_surface *xsurface);
struct wlr_xwayland_surface *xwayland_surface_from_view(struct view *view); struct wlr_xwayland_surface *xwayland_surface_from_view(struct view *view);
bool xwayland_apply_size_hints(struct view *view, int *w, int *h); bool xwayland_apply_size_hints(struct view *view, int *w, int *h);

View file

@ -595,23 +595,9 @@ static const struct view_impl xwayland_view_impl = {
.move_to_back = xwayland_view_move_to_back, .move_to_back = xwayland_view_move_to_back,
}; };
static void struct xwayland_view *
handle_new_surface(struct wl_listener *listener, void *data) xwayland_view_create(struct server *server, struct wlr_xwayland_surface *xsurface)
{ {
struct server *server =
wl_container_of(listener, server, xwayland_new_surface);
struct wlr_xwayland_surface *xsurface = data;
wlr_xwayland_surface_ping(xsurface);
/*
* We do not create 'views' for xwayland override_redirect surfaces,
* but add them to server.unmanaged_surfaces so that we can render them
*/
if (xsurface->override_redirect) {
xwayland_unmanaged_create(server, xsurface, /* mapped */ false);
return;
}
struct xwayland_view *xwayland_view = znew(*xwayland_view); struct xwayland_view *xwayland_view = znew(*xwayland_view);
struct view *view = &xwayland_view->base; struct view *view = &xwayland_view->base;
@ -620,20 +606,18 @@ handle_new_surface(struct wl_listener *listener, void *data)
view->impl = &xwayland_view_impl; view->impl = &xwayland_view_impl;
/* /*
* Set two-way view <-> xsurface association. Usually the * Set two-way view <-> xsurface association. Usually the association
* association remains until the xsurface is destroyed (which * remains until the xsurface is destroyed (which also destroys the
* also destroys the view). The only exception is caused by * view). The only exception is caused by setting override-redirect on
* setting override-redirect on the xsurface, which removes it * the xsurface, which removes it from the view (destroying the view)
* from the view (destroying the view) and makes it an * and makes it an "unmanaged" surface.
* "unmanaged" surface.
*/ */
xwayland_view->xwayland_surface = xsurface; xwayland_view->xwayland_surface = xsurface;
xsurface->data = view; xsurface->data = view;
view->workspace = server->workspace_current; view->workspace = server->workspace_current;
view->scene_tree = wlr_scene_tree_create(view->workspace->tree); view->scene_tree = wlr_scene_tree_create(view->workspace->tree);
node_descriptor_create(&view->scene_tree->node, node_descriptor_create(&view->scene_tree->node, LAB_NODE_DESC_VIEW, view);
LAB_NODE_DESC_VIEW, view);
view->map.notify = handle_map; view->map.notify = handle_map;
wl_signal_add(&xsurface->events.map, &view->map); wl_signal_add(&xsurface->events.map, &view->map);
@ -657,25 +641,41 @@ handle_new_surface(struct wl_listener *listener, void *data)
/* Events specific to XWayland views */ /* Events specific to XWayland views */
xwayland_view->request_activate.notify = handle_request_activate; xwayland_view->request_activate.notify = handle_request_activate;
wl_signal_add(&xsurface->events.request_activate, wl_signal_add(&xsurface->events.request_activate, &xwayland_view->request_activate);
&xwayland_view->request_activate);
xwayland_view->request_configure.notify = handle_request_configure; xwayland_view->request_configure.notify = handle_request_configure;
wl_signal_add(&xsurface->events.request_configure, wl_signal_add(&xsurface->events.request_configure, &xwayland_view->request_configure);
&xwayland_view->request_configure);
xwayland_view->set_app_id.notify = handle_set_class; xwayland_view->set_app_id.notify = handle_set_class;
wl_signal_add(&xsurface->events.set_class, &xwayland_view->set_app_id); wl_signal_add(&xsurface->events.set_class, &xwayland_view->set_app_id);
xwayland_view->set_decorations.notify = handle_set_decorations; xwayland_view->set_decorations.notify = handle_set_decorations;
wl_signal_add(&xsurface->events.set_decorations, wl_signal_add(&xsurface->events.set_decorations, &xwayland_view->set_decorations);
&xwayland_view->set_decorations);
xwayland_view->override_redirect.notify = handle_override_redirect; xwayland_view->override_redirect.notify = handle_override_redirect;
wl_signal_add(&xsurface->events.set_override_redirect, wl_signal_add(&xsurface->events.set_override_redirect, &xwayland_view->override_redirect);
&xwayland_view->override_redirect);
wl_list_insert(&view->server->views, &view->link); wl_list_insert(&view->server->views, &view->link);
return xwayland_view;
}
static void
handle_new_surface(struct wl_listener *listener, void *data)
{
struct server *server =
wl_container_of(listener, server, xwayland_new_surface);
struct wlr_xwayland_surface *xsurface = data;
wlr_xwayland_surface_ping(xsurface);
/*
* We do not create 'views' for xwayland override_redirect surfaces,
* but add them to server.unmanaged_surfaces so that we can render them
*/
if (xsurface->override_redirect) {
xwayland_unmanaged_create(server, xsurface, /* mapped */ false);
return;
}
xwayland_view_create(server, xsurface);
} }
static void static void