mirror of
https://github.com/labwc/labwc.git
synced 2025-10-29 05:40:24 -04:00
Config: add OSD font configuration
This commit is contained in:
parent
238062a859
commit
859495a8be
5 changed files with 28 additions and 8 deletions
|
|
@ -54,6 +54,7 @@ Configuration must be wrapped in a <labwc_config> root-node.
|
|||
Places can be any of:
|
||||
- ActiveWindow - titlebar of active window
|
||||
- MenuItem - menu item (currently only root menu)
|
||||
- OSD - items in the on screen display
|
||||
If no place attribute is provided, the setting will be applied to all
|
||||
places.
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
<cornerRadius>8</cornerRadius>
|
||||
<font place="ActiveWindow"><name>sans</name><size>10</size></font>
|
||||
<font place="MenuItem"><name>sans</name><size>10</size></font>
|
||||
<font place="OSD"><name>sans</name><size>10</size></font>
|
||||
</theme>
|
||||
|
||||
<focus>
|
||||
|
|
|
|||
|
|
@ -25,8 +25,10 @@ struct rcxml {
|
|||
int corner_radius;
|
||||
char *font_name_activewindow;
|
||||
char *font_name_menuitem;
|
||||
char *font_name_osd;
|
||||
int font_size_activewindow;
|
||||
int font_size_menuitem;
|
||||
int font_size_osd;
|
||||
|
||||
/* keyboard */
|
||||
int repeat_rate;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ enum font_place {
|
|||
FONT_PLACE_UNKNOWN = 0,
|
||||
FONT_PLACE_ACTIVEWINDOW,
|
||||
FONT_PLACE_MENUITEM,
|
||||
FONT_PLACE_OSD,
|
||||
/* TODO: Add all places based on Openbox's rc.xml */
|
||||
};
|
||||
|
||||
|
|
@ -206,9 +207,11 @@ 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);
|
||||
rc.font_name_osd = strdup(content);
|
||||
} else if (!strcmp(nodename, "size")) {
|
||||
rc.font_size_activewindow = atoi(content);
|
||||
rc.font_size_menuitem = atoi(content);
|
||||
rc.font_size_osd = atoi(content);
|
||||
}
|
||||
break;
|
||||
case FONT_PLACE_ACTIVEWINDOW:
|
||||
|
|
@ -225,6 +228,13 @@ fill_font(char *nodename, char *content, enum font_place place)
|
|||
rc.font_size_menuitem = atoi(content);
|
||||
}
|
||||
break;
|
||||
case FONT_PLACE_OSD:
|
||||
if (!strcmp(nodename, "name")) {
|
||||
rc.font_name_osd = strdup(content);
|
||||
} else if (!strcmp(nodename, "size")) {
|
||||
rc.font_size_osd = atoi(content);
|
||||
}
|
||||
break;
|
||||
|
||||
/* TODO: implement for all font places */
|
||||
|
||||
|
|
@ -243,6 +253,8 @@ enum_font_place(const char *place)
|
|||
return FONT_PLACE_ACTIVEWINDOW;
|
||||
} else if (!strcasecmp(place, "MenuItem")) {
|
||||
return FONT_PLACE_MENUITEM;
|
||||
} else if (!strcasecmp(place, "OSD")) {
|
||||
return FONT_PLACE_OSD;
|
||||
}
|
||||
return FONT_PLACE_UNKNOWN;
|
||||
}
|
||||
|
|
@ -418,6 +430,7 @@ rcxml_init()
|
|||
rc.corner_radius = 8;
|
||||
rc.font_size_activewindow = 10;
|
||||
rc.font_size_menuitem = 10;
|
||||
rc.font_size_osd = 10;
|
||||
rc.doubleclick_time = 500;
|
||||
rc.repeat_rate = 25;
|
||||
rc.repeat_delay = 600;
|
||||
|
|
@ -525,6 +538,9 @@ post_processing(void)
|
|||
if (!rc.font_name_menuitem) {
|
||||
rc.font_name_menuitem = strdup("sans");
|
||||
}
|
||||
if (!rc.font_name_osd) {
|
||||
rc.font_name_osd = strdup("sans");
|
||||
}
|
||||
if (!wl_list_length(&rc.libinput_categories)) {
|
||||
/* So we still allow tap to click by default */
|
||||
struct libinput_category *l = libinput_category_create();
|
||||
|
|
@ -602,6 +618,7 @@ rcxml_finish(void)
|
|||
{
|
||||
zfree(rc.font_name_activewindow);
|
||||
zfree(rc.font_name_menuitem);
|
||||
zfree(rc.font_name_osd);
|
||||
zfree(rc.theme_name);
|
||||
|
||||
struct keybind *k, *k_tmp;
|
||||
|
|
|
|||
15
src/osd.c
15
src/osd.c
|
|
@ -119,9 +119,13 @@ osd_update(struct server *server)
|
|||
pango_layout_set_width(layout, w * PANGO_SCALE);
|
||||
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
|
||||
|
||||
/* TODO: use font description from config */
|
||||
PangoFontDescription *desc =
|
||||
pango_font_description_from_string("sans 10");
|
||||
struct font font = {
|
||||
.name = rc.font_name_osd,
|
||||
.size = rc.font_size_osd,
|
||||
};
|
||||
PangoFontDescription *desc = pango_font_description_new();
|
||||
pango_font_description_set_family(desc, font.name);
|
||||
pango_font_description_set_size(desc, font.size * PANGO_SCALE);
|
||||
pango_layout_set_font_description(layout, desc);
|
||||
pango_font_description_free(desc);
|
||||
|
||||
|
|
@ -136,11 +140,6 @@ osd_update(struct server *server)
|
|||
buf_init(&buf);
|
||||
y = OSD_BORDER_WIDTH;
|
||||
|
||||
/* vertically center align */
|
||||
struct font font = {
|
||||
.name = "sans",
|
||||
.size = 10,
|
||||
};
|
||||
y += (OSD_ITEM_HEIGHT - font_height(&font)) / 2;
|
||||
|
||||
wl_list_for_each(view, &server->views, link) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue