mirror of
https://github.com/cage-kiosk/cage.git
synced 2025-10-29 05:40:19 -04:00
Implement xdg-decoration
This commit adds a commandline switch (-d) to disable client side decorations, if possible. In this case, Cage will not draw any decorations of its own, in order to maximize screen real estate. The default behavior remains the same, i.e., if -d is not passed, clients will draw their client side decorations, if any. Fixes #32
This commit is contained in:
parent
996f641cf0
commit
2166fbdcfb
4 changed files with 76 additions and 6 deletions
46
xdg_shell.c
46
xdg_shell.c
|
|
@ -17,6 +17,30 @@
|
|||
#include "view.h"
|
||||
#include "xdg_shell.h"
|
||||
|
||||
static void
|
||||
xdg_decoration_handle_destroy(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct cg_xdg_decoration *xdg_decoration = wl_container_of(listener, xdg_decoration, destroy);
|
||||
|
||||
wl_list_remove(&xdg_decoration->destroy.link);
|
||||
wl_list_remove(&xdg_decoration->request_mode.link);
|
||||
free(xdg_decoration);
|
||||
}
|
||||
|
||||
static void
|
||||
xdg_decoration_handle_request_mode(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct cg_xdg_decoration *xdg_decoration = wl_container_of(listener, xdg_decoration, request_mode);
|
||||
enum wlr_xdg_toplevel_decoration_v1_mode mode;
|
||||
|
||||
if (xdg_decoration->server->xdg_decoration) {
|
||||
mode = WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE;
|
||||
} else {
|
||||
mode = WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE;
|
||||
}
|
||||
wlr_xdg_toplevel_decoration_v1_set_mode(xdg_decoration->wlr_decoration, mode);
|
||||
}
|
||||
|
||||
static void
|
||||
xdg_popup_destroy(struct cg_view_child *child)
|
||||
{
|
||||
|
|
@ -304,3 +328,25 @@ handle_xdg_shell_surface_new(struct wl_listener *listener, void *data)
|
|||
xdg_shell_view->new_popup.notify = handle_new_xdg_popup;
|
||||
wl_signal_add(&xdg_surface->events.new_popup, &xdg_shell_view->new_popup);
|
||||
}
|
||||
|
||||
void
|
||||
handle_xdg_toplevel_decoration(struct wl_listener *listener, void *data)
|
||||
{
|
||||
struct cg_server *server = wl_container_of(listener, server, xdg_toplevel_decoration);
|
||||
struct wlr_xdg_toplevel_decoration_v1 *wlr_decoration = data;
|
||||
|
||||
struct cg_xdg_decoration *xdg_decoration = calloc(1, sizeof(struct cg_xdg_decoration));
|
||||
if (!xdg_decoration) {
|
||||
return;
|
||||
}
|
||||
|
||||
xdg_decoration->wlr_decoration = wlr_decoration;
|
||||
xdg_decoration->server = server;
|
||||
|
||||
xdg_decoration->destroy.notify = xdg_decoration_handle_destroy;
|
||||
wl_signal_add(&wlr_decoration->events.destroy, &xdg_decoration->destroy);
|
||||
xdg_decoration->request_mode.notify = xdg_decoration_handle_request_mode;
|
||||
wl_signal_add(&wlr_decoration->events.request_mode, &xdg_decoration->request_mode);
|
||||
|
||||
xdg_decoration_handle_request_mode(&xdg_decoration->request_mode, wlr_decoration);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue