summaryrefslogtreecommitdiff
path: root/src/daemon/daemon.c
diff options
context:
space:
mode:
authorGiedrius Statkevičius <[email protected]>2015-07-22 12:39:16 +0300
committerGiedrius Statkevičius <[email protected]>2015-07-25 18:18:38 +0300
commitdbb6e0ba03d3e049e0c33ab784740e2b4123663d (patch)
tree4bed5a90d1c46b303112e0a4ce3639a624de7a9c /src/daemon/daemon.c
parent2296eaf57e3f07f6f19ab884e3206155ba3ea8a8 (diff)
downloadmate-notification-daemon-dbb6e0ba03d3e049e0c33ab784740e2b4123663d.tar.bz2
mate-notification-daemon-dbb6e0ba03d3e049e0c33ab784740e2b4123663d.tar.xz
daemon: refactor scale_factor calculation
Avoid problematic comparison between two floats, remove two unneeded variables and in general reduce the amount of work in that function
Diffstat (limited to 'src/daemon/daemon.c')
-rw-r--r--src/daemon/daemon.c14
1 files changed, 1 insertions, 13 deletions
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c
index 3eac838..9011588 100644
--- a/src/daemon/daemon.c
+++ b/src/daemon/daemon.c
@@ -1123,25 +1123,13 @@ static GdkPixbuf* _notify_daemon_scale_pixbuf(GdkPixbuf *pixbuf, gboolean no_str
{
int pw;
int ph;
- float scale_factor_x = 1.0;
- float scale_factor_y = 1.0;
float scale_factor = 1.0;
pw = gdk_pixbuf_get_width (pixbuf);
ph = gdk_pixbuf_get_height (pixbuf);
/* Determine which dimension requires the smallest scale. */
- scale_factor_x = (float) IMAGE_SIZE / (float) pw;
- scale_factor_y = (float) IMAGE_SIZE / (float) ph;
-
- if (scale_factor_x > scale_factor_y)
- {
- scale_factor = scale_factor_y;
- }
- else
- {
- scale_factor = scale_factor_x;
- }
+ scale_factor = (float) IMAGE_SIZE / (float) MAX(pw, ph);
/* always scale down, allow to disable scaling up */
if (scale_factor < 1.0 || !no_stretch_hint)