mirror of
https://github.com/cage-kiosk/cage.git
synced 2025-10-29 05:40:19 -04:00
shell: Use new map/unmap events
For xwayland we must listen on associate/dissociate to set up and tear down the map/unmap event handlers instead of during surface create/destroy.
This commit is contained in:
parent
4ea6a8b1a7
commit
2d4b7a4e23
3 changed files with 37 additions and 8 deletions
|
|
@ -238,9 +238,9 @@ handle_xdg_shell_surface_new(struct wl_listener *listener, void *data)
|
|||
xdg_shell_view->xdg_toplevel = xdg_surface->toplevel;
|
||||
|
||||
xdg_shell_view->map.notify = handle_xdg_shell_surface_map;
|
||||
wl_signal_add(&xdg_surface->events.map, &xdg_shell_view->map);
|
||||
wl_signal_add(&xdg_surface->surface->events.map, &xdg_shell_view->map);
|
||||
xdg_shell_view->unmap.notify = handle_xdg_shell_surface_unmap;
|
||||
wl_signal_add(&xdg_surface->events.unmap, &xdg_shell_view->unmap);
|
||||
wl_signal_add(&xdg_surface->surface->events.unmap, &xdg_shell_view->unmap);
|
||||
xdg_shell_view->destroy.notify = handle_xdg_shell_surface_destroy;
|
||||
wl_signal_add(&xdg_surface->events.destroy, &xdg_shell_view->destroy);
|
||||
xdg_shell_view->request_fullscreen.notify = handle_xdg_shell_surface_request_fullscreen;
|
||||
|
|
|
|||
39
xwayland.c
39
xwayland.c
|
|
@ -41,8 +41,15 @@ static void
|
|||
get_geometry(struct cg_view *view, int *width_out, int *height_out)
|
||||
{
|
||||
struct cg_xwayland_view *xwayland_view = xwayland_view_from_view(view);
|
||||
*width_out = xwayland_view->xwayland_surface->surface->current.width;
|
||||
*height_out = xwayland_view->xwayland_surface->surface->current.height;
|
||||
struct wlr_xwayland_surface *xsurface = xwayland_view->xwayland_surface;
|
||||
if (xsurface->surface == NULL) {
|
||||
*width_out = 0;
|
||||
*height_out = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
*width_out = xsurface->surface->current.width;
|
||||
*height_out = xsurface->surface->current.height;
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
@ -151,6 +158,26 @@ static const struct cg_view_impl xwayland_view_impl = {
|
|||
.destroy = destroy,
|
||||
};
|
||||
|
||||
void
|
||||
handle_xwayland_associate(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct cg_xwayland_view *xwayland_view = wl_container_of(listener, xwayland_view, associate);
|
||||
struct wlr_xwayland_surface *xsurface = xwayland_view->xwayland_surface;
|
||||
|
||||
xwayland_view->map.notify = handle_xwayland_surface_map;
|
||||
wl_signal_add(&xsurface->surface->events.map, &xwayland_view->map);
|
||||
xwayland_view->unmap.notify = handle_xwayland_surface_unmap;
|
||||
wl_signal_add(&xsurface->surface->events.unmap, &xwayland_view->unmap);
|
||||
}
|
||||
|
||||
void
|
||||
handle_xwayland_dissociate(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct cg_xwayland_view *xwayland_view = wl_container_of(listener, xwayland_view, dissociate);
|
||||
wl_list_remove(&xwayland_view->map.link);
|
||||
wl_list_remove(&xwayland_view->unmap.link);
|
||||
}
|
||||
|
||||
void
|
||||
handle_xwayland_surface_new(struct wl_listener *listener, void *data)
|
||||
{
|
||||
|
|
@ -166,10 +193,10 @@ handle_xwayland_surface_new(struct wl_listener *listener, void *data)
|
|||
view_init(&xwayland_view->view, server, CAGE_XWAYLAND_VIEW, &xwayland_view_impl);
|
||||
xwayland_view->xwayland_surface = xwayland_surface;
|
||||
|
||||
xwayland_view->map.notify = handle_xwayland_surface_map;
|
||||
wl_signal_add(&xwayland_surface->events.map, &xwayland_view->map);
|
||||
xwayland_view->unmap.notify = handle_xwayland_surface_unmap;
|
||||
wl_signal_add(&xwayland_surface->events.unmap, &xwayland_view->unmap);
|
||||
xwayland_view->associate.notify = handle_xwayland_associate;
|
||||
wl_signal_add(&xwayland_surface->events.associate, &xwayland_view->associate);
|
||||
xwayland_view->dissociate.notify = handle_xwayland_dissociate;
|
||||
wl_signal_add(&xwayland_surface->events.dissociate, &xwayland_view->dissociate);
|
||||
xwayland_view->destroy.notify = handle_xwayland_surface_destroy;
|
||||
wl_signal_add(&xwayland_surface->events.destroy, &xwayland_view->destroy);
|
||||
xwayland_view->request_fullscreen.notify = handle_xwayland_surface_request_fullscreen;
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ struct cg_xwayland_view {
|
|||
struct cg_view view;
|
||||
struct wlr_xwayland_surface *xwayland_surface;
|
||||
struct wl_listener destroy;
|
||||
struct wl_listener associate;
|
||||
struct wl_listener dissociate;
|
||||
struct wl_listener unmap;
|
||||
struct wl_listener map;
|
||||
struct wl_listener request_fullscreen;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue