From: Christophe CURIS <[email protected]>

The macro 'wm_rint' is defined in 'config.h' by the configure script
to use an available rounding function from math library for
converting a double to an int.

Signed-off-by: Christophe CURIS <[email protected]>
---
 WINGs/WINGs/WINGsP.h |    1 +
 WINGs/wbrowser.c     |    2 +-
 WINGs/wcolorpanel.c  |   50 +++++++++++++++++++++++++-------------------------
 3 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/WINGs/WINGs/WINGsP.h b/WINGs/WINGs/WINGsP.h
index de01412..70179c8 100644
--- a/WINGs/WINGs/WINGsP.h
+++ b/WINGs/WINGs/WINGsP.h
@@ -1,6 +1,7 @@
 #ifndef _WINGSP_H_
 #define _WINGSP_H_
 
+#include "config.h"
 
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
diff --git a/WINGs/wbrowser.c b/WINGs/wbrowser.c
index 594e81c..1333578 100644
--- a/WINGs/wbrowser.c
+++ b/WINGs/wbrowser.c
@@ -559,7 +559,7 @@ static void scrollCallback(WMWidget * scroller, void *self)
 
                        floatValue = (floatValue * value) / value;
 
-                       newFirst = rint(floatValue * (float)(bPtr->columnCount 
- bPtr->maxVisibleColumns));
+                       newFirst = wm_rint(floatValue * 
(double)(bPtr->columnCount - bPtr->maxVisibleColumns));
 
                        if (bPtr->firstVisibleColumn != newFirst)
                                scrollToColumn(bPtr, newFirst, False);
diff --git a/WINGs/wcolorpanel.c b/WINGs/wcolorpanel.c
index ab70dd2..8f7d189 100644
--- a/WINGs/wcolorpanel.c
+++ b/WINGs/wcolorpanel.c
@@ -1909,7 +1909,7 @@ static void wheelInitMatrix(W_ColorPanel * panel)
                        ycor = 2 * y - 4 - colorWheelSize;
 
                        /* RColor.saturation is unsigned char and will wrap 
after 255 */
-                       sat = rint(255.0 * sqrt(xcor * xcor + ycor * ycor) / 
colorWheelSize);
+                       sat = wm_rint(255.0 * sqrt(xcor * xcor + ycor * ycor) / 
colorWheelSize);
 
                        cpColor.hsv.saturation = (unsigned char)sat;
 
@@ -1920,7 +1920,7 @@ static void wheelInitMatrix(W_ColorPanel * panel)
 
                        if (sat < 256) {
                                if (xcor != 0)
-                                       dhue[0] = rint(atan((double)ycor / 
(double)xcor) *
+                                       dhue[0] = wm_rint(atan((double)ycor / 
(double)xcor) *
                                                       (180.0 / M_PI)) + (xcor 
< 0 ? 180.0 : 0.0);
                                else
                                        dhue[0] = 270;
@@ -2204,7 +2204,7 @@ static void wheelPositionSelectionOutBounds(W_ColorPanel 
* panel, int x, int y)
        panel->color.hsv.value = 255 - 
WMGetSliderValue(panel->wheelBrightnessS);
 
        if (xcor != 0)
-               hue = rint(atan(-(double)ycor / (double)xcor) * (180.0 / M_PI));
+               hue = wm_rint(atan(-(double)ycor / (double)xcor) * (180.0 / 
M_PI));
        else {
                if (ycor < 0)
                        hue = 90;
@@ -2224,9 +2224,9 @@ static void wheelPositionSelectionOutBounds(W_ColorPanel 
* panel, int x, int y)
 
        wheelUndrawSelection(panel);
 
-       panel->colx = 2 + rint((colorWheelSize * (1.0 + 
cos(panel->color.hsv.hue * (M_PI / 180.0)))) / 2.0);
+       panel->colx = 2 + wm_rint((colorWheelSize * (1.0 + 
cos(panel->color.hsv.hue * (M_PI / 180.0)))) / 2.0);
        /* "+2" because of "colorWheelSize + 4" */
-       panel->coly = 2 + rint((colorWheelSize * (1.0 + 
sin(-panel->color.hsv.hue * (M_PI / 180.0)))) / 2.0);
+       panel->coly = 2 + wm_rint((colorWheelSize * (1.0 + 
sin(-panel->color.hsv.hue * (M_PI / 180.0)))) / 2.0);
 
        wheelUpdateSelection(panel);
        cpColor = panel->color;
@@ -2280,7 +2280,7 @@ static void grayBrightnessSliderCallback(WMWidget * w, 
void *data)
        sprintf(tmp, "%d", value);
 
        WMSetTextFieldText(panel->grayBrightnessT, tmp);
-       cpColor.rgb.red = cpColor.rgb.green = cpColor.rgb.blue = rint(2.55 * 
value);
+       cpColor.rgb.red = cpColor.rgb.green = cpColor.rgb.blue = wm_rint(2.55 * 
value);
        cpColor.set = cpRGB;
 
        updateSwatch(panel, cpColor);
@@ -2301,14 +2301,14 @@ static void grayPresetButtonCallback(WMWidget * w, void 
*data)
                i++;
        }
 
-       value = rint((100.0 * i) / 6.0);
+       value = wm_rint((100.0 * i) / 6.0);
        sprintf(tmp, "%d", value);
 
        WMSetTextFieldText(panel->grayBrightnessT, tmp);
-       cpColor.rgb.red = cpColor.rgb.green = cpColor.rgb.blue = rint((255.0 * 
i) / 6.0);
+       cpColor.rgb.red = cpColor.rgb.green = cpColor.rgb.blue = wm_rint((255.0 
* i) / 6.0);
        cpColor.set = cpRGB;
 
-       WMSetSliderValue(panel->grayBrightnessS, rint((100.0 * i) / 6.0));
+       WMSetSliderValue(panel->grayBrightnessS, wm_rint((100.0 * i) / 6.0));
 
        updateSwatch(panel, cpColor);
        panel->lastChanged = WMGrayModeColorPanel;
@@ -2331,7 +2331,7 @@ static void grayBrightnessTextFieldCallback(void 
*observerData, WMNotification *
        WMSetTextFieldText(panel->grayBrightnessT, tmp);
        WMSetSliderValue(panel->grayBrightnessS, value);
 
-       cpColor.rgb.red = cpColor.rgb.green = cpColor.rgb.blue = rint((255.0 * 
value) / 100.0);
+       cpColor.rgb.red = cpColor.rgb.green = cpColor.rgb.blue = wm_rint((255.0 
* value) / 100.0);
        cpColor.set = cpRGB;
 
        updateSwatch(panel, cpColor);
@@ -2431,9 +2431,9 @@ static void cmykSliderCallback(WMWidget * w, void *data)
        WMSetTextFieldText(panel->cmykBlackT, tmp);
 
        scale = 2.55 * (1.0 - (value[3] / 100.0));
-       cpColor.rgb.red = rint((100.0 - value[0]) * scale);
-       cpColor.rgb.green = rint((100.0 - value[1]) * scale);
-       cpColor.rgb.blue = rint((100.0 - value[2]) * scale);
+       cpColor.rgb.red = wm_rint((100.0 - value[0]) * scale);
+       cpColor.rgb.green = wm_rint((100.0 - value[1]) * scale);
+       cpColor.rgb.blue = wm_rint((100.0 - value[2]) * scale);
        cpColor.set = cpRGB;
 
        updateSwatch(panel, cpColor);
@@ -2479,9 +2479,9 @@ static void cmykTextFieldCallback(void *observerData, 
WMNotification * notificat
        WMSetSliderValue(panel->cmykBlackS, value[3]);
 
        scale = 2.55 * (1.0 - (value[3] / 100.0));
-       cpColor.rgb.red = rint((100.0 - value[0]) * scale);
-       cpColor.rgb.green = rint((100.0 - value[1]) * scale);
-       cpColor.rgb.blue = rint((100.0 - value[2]) * scale);
+       cpColor.rgb.red = wm_rint((100.0 - value[0]) * scale);
+       cpColor.rgb.green = wm_rint((100.0 - value[1]) * scale);
+       cpColor.rgb.blue = wm_rint((100.0 - value[2]) * scale);
        cpColor.set = cpRGB;
 
        updateSwatch(panel, cpColor);
@@ -2765,7 +2765,7 @@ static void customPalettePositionSelection(W_ColorPanel * 
panel, int x, int y)
        panel->palx = x;
        panel->paly = y;
 
-       ofs = (rint(x * panel->palXRatio) + rint(y * panel->palYRatio) * 
panel->customPaletteImg->width) * 3;
+       ofs = (wm_rint(x * panel->palXRatio) + wm_rint(y * panel->palYRatio) * 
panel->customPaletteImg->width) * 3;
 
        panel->color.rgb.red = panel->customPaletteImg->data[ofs];
        panel->color.rgb.green = panel->customPaletteImg->data[ofs + 1];
@@ -3231,10 +3231,10 @@ static void wheelInit(W_ColorPanel * panel)
 
        WMSetSliderValue(panel->wheelBrightnessS, 255 - panel->color.hsv.value);
 
-       panel->colx = 2 + rint((colorWheelSize / 2.0) *
+       panel->colx = 2 + wm_rint((colorWheelSize / 2.0) *
                               (1 + (panel->color.hsv.saturation / 255.0) *
                                cos(panel->color.hsv.hue * M_PI / 180.0)));
-       panel->coly = 2 + rint((colorWheelSize / 2.0) *
+       panel->coly = 2 + wm_rint((colorWheelSize / 2.0) *
                               (1 + (panel->color.hsv.saturation / 255.0) *
                                sin(-panel->color.hsv.hue * M_PI / 180.0)));
 
@@ -3254,7 +3254,7 @@ static void grayInit(W_ColorPanel * panel)
        if (panel->color.set != cpHSV)
                convertCPColor(&panel->color);
 
-       value = rint(panel->color.hsv.value / 2.55);
+       value = wm_rint(panel->color.hsv.value / 2.55);
        WMSetSliderValue(panel->grayBrightnessS, value);
 
        sprintf(tmp, "%d", value);
@@ -3288,9 +3288,9 @@ static void cmykInit(W_ColorPanel * panel)
        if (panel->color.set != cpRGB)
                convertCPColor(&panel->color);
 
-       value[0] = rint((255 - panel->color.rgb.red) / 2.55);
-       value[1] = rint((255 - panel->color.rgb.green) / 2.55);
-       value[2] = rint((255 - panel->color.rgb.blue) / 2.55);
+       value[0] = wm_rint((255 - panel->color.rgb.red) / 2.55);
+       value[1] = wm_rint((255 - panel->color.rgb.green) / 2.55);
+       value[2] = wm_rint((255 - panel->color.rgb.blue) / 2.55);
 
        WMSetSliderValue(panel->cmykCyanS, value[0]);
        WMSetSliderValue(panel->cmykMagentaS, value[1]);
@@ -3315,8 +3315,8 @@ static void hsbInit(W_ColorPanel * panel)
                convertCPColor(&panel->color);
 
        value[0] = panel->color.hsv.hue;
-       value[1] = rint(panel->color.hsv.saturation / 2.55);
-       value[2] = rint(panel->color.hsv.value / 2.55);
+       value[1] = wm_rint(panel->color.hsv.saturation / 2.55);
+       value[2] = wm_rint(panel->color.hsv.value / 2.55);
 
        WMSetSliderValue(panel->hsbHueS, value[0]);
        WMSetSliderValue(panel->hsbSaturationS, value[1]);
-- 
1.7.10.4


-- 
To unsubscribe, send mail to [email protected].

Reply via email to