]> git.mdlowis.com Git - proto/labwc.git/commitdiff
theme: add window_(in)active_label_text_color
authorJohan Malm <jgm323@gmail.com>
Fri, 15 Oct 2021 20:35:41 +0000 (21:35 +0100)
committerJohan Malm <jgm323@gmail.com>
Fri, 15 Oct 2021 20:35:41 +0000 (21:35 +0100)
Support both active and inactive colors for titlebar text

docs/labwc-theme.5.scd
include/labwc.h
include/theme.h
src/ssd.c
src/theme.c

index 31c9b35a05781e2d58e04d2f40a64806c725f15e..6f639905486fa0b631a1ab24da382797482785ef 100644 (file)
@@ -37,10 +37,16 @@ A theme consists of a themerc file and optionally some xbm icons.
        Border color of active window
 
 *window.active.title.bg.color*
-       Background for the focussed window's titlebar
+       Background color for the focussed window's titlebar
 
 *window.inactive.title.bg.color*
-       Background for non-focussed windows' titlebars
+       Background color for non-focussed windows' titlebars
+
+*window.active.label.text.color*
+       Text color for the focussed window's titlebar
+
+*window.inactive.label.text.color*
+       Text color non-focussed windows' titlebars
 
 *window.active.button.unpressed.image.color*
        Color of the images in titlebar buttons in their default, unpressed,
index 58244999b370cab1fd60d14d5709aeb3d42ea46c..132390a2a39149e055312e52fc9f697778933d10 100644 (file)
@@ -236,7 +236,12 @@ struct view {
                struct wl_list parts;
                struct wlr_box box; /* remember geo so we know when to update */
        } ssd;
-       struct wlr_texture *title;
+
+       /* The title is unique to each view, so we store these here */
+       struct {
+               struct wlr_texture *active;
+               struct wlr_texture *inactive;
+       } title;
 
        struct wlr_foreign_toplevel_handle_v1 *toplevel_handle;
        struct wl_listener toplevel_handle_request_maximize;
index 8041f94ebc94e6e3a017f2f00b350130d32e6982..8f4fa24f7164488f48072d6f4a8cdd8f019e8bfb 100644 (file)
@@ -20,6 +20,9 @@ struct theme {
        float window_active_title_bg_color[4];
        float window_inactive_title_bg_color[4];
 
+       float window_active_label_text_color[4];
+       float window_inactive_label_text_color[4];
+
        /* buttons */
        float window_active_button_iconify_unpressed_image_color[4];
        float window_active_button_max_unpressed_image_color[4];
index 0900fdd7dd413fb39e4f70638f5f61de346869d9..200e3f75957504350aafec434e6672f7d1677dcd 100644 (file)
--- a/src/ssd.c
+++ b/src/ssd.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0-only
 /*
  * Helpers for view server side decorations
  *
@@ -173,7 +174,7 @@ ssd_visible_box(struct view *view, enum ssd_part_type type)
                break;
        case LAB_SSD_PART_TITLE:
                box = ssd_box(view, type);
-               center_vertically(&box, view->title);
+               center_vertically(&box, view->title.active);
                break;
        case LAB_SSD_PART_CORNER_TOP_LEFT:
                box = ssd_box(view, type);
@@ -286,10 +287,13 @@ ssd_update_title(struct view *view)
 
        int max_width = part->box.width > 0 ? part->box.width : 1000;
 
-       /* TODO: use window.active.label.text.color here */
-       font_texture_create(view->server, &view->title, max_width,
+       font_texture_create(view->server, &view->title.active, max_width,
                view->impl->get_string_prop(view, "title"),
-               &font, theme->menu_items_active_text_color);
+               &font, theme->window_active_label_text_color);
+
+       font_texture_create(view->server, &view->title.inactive, max_width,
+               view->impl->get_string_prop(view, "title"),
+               &font, theme->window_inactive_label_text_color);
 
        part->box = ssd_visible_box(view, part->type);
 }
@@ -340,8 +344,8 @@ ssd_create(struct view *view)
        /* title text */
        part = add_part(view, LAB_SSD_PART_TITLE);
        ssd_update_title(view);
-       part->texture.active = &view->title;
-       part->texture.inactive = &view->title;
+       part->texture.active = &view->title.active;
+       part->texture.inactive = &view->title.inactive;
 }
 
 void
index 8525a79d349b2204917b2c1301fdfd5630f57e20..c0cfdb1c863b6f84944e7c2190184cf467464534 100644 (file)
@@ -85,6 +85,9 @@ theme_builtin(struct theme *theme)
        parse_hexstr("#dddad6", theme->window_active_title_bg_color);
        parse_hexstr("#f6f5f4", theme->window_inactive_title_bg_color);
 
+       parse_hexstr("#000000", theme->window_active_label_text_color);
+       parse_hexstr("#000000", theme->window_inactive_label_text_color);
+
        parse_hexstr("#000000",
                theme->window_active_button_iconify_unpressed_image_color);
        parse_hexstr("#000000",
@@ -154,6 +157,13 @@ entry(struct theme *theme, const char *key, const char *value)
                parse_hexstr(value, theme->window_inactive_title_bg_color);
        }
 
+       if (match(key, "window.active.label.text.color")) {
+               parse_hexstr(value, theme->window_active_label_text_color);
+       }
+       if (match(key, "window.inactive.lable.text.color")) {
+               parse_hexstr(value, theme->window_inactive_label_text_color);
+       }
+
        /* universal button */
        if (match(key, "window.active.button.unpressed.image.color")) {
                parse_hexstr(value,