kwo pushed a commit to branch master.
commit ccc5560d2357d133d36523fdbd409205b4084ddf
Author: Kim Woelders <[email protected]>
Date: Sat Jul 6 07:38:44 2013 +0200
No need for double - change to float.
---
src/eimage.c | 4 ++--
src/ewins.h | 2 +-
src/fx.c | 48 +++++++++++++++++++++++-------------------------
src/hints.h | 4 ++--
src/icccm.c | 38 +++++++++++++++++++-------------------
src/iconify.c | 37 ++++++++++++++++++++-----------------
src/magwin.c | 26 +++++++++++++-------------
src/pager.c | 20 ++++++++++----------
8 files changed, 90 insertions(+), 89 deletions(-)
diff --git a/src/eimage.c b/src/eimage.c
index 57d74ca..e4dfe88 100644
--- a/src/eimage.c
+++ b/src/eimage.c
@@ -563,8 +563,8 @@ ScaleTile(Win wsrc, Drawable src, Win wdst, Pixmap dst,
scale = (scale) ? 2 : 1;
- tw = (int)((double)(stw * scale * dw) / sw + .5);
- th = (int)((double)(sth * scale * dh) / sh + .5);
+ tw = (int)((float)(stw * scale * dw) / sw + .5f);
+ th = (int)((float)(sth * scale * dh) / sh + .5f);
#if 0
Eprintf("ScaleTile: Tile %#lx %dx%d -> %dx%d T %dx%d -> %dx%d\n", src,
stw, sth, tw, th, scale * dw, scale * dh, dw, dh);
diff --git a/src/ewins.h b/src/ewins.h
index e9d07f0..d18593a 100644
--- a/src/ewins.h
+++ b/src/ewins.h
@@ -189,7 +189,7 @@ struct _ewin {
int base_w, base_h;
int w_inc, h_inc;
int grav;
- double aspect_min, aspect_max;
+ float aspect_min, aspect_max;
char is_group_leader;
} icccm;
diff --git a/src/fx.c b/src/fx.c
index 9555b1b..263d62d 100644
--- a/src/fx.c
+++ b/src/fx.c
@@ -29,13 +29,11 @@
#include "eimage.h"
#include "emodule.h"
#include "settings.h"
+#include "util.h"
#include "xwin.h"
#include <math.h>
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-#define M_TWOPI (2 * M_PI)
+#define M_2PI_F ((float)(2 * M_PI))
#define FX_OP_ENABLE 1 /* Enable, start */
#define FX_OP_DISABLE 2 /* Disable, stop */
@@ -66,11 +64,11 @@ typedef struct {
Win win;
Pixmap above;
int count;
- double incv, inch;
+ float incv, inch;
GC gc1;
} fx_ripple_data_t;
-#define FX_RIPPLE_DATA_INIT { NULL, 0, 0, 0., 0., NULL }
+#define FX_RIPPLE_DATA_INIT { NULL, 0, 0, 0.f, 0.f, NULL }
static Animator *fx_ripple = NULL;
@@ -101,21 +99,21 @@ FX_ripple_timeout(EObj * eo __UNUSED__, int run
__UNUSED__, void *state)
if (d->count > 32)
d->count = 0;
- d->incv += 0.40;
- if (d->incv > M_TWOPI)
+ d->incv += 0.40f;
+ if (d->incv > M_2PI_F)
d->incv = 0;
- d->inch += 0.32;
- if (d->inch > M_TWOPI)
+ d->inch += 0.32f;
+ if (d->inch > M_2PI_F)
d->inch = 0;
SET_GC_CLIP(bgeo, d->gc1);
for (y = 0; y < FX_RIPPLE_WATERH; y++)
{
- double aa, a, p;
+ float aa, a, p;
int yoff, off, yy;
- p = (((double)(FX_RIPPLE_WATERH - y)) / ((double)FX_RIPPLE_WATERH));
+ p = (((float)(FX_RIPPLE_WATERH - y)) / ((float)FX_RIPPLE_WATERH));
a = p * p * 48 + d->incv;
yoff = y + (int)(sin(a) * 7) + 1;
yy = (FX_RIPPLE_WATERH * 2) - yoff;
@@ -170,17 +168,17 @@ FX_Ripple_Ops(int op)
#define FX_WAVE_WATERW 64
#define FX_WAVE_DEPTH 10
#define FX_WAVE_GRABH (FX_WAVE_WATERH + FX_WAVE_DEPTH)
-#define FX_WAVE_CROSSPERIOD 0.42
+#define FX_WAVE_CROSSPERIOD 0.42f
typedef struct {
Win win;
Pixmap above;
int count;
- double incv, inch, incx;
+ float incv, inch, incx;
GC gc1;
} fx_waves_data_t;
-#define FX_WAVE_DATA_INIT { NULL, 0, 0, 0., 0., 0., NULL }
+#define FX_WAVE_DATA_INIT { NULL, 0, 0, 0.f, 0.f, 0.f, NULL }
static Animator *fx_waves = NULL;
@@ -188,7 +186,7 @@ static int
FX_Wave_timeout(EObj * eo __UNUSED__, int run __UNUSED__, void *state)
{
fx_waves_data_t *d = (fx_waves_data_t *) state;
- double incx2;
+ float incx2;
int y;
EObj *bgeo;
@@ -217,16 +215,16 @@ FX_Wave_timeout(EObj * eo __UNUSED__, int run __UNUSED__,
void *state)
d->count = 0;
/* Increment and roll some other variables */
- d->incv += 0.40;
- if (d->incv > M_TWOPI)
+ d->incv += 0.40f;
+ if (d->incv > M_2PI_F)
d->incv = 0;
- d->inch += 0.32;
- if (d->inch > M_TWOPI)
+ d->inch += 0.32f;
+ if (d->inch > M_2PI_F)
d->inch = 0;
- d->incx += 0.32;
- if (d->incx > M_TWOPI)
+ d->incx += 0.32f;
+ if (d->incx > M_2PI_F)
d->incx = 0;
SET_GC_CLIP(bgeo, d->gc1);
@@ -243,12 +241,12 @@ FX_Wave_timeout(EObj * eo __UNUSED__, int run __UNUSED__,
void *state)
for (y = 0; y < FX_WAVE_WATERH; y++)
{
/* Variables */
- double aa, a, p;
+ float aa, a, p;
int yoff, off, yy;
int x;
/* Figure out the side-to-side movement */
- p = (((double)(FX_WAVE_WATERH - y)) / ((double)FX_WAVE_WATERH));
+ p = (((float)(FX_WAVE_WATERH - y)) / ((float)FX_WAVE_WATERH));
a = p * p * 48 + d->incv;
yoff = y + (int)(sin(a) * 7) + 1;
yy = (FX_WAVE_WATERH * 2) - yoff;
@@ -267,7 +265,7 @@ FX_Wave_timeout(EObj * eo __UNUSED__, int run __UNUSED__,
void *state)
/* Add something to incx2 and roll it */
incx2 += FX_WAVE_CROSSPERIOD;
- if (incx2 > M_TWOPI)
+ if (incx2 > M_2PI_F)
incx2 = 0;
/* Figure it out */
diff --git a/src/hints.h b/src/hints.h
index 0fbfdc8..0383679 100644
--- a/src/hints.h
+++ b/src/hints.h
@@ -156,8 +156,8 @@ void ICCCM_SetSizeConstraints(EWin * ewin,
unsigned int wmin,
unsigned int wbase,
unsigned int hbase,
unsigned int winc,
- unsigned int hinc, double amin,
- double amax);
+ unsigned int hinc,
+ float amin, float amax);
void ICCCM_Configure(EWin * ewin);
void ICCCM_AdoptStart(const EWin * ewin);
void ICCCM_Adopt(const EWin * ewin);
diff --git a/src/icccm.c b/src/icccm.c
index d93f693..13c5d6d 100644
--- a/src/icccm.c
+++ b/src/icccm.c
@@ -151,7 +151,7 @@ ICCCM_SizeMatch(const EWin * ewin, int wi, int hi, int
*pwo, int *pho)
{
int w, h;
int i, j;
- double aspect, dw, dh;
+ float aspect, dw, dh;
w = wi;
h = hi;
@@ -175,38 +175,38 @@ ICCCM_SizeMatch(const EWin * ewin, int wi, int hi, int
*pwo, int *pho)
/* Ignore aspect ratio constraints when fullscreening */
if (!ewin->state.fullscreen)
{
- aspect = ((double)w) / ((double)h);
+ aspect = ((float)w) / ((float)h);
dw = ewin->icccm.w_inc / 4.;
dh = ewin->icccm.h_inc / 4.;
if (Mode.mode == MODE_RESIZE_H)
{
if (aspect < ewin->icccm.aspect_min)
- h = (int)((double)w / ewin->icccm.aspect_min + dh);
+ h = (int)((float)w / ewin->icccm.aspect_min + dh);
else if (aspect > ewin->icccm.aspect_max)
- h = (int)((double)w / ewin->icccm.aspect_max + dh);
+ h = (int)((float)w / ewin->icccm.aspect_max + dh);
}
else if (Mode.mode == MODE_RESIZE_V)
{
if (aspect < ewin->icccm.aspect_min)
- w = (int)((double)h * ewin->icccm.aspect_min + dw);
+ w = (int)((float)h * ewin->icccm.aspect_min + dw);
else if (aspect > ewin->icccm.aspect_max)
- w = (int)((double)h * ewin->icccm.aspect_max + dw);
+ w = (int)((float)h * ewin->icccm.aspect_max + dw);
}
else
{
if (aspect < ewin->icccm.aspect_min)
{
if (ewin->icccm.aspect_min >= 1.)
- h = (int)((double)w / ewin->icccm.aspect_min + dh);
+ h = (int)((float)w / ewin->icccm.aspect_min + dh);
else
- w = (int)((double)h * ewin->icccm.aspect_min + dw);
+ w = (int)((float)h * ewin->icccm.aspect_min + dw);
}
else if (aspect > ewin->icccm.aspect_max)
{
if (ewin->icccm.aspect_max >= 1.)
- h = (int)((double)w / ewin->icccm.aspect_max + dh);
+ h = (int)((float)w / ewin->icccm.aspect_max + dh);
else
- w = (int)((double)h * ewin->icccm.aspect_max + dw);
+ w = (int)((float)h * ewin->icccm.aspect_max + dw);
}
}
}
@@ -244,7 +244,7 @@ ICCCM_SetSizeConstraints(EWin * ewin, unsigned int wmin,
unsigned int hmin,
unsigned int wmax, unsigned int hmax,
unsigned int wbase, unsigned int hbase,
unsigned int winc, unsigned int hinc,
- double amin, double amax)
+ float amin, float amax)
{
ewin->icccm.width_min = wmin;
ewin->icccm.height_min = hmin;
@@ -484,29 +484,29 @@ ICCCM_GetGeoms(EWin * ewin)
if (hint.flags & PAspect)
{
- if ((hint.min_aspect.y > 0.0) && (hint.min_aspect.x > 0.0))
+ if (hint.min_aspect.y > 0 && hint.min_aspect.x > 0)
{
ewin->icccm.aspect_min =
- ((double)hint.min_aspect.x) / ((double)hint.min_aspect.y);
+ ((float)hint.min_aspect.x) / ((float)hint.min_aspect.y);
}
else
{
- ewin->icccm.aspect_min = 0.0;
+ ewin->icccm.aspect_min = 0.f;
}
- if ((hint.max_aspect.y > 0.0) && (hint.max_aspect.x > 0.0))
+ if (hint.max_aspect.y > 0 && hint.max_aspect.x > 0)
{
ewin->icccm.aspect_max =
- ((double)hint.max_aspect.x) / ((double)hint.max_aspect.y);
+ ((float)hint.max_aspect.x) / ((float)hint.max_aspect.y);
}
else
{
- ewin->icccm.aspect_max = 65535.0;
+ ewin->icccm.aspect_max = 65535.f;
}
}
else
{
- ewin->icccm.aspect_min = 0.0;
- ewin->icccm.aspect_max = 65535.0;
+ ewin->icccm.aspect_min = 0.f;
+ ewin->icccm.aspect_max = 65535.f;
}
if (hint.flags & PBaseSize)
diff --git a/src/iconify.c b/src/iconify.c
index 1b6af3e..13a0d6b 100644
--- a/src/iconify.c
+++ b/src/iconify.c
@@ -34,6 +34,9 @@
#include "xwin.h"
#include <math.h>
+#define M_PI_F ((float)(M_PI))
+#define M_2PI_F ((float)(2 * M_PI))
+
static Container *SelectIconboxForEwin(EWin * ewin);
/* Silly hack to avoid name clash warning when using -Wshadow */
@@ -43,10 +46,10 @@ static Container *SelectIconboxForEwin(EWin * ewin);
#define IB_ANIM_STEP Conf.animation.step
static void
-IB_Animate_Sleep(unsigned int t0, double a)
+IB_Animate_Sleep(unsigned int t0, float a)
{
unsigned int t;
- double dt;
+ float dt;
t = GetTimeMs() - t0;
dt = 1e-3 * (t - a * IB_ANIM_TIME);
@@ -60,7 +63,7 @@ IB_Animate_A(char iconify, EWin * ewin, EWin * ibox)
{
EWin *fr, *to;
unsigned int t0;
- double a, aa, spd;
+ float a, aa, spd;
int x, y, x1, y1, x2, y2, x3, y3, x4, y4, w, h;
int fx, fy, fw, fh, tx, ty, tw, th;
Window root = WinGetXwin(VROOT);
@@ -109,12 +112,12 @@ IB_Animate_A(char iconify, EWin * ewin, EWin * ibox)
GCFunction | GCForeground | GCSubwindowMode | GCLineWidth,
&gcv);
- spd = (1. * IB_ANIM_STEP) / IB_ANIM_TIME;
+ spd = (1.f * IB_ANIM_STEP) / IB_ANIM_TIME;
t0 = GetTimeMs();
- for (a = 0.0; a < 1.0; a += spd)
+ for (a = 0.f; a < 1.f; a += spd)
{
- aa = 1.0 - a;
+ aa = 1.f - a;
x = (int)((fx * aa) + (tx * a));
y = (int)((fy * aa) + (ty * a));
@@ -126,14 +129,14 @@ IB_Animate_A(char iconify, EWin * ewin, EWin * ibox)
w /= 2; /* width/2 */
h /= 2; /* height/2 */
- x1 = (int)(x + w * (1 - .5 * sin(3.14159 + a * 6.2831853072)));
- y1 = (int)(y + h * cos(a * 6.2831853072));
- x2 = (int)(x + w * (1 - .5 * sin(a * 6.2831853072)));
- y2 = (int)(y - h * cos(a * 6.2831853072));
- x3 = (int)(x - w * (1 - .5 * sin(3.14159 + a * 6.2831853072)));
- y3 = (int)(y - h * cos(a * 6.2831853072));
- x4 = (int)(x - w * (1 - .5 * sin(a * 6.2831853072)));
- y4 = (int)(y + h * cos(a * 6.2831853072));
+ x1 = (int)(x + w * (1.f - .5f * sinf(M_PI_F + a * M_2PI_F)));
+ y1 = (int)(y + h * cosf(a * M_2PI_F));
+ x2 = (int)(x + w * (1.f - .5f * sinf(a * M_2PI_F)));
+ y2 = (int)(y - h * cosf(a * M_2PI_F));
+ x3 = (int)(x - w * (1.f - .5f * sinf(M_PI_F + a * M_2PI_F)));
+ y3 = (int)(y - h * cosf(a * M_2PI_F));
+ x4 = (int)(x - w * (1.f - .5f * sinf(a * M_2PI_F)));
+ y4 = (int)(y + h * cosf(a * M_2PI_F));
XDrawLine(disp, root, gc, x1, y1, x2, y2);
XDrawLine(disp, root, gc, x2, y2, x3, y3);
@@ -157,7 +160,7 @@ IB_Animate_B(char iconify, EWin * ewin, EWin * ibox)
{
EWin *fr, *to;
unsigned int t0;
- double a, spd;
+ float a, spd;
int x, y, w, h;
int fx, fy, fw, fh, tx, ty, tw, th;
Window root = WinGetXwin(VROOT);
@@ -207,10 +210,10 @@ IB_Animate_B(char iconify, EWin * ewin, EWin * ibox)
XDrawRectangle(disp, root, gc, tx, ty, tw, th);
XDrawRectangle(disp, root, gc, fx, fy, fw, fh);
- spd = (1. * IB_ANIM_STEP) / IB_ANIM_TIME;
+ spd = (1.f * IB_ANIM_STEP) / IB_ANIM_TIME;
t0 = GetTimeMs();
- for (a = 0.0; a < 1.0; a += spd)
+ for (a = 0.f; a < 1.f; a += spd)
{
x = (int)(fx + a * (tx - fx));
w = (int)(fw + a * (tw - fw));
diff --git a/src/magwin.c b/src/magwin.c
index eeaf89d..52109b3 100644
--- a/src/magwin.c
+++ b/src/magwin.c
@@ -104,7 +104,7 @@ MagwinRedraw(MagWindow * mw, int paint)
{
int ww, wh;
int sx, sy, sw, sh;
- double scale;
+ float scale;
int zoom_res;
Drawable draw;
char buf[128];
@@ -121,15 +121,15 @@ MagwinRedraw(MagWindow * mw, int paint)
mw->scale = -6 * zoom_res;
else if (mw->scale > 6 * zoom_res)
mw->scale = 6 * zoom_res;
- scale = pow(2., (double)(mw->scale) / zoom_res);
- sw = (int)((ww + .999 * scale) / scale);
+ scale = powf(2.f, (float)(mw->scale) / zoom_res);
+ sw = (int)((ww + .999f * scale) / scale);
if (sw > WinGetW(VROOT))
- scale = (double)ww / (double)WinGetW(VROOT);
- sh = (int)((wh + .999 * scale) / scale);
- if (sh > WinGetH(VROOT) && scale < (double)wh / (double)WinGetH(VROOT))
- scale = (double)wh / (double)WinGetH(VROOT);
- sw = (int)((ww + .999 * scale) / scale);
- sh = (int)((wh + .999 * scale) / scale);
+ scale = (float)ww / (float)WinGetW(VROOT);
+ sh = (int)((wh + .999f * scale) / scale);
+ if (sh > WinGetH(VROOT) && scale < (float)wh / (float)WinGetH(VROOT))
+ scale = (float)wh / (float)WinGetH(VROOT);
+ sw = (int)((ww + .999f * scale) / scale);
+ sh = (int)((wh + .999f * scale) / scale);
sx = mw->cx - sw / 2;
sy = mw->cy - sh / 2;
if (sx < 0)
@@ -150,8 +150,8 @@ MagwinRedraw(MagWindow * mw, int paint)
{
int dw, dh;
- dw = (int)(sw * scale + .5);
- dh = (int)(sh * scale + .5);
+ dw = (int)(sw * scale + .5f);
+ dh = (int)(sh * scale + .5f);
draw = ECompMgrGetRootBuffer();
ScaleRect(VROOT, draw, EwinGetClientWin(mw->ewin),
EwinGetClientXwin(mw->ewin), sx, sy, sw, sh,
@@ -369,7 +369,7 @@ MagwinEvent(Win win __UNUSED__, XEvent * ev, void *prm)
if (mw->btn_down)
{
int dx, dy;
- double scale;
+ float scale;
dx = Mode.events.mx - mw->stroke_mx;
dy = Mode.events.my - mw->stroke_my;
@@ -379,7 +379,7 @@ MagwinEvent(Win win __UNUSED__, XEvent * ev, void *prm)
if (!mw->stroke)
break;
- scale = pow(2., (double)(mw->scale) / Conf.magwin.zoom_res);
+ scale = powf(2.f, (float)(mw->scale) / Conf.magwin.zoom_res);
mw->cx = mw->stroke_cx - (int)(dx / scale);
mw->cy = mw->stroke_cy - (int)(dy / scale);
mw->update = 1;
diff --git a/src/pager.c b/src/pager.c
index da2c7b3..6b983f9 100644
--- a/src/pager.c
+++ b/src/pager.c
@@ -522,21 +522,21 @@ static void
PagerReconfigure(Pager * p, int apply)
{
int ax, ay, w, h, dx, dy;
- double aspect, f;
+ float aspect, f;
DesksGetAreaSize(&ax, &ay);
- aspect = ((double)WinGetW(VROOT)) / ((double)WinGetH(VROOT));
+ aspect = ((float)WinGetW(VROOT)) / ((float)WinGetH(VROOT));
dx = 2;
for (;;)
{
f = dx / aspect;
- dy = (int)(f + .5);
- f -= (double)dy;
+ dy = (int)(f + .5f);
+ f -= (float)dy;
if (f < 0)
f = -f;
- if (f < .1)
+ if (f < .1f)
break;
if (dx >= 8)
break;
@@ -548,13 +548,13 @@ PagerReconfigure(Pager * p, int apply)
WinGetH(VROOT) / 64 * ay,
WinGetW(VROOT) / 4 * ax,
WinGetH(VROOT) / 4 * ay, 0, 0, dx * ax, dy * ay,
- aspect * ((double)ax / (double)ay),
- aspect * ((double)ax / (double)ay));
+ aspect * ((float)ax / (float)ay),
+ aspect * ((float)ax / (float)ay));
if (apply)
{
- w = (int)((double)ax * (double)WinGetW(VROOT) / (double)p->scale + .5);
- h = (int)((double)ay * (double)WinGetH(VROOT) / (double)p->scale + .5);
+ w = (int)((float)ax * (float)WinGetW(VROOT) / (float)p->scale + .5f);
+ h = (int)((float)ay * (float)WinGetH(VROOT) / (float)p->scale + .5f);
EwinResize(p->ewin, w + (dx * ax) / 2, h + (dy * ay) / 2, 0);
EwinReposition(p->ewin);
}
@@ -682,7 +682,7 @@ _PagerEwinMoveResize(EWin * ewin, int resize __UNUSED__)
p->dw = w / ax;
p->dh = h / ay;
- if (p->scale <= 0. || Mode.op_source == OPSRC_USER)
+ if (p->scale <= 0.f || Mode.op_source == OPSRC_USER)
p->scale = ((float)WinGetW(VROOT) / p->dw +
(float)WinGetH(VROOT) / p->dh) / 2;
--
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev