diff options
author | Carsten Haitzler <raster@rasterman.com> | 2005-01-20 13:42:51 +0000 |
---|---|---|
committer | Carsten Haitzler <raster@rasterman.com> | 2005-01-20 13:42:51 +0000 |
commit | 45ef78688ca6296166735cb01d433d4286ca8eec (patch) | |
tree | 51203a0e434e99e2946442b0d6ccc3349ee93e2e /src/bin/e_resist.c | |
parent | 08ef1688d6a8d9ef9dea7dc320e79dd73247414c (diff) | |
download | enlightenment-45ef78688ca6296166735cb01d433d4286ca8eec.tar.gz |
more gadman work... on the way there...
SVN revision: 13027
Diffstat (limited to 'src/bin/e_resist.c')
-rw-r--r-- | src/bin/e_resist.c | 207 |
1 files changed, 190 insertions, 17 deletions
diff --git a/src/bin/e_resist.c b/src/bin/e_resist.c index 91ae3a966b..c1b8e816d6 100644 --- a/src/bin/e_resist.c +++ b/src/bin/e_resist.c @@ -10,10 +10,10 @@ struct _E_Resist_Rect }; int -e_resist_container_position(E_Container *con, Evas_List *skiplist, - int px, int py, int pw, int ph, - int x, int y, int w, int h, - int *rx, int *ry) +e_resist_container_border_position(E_Container *con, Evas_List *skiplist, + int px, int py, int pw, int ph, + int x, int y, int w, int h, + int *rx, int *ry) { int resist = 1; int desk_resist = 32; @@ -34,9 +34,6 @@ e_resist_container_position(E_Container *con, Evas_List *skiplist, dx = x - px; dy = y - py; - /* FIXME: need to make resist obscales where it resists being moved OUT */ - /* of the box */ - /* edges of screen */ #define OBSTACLE(_x, _y, _w, _h, _resist) \ { \ @@ -52,16 +49,7 @@ e_resist_container_position(E_Container *con, Evas_List *skiplist, r->resist_out = 1; \ rects = evas_list_append(rects, r); \ } -#if 0 /* dont need this anymore */ - OBSTACLE(-1000000, -1000000, 2000000 + con->w, 1000000, - desk_resist); - OBSTACLE(-1000000, -1000000, 1000000, 2000000 + con->h, - desk_resist); - OBSTACLE(-1000000, con->h, 2000000 + con->w, 1000000, - desk_resist); - OBSTACLE(con->w, -1000000, 1000000, 2000000 + con->h, - desk_resist); -#endif + for (l = con->zones; l; l = l->next) { E_Zone *zone; @@ -237,3 +225,188 @@ e_resist_container_position(E_Container *con, Evas_List *skiplist, *ry = y; return 1; } + +int +e_resist_container_gadman_position(E_Container *con, Evas_List *skiplist, + int px, int py, int pw, int ph, + int x, int y, int w, int h, + int *rx, int *ry) +{ + int resist = 1; + int gad_resist = 4800; + int dx, dy, d, pd; + int resist_x = 0, resist_y = 0; + Evas_List *l, *ll, *rects = NULL; + E_Resist_Rect *r; + + /* FIXME: get resist values from config */ + if (!resist) + { + *rx = x; + *ry = y; + return 0; + } + + dx = x - px; + dy = y - py; + + for (l = con->gadman->clients; l; l = l->next) + { + E_Gadman_Client *gmc; + int ok; + + gmc = l->data; + ok = 1; + for (ll = skiplist; ll; ll = ll->next) + { + if (ll->data == gmc) + { + ok = 0; + break; + } + } + if (ok) + { + r = E_NEW(E_Resist_Rect, 1); + + r->x = gmc->x; + r->y = gmc->y; + r->w = gmc->w; + r->h = gmc->h; + r->v1 = gad_resist; + rects = evas_list_append(rects, r); + } + } + + for (l = rects; l; l = l->next) + { + r = l->data; + if (E_SPANS_COMMON(r->y, r->h, y, h)) + { + if (dx > 0) + { + /* moving right */ + if (r->resist_out) + { + /* check right edge of windows against left */ + d = x + w - (r->x + r->w); + pd = px + pw - (r->x + r->w); + if ((d > 0) && (pd <= 0) && (d <= r->v1)) + { + if (-resist_x < d) + resist_x = -d; + } + } + else + { + /* check left edge of windows against right */ + d = r->x - (x + w); + pd = r->x - (px + pw); + if ((d < 0) && (pd >= 0) && (d >= -r->v1)) + { + if (resist_x > d) + resist_x = d; + } + } + } + else if (dx < 0) + { + /* moving left */ + if (r->resist_out) + { + /* check left edge of windows against right */ + d = r->x - x; + pd = r->x - px; + if ((d > 0) && (pd <= 0) && (d <= r->v1)) + { + if (resist_x < d) + resist_x = d; + } + } + else + { + /* check right edge of windows against left */ + d = x - (r->x + r->w); + pd = px - (r->x + r->w); + if ((d < 0) && (pd >= 0) && (d >= -r->v1)) + { + if (-resist_x > d) + resist_x = -d; + } + } + } + } + if (E_SPANS_COMMON(r->x, r->w, x, w)) + { + if (dy > 0) + { + /* moving down */ + if (r->resist_out) + { + /* check bottom edge of windows against top */ + d = y + h - (r->y + r->h); + pd = py + ph - (r->y + r->h); + if ((d > 0) && (pd <= 0) && (d <= r->v1)) + { + if (-resist_y < d) + resist_y = -d; + } + } + else + { + /* check top edge of windows against bottom */ + d = r->y - (y + h); + pd = r->y - (py + ph); + if ((d < 0) && (pd >= 0) && (d >= -r->v1)) + { + if (resist_y > d) + resist_y = d; + } + } + } + else if (dy < 0) + { + /* moving up */ + if (r->resist_out) + { + /* check top edge of windows against bottom */ + d = r->y - y; + pd = r->y - py; + if ((d > 0) && (pd <= 0) && (d <= r->v1)) + { + if (resist_y < d) + resist_y = d; + } + } + else + { + /* moving up - check bottom edge of windows against top */ + d = y - (r->y + r->h); + pd = py - (r->y + r->h); + if ((d < 0) && (pd >= 0) && (d >= -r->v1)) + { + if (-resist_y > d) + resist_y = -d; + } + } + } + } + } + if (rects) + { + for (l = rects; l; l = l->next) + { + E_FREE(l->data); + } + evas_list_free(rects); + } + if (dx != 0) + *rx = x + resist_x; + else + *rx = x; + if (dy != 0) + *ry = y + resist_y; + else + *ry = y; + return 1; +} |