summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/constraints.c21
-rw-r--r--src/core/effects.c8
-rw-r--r--src/core/place.c8
-rw-r--r--src/core/screen.c9
-rw-r--r--src/core/window.c14
-rw-r--r--src/ui/draw-workspace.c8
-rw-r--r--src/ui/gradient.c43
-rw-r--r--src/ui/theme.c24
-rw-r--r--src/wm-tester/test-gravity.c4
9 files changed, 73 insertions, 66 deletions
diff --git a/src/core/constraints.c b/src/core/constraints.c
index a89ef138..e95dec03 100644
--- a/src/core/constraints.c
+++ b/src/core/constraints.c
@@ -541,15 +541,15 @@ place_window_if_needed(MetaWindow *window,
*/
if (info->current.width >= info->work_area_xinerama.width)
{
- info->current.width = .75 * info->work_area_xinerama.width;
+ info->current.width = (int) (.75 * (double) info->work_area_xinerama.width);
info->current.x = info->work_area_xinerama.x +
- .125 * info->work_area_xinerama.width;
+ (int) (.125 * (double) info->work_area_xinerama.width);
}
if (info->current.height >= info->work_area_xinerama.height)
{
- info->current.height = .75 * info->work_area_xinerama.height;
+ info->current.height = (int) (.75 * (double) info->work_area_xinerama.height);
info->current.y = info->work_area_xinerama.y +
- .083 * info->work_area_xinerama.height;
+ (int) (.083 * (double) info->work_area_xinerama.height);
}
if (window->maximize_horizontally_after_placement ||
@@ -1225,7 +1225,8 @@ constrain_aspect_ratio (MetaWindow *window,
{
double minr, maxr;
gboolean constraints_are_inconsistent, constraint_already_satisfied;
- int fudge, new_width, new_height;
+ int fudge;
+ double new_width, new_height;
double best_width, best_height;
double alt_width, alt_height;
MetaRectangle *start_rect;
@@ -1286,20 +1287,18 @@ constrain_aspect_ratio (MetaWindow *window,
return constraint_already_satisfied;
/*** Enforce constraint ***/
- new_width = info->current.width;
- new_height = info->current.height;
+ new_width = (double) info->current.width;
+ new_height = (double) info->current.height;
switch (info->resize_gravity)
{
case WestGravity:
case EastGravity:
- /* Yeah, I suck for doing implicit rounding -- sue me */
new_height = CLAMP (new_height, new_width / maxr, new_width / minr);
break;
case NorthGravity:
case SouthGravity:
- /* Yeah, I suck for doing implicit rounding -- sue me */
new_width = CLAMP (new_width, new_height * minr, new_height * maxr);
break;
@@ -1344,8 +1343,8 @@ constrain_aspect_ratio (MetaWindow *window,
meta_rectangle_resize_with_gravity (start_rect,
&info->current,
info->resize_gravity,
- new_width,
- new_height);
+ (int) new_width,
+ (int) new_height);
return TRUE;
}
diff --git a/src/core/effects.c b/src/core/effects.c
index 6c0f7fdd..1ca9f349 100644
--- a/src/core/effects.c
+++ b/src/core/effects.c
@@ -371,10 +371,10 @@ effects_draw_box_animation_timeout (BoxAnimationContext *context)
draw_rect = context->start_rect;
/* Now add a delta proportional to elapsed time. */
- draw_rect.x += (context->end_rect.x - context->start_rect.x) * fraction;
- draw_rect.y += (context->end_rect.y - context->start_rect.y) * fraction;
- draw_rect.width += (context->end_rect.width - context->start_rect.width) * fraction;
- draw_rect.height += (context->end_rect.height - context->start_rect.height) * fraction;
+ draw_rect.x += (int) (fraction * (double) (context->end_rect.x - context->start_rect.x));
+ draw_rect.y += (int) (fraction * (double) (context->end_rect.y - context->start_rect.y));
+ draw_rect.width += (int) (fraction * (double) (context->end_rect.width - context->start_rect.width));
+ draw_rect.height += (int) (fraction * (double) (context->end_rect.height - context->start_rect.height));
/* don't confuse X or gdk-pixbuf with bogus rectangles */
if (draw_rect.width < 1)
diff --git a/src/core/place.c b/src/core/place.c
index b3fa6569..1aafff79 100644
--- a/src/core/place.c
+++ b/src/core/place.c
@@ -46,8 +46,8 @@ northwestcmp (gconstpointer a, gconstpointer b)
{
MetaWindow *aw = (gpointer) a;
MetaWindow *bw = (gpointer) b;
- int from_origin_a;
- int from_origin_b;
+ double from_origin_a;
+ double from_origin_b;
int ax, ay, bx, by;
/* we're interested in the frame position for cascading,
@@ -76,8 +76,8 @@ northwestcmp (gconstpointer a, gconstpointer b)
}
/* probably there's a fast good-enough-guess we could use here. */
- from_origin_a = sqrt (ax * ax + ay * ay);
- from_origin_b = sqrt (bx * bx + by * by);
+ from_origin_a = sqrt ((double) (ax * ax + ay * ay));
+ from_origin_b = sqrt ((double) (bx * bx + by * by));
if (from_origin_a < from_origin_b)
return -1;
diff --git a/src/core/screen.c b/src/core/screen.c
index c5962cb2..99932393 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -1214,7 +1214,7 @@ meta_screen_update_cursor (MetaScreen *screen)
}
#define MAX_PREVIEW_SCREEN_FRACTION 0.33
-#define MAX_PREVIEW_SIZE 300
+#define MAX_PREVIEW_SIZE 300.0
static cairo_surface_t *
get_window_surface (MetaWindow *window)
@@ -1222,7 +1222,8 @@ get_window_surface (MetaWindow *window)
cairo_surface_t *surface, *scaled;
cairo_t *cr;
const MetaXineramaScreenInfo *current;
- int width, height, max_columns, max_size;
+ int width, height, max_columns;
+ double max_size;
double ratio;
surface = meta_compositor_get_window_surface (window->display->compositor, window);
@@ -1239,14 +1240,14 @@ get_window_surface (MetaWindow *window)
/* Scale surface to fit current screen */
if (width > height)
{
- max_size = MIN (MAX_PREVIEW_SIZE, current->rect.width / max_columns * MAX_PREVIEW_SCREEN_FRACTION);
+ max_size = MIN (MAX_PREVIEW_SIZE, MAX_PREVIEW_SCREEN_FRACTION * ((double) current->rect.width) / ((double) max_columns));
ratio = ((double) width) / max_size;
width = (int) max_size;
height = (int) (((double) height) / ratio);
}
else
{
- max_size = MIN (MAX_PREVIEW_SIZE, current->rect.height / max_columns * MAX_PREVIEW_SCREEN_FRACTION);
+ max_size = MIN (MAX_PREVIEW_SIZE, MAX_PREVIEW_SCREEN_FRACTION * ((double) current->rect.height) / ((double) max_columns));
ratio = ((double) height) / max_size;
height = (int) max_size;
width = (int) (((double) width) / ratio);
diff --git a/src/core/window.c b/src/core/window.c
index eef77bab..00ddd58a 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -2911,10 +2911,10 @@ static void meta_window_transform_to_monitor(MetaRectangle *target_rect,
target_rect->x -= from_monitor->x;
target_rect->y -= from_monitor->y;
- target_rect->width *= horizontal_ratio;
- target_rect->height *= vertical_ratio;
- target_rect->x *= horizontal_ratio;
- target_rect->y *= vertical_ratio;
+ target_rect->width = (int) (horizontal_ratio * (double) target_rect->width);
+ target_rect->height = (int) (vertical_ratio * (double) target_rect->height);
+ target_rect->x = (int) (horizontal_ratio * (double) target_rect->x);
+ target_rect->y = (int) (vertical_ratio * (double) target_rect->y);
target_rect->x += to_monitor->x;
target_rect->y += to_monitor->y;
@@ -7174,7 +7174,7 @@ meta_window_titlebar_is_onscreen (MetaWindow *window)
gboolean is_onscreen;
const int min_height_needed = 8;
- const int min_width_percent = 0.5;
+ const double min_width_percent = 0.5;
const int min_width_absolute = 50;
/* Titlebar can't be offscreen if there is no titlebar... */
@@ -7197,7 +7197,7 @@ meta_window_titlebar_is_onscreen (MetaWindow *window)
meta_rectangle_intersect (&titlebar_rect, spanning_rect, &overlap);
if (overlap.height > MIN (titlebar_rect.height, min_height_needed) &&
- overlap.width > MIN (titlebar_rect.width * min_width_percent,
+ overlap.width > MIN ((int) (min_width_percent * (double) titlebar_rect.width),
min_width_absolute))
{
is_onscreen = TRUE;
@@ -7423,7 +7423,7 @@ update_move (MetaWindow *window,
((double)display->grab_initial_window_pos.width);
display->grab_initial_window_pos.x =
- x - window->saved_rect.width * prop;
+ x - (int) (prop * (double) window->saved_rect.width);
display->grab_initial_window_pos.y = y;
if (window->frame)
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;
}
diff --git a/src/wm-tester/test-gravity.c b/src/wm-tester/test-gravity.c
index cb8512a0..68aad509 100644
--- a/src/wm-tester/test-gravity.c
+++ b/src/wm-tester/test-gravity.c
@@ -83,8 +83,8 @@ calculate_position (int i, int is_doubled, int *x, int *y)
yoff *= 2;
}
- *x = screen_x_fraction[i % 3] * screen_width + xoff;
- *y = screen_y_fraction[i / 3] * screen_height + yoff;
+ *x = (int) (screen_x_fraction[i % 3] * (double) screen_width) + xoff;
+ *y = (int) (screen_y_fraction[i / 3] * (double) screen_height) + yoff;
}
}