Skip to content

Commit

Permalink
handle icon in minimum width calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
apprehensions committed Mar 22, 2024
1 parent 12f4386 commit 309ca6f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions render.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ static int render_notification(cairo_t *cairo, struct mako_state *state, struct
int notif_width =
(style->width <= surface->width) ? style->width : surface->width;


// text_x is the offset of the text inside our draw operation
double text_x = style->padding.left;
if (icon != NULL && style->icon_location == MAKO_ICON_LOCATION_LEFT) {
Expand Down Expand Up @@ -173,8 +172,15 @@ static int render_notification(cairo_t *cairo, struct mako_state *state, struct
int text_height = buffer_text_height / scale;
int text_width = buffer_text_width / scale;

notif_width = MAX(style->min_width, text_width + border_size + padding_width);
int min_width = text_width + border_size + padding_width;
if (icon && ! icon_vertical) {
min_width += icon->width;
min_width += style->icon_location == MAKO_ICON_LOCATION_LEFT ?
style->padding.left : style->padding.right;
}

notif_width = MAX(style->min_width, min_width);

// offset_x is for the entire draw operation inside the surface
int offset_x;
if (surface->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT) {
Expand Down

0 comments on commit 309ca6f

Please sign in to comment.