3 typedef struct _E_Resist_Rect E_Resist_Rect;
12 static void _e_resist_rects(Eina_List *rects, int px, int py, int pw, int ph, int x, int y, int w, int h, int *rx, int *ry, int *rw, int *rh);
15 e_resist_container_border_position(E_Container *con, Eina_List *skiplist,
16 int px, int py, int pw, int ph,
17 int x, int y, int w, int h,
18 int *rx, int *ry, int *rw, int *rh)
20 Eina_List *l, *ll, *rects = NULL;
28 if (!e_config->use_resist)
38 #define OBSTACLE(_x, _y, _w, _h, _resist) \
40 r = E_NEW(E_Resist_Rect, 1); \
41 r->x = _x; r->y = _y; r->w = _w; r->h = _h; r->v1 = _resist; \
43 rects = eina_list_append(rects, r); \
45 #define HOLDER(_x, _y, _w, _h, _resist) \
47 r = E_NEW(E_Resist_Rect, 1); \
48 r->x = _x; r->y = _y; r->w = _w; r->h = _h; r->v1 = _resist; \
50 rects = eina_list_append(rects, r); \
53 EINA_LIST_FOREACH(con->zones, l, zone)
55 HOLDER(zone->x, zone->y, zone->w, zone->h, e_config->desk_resist);
57 /* FIXME: need to add resist or complete BLOCKS for things like ibar */
58 /* can add code here to add more fake obstacles with custom resist values */
59 /* here if need be - ie xinerama middle between screens and panels etc. */
61 bl = e_container_border_list_first(con);
62 while ((bd = e_container_border_list_next(bl)))
69 EINA_LIST_FOREACH(skiplist, ll, bd2)
77 if (ok && bd->offer_resistance)
79 OBSTACLE(bd->x, bd->y, bd->w, bd->h, e_config->window_resist);
83 e_container_border_list_free(bl);
85 desk = e_desk_current_get(e_zone_current_get(con));
86 EINA_LIST_FOREACH(e_shelf_list(), l, es)
89 E_Config_Shelf_Desk *sd;
91 if (es->zone->container == con)
93 if (es->cfg->desk_show_mode)
95 EINA_LIST_FOREACH(es->cfg->desk_list, ll2, sd)
98 if ((sd->x == desk->x) && (sd->y == desk->y))
100 OBSTACLE(es->x + es->zone->x, es->y + es->zone->y, es->w, es->h,
101 e_config->gadget_resist);
108 OBSTACLE(es->x + es->zone->x, es->y + es->zone->y, es->w, es->h,
109 e_config->gadget_resist);
115 _e_resist_rects(rects,
120 E_FREE_LIST(rects, E_FREE);
126 e_resist_container_gadman_position(E_Container *con, Eina_List *skiplist __UNUSED__,
127 int px, int py, int pw, int ph,
128 int x, int y, int w, int h,
131 Eina_List *l, *rects = NULL;
135 if (!e_config->use_resist)
142 EINA_LIST_FOREACH(e_shelf_list(), l, es)
144 if (es->zone->container == con)
146 OBSTACLE(es->x + es->zone->x, es->y + es->zone->y, es->w, es->h,
147 e_config->gadget_resist);
153 _e_resist_rects(rects,
158 E_FREE_LIST(rects, E_FREE);
164 _e_resist_rects(Eina_List *rects,
165 int px, int py, int pw, int ph,
166 int x, int y, int w, int h,
167 int *rx, int *ry, int *rw, int *rh)
169 int dx, dy, dw, dh, d, pd;
170 int resist_x = 0, resist_y = 0;
171 int resist_w = 0, resist_h = 0;
175 #ifdef _F_USE_RESIST_MAGNETIC_EFFECT_
176 const int magnet_eff_margin = 30;
178 int magnet_gain_x = 0;
179 int magnet_gain_y = 0;
187 EINA_LIST_FOREACH(rects, l, r)
189 if (E_SPANS_COMMON(r->y, r->h, y, h))
191 #ifdef _F_USE_RESIST_MAGNETIC_EFFECT_
194 gap = (r->x + r->w) - (x + w);
195 if (gap >= 0 && gap <= magnet_eff_margin)
197 if (magnet_gain_x == 0 || magnet_gain_x > gap)
202 if (gap >= 0 && gap <= magnet_eff_margin)
204 if (magnet_gain_x == 0 || magnet_gain_x > gap)
205 magnet_gain_x = -gap;
210 gap = r->x - (x + w);
211 if (gap >= 0 && gap <= magnet_eff_margin)
213 if (magnet_gain_x == 0 || magnet_gain_x > gap)
217 gap = x - (r->x + r->w);
218 if (gap >= 0 && gap <= magnet_eff_margin)
220 if (magnet_gain_x == 0 || magnet_gain_x > gap)
221 magnet_gain_x = -gap;
230 /* check right edge of windows against left */
231 d = x + w - (r->x + r->w);
232 pd = px + pw - (r->x + r->w);
233 if ((d > 0) && (pd <= 0) && (d <= r->v1))
241 /* check left edge of windows against right */
243 pd = r->x - (px + pw);
244 if ((d < 0) && (pd >= 0) && (d >= -r->v1))
256 /* check left edge of windows against right */
259 if ((d > 0) && (pd <= 0) && (d <= r->v1))
270 /* check right edge of windows against left */
271 d = x - (r->x + r->w);
272 pd = px - (r->x + r->w);
273 if ((d < 0) && (pd >= 0) && (d >= -r->v1))
283 if ((dw > 0) && (dx == 0))
285 /* enlarging window by moving lower corner */
288 /* check right edge of windows against left */
289 d = x + w - (r->x + r->w);
290 pd = px + pw - (r->x + r->w);
291 if ((d > 0) && (pd <= 0) && (d <= r->v1))
299 /* check left edge of windows against right */
301 pd = r->x - (px + pw);
302 if ((d < 0) && (pd >= 0) && (d >= -r->v1))
310 if (E_SPANS_COMMON(r->x, r->w, x, w))
312 #ifdef _F_USE_RESIST_MAGNETIC_EFFECT_
315 gap = (r->y + r->h) - (y + h);
316 if (gap >= 0 && gap <= magnet_eff_margin)
318 if (magnet_gain_y == 0 || magnet_gain_y > gap)
323 if (gap >= 0 && gap <= magnet_eff_margin)
325 if (magnet_gain_y == 0 || magnet_gain_y > gap)
326 magnet_gain_y = -gap;
331 gap = r->y - (y + h);
332 if (gap >= 0 && gap <= magnet_eff_margin)
334 if (magnet_gain_y == 0 || magnet_gain_y > gap)
338 gap = y - (r->y + r->h);
339 if (gap >= 0 && gap <= magnet_eff_margin)
341 if (magnet_gain_y == 0 || magnet_gain_y >gap)
342 magnet_gain_y = -gap;
351 /* check bottom edge of windows against top */
352 d = y + h - (r->y + r->h);
353 pd = py + ph - (r->y + r->h);
354 if ((d > 0) && (pd <= 0) && (d <= r->v1))
362 /* check top edge of windows against bottom */
364 pd = r->y - (py + ph);
365 if ((d < 0) && (pd >= 0) && (d >= -r->v1))
377 /* check top edge of windows against bottom */
380 if ((d > 0) && (pd <= 0) && (d <= r->v1))
391 /* moving up - check bottom edge of windows against top */
392 d = y - (r->y + r->h);
393 pd = py - (r->y + r->h);
394 if ((d < 0) && (pd >= 0) && (d >= -r->v1))
404 if ((dh > 0) && (dy == 0))
406 /* enlarging window by moving lower corner */
409 /* check bottom edge of windows against top */
410 d = y + h - (r->y + r->h);
411 pd = py + ph - (r->y + r->h);
412 if ((d > 0) && (pd <= 0) && (d <= r->v1))
420 /* check top edge of windows against bottom */
422 pd = r->y - (py + ph);
423 if ((d < 0) && (pd >= 0) && (d >= -r->v1))
435 #ifdef _F_USE_RESIST_MAGNETIC_EFFECT_
436 *rx = x + (abs(resist_x) > abs(magnet_gain_x) ?
437 resist_x : magnet_gain_x);
447 #ifdef _F_USE_RESIST_MAGNETIC_EFFECT_
448 *ry = y + (abs(resist_y) > abs(magnet_gain_y) ?
449 resist_y : magnet_gain_y);