forked from enlightenment/efl
ecore evas - wayland - avoid divide by 0 if height is 0
fixes CID 1379247
This commit is contained in:
parent
dea4e5aa46
commit
92e8935fa6
|
@ -316,41 +316,45 @@ _ecore_evas_wl_common_resize(Ecore_Evas *ee, int w, int h)
|
||||||
/* copied from e_client.c */
|
/* copied from e_client.c */
|
||||||
Evas_Aspect_Control aspect;
|
Evas_Aspect_Control aspect;
|
||||||
int aw, ah;
|
int aw, ah;
|
||||||
double val, a = (double)w / h;
|
double val, a;
|
||||||
|
|
||||||
if (fabs(a - ee->prop.aspect) > 0.001)
|
if (h > 0)
|
||||||
{
|
{
|
||||||
int step_w = ee->prop.step.w ?: 1, step_h = ee->prop.step.h ?: 1;
|
a = (double)w / (double)h;
|
||||||
if (wdata->resizing || wdata->win->resizing)
|
if (fabs(a - ee->prop.aspect) > 0.001)
|
||||||
ew = wdata->cw, eh = wdata->ch;
|
|
||||||
if (abs(w - ew) > abs(h - eh))
|
|
||||||
aspect = EVAS_ASPECT_CONTROL_HORIZONTAL;
|
|
||||||
else
|
|
||||||
aspect = EVAS_ASPECT_CONTROL_VERTICAL;
|
|
||||||
switch (aspect)
|
|
||||||
{
|
{
|
||||||
case EVAS_ASPECT_CONTROL_HORIZONTAL:
|
int step_w = ee->prop.step.w ?: 1;
|
||||||
val = ((h - (w / ee->prop.aspect)) * step_h) / step_h;
|
int step_h = ee->prop.step.h ?: 1;
|
||||||
if (val > 0)
|
|
||||||
ah = ceil(val);
|
if (wdata->resizing || wdata->win->resizing)
|
||||||
|
ew = wdata->cw, eh = wdata->ch;
|
||||||
|
if (abs(w - ew) > abs(h - eh))
|
||||||
|
aspect = EVAS_ASPECT_CONTROL_HORIZONTAL;
|
||||||
else
|
else
|
||||||
ah = floor(val);
|
aspect = EVAS_ASPECT_CONTROL_VERTICAL;
|
||||||
if ((h - ah > minh) || (minh < 1))
|
switch (aspect)
|
||||||
{
|
{
|
||||||
h -= ah;
|
case EVAS_ASPECT_CONTROL_HORIZONTAL:
|
||||||
|
val = ((h - (w / ee->prop.aspect)) *
|
||||||
|
step_h) / step_h;
|
||||||
|
if (val > 0) ah = ceil(val);
|
||||||
|
else ah = floor(val);
|
||||||
|
if ((h - ah > minh) || (minh < 1))
|
||||||
|
{
|
||||||
|
h -= ah;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
EINA_FALLTHROUGH;
|
||||||
|
/* no break */
|
||||||
|
default:
|
||||||
|
val = (((h * ee->prop.aspect) - w) *
|
||||||
|
step_w) / step_w;
|
||||||
|
if (val > 0) aw = ceil(val);
|
||||||
|
else aw = floor(val);
|
||||||
|
if ((w + aw < maxw) || (maxw < 1))
|
||||||
|
w += aw;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
EINA_FALLTHROUGH;
|
|
||||||
/* no break */
|
|
||||||
default:
|
|
||||||
val = (((h * ee->prop.aspect) - w) * step_w) / step_w;
|
|
||||||
if (val > 0)
|
|
||||||
aw = ceil(val);
|
|
||||||
else
|
|
||||||
aw = floor(val);
|
|
||||||
if ((w + aw < maxw) || (maxw < 1))
|
|
||||||
w += aw;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue