add safety checks for elm_win_center
authordiscomfitor <discomfitor@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 4 Dec 2011 20:44:41 +0000 (20:44 +0000)
committerdiscomfitor <discomfitor@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 4 Dec 2011 20:44:41 +0000 (20:44 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@65870 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/elm_win.c

index 6eedc60..b4d1f88 100644 (file)
@@ -1778,11 +1778,15 @@ elm_win_center(Evas_Object *obj, Eina_Bool h, Eina_Bool v)
    win = elm_widget_data_get(obj);
    if (!win) return;
    ecore_evas_screen_geometry_get(win->ee, NULL, NULL, &screen_w, &screen_h);
+   if ((!screen_w) || (!screen_h)) return;
    evas_object_geometry_get(obj, NULL, NULL, &win_w, &win_h);
+   if ((!win_w) || (!win_h)) return;
    if (h) nx = win_w >= screen_w ? 0 : (screen_w / 2) - (win_w / 2);
    else nx = win->screen.x;
    if (v) ny = win_h >= screen_h ? 0 : (screen_h / 2) - (win_h / 2);
    else ny = win->screen.y;
+   if (nx < 0) nx = 0;
+   if (ny < 0) ny = 0;
    evas_object_move(obj, nx, ny);
 }