mirror of
https://github.com/cage-kiosk/cage.git
synced 2025-10-29 05:40:19 -04:00
With Cage becoming more popular since its mention on Phoronix and
therefore getting more use-cases than just my own project, add XWayland
support. The refactoring of 2cf40f7 makes this much easier. Note that
this is a no-cost addition for those of us not using XWayland as it is a
compile-time option that needs to be explicitly enabled by adding
`-Dxwayland=true` to your meson command.
86 lines
2.3 KiB
C
86 lines
2.3 KiB
C
/*
|
|
* Cage: A Wayland kiosk.
|
|
*
|
|
* Copyright (C) 2018 Jente Hidskes
|
|
*
|
|
* See the LICENSE file accompanying this file.
|
|
*/
|
|
|
|
#include <stdbool.h>
|
|
#include <wayland-server.h>
|
|
#include <wlr/types/wlr_box.h>
|
|
#include <wlr/xwayland.h>
|
|
|
|
#include "server.h"
|
|
#include "view.h"
|
|
|
|
static void
|
|
activate(struct cg_view *view, bool activate)
|
|
{
|
|
wlr_xwayland_surface_activate(view->xwayland_surface, activate);
|
|
}
|
|
|
|
static void
|
|
maximize(struct cg_view *view, int output_width, int output_height)
|
|
{
|
|
wlr_xwayland_surface_configure(view->xwayland_surface, 0, 0, output_width, output_height);
|
|
wlr_xwayland_surface_set_maximized(view->xwayland_surface, true);
|
|
}
|
|
|
|
static void
|
|
get_geometry(struct cg_view *view, int *width_out, int *height_out)
|
|
{
|
|
*width_out = view->xwayland_surface->surface->current.width;
|
|
*height_out = view->xwayland_surface->surface->current.height;
|
|
}
|
|
|
|
static bool
|
|
is_primary(struct cg_view *view)
|
|
{
|
|
struct wlr_xwayland_surface *parent = view->xwayland_surface->parent;
|
|
return parent == NULL;
|
|
}
|
|
|
|
static void
|
|
handle_xwayland_surface_unmap(struct wl_listener *listener, void *data)
|
|
{
|
|
struct cg_view *view = wl_container_of(listener, view, unmap);
|
|
view_unmap(view);
|
|
}
|
|
|
|
static void
|
|
handle_xwayland_surface_map(struct wl_listener *listener, void *data)
|
|
{
|
|
struct cg_view *view = wl_container_of(listener, view, map);
|
|
view_map(view, view->xwayland_surface->surface);
|
|
}
|
|
|
|
static void
|
|
handle_xwayland_surface_destroy(struct wl_listener *listener, void *data)
|
|
{
|
|
struct cg_view *view = wl_container_of(listener, view, destroy);
|
|
view_destroy(view);
|
|
}
|
|
|
|
void
|
|
handle_xwayland_surface_new(struct wl_listener *listener, void *data)
|
|
{
|
|
struct cg_server *server = wl_container_of(listener, server, new_xwayland_surface);
|
|
struct wlr_xwayland_surface *xwayland_surface = data;
|
|
|
|
struct cg_view *view = cg_view_create(server);
|
|
view->type = CAGE_XWAYLAND_VIEW;
|
|
view->xwayland_surface = xwayland_surface;
|
|
|
|
view->map.notify = handle_xwayland_surface_map;
|
|
wl_signal_add(&xwayland_surface->events.map, &view->map);
|
|
view->unmap.notify = handle_xwayland_surface_unmap;
|
|
wl_signal_add(&xwayland_surface->events.unmap, &view->unmap);
|
|
view->destroy.notify = handle_xwayland_surface_destroy;
|
|
wl_signal_add(&xwayland_surface->events.destroy, &view->destroy);
|
|
|
|
view->activate = activate;
|
|
view->maximize = maximize;
|
|
view->get_geometry = get_geometry;
|
|
view->is_primary = is_primary;
|
|
}
|