diff options
author | rbuj <[email protected]> | 2021-12-14 12:16:15 +0100 |
---|---|---|
committer | raveit65 <[email protected]> | 2022-03-11 16:52:11 +0100 |
commit | 35fdef86b64ccd3307f3aeac05a496f8c8fc426f (patch) | |
tree | 832890a2d631501ff6e8bf604d5f2629d47f64d4 | |
parent | e1cc6f63f409abe17d0f6803b0697a87ed57985e (diff) | |
download | mate-screensaver-35fdef86b64ccd3307f3aeac05a496f8c8fc426f.tar.bz2 mate-screensaver-35fdef86b64ccd3307f3aeac05a496f8c8fc426f.tar.xz |
gs-fade: Fix -Wfloat-conversion warnings
-rw-r--r-- | src/gs-fade.c | 49 |
1 files changed, 18 insertions, 31 deletions
diff --git a/src/gs-fade.c b/src/gs-fade.c index bf25b2f..c4e12b4 100644 --- a/src/gs-fade.c +++ b/src/gs-fade.c @@ -224,9 +224,9 @@ xf86_whack_gamma (int screen, for (i = 0; i < gamma_info->size; i++) { - r[i] = gamma_info->r[i] * ratio; - g[i] = gamma_info->g[i] * ratio; - b[i] = gamma_info->b[i] * ratio; + r[i] = (unsigned short) (ratio * (float) gamma_info->r[i]); + g[i] = (unsigned short) (ratio * (float) gamma_info->g[i]); + b[i] = (unsigned short) (ratio * (float) gamma_info->b[i]); } status = XF86VidModeSetGammaRamp (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), screen, gamma_info->size, r, g, b); @@ -546,9 +546,9 @@ static void xrandr_crtc_whack_gamma (MateRRCrtc *crtc, for (i = 0; i < gamma_info->size; i++) { - r[i] = gamma_info->r[i] * ratio; - g[i] = gamma_info->g[i] * ratio; - b[i] = gamma_info->b[i] * ratio; + r[i] = (unsigned short) (ratio * (float) gamma_info->r[i]); + g[i] = (unsigned short) (ratio * (float) gamma_info->g[i]); + b[i] = (unsigned short) (ratio * (float) gamma_info->b[i]); } mate_rr_crtc_set_gamma (crtc, gamma_info->size, @@ -652,7 +652,7 @@ gs_fade_out_iter (GSFade *fade) static gboolean gs_fade_stop (GSFade *fade) { - if (fade->priv->timer_id > 0) + if (fade->priv->timer_id != 0) { g_source_remove (fade->priv->timer_id); fade->priv->timer_id = 0; @@ -719,41 +719,28 @@ static void gs_fade_start (GSFade *fade, guint timeout) { - guint steps_per_sec = 60; - guint msecs_per_step; - gboolean active_fade, res; - g_return_if_fail (GS_IS_FADE (fade)); - if (fade->priv->screen_priv.fade_type != FADE_TYPE_NONE) - { - res = fade->priv->screen_priv.fade_setup (fade); - if (res == FALSE) - return; - } + if ((fade->priv->screen_priv.fade_type != FADE_TYPE_NONE) && + (fade->priv->screen_priv.fade_setup (fade) == FALSE)) + return; - if (fade->priv->timer_id > 0) - { + if (fade->priv->timer_id != 0) gs_fade_stop (fade); - } fade->priv->active = TRUE; - gs_fade_set_timeout (fade, timeout); - active_fade = FALSE; if (fade->priv->screen_priv.fade_type != FADE_TYPE_NONE) - active_fade = TRUE; - - if (active_fade) { - guint num_steps; - - num_steps = (fade->priv->timeout / 1000.0) * steps_per_sec; - msecs_per_step = 1000 / steps_per_sec; - fade->priv->alpha_per_iter = 1.0 / (gdouble)num_steps; + double steps_per_sec = 60.0; + double msecs_per_step = 1000.0 / steps_per_sec; + double num_steps = ((double) fade->priv->timeout) / msecs_per_step; - fade->priv->timer_id = g_timeout_add (msecs_per_step, (GSourceFunc)fade_out_timer, fade); + fade->priv->alpha_per_iter = 1.0 / num_steps; + fade->priv->timer_id = g_timeout_add ((guint) msecs_per_step, + (GSourceFunc) fade_out_timer, + fade); } else { |