aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-10-11 16:47:26 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-10-11 16:47:26 +0000
commit6afe64b7f4a00c7f6b1787c84703b64f8c3ce7e5 (patch)
tree1ed736770d37997ea7e54555618a93a15f6bba97
parentcsi: implement ‘CSI ? 1042 h/l’ - enable/disable bell-is-urgent (diff)
wayland: don’t instantiate a decoration object when user disabled decorations
An application opts *in* for being compositor-decorated by instantiating a decoration object. This means, even if we request e.g. CSDs, the compositor can choose to use SSDs. By *not* instantiating a decorator object, the compositor *must* not decorate the window for us. So, when the user has set csd.preferred=none, we absolute do not want the compositor to decorate us. Thus, we refrain from instantiating a decoration object.
-rw-r--r--wayland.c44
1 files changed, 19 insertions, 25 deletions
diff --git a/wayland.c b/wayland.c
index 2088ac87..72e87206 100644
--- a/wayland.c
+++ b/wayland.c
@@ -635,29 +635,23 @@ xdg_toplevel_decoration_configure(void *data,
{
struct wl_window *win = data;
- if (win->term->conf->csd.preferred == CONF_CSD_PREFER_NONE) {
- /* User explicitly disabled window decorations */
- LOG_INFO("window decorations disabled");
+ assert(win->term->conf->csd.preferred != CONF_CSD_PREFER_NONE);
+ 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");
win->use_csd = CSD_NO;
csd_destroy(win);
- } 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;
+ 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;
- }
+ default:
+ LOG_ERR("unimplemented: unknown XDG toplevel decoration mode: %u", mode);
+ break;
}
if (win->is_configured && win->use_csd == CSD_YES) {
@@ -1191,7 +1185,11 @@ wayl_win_init(struct terminal *term)
xdg_toplevel_set_app_id(win->xdg_toplevel, conf->app_id);
- if (wayl->xdg_decoration_manager != NULL) {
+ if (conf->csd.preferred == CONF_CSD_PREFER_NONE) {
+ /* User specifically do *not* want decorations */
+ win->use_csd = CSD_NO;
+ LOG_INFO("window decorations disabled by user");
+ } else if (wayl->xdg_decoration_manager != NULL) {
win->xdg_toplevel_decoration = zxdg_decoration_manager_v1_get_toplevel_decoration(
wayl->xdg_decoration_manager, win->xdg_toplevel);
@@ -1206,10 +1204,6 @@ 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;