From c5b9e2665d4d17ace6a9027a065c746c70d967e1 Mon Sep 17 00:00:00 2001 From: dd <26994007+diredocks@users.noreply.github.com> Date: Fri, 6 Jun 2025 04:46:58 +0800 Subject: [PATCH] ssd: add configurable drop-shadows for tiled windows --- docs/labwc-config.5.scd | 6 ++++++ docs/rc.xml.all | 1 + include/config/rcxml.h | 1 + src/config/rcxml.c | 3 +++ src/ssd/ssd-shadow.c | 14 ++++++++++++-- 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/docs/labwc-config.5.scd b/docs/labwc-config.5.scd index 52198062..24956f12 100644 --- a/docs/labwc-config.5.scd +++ b/docs/labwc-config.5.scd @@ -522,6 +522,12 @@ extending outward from the snapped edge. ** [yes|no] Should drop-shadows be rendered behind windows. Default is no. +** [yes|no] + Should drop-shadows be rendered behind tiled windows. This won't take + effect if is smaller than window.active.shadow.size in theme. + + Default is no. + ** The font to use for a specific element of a window, menu or OSD. Places can be any of: diff --git a/docs/rc.xml.all b/docs/rc.xml.all index b4525223..0bb9182d 100644 --- a/docs/rc.xml.all +++ b/docs/rc.xml.all @@ -38,6 +38,7 @@ 8 yes no + no sans 10 diff --git a/include/config/rcxml.h b/include/config/rcxml.h index 3867618e..23312f79 100644 --- a/include/config/rcxml.h +++ b/include/config/rcxml.h @@ -92,6 +92,7 @@ struct rcxml { bool title_layout_loaded; bool ssd_keep_border; bool shadows_enabled; + bool shadows_on_tiled; struct font font_activewindow; struct font font_inactivewindow; struct font font_menuheader; diff --git a/src/config/rcxml.c b/src/config/rcxml.c index eab3f65b..a3e8f85e 100644 --- a/src/config/rcxml.c +++ b/src/config/rcxml.c @@ -1155,6 +1155,8 @@ entry(xmlNode *node, char *nodename, char *content, struct parser_state *state) set_bool(content, &rc.ssd_keep_border); } else if (!strcasecmp(nodename, "dropShadows.theme")) { set_bool(content, &rc.shadows_enabled); + } else if (!strcasecmp(nodename, "dropShadowsOnTiled.theme")) { + set_bool(content, &rc.shadows_on_tiled); } else if (!strcmp(nodename, "name.font.theme")) { fill_font(nodename, content, font_place); } else if (!strcmp(nodename, "size.font.theme")) { @@ -1508,6 +1510,7 @@ rcxml_init(void) rc.ssd_keep_border = true; rc.corner_radius = 8; rc.shadows_enabled = false; + rc.shadows_on_tiled = false; rc.gap = 0; rc.adaptive_sync = LAB_ADAPTIVE_SYNC_DISABLED; diff --git a/src/ssd/ssd-shadow.c b/src/ssd/ssd-shadow.c index 0559628c..29ee1ca2 100644 --- a/src/ssd/ssd-shadow.c +++ b/src/ssd/ssd-shadow.c @@ -284,9 +284,19 @@ ssd_shadow_update(struct ssd *ssd) assert(ssd->shadow.tree); struct view *view = ssd->view; + struct theme *theme = ssd->view->server->theme; bool maximized = view->maximized == VIEW_AXIS_BOTH; - bool show_shadows = - rc.shadows_enabled && !maximized && !view_is_tiled(ssd->view); + bool tiled_shadows = false; + if (rc.shadows_on_tiled) { + if (rc.gap >= theme->window[THEME_ACTIVE].shadow_size + && rc.gap >= theme->window[THEME_INACTIVE].shadow_size) { + tiled_shadows = true; + } else { + wlr_log(WLR_INFO, "gap size < shadow_size, ignore rc.shadows_ontiled"); + } + }; + bool show_shadows = rc.shadows_enabled && !maximized + && (!view_is_tiled(ssd->view) || tiled_shadows); wlr_scene_node_set_enabled(&ssd->shadow.tree->node, show_shadows); if (show_shadows) { set_shadow_geometry(ssd); -- 2.52.0