diff --git a/src/bin/e_utils.c b/src/bin/e_utils.c index 8254445fd..e5e83ea84 100644 --- a/src/bin/e_utils.c +++ b/src/bin/e_utils.c @@ -1059,48 +1059,9 @@ e_util_win_auto_resize_fill(E_Win *win) if (zone) { - const Eina_List *l; - const E_Shelf *shelf; - int w, h; + int w, h; - w = zone->w; - h = zone->h; - EINA_LIST_FOREACH(e_shelf_list(), l, shelf) - { - E_Gadcon_Orient orient; - - if (shelf->zone != zone) - continue; - - if (shelf->cfg) - orient = shelf->cfg->orient; - else - orient = shelf->gadcon->orient; - - switch (orient) - { - case E_GADCON_ORIENT_FLOAT: - break; - case E_GADCON_ORIENT_TOP: - case E_GADCON_ORIENT_BOTTOM: - case E_GADCON_ORIENT_HORIZ: - case E_GADCON_ORIENT_CORNER_LT: - case E_GADCON_ORIENT_CORNER_RT: - case E_GADCON_ORIENT_CORNER_LB: - case E_GADCON_ORIENT_CORNER_RB: - h -= shelf->h; - break; - case E_GADCON_ORIENT_VERT: - case E_GADCON_ORIENT_LEFT: - case E_GADCON_ORIENT_RIGHT: - case E_GADCON_ORIENT_CORNER_TL: - case E_GADCON_ORIENT_CORNER_TR: - case E_GADCON_ORIENT_CORNER_BL: - case E_GADCON_ORIENT_CORNER_BR: - w -= shelf->w; - break; - } - } + e_zone_useful_geometry_calc(zone, NULL, NULL, &w, &h); w = _win_auto_size_calc(w, win->min_w); h = _win_auto_size_calc(h, win->min_h); diff --git a/src/bin/e_win.c b/src/bin/e_win.c index 1c9b920c6..abb96127e 100644 --- a/src/bin/e_win.c +++ b/src/bin/e_win.c @@ -328,10 +328,14 @@ e_win_centered_set(E_Win *win, int centered) } if ((win->border) && (centered)) { + int x, y, w, h; + + e_zone_useful_geometry_calc(win->border->zone, &x, &y, &w, &h); + /* The window is visible, move it to the right spot */ e_border_move(win->border, - win->border->zone->x + (win->border->zone->w - win->border->w) / 2, - win->border->zone->y + (win->border->zone->h - win->border->h) / 2); + win->border->zone->x + x + (w - win->border->w) / 2, + win->border->zone->y + y + (h - win->border->h) / 2); } } diff --git a/src/bin/e_zone.c b/src/bin/e_zone.c index e9e2a1b45..c9399204c 100644 --- a/src/bin/e_zone.c +++ b/src/bin/e_zone.c @@ -826,6 +826,77 @@ e_zone_flip_win_restore(void) } } +/** + * Calculate the useful (or free, without any shelves) area. + */ +EAPI void +e_zone_useful_geometry_calc(const E_Zone *zone, int *x, int *y, int *w, int *h) +{ + const Eina_List *l; + const E_Shelf *shelf; + int x0, x1, y0, y1; + + x0 = 0; + y0 = 0; + x1 = zone->w; + y1 = zone->h; + EINA_LIST_FOREACH(e_shelf_list(), l, shelf) + { + E_Gadcon_Orient orient; + + if (shelf->zone != zone) + continue; + + if (shelf->cfg) + { + if (shelf->cfg->autohide) + continue; + orient = shelf->cfg->orient; + } + else + orient = shelf->gadcon->orient; + + switch (orient) + { + /* these are non-edje orientations */ + case E_GADCON_ORIENT_FLOAT: + case E_GADCON_ORIENT_HORIZ: + case E_GADCON_ORIENT_VERT: + break; + case E_GADCON_ORIENT_TOP: + case E_GADCON_ORIENT_CORNER_TL: + case E_GADCON_ORIENT_CORNER_TR: + if (y0 < shelf->h) + y0 = shelf->h; + break; + case E_GADCON_ORIENT_BOTTOM: + case E_GADCON_ORIENT_CORNER_BL: + case E_GADCON_ORIENT_CORNER_BR: + if (y1 > zone->h - shelf->h) + y1 = zone->h - shelf->h; + break; + break; + case E_GADCON_ORIENT_LEFT: + case E_GADCON_ORIENT_CORNER_LT: + case E_GADCON_ORIENT_CORNER_LB: + if (x0 < shelf->w) + x0 = shelf->w; + break; + case E_GADCON_ORIENT_RIGHT: + case E_GADCON_ORIENT_CORNER_RT: + case E_GADCON_ORIENT_CORNER_RB: + if (y1 > zone->w - shelf->w) + y1 = zone->w - shelf->w; + break; + } + } + + if (x) *x = x0; + if (y) *y = y0; + if (w) *w = x1 - x0; + if (h) *h = y1 - y0; +} + /* local subsystem functions */ static void _e_zone_free(E_Zone *zone) diff --git a/src/bin/e_zone.h b/src/bin/e_zone.h index 9c84038c2..1681855f7 100644 --- a/src/bin/e_zone.h +++ b/src/bin/e_zone.h @@ -138,6 +138,8 @@ EAPI void e_zone_desk_linear_flip_to(E_Zone *zone, int x); EAPI void e_zone_flip_win_disable(void); EAPI void e_zone_flip_win_restore(void); +EAPI void e_zone_useful_geometry_calc(const E_Zone *zone, int *x, int *y, int *w, int *h); + extern EAPI int E_EVENT_ZONE_DESK_COUNT_SET; extern EAPI int E_EVENT_ZONE_MOVE_RESIZE; extern EAPI int E_EVENT_ZONE_ADD;