diff options
author | rbuj <[email protected]> | 2021-12-12 11:39:14 +0100 |
---|---|---|
committer | raveit65 <[email protected]> | 2022-03-11 18:54:19 +0100 |
commit | 5e8097475ba237bc0bc71ad78a7cbdf2d71f7b87 (patch) | |
tree | 178f99b087d96213a85ac3bdff7e01a2cff5cb92 /src/core | |
parent | 480cc60e3b3596a7fa8e196a08974b6086217bf0 (diff) | |
download | marco-5e8097475ba237bc0bc71ad78a7cbdf2d71f7b87.tar.bz2 marco-5e8097475ba237bc0bc71ad78a7cbdf2d71f7b87.tar.xz |
Fix some -Wfloat-conversion warnings
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/constraints.c | 21 | ||||
-rw-r--r-- | src/core/effects.c | 8 | ||||
-rw-r--r-- | src/core/place.c | 8 | ||||
-rw-r--r-- | src/core/screen.c | 9 | ||||
-rw-r--r-- | src/core/window.c | 14 |
5 files changed, 30 insertions, 30 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) |