diff --git a/src/common/font.c b/src/common/font.c index 81784ea8..b307729c 100644 --- a/src/common/font.c +++ b/src/common/font.c @@ -22,7 +22,7 @@ static PangoRectangle font_extents(struct font *font, const char *string) { PangoRectangle rect = { 0 }; - if (!string) { + if (string_null_or_empty(string)) { return rect; } cairo_surface_t *surface; @@ -43,10 +43,6 @@ font_extents(struct font *font, const char *string) pango_layout_get_extents(layout, NULL, &rect); pango_extents_to_pixels(&rect, NULL); - /* we put a 2 px edge on each side - because Openbox does it :) */ - /* TODO: remove the 4 pixel addition and always do the padding by the caller */ - rect.width += 4; - cairo_destroy(c); cairo_surface_destroy(surface); pango_font_description_free(desc); diff --git a/src/menu/menu.c b/src/menu/menu.c index e7a7b90c..455035ec 100644 --- a/src/menu/menu.c +++ b/src/menu/menu.c @@ -135,6 +135,7 @@ item_create(struct menu *menu, const char *text, const char *icon_name, bool sho assert(menu); assert(text); + struct theme *theme = menu->server->theme; struct menuitem *menuitem = znew(*menuitem); menuitem->parent = menu; menuitem->selectable = true; @@ -151,7 +152,8 @@ item_create(struct menu *menu, const char *text, const char *icon_name, bool sho menuitem->native_width = font_width(&rc.font_menuitem, text); if (menuitem->arrow) { - menuitem->native_width += font_width(&rc.font_menuitem, menuitem->arrow); + menuitem->native_width += font_width(&rc.font_menuitem, menuitem->arrow) + + theme->menu_items_padding_x; } wl_list_append(&menu->menuitems, &menuitem->link); @@ -177,7 +179,7 @@ item_create_scene_for_state(struct menuitem *item, float *text_color, int bg_width = menu->size.width - 2 * theme->menu_border_width; int arrow_width = item->arrow ? - font_width(&rc.font_menuitem, item->arrow) : 0; + font_width(&rc.font_menuitem, item->arrow) + theme->menu_items_padding_x : 0; int label_max_width = bg_width - 2 * theme->menu_items_padding_x - arrow_width - icon_width; @@ -227,7 +229,7 @@ item_create_scene_for_state(struct menuitem *item, float *text_color, scaled_font_buffer_update(arrow_buffer, item->arrow, -1, &rc.font_menuitem, text_color, bg_color); /* Vertically center and right-align arrow */ - x += label_max_width; + x += label_max_width + theme->menu_items_padding_x; y = (theme->menu_item_height - label_buffer->height) / 2; wlr_scene_node_set_position(&arrow_buffer->scene_buffer->node, x, y); diff --git a/src/ssd/resize-indicator.c b/src/ssd/resize-indicator.c index 6c22e656..3a635edc 100644 --- a/src/ssd/resize-indicator.c +++ b/src/ssd/resize-indicator.c @@ -193,9 +193,6 @@ resize_indicator_update(struct view *view) /* Let the indicator change width as required by the content */ int width = font_width(&rc.font_osd, text); - /* font_extents() adds 4 pixels to the calculated width */ - width -= 4; - resize_indicator_set_size(indicator, width); /* Center the indicator in the window */