1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-18 12:00:31 +01:00

Fixed floating point constants defined as double but expected as float

To preserve the accuracy of the operation, the C standard request that the
mathematical operation is performed using double precision, but in many
case this is not necessary so this patch fixes a few constants to avoid
that conversion.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
Christophe CURIS
2015-05-24 15:49:06 +02:00
committed by Carlos R. Mafra
parent 1df08cc492
commit 79a95d7173
8 changed files with 31 additions and 31 deletions

View File

@@ -211,7 +211,7 @@ static void willResizeColorWell(W_ViewDelegate * self, WMView * view, unsigned i
if (*height < MIN_HEIGHT)
*height = MIN_HEIGHT;
bw = (int)((float)WMIN(*width, *height) * 0.24);
bw = (int)((float)WMIN(*width, *height) * 0.24F);
W_ResizeView(cPtr->colorView, *width - 2 * bw, *height - 2 * bw);

View File

@@ -168,10 +168,10 @@ void WMSetScrollerParameters(WMScroller * sPtr, float floatValue, float knobProp
assert(!isnan(floatValue));
if (floatValue < 0.0)
sPtr->floatValue = 0.0;
else if (floatValue > 1.0)
sPtr->floatValue = 1.0;
if (floatValue < 0.0F)
sPtr->floatValue = 0.0F;
else if (floatValue > 1.0F)
sPtr->floatValue = 1.0F;
else
sPtr->floatValue = floatValue;
@@ -180,9 +180,9 @@ void WMSetScrollerParameters(WMScroller * sPtr, float floatValue, float knobProp
sPtr->knobProportion = min_knob_proportion;
sPtr->flags.documentFullyVisible = 0;
} else if (knobProportion >= 1.0) {
} else if (knobProportion >= 1.0F) {
sPtr->knobProportion = 1.0;
sPtr->knobProportion = 1.0F;
sPtr->flags.documentFullyVisible = 1;
} else {
@@ -344,7 +344,7 @@ static int knobLength(Scroller * sPtr)
length -= 2 * (BUTTON_SIZE + 1);
}
tmp = (int)((float)length * sPtr->knobProportion + 0.5);
tmp = (int)((float)length * sPtr->knobProportion + 0.5F);
/* keep minimum size */
if (tmp < BUTTON_SIZE)
tmp = BUTTON_SIZE;
@@ -418,7 +418,7 @@ static void paintScroller(Scroller * sPtr)
length - (int)(knobP + knobL), view->size.height - 4);
} else {
/* before */
if (knobP > 0.0)
if (knobP > 0.0F)
XFillRectangle(scr->display, d, scr->stippleGC,
2, ofs, view->size.width - 4, (int)knobP);

View File

@@ -506,7 +506,7 @@ static void updateScrollerProportion(ScrollView * sPtr)
prop = (float)sPtr->viewport->size.width / (float)sPtr->contentView->size.width;
if (oldP < 1.0)
if (oldP < 1.0F)
value = (prop * oldV) / oldP;
else
value = 0;
@@ -518,7 +518,7 @@ static void updateScrollerProportion(ScrollView * sPtr)
prop = (float)sPtr->viewport->size.height / (float)sPtr->contentView->size.height;
if (oldP < 1.0)
if (oldP < 1.0F)
value = (prop * oldV) / oldP;
else
value = 0;

View File

@@ -298,7 +298,7 @@ static void showData(_Panel * panel)
sprintf(buffer, "%i", a);
WMSetTextFieldText(panel->threT, buffer);
WMSetSliderValue(panel->speedS, (accel - 0.25) / 0.25);
WMSetSliderValue(panel->speedS, (accel - 0.25F) / 0.25F);
panel->acceleration = accel;
sprintf(buffer, "%.2f", accel);

View File

@@ -201,14 +201,14 @@ void slide_windows(Window wins[], int n, int from_x, int from_y, int to_x, int t
px = slide_steps;
else if (px > -slide_steps && px < 0)
px = -slide_steps;
py = (is_dx_nul ? 0.0 : px * dy / dx);
py = (is_dx_nul ? 0.0F : px * dy / dx);
} else {
py = dy / slide_slowdown;
if (py < slide_steps && py > 0)
py = slide_steps;
else if (py > -slide_steps && py < 0)
py = -slide_steps;
px = (is_dy_nul ? 0.0 : py * dx / dy);
px = (is_dy_nul ? 0.0F : py * dx / dy);
}
while (((int)x) != to_x ||
@@ -221,19 +221,19 @@ void slide_windows(Window wins[], int n, int from_x, int from_y, int to_x, int t
y = (float)to_y;
if (dx_is_bigger) {
px = px * (1.0 - 1 / (float)slide_slowdown);
px = px * (1.0F - 1 / (float)slide_slowdown);
if (px < slide_steps && px > 0)
px = slide_steps;
else if (px > -slide_steps && px < 0)
px = -slide_steps;
py = (is_dx_nul ? 0.0 : px * dy / dx);
py = (is_dx_nul ? 0.0F : px * dy / dx);
} else {
py = py * (1.0 - 1 / (float)slide_slowdown);
py = py * (1.0F - 1 / (float)slide_slowdown);
if (py < slide_steps && py > 0)
py = slide_steps;
else if (py > -slide_steps && py < 0)
py = -slide_steps;
px = (is_dy_nul ? 0.0 : py * dx / dy);
px = (is_dy_nul ? 0.0F : py * dx / dy);
}
for (i = 0; i < n; i++) {

View File

@@ -47,7 +47,7 @@ void RCombineAlpha(unsigned char *d, unsigned char *s, int s_has_alpha,
cratio = 0;
} else {
ratio = (float)sa / alpha;
cratio = 1.0 - ratio;
cratio = 1.0F - ratio;
}
*d = (int)*d * cratio + (int)*s * ratio;

View File

@@ -438,7 +438,7 @@ static void gatherconfig(RContext * context, int screen_n)
ptr = mygetenv("WRASTER_GAMMA", screen_n);
if (ptr) {
float g1, g2, g3;
if (sscanf(ptr, "%f/%f/%f", &g1, &g2, &g3) != 3 || g1 <= 0.0 || g2 <= 0.0 || g3 <= 0.0) {
if (sscanf(ptr, "%f/%f/%f", &g1, &g2, &g3) != 3 || g1 <= 0.0F || g2 <= 0.0F || g3 <= 0.0F) {
printf("wrlib: invalid value(s) for gamma correction \"%s\"\n", ptr);
} else {
context->attribs->flags |= RC_GammaCorrection;

View File

@@ -48,26 +48,26 @@ RImage *RRotateImage(RImage *image, float angle)
* candidate for an Epsilon when trying to compare angle
* to known values
*/
static const float min_usable_angle = 0.00699;
static const float min_usable_angle = 0.00699F;
angle = fmod(angle, 360.0);
if (angle < 0.0)
angle += 360.0;
if (angle < 0.0F)
angle += 360.0F;
if (angle < min_usable_angle) {
/* Rotate by 0 degree */
return RCloneImage(image);
} else if ((angle > 90.0 - min_usable_angle) &&
(angle < 90.0 + min_usable_angle)) {
} else if ((angle > 90.0F - min_usable_angle) &&
(angle < 90.0F + min_usable_angle)) {
return rotate_image_90(image);
} else if ((angle > 180.0 - min_usable_angle) &&
(angle < 180.0 + min_usable_angle)) {
} else if ((angle > 180.0F - min_usable_angle) &&
(angle < 180.0F + min_usable_angle)) {
return wraster_rotate_image_180(image);
} else if ((angle > 270.0 - min_usable_angle) &&
(angle < 270.0 + min_usable_angle)) {
} else if ((angle > 270.0F - min_usable_angle) &&
(angle < 270.0F + min_usable_angle)) {
return rotate_image_270(image);
} else {
@@ -341,8 +341,8 @@ static RImage *rotate_image_any(RImage *source, float angle)
int dpr, dpru, p;
/* only 180o for now */
if (angle > 180.0)
angle -= 180.0;
if (angle > 180.0F)
angle -= 180.0F;
angle = (angle * WM_PI) / 180.0;