From 5e8097475ba237bc0bc71ad78a7cbdf2d71f7b87 Mon Sep 17 00:00:00 2001 From: rbuj Date: Sun, 12 Dec 2021 11:39:14 +0100 Subject: Fix some -Wfloat-conversion warnings --- src/ui/draw-workspace.c | 8 ++++---- src/ui/gradient.c | 43 ++++++++++++++++++++++++------------------- src/ui/theme.c | 24 +++++++++++++----------- 3 files changed, 41 insertions(+), 34 deletions(-) (limited to 'src/ui') diff --git a/src/ui/draw-workspace.c b/src/ui/draw-workspace.c index fc8f82e5..c5519cae 100644 --- a/src/ui/draw-workspace.c +++ b/src/ui/draw-workspace.c @@ -46,10 +46,10 @@ get_window_rect (const WnckWindowDisplayInfo *win, width = win->width; height = win->height; - x *= width_ratio; - y *= height_ratio; - width *= width_ratio; - height *= height_ratio; + x = (int) (width_ratio * (double) x); + y = (int) (height_ratio * (double) y); + width = (int) (width_ratio * (double) width); + height = (int) (height_ratio * (double) height); x += workspace_rect->x; y += workspace_rect->y; diff --git a/src/ui/gradient.c b/src/ui/gradient.c index 7a9be6ad..a059e564 100644 --- a/src/ui/gradient.c +++ b/src/ui/gradient.c @@ -771,6 +771,7 @@ meta_gradient_create_interwoven (int width, unsigned char *ptr; unsigned char *pixels; int rowstride; + double height_scaling; pixbuf = blank_pixbuf (width, height); if (pixbuf == NULL) @@ -779,25 +780,29 @@ meta_gradient_create_interwoven (int width, pixels = gdk_pixbuf_get_pixels (pixbuf); rowstride = gdk_pixbuf_get_rowstride (pixbuf); - r1 = (long)(colors1[0].red*0xffffff); - g1 = (long)(colors1[0].green*0xffffff); - b1 = (long)(colors1[0].blue*0xffffff); - a1 = (long)(colors1[0].alpha*0xffffff); - - r2 = (long)(colors2[0].red*0xffffff); - g2 = (long)(colors2[0].green*0xffffff); - b2 = (long)(colors2[0].blue*0xffffff); - a2 = (long)(colors2[0].alpha*0xffffff); - - dr1 = ((colors1[1].red-colors1[0].red)*0xffffff)/(int)height; - dg1 = ((colors1[1].green-colors1[0].green)*0xffffff)/(int)height; - db1 = ((colors1[1].blue-colors1[0].blue)*0xffffff)/(int)height; - da1 = ((colors1[1].alpha-colors1[0].alpha)*0xffffff)/(int)height; - - dr2 = ((colors2[1].red-colors2[0].red)*0xffffff)/(int)height; - dg2 = ((colors2[1].green-colors2[0].green)*0xffffff)/(int)height; - db2 = ((colors2[1].blue-colors2[0].blue)*0xffffff)/(int)height; - da2 = ((colors2[1].alpha-colors2[0].alpha)*0xffffff)/(int)height; +#define RGBA_SCALING 16777215.0 /* 0xffffff */ + r1 = (long) (colors1[0].red * RGBA_SCALING); + g1 = (long) (colors1[0].green * RGBA_SCALING); + b1 = (long) (colors1[0].blue * RGBA_SCALING); + a1 = (long) (colors1[0].alpha * RGBA_SCALING); + + r2 = (long) (colors2[0].red * RGBA_SCALING); + g2 = (long) (colors2[0].green * RGBA_SCALING); + b2 = (long) (colors2[0].blue * RGBA_SCALING); + a2 = (long) (colors2[0].alpha * RGBA_SCALING); + + height_scaling = RGBA_SCALING / (gdouble) height; + + dr1 = (long) (colors1[1].red-colors1[0].red * height_scaling); + dg1 = (long) (colors1[1].green-colors1[0].green * height_scaling); + db1 = (long) (colors1[1].blue-colors1[0].blue * height_scaling); + da1 = (long) (colors1[1].alpha-colors1[0].alpha * height_scaling); + + dr2 = (long) (colors2[1].red-colors2[0].red * height_scaling); + dg2 = (long) (colors2[1].green-colors2[0].green * height_scaling); + db2 = (long) (colors2[1].blue-colors2[0].blue * height_scaling); + da2 = (long) (colors2[1].alpha-colors2[0].alpha * height_scaling); +#undef RGBA_SCALING for (i=0,k=0,l=0,ll=thickness1; ibutton_border.top - layout->button_border.bottom; - button_width = button_height / layout->button_aspect; + button_width = (int) (((double) button_height) / layout->button_aspect); break; case META_BUTTON_SIZING_FIXED: button_width = layout->button_width; @@ -882,12 +882,12 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout *layout, space_used_by_buttons = 0; space_used_by_buttons += button_width * n_left; - space_used_by_buttons += (button_width * 0.75) * n_left_spacers; + space_used_by_buttons += (int) (0.75 * (double) (button_width * n_left_spacers)); space_used_by_buttons += layout->button_border.left * n_left; space_used_by_buttons += layout->button_border.right * n_left; space_used_by_buttons += button_width * n_right; - space_used_by_buttons += (button_width * 0.75) * n_right_spacers; + space_used_by_buttons += (int) (0.75 * (double) (button_width * n_right_spacers)); space_used_by_buttons += layout->button_border.left * n_right; space_used_by_buttons += layout->button_border.right * n_right; @@ -988,7 +988,7 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout *layout, rect = right_func_rects[i]; rect->visible.x = x - layout->button_border.right - button_width; if (right_buttons_has_spacer[i]) - rect->visible.x -= (button_width * 0.75); + rect->visible.x -= (int) (0.75 * (double) button_width); rect->visible.y = button_y; rect->visible.width = button_width; @@ -1047,7 +1047,7 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout *layout, x = rect->visible.x + rect->visible.width + layout->button_border.right; if (left_buttons_has_spacer[i]) - x += (button_width * 0.75); + x += (int) (0.75 * (double) button_width); *(left_bg_rects[i]) = rect->visible; } @@ -2880,7 +2880,7 @@ pos_eval (MetaDrawSpec *spec, *val_p = expr.d.int_val; break; case POS_EXPR_DOUBLE: - *val_p = expr.d.double_val; + *val_p = (int) expr.d.double_val; break; case POS_EXPR_OPERATOR: g_assert_not_reached (); @@ -6234,6 +6234,7 @@ meta_gtk_widget_get_font_desc (GtkWidget *widget, const PangoFontDescription *override) { PangoFontDescription *font_desc; + gint font_size; GtkStyleContext *style = gtk_widget_get_style_context (widget); GtkStateFlags state = gtk_widget_get_state_flags (widget); @@ -6242,8 +6243,9 @@ meta_gtk_widget_get_font_desc (GtkWidget *widget, if (override) pango_font_description_merge (font_desc, override, TRUE); + font_size = pango_font_description_get_size (font_desc); pango_font_description_set_size (font_desc, - MAX (pango_font_description_get_size (font_desc) * scale, 1)); + MAX ((gint) (scale * (double) font_size), 1)); return font_desc; } -- cgit v1.2.1