From 54554f43ddc300e8b2fb0386ea72c12f52c3da72 Mon Sep 17 00:00:00 2001 From: Johan Malm Date: Thu, 5 Feb 2026 20:52:53 +0000 Subject: [PATCH] theme: add option window.button.hover.bg.color --- docs/labwc-theme.5.scd | 12 ++++++++++++ docs/themerc | 3 ++- include/theme.h | 3 ++- src/theme.c | 11 ++++++++--- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/docs/labwc-theme.5.scd b/docs/labwc-theme.5.scd index 653f3b1e..75556bb2 100644 --- a/docs/labwc-theme.5.scd +++ b/docs/labwc-theme.5.scd @@ -173,6 +173,18 @@ window.*.title.bg.colorTo.splitTo: #557485 Space between titlebar buttons, in pixels. Default is 0. +Note: The *window.button.hover* namespace (below) relates to button hover +overlay effects which work with all buttons including svg, png and xbm. + +Openbox only supports hover effects rendered behind buttons which makes sense +for the xbm format, but not for others. For reference, these are defined by +*window.active|inactive.button.STATE.bg* where *STATE* can be any of *pressed*, +*hover* and *disabled*. These are not (yet) supported by labwc and are mentioned +here for comparison only. + +*window.button.hover.bg.color* + Color of the hover effect of a titlebar button. Default is #80808020. + *window.button.hover.bg.corner-radius* Radius of the hover effect of a titlebar button, in pixels. Default is 0. diff --git a/docs/themerc b/docs/themerc index 9139170c..83ea726b 100644 --- a/docs/themerc +++ b/docs/themerc @@ -44,7 +44,8 @@ window.button.width: 26 window.button.height: 26 window.button.spacing: 0 -# window button hover effect +# window button hover overlay +window.button.hover.bg.color: #80808020 window.button.hover.bg.corner-radius: 0 # window buttons diff --git a/include/theme.h b/include/theme.h index 58ea3e13..beba06cc 100644 --- a/include/theme.h +++ b/include/theme.h @@ -78,7 +78,8 @@ struct theme { int window_button_height; int window_button_spacing; - /* the corner radius of the hover effect */ + /* button hover effect */ + float window_button_hover_bg_color[4]; int window_button_hover_bg_corner_radius; /* diff --git a/src/theme.c b/src/theme.c index f6684ee9..eeba3050 100644 --- a/src/theme.c +++ b/src/theme.c @@ -76,9 +76,7 @@ zdrop(struct lab_data_buffer **buffer) static void draw_hover_overlay_on_button(cairo_t *cairo, int w, int h) { - /* Overlay (pre-multiplied alpha) */ - float overlay_color[4] = { 0.15f, 0.15f, 0.15f, 0.3f}; - set_cairo_color(cairo, overlay_color); + set_cairo_color(cairo, rc.theme->window_button_hover_bg_color); int r = rc.theme->window_button_hover_bg_corner_radius; cairo_new_sub_path(cairo); @@ -560,6 +558,8 @@ theme_builtin(struct theme *theme, struct server *server) theme->window_button_width = 26; theme->window_button_height = 26; theme->window_button_spacing = 0; + + parse_hexstr("#80808020", theme->window_button_hover_bg_color); theme->window_button_hover_bg_corner_radius = 0; for (enum lab_node_type type = LAB_NODE_BUTTON_FIRST; @@ -787,6 +787,11 @@ entry(struct theme *theme, const char *key, const char *value) theme->window_button_spacing = get_int_if_positive( value, "window.button.spacing"); } + + /* botton hover overlay */ + if (match_glob(key, "window.button.hover.bg.color")) { + parse_color(value, theme->window_button_hover_bg_color); + } if (match_glob(key, "window.button.hover.bg.corner-radius")) { theme->window_button_hover_bg_corner_radius = get_int_if_positive( value, "window.button.hover.bg.corner-radius");