feat: implement <font place="InactiveWindow"> (ref scope: 2.4.7)

This commit is contained in:
Ludgie 2023-12-07 08:06:42 +01:00 committed by GitHub
parent d59b1d0966
commit 0a9671cad5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 3 deletions

View file

@ -51,6 +51,7 @@ struct rcxml {
int corner_radius; int corner_radius;
bool ssd_keep_border; bool ssd_keep_border;
struct font font_activewindow; struct font font_activewindow;
struct font font_inactivewindow;
struct font font_menuitem; struct font font_menuitem;
struct font font_osd; struct font font_osd;
/* Pointer to current theme */ /* Pointer to current theme */

View file

@ -61,6 +61,7 @@ enum font_place {
FONT_PLACE_NONE = 0, FONT_PLACE_NONE = 0,
FONT_PLACE_UNKNOWN, FONT_PLACE_UNKNOWN,
FONT_PLACE_ACTIVEWINDOW, FONT_PLACE_ACTIVEWINDOW,
FONT_PLACE_INACTIVEWINDOW,
FONT_PLACE_MENUITEM, FONT_PLACE_MENUITEM,
FONT_PLACE_OSD, FONT_PLACE_OSD,
/* TODO: Add all places based on Openbox's rc.xml */ /* 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 * attribute, we set all font variables
*/ */
set_font_attr(&rc.font_activewindow, nodename, content); 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_menuitem, nodename, content);
set_font_attr(&rc.font_osd, nodename, content); set_font_attr(&rc.font_osd, nodename, content);
break; break;
case FONT_PLACE_ACTIVEWINDOW: case FONT_PLACE_ACTIVEWINDOW:
set_font_attr(&rc.font_activewindow, nodename, content); set_font_attr(&rc.font_activewindow, nodename, content);
break; break;
case FONT_PLACE_INACTIVEWINDOW:
set_font_attr(&rc.font_inactivewindow, nodename, content);
break;
case FONT_PLACE_MENUITEM: case FONT_PLACE_MENUITEM:
set_font_attr(&rc.font_menuitem, nodename, content); set_font_attr(&rc.font_menuitem, nodename, content);
break; break;
@ -949,6 +954,7 @@ rcxml_init(void)
rc.corner_radius = 8; rc.corner_radius = 8;
init_font_defaults(&rc.font_activewindow); init_font_defaults(&rc.font_activewindow);
init_font_defaults(&rc.font_inactivewindow);
init_font_defaults(&rc.font_menuitem); init_font_defaults(&rc.font_menuitem);
init_font_defaults(&rc.font_osd); init_font_defaults(&rc.font_osd);
@ -1256,6 +1262,9 @@ post_processing(void)
if (!rc.font_activewindow.name) { if (!rc.font_activewindow.name) {
rc.font_activewindow.name = xstrdup("sans"); rc.font_activewindow.name = xstrdup("sans");
} }
if (!rc.font_inactivewindow.name) {
rc.font_inactivewindow.name = xstrdup("sans");
}
if (!rc.font_menuitem.name) { if (!rc.font_menuitem.name) {
rc.font_menuitem.name = xstrdup("sans"); rc.font_menuitem.name = xstrdup("sans");
} }
@ -1440,6 +1449,7 @@ void
rcxml_finish(void) rcxml_finish(void)
{ {
zfree(rc.font_activewindow.name); zfree(rc.font_activewindow.name);
zfree(rc.font_inactivewindow.name);
zfree(rc.font_menuitem.name); zfree(rc.font_menuitem.name);
zfree(rc.font_osd.name); zfree(rc.font_osd.name);
zfree(rc.theme_name); zfree(rc.theme_name);

View file

@ -317,6 +317,7 @@ ssd_update_title(struct ssd *ssd)
bool title_unchanged = state->text && !strcmp(title, state->text); bool title_unchanged = state->text && !strcmp(title, state->text);
float *text_color; float *text_color;
struct font *font = NULL;
struct ssd_part *part; struct ssd_part *part;
struct ssd_sub_tree *subtree; struct ssd_sub_tree *subtree;
struct ssd_state_title_width *dstate; struct ssd_state_title_width *dstate;
@ -327,9 +328,11 @@ ssd_update_title(struct ssd *ssd)
if (subtree == &ssd->titlebar.active) { if (subtree == &ssd->titlebar.active) {
dstate = &state->active; dstate = &state->active;
text_color = theme->window_active_label_text_color; text_color = theme->window_active_label_text_color;
font = &rc.font_activewindow;
} else { } else {
dstate = &state->inactive; dstate = &state->inactive;
text_color = theme->window_inactive_label_text_color; text_color = theme->window_inactive_label_text_color;
font = &rc.font_inactivewindow;
} }
if (title_bg_width <= 0) { if (title_bg_width <= 0) {
@ -356,9 +359,8 @@ ssd_update_title(struct ssd *ssd)
} }
if (part->buffer) { if (part->buffer) {
/* TODO: Do we only have active window fonts? */
scaled_font_buffer_update(part->buffer, title, scaled_font_buffer_update(part->buffer, title,
title_bg_width, &rc.font_activewindow, title_bg_width, font,
text_color, NULL); text_color, NULL);
} }

View file

@ -848,7 +848,7 @@ create_corners(struct theme *theme)
static void static void
post_processing(struct theme *theme) 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) { if (theme->title_height < h) {
theme->title_height = h + 2 * theme->padding_height; theme->title_height = h + 2 * theme->padding_height;
} }