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;
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);
assert(menu);
assert(text);
+ struct theme *theme = menu->server->theme;
struct menuitem *menuitem = znew(*menuitem);
menuitem->parent = menu;
menuitem->selectable = true;
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);
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;
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);
/* 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 */