mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 12:28:22 +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:
committed by
Carlos R. Mafra
parent
1df08cc492
commit
79a95d7173
@@ -211,7 +211,7 @@ static void willResizeColorWell(W_ViewDelegate * self, WMView * view, unsigned i
|
|||||||
if (*height < MIN_HEIGHT)
|
if (*height < MIN_HEIGHT)
|
||||||
*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);
|
W_ResizeView(cPtr->colorView, *width - 2 * bw, *height - 2 * bw);
|
||||||
|
|
||||||
|
|||||||
@@ -168,10 +168,10 @@ void WMSetScrollerParameters(WMScroller * sPtr, float floatValue, float knobProp
|
|||||||
|
|
||||||
assert(!isnan(floatValue));
|
assert(!isnan(floatValue));
|
||||||
|
|
||||||
if (floatValue < 0.0)
|
if (floatValue < 0.0F)
|
||||||
sPtr->floatValue = 0.0;
|
sPtr->floatValue = 0.0F;
|
||||||
else if (floatValue > 1.0)
|
else if (floatValue > 1.0F)
|
||||||
sPtr->floatValue = 1.0;
|
sPtr->floatValue = 1.0F;
|
||||||
else
|
else
|
||||||
sPtr->floatValue = floatValue;
|
sPtr->floatValue = floatValue;
|
||||||
|
|
||||||
@@ -180,9 +180,9 @@ void WMSetScrollerParameters(WMScroller * sPtr, float floatValue, float knobProp
|
|||||||
sPtr->knobProportion = min_knob_proportion;
|
sPtr->knobProportion = min_knob_proportion;
|
||||||
sPtr->flags.documentFullyVisible = 0;
|
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;
|
sPtr->flags.documentFullyVisible = 1;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -344,7 +344,7 @@ static int knobLength(Scroller * sPtr)
|
|||||||
length -= 2 * (BUTTON_SIZE + 1);
|
length -= 2 * (BUTTON_SIZE + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = (int)((float)length * sPtr->knobProportion + 0.5);
|
tmp = (int)((float)length * sPtr->knobProportion + 0.5F);
|
||||||
/* keep minimum size */
|
/* keep minimum size */
|
||||||
if (tmp < BUTTON_SIZE)
|
if (tmp < BUTTON_SIZE)
|
||||||
tmp = BUTTON_SIZE;
|
tmp = BUTTON_SIZE;
|
||||||
@@ -418,7 +418,7 @@ static void paintScroller(Scroller * sPtr)
|
|||||||
length - (int)(knobP + knobL), view->size.height - 4);
|
length - (int)(knobP + knobL), view->size.height - 4);
|
||||||
} else {
|
} else {
|
||||||
/* before */
|
/* before */
|
||||||
if (knobP > 0.0)
|
if (knobP > 0.0F)
|
||||||
XFillRectangle(scr->display, d, scr->stippleGC,
|
XFillRectangle(scr->display, d, scr->stippleGC,
|
||||||
2, ofs, view->size.width - 4, (int)knobP);
|
2, ofs, view->size.width - 4, (int)knobP);
|
||||||
|
|
||||||
|
|||||||
@@ -506,7 +506,7 @@ static void updateScrollerProportion(ScrollView * sPtr)
|
|||||||
|
|
||||||
prop = (float)sPtr->viewport->size.width / (float)sPtr->contentView->size.width;
|
prop = (float)sPtr->viewport->size.width / (float)sPtr->contentView->size.width;
|
||||||
|
|
||||||
if (oldP < 1.0)
|
if (oldP < 1.0F)
|
||||||
value = (prop * oldV) / oldP;
|
value = (prop * oldV) / oldP;
|
||||||
else
|
else
|
||||||
value = 0;
|
value = 0;
|
||||||
@@ -518,7 +518,7 @@ static void updateScrollerProportion(ScrollView * sPtr)
|
|||||||
|
|
||||||
prop = (float)sPtr->viewport->size.height / (float)sPtr->contentView->size.height;
|
prop = (float)sPtr->viewport->size.height / (float)sPtr->contentView->size.height;
|
||||||
|
|
||||||
if (oldP < 1.0)
|
if (oldP < 1.0F)
|
||||||
value = (prop * oldV) / oldP;
|
value = (prop * oldV) / oldP;
|
||||||
else
|
else
|
||||||
value = 0;
|
value = 0;
|
||||||
|
|||||||
@@ -298,7 +298,7 @@ static void showData(_Panel * panel)
|
|||||||
sprintf(buffer, "%i", a);
|
sprintf(buffer, "%i", a);
|
||||||
WMSetTextFieldText(panel->threT, buffer);
|
WMSetTextFieldText(panel->threT, buffer);
|
||||||
|
|
||||||
WMSetSliderValue(panel->speedS, (accel - 0.25) / 0.25);
|
WMSetSliderValue(panel->speedS, (accel - 0.25F) / 0.25F);
|
||||||
|
|
||||||
panel->acceleration = accel;
|
panel->acceleration = accel;
|
||||||
sprintf(buffer, "%.2f", accel);
|
sprintf(buffer, "%.2f", accel);
|
||||||
|
|||||||
12
src/misc.c
12
src/misc.c
@@ -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;
|
px = slide_steps;
|
||||||
else if (px > -slide_steps && px < 0)
|
else if (px > -slide_steps && px < 0)
|
||||||
px = -slide_steps;
|
px = -slide_steps;
|
||||||
py = (is_dx_nul ? 0.0 : px * dy / dx);
|
py = (is_dx_nul ? 0.0F : px * dy / dx);
|
||||||
} else {
|
} else {
|
||||||
py = dy / slide_slowdown;
|
py = dy / slide_slowdown;
|
||||||
if (py < slide_steps && py > 0)
|
if (py < slide_steps && py > 0)
|
||||||
py = slide_steps;
|
py = slide_steps;
|
||||||
else if (py > -slide_steps && py < 0)
|
else if (py > -slide_steps && py < 0)
|
||||||
py = -slide_steps;
|
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 ||
|
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;
|
y = (float)to_y;
|
||||||
|
|
||||||
if (dx_is_bigger) {
|
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)
|
if (px < slide_steps && px > 0)
|
||||||
px = slide_steps;
|
px = slide_steps;
|
||||||
else if (px > -slide_steps && px < 0)
|
else if (px > -slide_steps && px < 0)
|
||||||
px = -slide_steps;
|
px = -slide_steps;
|
||||||
py = (is_dx_nul ? 0.0 : px * dy / dx);
|
py = (is_dx_nul ? 0.0F : px * dy / dx);
|
||||||
} else {
|
} else {
|
||||||
py = py * (1.0 - 1 / (float)slide_slowdown);
|
py = py * (1.0F - 1 / (float)slide_slowdown);
|
||||||
if (py < slide_steps && py > 0)
|
if (py < slide_steps && py > 0)
|
||||||
py = slide_steps;
|
py = slide_steps;
|
||||||
else if (py > -slide_steps && py < 0)
|
else if (py > -slide_steps && py < 0)
|
||||||
py = -slide_steps;
|
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++) {
|
for (i = 0; i < n; i++) {
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ void RCombineAlpha(unsigned char *d, unsigned char *s, int s_has_alpha,
|
|||||||
cratio = 0;
|
cratio = 0;
|
||||||
} else {
|
} else {
|
||||||
ratio = (float)sa / alpha;
|
ratio = (float)sa / alpha;
|
||||||
cratio = 1.0 - ratio;
|
cratio = 1.0F - ratio;
|
||||||
}
|
}
|
||||||
|
|
||||||
*d = (int)*d * cratio + (int)*s * ratio;
|
*d = (int)*d * cratio + (int)*s * ratio;
|
||||||
|
|||||||
@@ -438,7 +438,7 @@ static void gatherconfig(RContext * context, int screen_n)
|
|||||||
ptr = mygetenv("WRASTER_GAMMA", screen_n);
|
ptr = mygetenv("WRASTER_GAMMA", screen_n);
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
float g1, g2, g3;
|
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);
|
printf("wrlib: invalid value(s) for gamma correction \"%s\"\n", ptr);
|
||||||
} else {
|
} else {
|
||||||
context->attribs->flags |= RC_GammaCorrection;
|
context->attribs->flags |= RC_GammaCorrection;
|
||||||
|
|||||||
@@ -48,26 +48,26 @@ RImage *RRotateImage(RImage *image, float angle)
|
|||||||
* candidate for an Epsilon when trying to compare angle
|
* candidate for an Epsilon when trying to compare angle
|
||||||
* to known values
|
* to known values
|
||||||
*/
|
*/
|
||||||
static const float min_usable_angle = 0.00699;
|
static const float min_usable_angle = 0.00699F;
|
||||||
|
|
||||||
angle = fmod(angle, 360.0);
|
angle = fmod(angle, 360.0);
|
||||||
if (angle < 0.0)
|
if (angle < 0.0F)
|
||||||
angle += 360.0;
|
angle += 360.0F;
|
||||||
|
|
||||||
if (angle < min_usable_angle) {
|
if (angle < min_usable_angle) {
|
||||||
/* Rotate by 0 degree */
|
/* Rotate by 0 degree */
|
||||||
return RCloneImage(image);
|
return RCloneImage(image);
|
||||||
|
|
||||||
} else if ((angle > 90.0 - min_usable_angle) &&
|
} else if ((angle > 90.0F - min_usable_angle) &&
|
||||||
(angle < 90.0 + min_usable_angle)) {
|
(angle < 90.0F + min_usable_angle)) {
|
||||||
return rotate_image_90(image);
|
return rotate_image_90(image);
|
||||||
|
|
||||||
} else if ((angle > 180.0 - min_usable_angle) &&
|
} else if ((angle > 180.0F - min_usable_angle) &&
|
||||||
(angle < 180.0 + min_usable_angle)) {
|
(angle < 180.0F + min_usable_angle)) {
|
||||||
return wraster_rotate_image_180(image);
|
return wraster_rotate_image_180(image);
|
||||||
|
|
||||||
} else if ((angle > 270.0 - min_usable_angle) &&
|
} else if ((angle > 270.0F - min_usable_angle) &&
|
||||||
(angle < 270.0 + min_usable_angle)) {
|
(angle < 270.0F + min_usable_angle)) {
|
||||||
return rotate_image_270(image);
|
return rotate_image_270(image);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -341,8 +341,8 @@ static RImage *rotate_image_any(RImage *source, float angle)
|
|||||||
int dpr, dpru, p;
|
int dpr, dpru, p;
|
||||||
|
|
||||||
/* only 180o for now */
|
/* only 180o for now */
|
||||||
if (angle > 180.0)
|
if (angle > 180.0F)
|
||||||
angle -= 180.0;
|
angle -= 180.0F;
|
||||||
|
|
||||||
angle = (angle * WM_PI) / 180.0;
|
angle = (angle * WM_PI) / 180.0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user