Skip to content

Commit

Permalink
Fix issue with ceil and floor
Browse files Browse the repository at this point in the history
  • Loading branch information
wfdewith committed Dec 13, 2014
1 parent f4cdb2a commit dfb4c93
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions x.c
Expand Up @@ -452,6 +452,7 @@ static dimension_t x_render_layout(cairo_t *c, colored_layout *cl, dimension_t d
int bg_width = dim.w;
int bg_height = MAX(settings.notification_height, (2 * settings.padding) + h);
double bg_half_height = settings.notification_height/2.0;
int pango_offset = (int) floor(h/2.0);

/* adding frame */
bg_x += settings.frame_width;
Expand All @@ -471,18 +472,18 @@ static dimension_t x_render_layout(cairo_t *c, colored_layout *cl, dimension_t d
if (use_padding)
dim.y += settings.padding;
else
dim.y += (int) (ceil(bg_half_height) - floor(h/2.0));
dim.y += (int) (ceil(bg_half_height) - pango_offset);
if (cl->icon && settings.icon_position == icons_left)
cairo_move_to(c, cairo_image_surface_get_width(cl->icon) + 2 * settings.h_padding, dim.y);
else cairo_move_to(c, settings.h_padding, dim.y);
cairo_set_source_rgb(c, cl->fg.r, cl->fg.g, cl->fg.b);
pango_cairo_update_layout(c, cl->l);
pango_cairo_show_layout(c, cl->l);

if (use_padding)
dim.y += h + settings.padding;
else
dim.y += (int) (floor(bg_half_height) + ceil(h/2.0));
dim.y += (int) (floor(bg_half_height) + pango_offset);

color_t sep_color = x_get_separator_color(cl->fg, cl->bg);
if (settings.separator_height > 0 && !last) {
cairo_set_source_rgb(c, sep_color.r, sep_color.g, sep_color.b);
Expand Down

0 comments on commit dfb4c93

Please sign in to comment.