]> git.mdlowis.com Git - proto/labwc.git/commitdiff
feat: implement <font place="InactiveWindow"> (ref scope: 2.4.7) (#1292)
authorLudgie <77110723+ludg1e@users.noreply.github.com>
Thu, 7 Dec 2023 08:28:27 +0000 (09:28 +0100)
committerGitHub <noreply@github.com>
Thu, 7 Dec 2023 08:28:27 +0000 (09:28 +0100)
* feat: implement <font place="InactiveWindow"> (ref scope: 2.4.7)
* docs: add inactivewindow

docs/labwc-config.5.scd
docs/rc.xml.all
include/config/rcxml.h
src/config/rcxml.c
src/ssd/ssd_titlebar.c
src/theme.c

index bf658ebc42475e81c4268d69bf3410b5865bba45..43dec32893e4011d4d4993c8e52345cb7839f56a 100644 (file)
@@ -238,6 +238,7 @@ windows using the mouse.
        The font to use for a specific element of a window, menu or OSD.
        Places can be any of:
        - ActiveWindow - titlebar of active window
+       - InactiveWindow - titlebar of all windows that aren't focused by the cursor
        - MenuItem - menu item (currently only root menu)
        - OnScreenDisplay - items in the on screen display
        If no place attribute is provided, the setting will be applied to all
index 92a5920aa50c8fa288b95a561291db5f18ed43a7..7c59660a5c0706a9032d83f9ced6cbfd7b86ad9c 100644 (file)
       <slant>normal</slant>
       <weight>normal</weight>
     </font>
+    <font place="InactiveWindow">
+      <name>sans</name>
+      <size>10</size>
+      <slant>normal</slant>
+      <weight>normal</weight>
+    </font>
     <font place="MenuItem">
       <name>sans</name>
       <size>10</size>
index ed87a91f42ceb074b6992fe7040c0c4638d457b3..62cc5a15f2fd18e03dcf607e5a53cecb2407272c 100644 (file)
@@ -51,6 +51,7 @@ struct rcxml {
        int corner_radius;
        bool ssd_keep_border;
        struct font font_activewindow;
+       struct font font_inactivewindow;
        struct font font_menuitem;
        struct font font_osd;
        /* Pointer to current theme */
index ed4c1847e3cfcd97efcbd9f93d2018ade88deffb..45bb898bea9530bcee7e3896837a6afcd9583ec7 100644 (file)
@@ -61,6 +61,7 @@ enum font_place {
        FONT_PLACE_NONE = 0,
        FONT_PLACE_UNKNOWN,
        FONT_PLACE_ACTIVEWINDOW,
+       FONT_PLACE_INACTIVEWINDOW,
        FONT_PLACE_MENUITEM,
        FONT_PLACE_OSD,
        /* TODO: Add all places based on Openbox's rc.xml */
@@ -564,12 +565,16 @@ fill_font(char *nodename, char *content, enum font_place place)
                 * attribute, we set all font variables
                 */
                set_font_attr(&rc.font_activewindow, nodename, content);
+               set_font_attr(&rc.font_inactivewindow, nodename, content);
                set_font_attr(&rc.font_menuitem, nodename, content);
                set_font_attr(&rc.font_osd, nodename, content);
                break;
        case FONT_PLACE_ACTIVEWINDOW:
                set_font_attr(&rc.font_activewindow, nodename, content);
                break;
+       case FONT_PLACE_INACTIVEWINDOW:
+               set_font_attr(&rc.font_inactivewindow, nodename, content);
+               break;
        case FONT_PLACE_MENUITEM:
                set_font_attr(&rc.font_menuitem, nodename, content);
                break;
@@ -592,6 +597,8 @@ enum_font_place(const char *place)
        }
        if (!strcasecmp(place, "ActiveWindow")) {
                return FONT_PLACE_ACTIVEWINDOW;
+       } else if (!strcasecmp(place, "InactiveWindow")) {
+               return FONT_PLACE_INACTIVEWINDOW;
        } else if (!strcasecmp(place, "MenuItem")) {
                return FONT_PLACE_MENUITEM;
        } else if (!strcasecmp(place, "OnScreenDisplay")
@@ -949,6 +956,7 @@ rcxml_init(void)
        rc.corner_radius = 8;
 
        init_font_defaults(&rc.font_activewindow);
+       init_font_defaults(&rc.font_inactivewindow);
        init_font_defaults(&rc.font_menuitem);
        init_font_defaults(&rc.font_osd);
 
@@ -1256,6 +1264,9 @@ post_processing(void)
        if (!rc.font_activewindow.name) {
                rc.font_activewindow.name = xstrdup("sans");
        }
+       if (!rc.font_inactivewindow.name) {
+               rc.font_inactivewindow.name = xstrdup("sans");
+       }
        if (!rc.font_menuitem.name) {
                rc.font_menuitem.name = xstrdup("sans");
        }
@@ -1440,6 +1451,7 @@ void
 rcxml_finish(void)
 {
        zfree(rc.font_activewindow.name);
+       zfree(rc.font_inactivewindow.name);
        zfree(rc.font_menuitem.name);
        zfree(rc.font_osd.name);
        zfree(rc.theme_name);
index 7b2ef2f3a70216fb424e3fb13cb834bc40ffcfcf..fc28e64afd35099fadd942d6663579f0b164348d 100644 (file)
@@ -317,6 +317,7 @@ ssd_update_title(struct ssd *ssd)
        bool title_unchanged = state->text && !strcmp(title, state->text);
 
        float *text_color;
+       struct font *font = NULL;
        struct ssd_part *part;
        struct ssd_sub_tree *subtree;
        struct ssd_state_title_width *dstate;
@@ -327,9 +328,11 @@ ssd_update_title(struct ssd *ssd)
                if (subtree == &ssd->titlebar.active) {
                        dstate = &state->active;
                        text_color = theme->window_active_label_text_color;
+                       font = &rc.font_activewindow;
                } else {
                        dstate = &state->inactive;
                        text_color = theme->window_inactive_label_text_color;
+                       font = &rc.font_inactivewindow;
                }
 
                if (title_bg_width <= 0) {
@@ -356,9 +359,8 @@ ssd_update_title(struct ssd *ssd)
                }
 
                if (part->buffer) {
-                       /* TODO: Do we only have active window fonts? */
                        scaled_font_buffer_update(part->buffer, title,
-                               title_bg_width, &rc.font_activewindow,
+                               title_bg_width, font,
                                text_color, NULL);
                }
 
index 97a00695bfe4e8a169f9e3b3d39cb8e2096a7a7c..7deceaeb96d8bb94228fc73426e2ba0450d7f178 100644 (file)
@@ -848,7 +848,7 @@ create_corners(struct theme *theme)
 static void
 post_processing(struct theme *theme)
 {
-       int h = font_height(&rc.font_activewindow);
+       int h = MAX(font_height(&rc.font_activewindow), font_height(&rc.font_inactivewindow));
        if (theme->title_height < h) {
                theme->title_height = h + 2 * theme->padding_height;
        }