summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorrbuj <[email protected]>2021-12-12 11:39:14 +0100
committerraveit65 <[email protected]>2022-03-11 18:54:19 +0100
commit5e8097475ba237bc0bc71ad78a7cbdf2d71f7b87 (patch)
tree178f99b087d96213a85ac3bdff7e01a2cff5cb92 /src/ui
parent480cc60e3b3596a7fa8e196a08974b6086217bf0 (diff)
downloadmarco-5e8097475ba237bc0bc71ad78a7cbdf2d71f7b87.tar.bz2
marco-5e8097475ba237bc0bc71ad78a7cbdf2d71f7b87.tar.xz
Fix some -Wfloat-conversion warnings
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/draw-workspace.c8
-rw-r--r--src/ui/gradient.c43
-rw-r--r--src/ui/theme.c24
3 files changed, 41 insertions, 34 deletions
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; i<height; i++)
{
diff --git a/src/ui/theme.c b/src/ui/theme.c
index a78f9ce2..25d35b1f 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -108,8 +108,8 @@ scale_surface (cairo_surface_t *surface,
gdouble scale_x;
gdouble scale_y;
cairo_content_t content;
- gint width;
- gint height;
+ gdouble width;
+ gdouble height;
cairo_surface_t *scaled;
cairo_t *cr;
@@ -131,7 +131,7 @@ scale_surface (cairo_surface_t *surface,
width = ceil (new_width);
height = ceil (new_height);
- scaled = cairo_surface_create_similar (surface, content, width, height);
+ scaled = cairo_surface_create_similar (surface, content, (int) width, (int) height);
cr = cairo_create (scaled);
cairo_scale (cr, scale_x, scale_y);
@@ -185,7 +185,7 @@ get_surface_from_pixbuf (GdkPixbuf *pixbuf,
width = ceil (width);
height = ceil (height);
- copy = cairo_surface_create_similar (surface, content, width, height);
+ copy = cairo_surface_create_similar (surface, content, (int) width, (int) height);
cr = cairo_create (copy);
cairo_set_source_surface (cr, surface, 0, 0);
@@ -779,7 +779,7 @@ meta_frame_layout_calc_geometry (const MetaFrameLayout *layout,
{
case META_BUTTON_SIZING_ASPECT:
button_height = borders.visible.top - layout->button_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;
}