From 3990018bb9404d068b9731ac558b9cdaca032f37 Mon Sep 17 00:00:00 2001 From: Johan Malm Date: Fri, 20 Aug 2021 20:27:52 +0100 Subject: [PATCH] config: support setting menu item font In rc.xml, support --- docs/labwc-config.5.scd | 3 ++- include/config/rcxml.h | 2 ++ src/config/rcxml.c | 20 +++++++++++++++++--- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/docs/labwc-config.5.scd b/docs/labwc-config.5.scd index a1eb5566..7e7934d8 100644 --- a/docs/labwc-config.5.scd +++ b/docs/labwc-config.5.scd @@ -46,6 +46,7 @@ Configuration must be wrapped in a root-node. The font to use for a specific element of a window, menu or OSD. Places can be any of: - ActiveWindow - titlebar of active window + - MenuItem - menu item (currently only root menu) If no place attribute is provided, the setting will be applied to all places. @@ -53,7 +54,7 @@ Configuration must be wrapped in a root-node. Describes font name. Default is sans. ** - Font size in pixels. Default is 8. + Font size in pixels. Default is 10. # KEYBOARD diff --git a/include/config/rcxml.h b/include/config/rcxml.h index 188ea5bd..07433301 100644 --- a/include/config/rcxml.h +++ b/include/config/rcxml.h @@ -14,7 +14,9 @@ struct rcxml { char *theme_name; int corner_radius; char *font_name_activewindow; + char *font_name_menuitem; int font_size_activewindow; + int font_size_menuitem; struct wl_list keybinds; }; diff --git a/src/config/rcxml.c b/src/config/rcxml.c index e76adea6..fefd9baa 100644 --- a/src/config/rcxml.c +++ b/src/config/rcxml.c @@ -25,7 +25,7 @@ static struct keybind *current_keybind; enum font_place { FONT_PLACE_UNKNOWN = 0, FONT_PLACE_ACTIVEWINDOW, - FONT_PLACE_INACTIVEWINDOW, + FONT_PLACE_MENUITEM, /* TODO: Add all places based on Openbox's rc.xml */ }; @@ -89,8 +89,10 @@ fill_font(char *nodename, char *content, enum font_place place) */ if (!strcmp(nodename, "name")) { rc.font_name_activewindow = strdup(content); + rc.font_name_menuitem = strdup(content); } else if (!strcmp(nodename, "size")) { rc.font_size_activewindow = atoi(content); + rc.font_size_menuitem = atoi(content); } break; case FONT_PLACE_ACTIVEWINDOW: @@ -100,6 +102,13 @@ fill_font(char *nodename, char *content, enum font_place place) rc.font_size_activewindow = atoi(content); } break; + case FONT_PLACE_MENUITEM: + if (!strcmp(nodename, "name")) { + rc.font_name_menuitem = strdup(content); + } else if (!strcmp(nodename, "size")) { + rc.font_size_menuitem = atoi(content); + } + break; /* TODO: implement for all font places */ @@ -116,8 +125,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; } return FONT_PLACE_UNKNOWN; } @@ -248,6 +257,7 @@ rcxml_init() rc.xdg_shell_server_side_deco = true; rc.corner_radius = 8; rc.font_size_activewindow = 10; + rc.font_size_menuitem = 10; } static void @@ -281,6 +291,9 @@ post_processing(void) if (!rc.font_name_activewindow) { rc.font_name_activewindow = strdup("sans"); } + if (!rc.font_name_menuitem) { + rc.font_name_menuitem = strdup("sans"); + } } static void @@ -352,6 +365,7 @@ void rcxml_finish(void) { zfree(rc.font_name_activewindow); + zfree(rc.font_name_menuitem); zfree(rc.theme_name); struct keybind *k, *k_tmp; -- 2.52.0