From 6ff97128fc55573274fb21b6e56821db02cf162b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 10 Oct 2020 11:04:17 +0200 Subject: [PATCH] =?UTF-8?q?conf:=20csd.preferred=20can=20now=20be=20set=20?= =?UTF-8?q?to=20=E2=80=98none=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When csd.preferred == none, we will request CSDs from the compositor, but internally render as if we are using SSDs. That is, we don’t render any window decorations at all. Note that some compositors may ignore our request to use CSDs, and still render SSDs for us. Closes #163 --- CHANGELOG.md | 3 +++ config.c | 6 +++++- config.h | 2 +- doc/foot.ini.5.scd | 17 +++++++++++++---- wayland.c | 38 ++++++++++++++++++++++++-------------- 5 files changed, 46 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99e8a247..33d5e98d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,9 @@ from `1.0` to `3.0`. * `shift`+`insert` now pastes from the primary selection by default. This is in addition to middle-clicking with the mouse. +* **csd.preferred** can now be set to `none` to disable window + decorations. Note that some compositors will render SSDs despite + this option being used (https://codeberg.org/dnkl/foot/issues/163). ### Deprecated diff --git a/config.c b/config.c index 1548c102..bcebcb2a 100644 --- a/config.c +++ b/config.c @@ -813,8 +813,12 @@ parse_section_csd(const char *key, const char *value, struct config *conf, conf->csd.preferred = CONF_CSD_PREFER_SERVER; else if (strcmp(value, "client") == 0) conf->csd.preferred = CONF_CSD_PREFER_CLIENT; + else if (strcmp(value, "none") == 0) + conf->csd.preferred = CONF_CSD_PREFER_NONE; else { - LOG_AND_NOTIFY_ERR("%s:%d: csd.preferred: expected either 'server' or 'client'", path, lineno); + LOG_AND_NOTIFY_ERR( + "%s:%d: csd.preferred: expected either " + "'server', 'client' or 'none'", path, lineno); return false; } } diff --git a/config.h b/config.h index 8e129329..6cbff2e6 100644 --- a/config.h +++ b/config.h @@ -140,7 +140,7 @@ struct config { } bindings; struct { - enum { CONF_CSD_PREFER_SERVER, CONF_CSD_PREFER_CLIENT } preferred; + enum { CONF_CSD_PREFER_NONE, CONF_CSD_PREFER_SERVER, CONF_CSD_PREFER_CLIENT } preferred; int title_height; int border_width; diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd index a432b807..dd8e5f44 100644 --- a/doc/foot.ini.5.scd +++ b/doc/foot.ini.5.scd @@ -238,10 +238,19 @@ values here are in AARRGGBB format. I.e. they contain an alpha component. *preferred* - Which type of window decorations to prefer: *client* (CSD) or - *server* (SSD). Note that this is only a hint to the - compositor. Depending on the compositor's configuration and - capabilities, it may not have any effect. Default: _server_. + Which type of window decorations to prefer: *client* (CSD), + *server* (SSD) or *none*. + + Note that this is only a hint to the compositor. Depending on + compositor support, and how it has been configured, it may + instruct foot to use CSDs even though this option has been set to + *client*, or to use SSDs even though CSDs were requested. + + The exception is *none*. In this mode, foot will technically + request CSDs from the compositor, but will not actually render any + window decorations at all, regardless of the compositors response. + +Default: _server_. *size* Height, in pixels (subject to output scaling), of the diff --git a/wayland.c b/wayland.c index dce240d3..2088ac87 100644 --- a/wayland.c +++ b/wayland.c @@ -635,22 +635,29 @@ xdg_toplevel_decoration_configure(void *data, { struct wl_window *win = data; - switch (mode) { - case ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE: - LOG_INFO("using CSD decorations"); - win->use_csd = CSD_YES; - csd_instantiate(win); - break; - - case ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE: - LOG_INFO("using SSD decorations"); + if (win->term->conf->csd.preferred == CONF_CSD_PREFER_NONE) { + /* User explicitly disabled window decorations */ + LOG_INFO("window decorations disabled"); win->use_csd = CSD_NO; csd_destroy(win); - break; + } else { + switch (mode) { + case ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE: + LOG_INFO("using CSD decorations"); + win->use_csd = CSD_YES; + csd_instantiate(win); + break; - default: - LOG_ERR("unimplemented: unknown XDG toplevel decoration mode: %u", mode); - break; + case ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE: + LOG_INFO("using SSD decorations"); + win->use_csd = CSD_NO; + csd_destroy(win); + break; + + default: + LOG_ERR("unimplemented: unknown XDG toplevel decoration mode: %u", mode); + break; + } } if (win->is_configured && win->use_csd == CSD_YES) { @@ -1184,7 +1191,6 @@ wayl_win_init(struct terminal *term) xdg_toplevel_set_app_id(win->xdg_toplevel, conf->app_id); - /* Request server-side decorations */ if (wayl->xdg_decoration_manager != NULL) { win->xdg_toplevel_decoration = zxdg_decoration_manager_v1_get_toplevel_decoration( wayl->xdg_decoration_manager, win->xdg_toplevel); @@ -1200,6 +1206,10 @@ wayl_win_init(struct terminal *term) zxdg_toplevel_decoration_v1_add_listener( win->xdg_toplevel_decoration, &xdg_toplevel_decoration_listener, win); + } else if (conf->csd.preferred == CONF_CSD_PREFER_NONE) { + /* No decoration manager - and user specifically do *not* want CSDs */ + win->use_csd = CSD_NO; + LOG_INFO("no decoration manager available - user has disabled CSDs"); } else { /* No decoration manager - thus we *must* draw our own decorations */ win->use_csd = CSD_YES;