Refactor hacky floating point casts
Avoid casting an int to a double for a calculation only to cast it back, instead prefer to use integer operations where appropriate.
This commit is contained in:
parent
4e57e1db1c
commit
5e7f58203e
@ -483,8 +483,6 @@ static struct dimensions layout_render(cairo_surface_t *srf, colored_layout *cl,
|
||||
pango_layout_get_pixel_size(cl->l, NULL, &h_text);
|
||||
|
||||
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);
|
||||
|
||||
cairo_surface_t *content = render_background(srf, cl, cl_next, dim.y, dim.w, bg_height, first, last);
|
||||
cairo_t *c = cairo_create(content);
|
||||
@ -502,7 +500,7 @@ static struct dimensions layout_render(cairo_surface_t *srf, colored_layout *cl,
|
||||
if (settings.notification_height <= (2 * settings.padding) + h)
|
||||
dim.y += h + 2 * settings.padding;
|
||||
else
|
||||
dim.y += 2 *( (int) (ceil(bg_half_height) - pango_offset));
|
||||
dim.y += settings.notification_height;
|
||||
|
||||
cairo_destroy(c);
|
||||
cairo_surface_destroy(content);
|
||||
|
@ -161,11 +161,11 @@ cairo_surface_t *icon_get_for_notification(const notification *n)
|
||||
if (w >= h) {
|
||||
scaled = gdk_pixbuf_scale_simple(pixbuf,
|
||||
settings.max_icon_size,
|
||||
(int) ((double) settings.max_icon_size / w * h),
|
||||
(settings.max_icon_size * h) / w,
|
||||
GDK_INTERP_BILINEAR);
|
||||
} else {
|
||||
scaled = gdk_pixbuf_scale_simple(pixbuf,
|
||||
(int) ((double) settings.max_icon_size / h * w),
|
||||
(settings.max_icon_size * w) / h,
|
||||
settings.max_icon_size,
|
||||
GDK_INTERP_BILINEAR);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user