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.
This commit is contained in:
Daniel Eklöf 2020-10-11 18:47:26 +02:00
parent 17761dce63
commit 6afe64b7f4
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -635,12 +635,7 @@ xdg_toplevel_decoration_configure(void *data,
{ {
struct wl_window *win = data; struct wl_window *win = data;
if (win->term->conf->csd.preferred == CONF_CSD_PREFER_NONE) { assert(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);
} else {
switch (mode) { switch (mode) {
case ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE: case ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE:
LOG_INFO("using CSD decorations"); LOG_INFO("using CSD decorations");
@ -658,7 +653,6 @@ xdg_toplevel_decoration_configure(void *data,
LOG_ERR("unimplemented: unknown XDG toplevel decoration mode: %u", mode); LOG_ERR("unimplemented: unknown XDG toplevel decoration mode: %u", mode);
break; break;
} }
}
if (win->is_configured && win->use_csd == CSD_YES) { if (win->is_configured && win->use_csd == CSD_YES) {
struct terminal *term = win->term; struct terminal *term = win->term;
@ -1191,7 +1185,11 @@ wayl_win_init(struct terminal *term)
xdg_toplevel_set_app_id(win->xdg_toplevel, conf->app_id); 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( win->xdg_toplevel_decoration = zxdg_decoration_manager_v1_get_toplevel_decoration(
wayl->xdg_decoration_manager, win->xdg_toplevel); wayl->xdg_decoration_manager, win->xdg_toplevel);
@ -1206,10 +1204,6 @@ wayl_win_init(struct terminal *term)
zxdg_toplevel_decoration_v1_add_listener( zxdg_toplevel_decoration_v1_add_listener(
win->xdg_toplevel_decoration, &xdg_toplevel_decoration_listener, win); 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 { } else {
/* No decoration manager - thus we *must* draw our own decorations */ /* No decoration manager - thus we *must* draw our own decorations */
win->use_csd = CSD_YES; win->use_csd = CSD_YES;