formatting

SVN revision: 80356
This commit is contained in:
Mike Blumenkrantz 2012-12-06 12:48:14 +00:00
parent 33c59fd351
commit 3a87b43a19
1 changed files with 278 additions and 277 deletions

View File

@ -13,9 +13,9 @@ static void _e_resist_rects(Eina_List *rects, int px, int py, int pw, int ph, in
EAPI int EAPI int
e_resist_container_border_position(E_Container *con, Eina_List *skiplist, e_resist_container_border_position(E_Container *con, Eina_List *skiplist,
int px, int py, int pw, int ph, int px, int py, int pw, int ph,
int x, int y, int w, int h, int x, int y, int w, int h,
int *rx, int *ry, int *rw, int *rh) int *rx, int *ry, int *rw, int *rh)
{ {
Eina_List *l, *ll, *rects = NULL; Eina_List *l, *ll, *rects = NULL;
E_Resist_Rect *r; E_Resist_Rect *r;
@ -27,32 +27,32 @@ e_resist_container_border_position(E_Container *con, Eina_List *skiplist,
if (!e_config->use_resist) if (!e_config->use_resist)
{ {
*rx = x; *rx = x;
*ry = y; *ry = y;
*rw = w; *rw = w;
*rh = h; *rh = h;
return 0; return 0;
} }
/* edges of screen */ /* edges of screen */
#define OBSTACLE(_x, _y, _w, _h, _resist) \ #define OBSTACLE(_x, _y, _w, _h, _resist) \
{ \ { \
r = E_NEW(E_Resist_Rect, 1); \ r = E_NEW(E_Resist_Rect, 1); \
r->x = _x; r->y = _y; r->w = _w; r->h = _h; r->v1 = _resist; \ r->x = _x; r->y = _y; r->w = _w; r->h = _h; r->v1 = _resist; \
r->resist_out = 0; \ r->resist_out = 0; \
rects = eina_list_append(rects, r); \ rects = eina_list_append(rects, r); \
} }
#define HOLDER(_x, _y, _w, _h, _resist) \ #define HOLDER(_x, _y, _w, _h, _resist) \
{ \ { \
r = E_NEW(E_Resist_Rect, 1); \ r = E_NEW(E_Resist_Rect, 1); \
r->x = _x; r->y = _y; r->w = _w; r->h = _h; r->v1 = _resist; \ r->x = _x; r->y = _y; r->w = _w; r->h = _h; r->v1 = _resist; \
r->resist_out = 1; \ r->resist_out = 1; \
rects = eina_list_append(rects, r); \ rects = eina_list_append(rects, r); \
} }
EINA_LIST_FOREACH(con->zones, l, zone) EINA_LIST_FOREACH(con->zones, l, zone)
{ {
HOLDER(zone->x, zone->y, zone->w, zone->h, e_config->desk_resist); HOLDER(zone->x, zone->y, zone->w, zone->h, e_config->desk_resist);
} }
/* FIXME: need to add resist or complete BLOCKS for things like ibar */ /* FIXME: need to add resist or complete BLOCKS for things like ibar */
/* can add code here to add more fake obstacles with custom resist values */ /* can add code here to add more fake obstacles with custom resist values */
@ -61,72 +61,72 @@ e_resist_container_border_position(E_Container *con, Eina_List *skiplist,
bl = e_container_border_list_first(con); bl = e_container_border_list_first(con);
while ((bd = e_container_border_list_next(bl))) while ((bd = e_container_border_list_next(bl)))
{ {
if (bd->visible) if (bd->visible)
{ {
int ok; int ok;
ok = 1; ok = 1;
EINA_LIST_FOREACH(skiplist, ll, bd2) EINA_LIST_FOREACH(skiplist, ll, bd2)
{ {
if (bd2 == bd) if (bd2 == bd)
{ {
ok = 0; ok = 0;
break; break;
} }
} }
if (ok && bd->offer_resistance) if (ok && bd->offer_resistance)
{ {
OBSTACLE(bd->x, bd->y, bd->w, bd->h, e_config->window_resist); OBSTACLE(bd->x, bd->y, bd->w, bd->h, e_config->window_resist);
} }
} }
} }
e_container_border_list_free(bl); e_container_border_list_free(bl);
desk = e_desk_current_get(e_zone_current_get(con)); desk = e_desk_current_get(e_zone_current_get(con));
EINA_LIST_FOREACH(e_shelf_list(), l, es) EINA_LIST_FOREACH(e_shelf_list(), l, es)
{ {
Eina_List *ll2; Eina_List *ll2;
E_Config_Shelf_Desk *sd; E_Config_Shelf_Desk *sd;
if (es->zone->container == con) if (es->zone->container == con)
{ {
if (es->cfg->desk_show_mode) if (es->cfg->desk_show_mode)
{ {
EINA_LIST_FOREACH(es->cfg->desk_list, ll2, sd) EINA_LIST_FOREACH(es->cfg->desk_list, ll2, sd)
{ {
if (!sd) continue; if (!sd) continue;
if ((sd->x == desk->x) && (sd->y == desk->y)) if ((sd->x == desk->x) && (sd->y == desk->y))
{ {
OBSTACLE(es->x + es->zone->x, es->y + es->zone->y, es->w, es->h, OBSTACLE(es->x + es->zone->x, es->y + es->zone->y, es->w, es->h,
e_config->gadget_resist); e_config->gadget_resist);
break; break;
} }
} }
} }
else else
{ {
OBSTACLE(es->x + es->zone->x, es->y + es->zone->y, es->w, es->h, OBSTACLE(es->x + es->zone->x, es->y + es->zone->y, es->w, es->h,
e_config->gadget_resist); e_config->gadget_resist);
} }
} }
} }
if (rects) if (rects)
{ {
_e_resist_rects(rects, _e_resist_rects(rects,
px, py, pw, ph, px, py, pw, ph,
x, y, w, h, x, y, w, h,
rx, ry, rw, rh); rx, ry, rw, rh);
E_FREE_LIST(rects, E_FREE); E_FREE_LIST(rects, E_FREE);
} }
return 1; return 1;
} }
EAPI int EAPI int
e_resist_container_gadman_position(E_Container *con, Eina_List *skiplist __UNUSED__, e_resist_container_gadman_position(E_Container *con, Eina_List *skiplist __UNUSED__,
int px, int py, int pw, int ph, int px, int py, int pw, int ph,
int x, int y, int w, int h, int x, int y, int w, int h,
int *rx, int *ry) int *rx, int *ry)
{ {
Eina_List *l, *rects = NULL; Eina_List *l, *rects = NULL;
E_Resist_Rect *r; E_Resist_Rect *r;
@ -134,37 +134,37 @@ e_resist_container_gadman_position(E_Container *con, Eina_List *skiplist __UNUSE
if (!e_config->use_resist) if (!e_config->use_resist)
{ {
*rx = x; *rx = x;
*ry = y; *ry = y;
return 0; return 0;
} }
EINA_LIST_FOREACH(e_shelf_list(), l, es) EINA_LIST_FOREACH(e_shelf_list(), l, es)
{ {
if (es->zone->container == con) if (es->zone->container == con)
{ {
OBSTACLE(es->x + es->zone->x, es->y + es->zone->y, es->w, es->h, OBSTACLE(es->x + es->zone->x, es->y + es->zone->y, es->w, es->h,
e_config->gadget_resist); e_config->gadget_resist);
} }
} }
if (rects) if (rects)
{ {
_e_resist_rects(rects, _e_resist_rects(rects,
px, py, pw, ph, px, py, pw, ph,
x, y, w, h, x, y, w, h,
rx, ry, NULL, NULL); rx, ry, NULL, NULL);
E_FREE_LIST(rects, E_FREE); E_FREE_LIST(rects, E_FREE);
} }
return 1; return 1;
} }
static void static void
_e_resist_rects(Eina_List *rects, _e_resist_rects(Eina_List *rects,
int px, int py, int pw, int ph, int px, int py, int pw, int ph,
int x, int y, int w, int h, int x, int y, int w, int h,
int *rx, int *ry, int *rw, int *rh) int *rx, int *ry, int *rw, int *rh)
{ {
int dx, dy, dw, dh, d, pd; int dx, dy, dw, dh, d, pd;
int resist_x = 0, resist_y = 0; int resist_x = 0, resist_y = 0;
@ -179,207 +179,208 @@ _e_resist_rects(Eina_List *rects,
EINA_LIST_FOREACH(rects, l, r) EINA_LIST_FOREACH(rects, l, r)
{ {
if (E_SPANS_COMMON(r->y, r->h, y, h)) if (E_SPANS_COMMON(r->y, r->h, y, h))
{ {
if (dx > 0) if (dx > 0)
{ {
/* moving right */ /* moving right */
if (r->resist_out) if (r->resist_out)
{ {
/* check right edge of windows against left */ /* check right edge of windows against left */
d = x + w - (r->x + r->w); d = x + w - (r->x + r->w);
pd = px + pw - (r->x + r->w); pd = px + pw - (r->x + r->w);
if ((d > 0) && (pd <= 0) && (d <= r->v1)) if ((d > 0) && (pd <= 0) && (d <= r->v1))
{ {
if (-resist_x < d) if (-resist_x < d)
resist_x = -d; resist_x = -d;
} }
} }
else else
{ {
/* check left edge of windows against right */ /* check left edge of windows against right */
d = r->x - (x + w); d = r->x - (x + w);
pd = r->x - (px + pw); pd = r->x - (px + pw);
if ((d < 0) && (pd >= 0) && (d >= -r->v1)) if ((d < 0) && (pd >= 0) && (d >= -r->v1))
{ {
if (resist_x > d) if (resist_x > d)
resist_x = d; resist_x = d;
} }
} }
} }
else if (dx < 0) else if (dx < 0)
{ {
/* moving left */ /* moving left */
if (r->resist_out) if (r->resist_out)
{ {
/* check left edge of windows against right */ /* check left edge of windows against right */
d = r->x - x; d = r->x - x;
pd = r->x - px; pd = r->x - px;
if ((d > 0) && (pd <= 0) && (d <= r->v1)) if ((d > 0) && (pd <= 0) && (d <= r->v1))
{ {
if (resist_x < d) if (resist_x < d)
{ {
resist_x = d; resist_x = d;
resist_w = -d; resist_w = -d;
} }
} }
} }
else else
{ {
/* check right edge of windows against left */ /* check right edge of windows against left */
d = x - (r->x + r->w); d = x - (r->x + r->w);
pd = px - (r->x + r->w); pd = px - (r->x + r->w);
if ((d < 0) && (pd >= 0) && (d >= -r->v1)) if ((d < 0) && (pd >= 0) && (d >= -r->v1))
{ {
if (-resist_x > d) if (-resist_x > d)
{ {
resist_x = -d; resist_x = -d;
resist_w = d; resist_w = d;
} }
} }
} }
} }
if ((dw > 0) && (dx == 0)) if ((dw > 0) && (dx == 0))
{ {
/* enlarging window by moving lower corner */ /* enlarging window by moving lower corner */
if (r->resist_out) if (r->resist_out)
{ {
/* check right edge of windows against left */ /* check right edge of windows against left */
d = x + w - (r->x + r->w); d = x + w - (r->x + r->w);
pd = px + pw - (r->x + r->w); pd = px + pw - (r->x + r->w);
if ((d > 0) && (pd <= 0) && (d <= r->v1)) if ((d > 0) && (pd <= 0) && (d <= r->v1))
{ {
if (-resist_w < d) if (-resist_w < d)
resist_w = -d; resist_w = -d;
} }
} }
else else
{ {
/* check left edge of windows against right */ /* check left edge of windows against right */
d = r->x - (x + w); d = r->x - (x + w);
pd = r->x - (px + pw); pd = r->x - (px + pw);
if ((d < 0) && (pd >= 0) && (d >= -r->v1)) if ((d < 0) && (pd >= 0) && (d >= -r->v1))
{ {
if (resist_w > d) if (resist_w > d)
resist_w = d; resist_w = d;
} }
} }
} }
} }
if (E_SPANS_COMMON(r->x, r->w, x, w)) if (E_SPANS_COMMON(r->x, r->w, x, w))
{ {
if (dy > 0) if (dy > 0)
{ {
/* moving down */ /* moving down */
if (r->resist_out) if (r->resist_out)
{ {
/* check bottom edge of windows against top */ /* check bottom edge of windows against top */
d = y + h - (r->y + r->h); d = y + h - (r->y + r->h);
pd = py + ph - (r->y + r->h); pd = py + ph - (r->y + r->h);
if ((d > 0) && (pd <= 0) && (d <= r->v1)) if ((d > 0) && (pd <= 0) && (d <= r->v1))
{ {
if (-resist_y < d) if (-resist_y < d)
resist_y = -d; resist_y = -d;
} }
} }
else else
{ {
/* check top edge of windows against bottom */ /* check top edge of windows against bottom */
d = r->y - (y + h); d = r->y - (y + h);
pd = r->y - (py + ph); pd = r->y - (py + ph);
if ((d < 0) && (pd >= 0) && (d >= -r->v1)) if ((d < 0) && (pd >= 0) && (d >= -r->v1))
{ {
if (resist_y > d) if (resist_y > d)
resist_y = d; resist_y = d;
} }
} }
} }
else if (dy < 0) else if (dy < 0)
{ {
/* moving up */ /* moving up */
if (r->resist_out) if (r->resist_out)
{ {
/* check top edge of windows against bottom */ /* check top edge of windows against bottom */
d = r->y - y; d = r->y - y;
pd = r->y - py; pd = r->y - py;
if ((d > 0) && (pd <= 0) && (d <= r->v1)) if ((d > 0) && (pd <= 0) && (d <= r->v1))
{ {
if (resist_y < d) if (resist_y < d)
{ {
resist_y = d; resist_y = d;
resist_h = -d; resist_h = -d;
} }
} }
} }
else else
{ {
/* moving up - check bottom edge of windows against top */ /* moving up - check bottom edge of windows against top */
d = y - (r->y + r->h); d = y - (r->y + r->h);
pd = py - (r->y + r->h); pd = py - (r->y + r->h);
if ((d < 0) && (pd >= 0) && (d >= -r->v1)) if ((d < 0) && (pd >= 0) && (d >= -r->v1))
{ {
if (-resist_y > d) if (-resist_y > d)
{ {
resist_y = -d; resist_y = -d;
resist_h = d; resist_h = d;
} }
} }
} }
} }
if ((dh > 0) && (dy == 0)) if ((dh > 0) && (dy == 0))
{ {
/* enlarging window by moving lower corner */ /* enlarging window by moving lower corner */
if (r->resist_out) if (r->resist_out)
{ {
/* check bottom edge of windows against top */ /* check bottom edge of windows against top */
d = y + h - (r->y + r->h); d = y + h - (r->y + r->h);
pd = py + ph - (r->y + r->h); pd = py + ph - (r->y + r->h);
if ((d > 0) && (pd <= 0) && (d <= r->v1)) if ((d > 0) && (pd <= 0) && (d <= r->v1))
{ {
if (-resist_h < d) if (-resist_h < d)
resist_h = -d; resist_h = -d;
} }
} }
else else
{ {
/* check top edge of windows against bottom */ /* check top edge of windows against bottom */
d = r->y - (y + h); d = r->y - (y + h);
pd = r->y - (py + ph); pd = r->y - (py + ph);
if ((d < 0) && (pd >= 0) && (d >= -r->v1)) if ((d < 0) && (pd >= 0) && (d >= -r->v1))
{ {
if (resist_h > d) if (resist_h > d)
resist_h = d; resist_h = d;
} }
} }
} }
} }
} }
if (rx) if (rx)
{ {
if (dx != 0) if (dx != 0)
*rx = x + resist_x; *rx = x + resist_x;
else else
*rx = x; *rx = x;
} }
if (ry) if (ry)
{ {
if (dy != 0) if (dy != 0)
*ry = y + resist_y; *ry = y + resist_y;
else else
*ry = y; *ry = y;
} }
if (rw) if (rw)
{ {
if (dw != 0) if (dw != 0)
*rw = w + resist_w; *rw = w + resist_w;
else else
*rw = w; *rw = w;
} }
if (rh) if (rh)
{ {
if (dh != 0) if (dh != 0)
*rh = h + resist_h; *rh = h + resist_h;
else else
*rh = h; *rh = h;
} }
} }