summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2016-11-07 12:39:05 -0500
committerMike Blumenkrantz <zmike@osg.samsung.com>2016-11-18 11:44:41 -0500
commit5972d0369ab2722bcbc3d1aeee39eea9d8b7f00a (patch)
tree05947425b3fb4729d1d0a62746f47ae3f1e22e65
parent99a9312b520066aa88e0ce2a92ed95d9ee90448b (diff)
break out e_place_desk_region_smart() area calcs into separate function
no functional changes
-rw-r--r--src/bin/e_place.c187
1 files changed, 97 insertions, 90 deletions
diff --git a/src/bin/e_place.c b/src/bin/e_place.c
index 3a25bdcd6..112f3f9b4 100644
--- a/src/bin/e_place.c
+++ b/src/bin/e_place.c
@@ -209,6 +209,97 @@ _e_place_desk_region_smart_obstacle_add(char *u_x, char *u_y, int **a_x, int **a
209 } 209 }
210} 210}
211 211
212static int
213_e_place_desk_region_smart_area_calc(int x, int y, int xx, int yy, int zx, int zy, int zw, int zh, int w, int h, Eina_List *skiplist, E_Desk *desk, int area, int *rx, int *ry)
214{
215 if ((x <= MAX(zx, zx + (zw - w))) &&
216 (y <= MAX(zy, zy + (zh - h))))
217 {
218 int ar = 0;
219
220 ar = _e_place_coverage_client_add(skiplist, ar,
221 x, y,
222 w, h);
223
224 if (e_config->window_placement_policy == E_WINDOW_PLACEMENT_SMART)
225 ar = _e_place_coverage_zone_obstacles_add(desk, ar,
226 x, y,
227 w, h);
228
229 if (ar < area)
230 {
231 area = ar;
232 *rx = x;
233 *ry = y;
234 if (ar == 0) return ar;
235 }
236 }
237 if ((MAX(zx, xx - w) > zx) && (y <= MAX(zy, zy + (zh - h))))
238 {
239 int ar = 0;
240
241 ar = _e_place_coverage_client_add(skiplist, ar,
242 xx - w, y,
243 w, h);
244
245 if (e_config->window_placement_policy == E_WINDOW_PLACEMENT_SMART)
246 ar = _e_place_coverage_zone_obstacles_add(desk, ar,
247 xx - w, y,
248 w, h);
249
250 if (ar < area)
251 {
252 area = ar;
253 *rx = xx - w;
254 *ry = y;
255 if (ar == 0) return ar;
256 }
257 }
258 if ((MAX(zx, xx - w) > zx) && (MAX(zy, yy - h) > zy))
259 {
260 int ar = 0;
261
262 ar = _e_place_coverage_client_add(skiplist, ar,
263 xx - w, yy - h,
264 w, h);
265
266 if (e_config->window_placement_policy == E_WINDOW_PLACEMENT_SMART)
267 ar = _e_place_coverage_zone_obstacles_add(desk, ar,
268 xx - w, yy - h,
269 w, h);
270
271 if (ar < area)
272 {
273 area = ar;
274 *rx = xx - w;
275 *ry = yy - h;
276 if (ar == 0) return ar;
277 }
278 }
279 if ((x <= MAX(zx, zx + (zw - w))) && (MAX(zy, yy - h) > zy))
280 {
281 int ar = 0;
282
283 ar = _e_place_coverage_client_add(skiplist, ar,
284 x, yy - h,
285 w, h);
286
287 if (e_config->window_placement_policy == E_WINDOW_PLACEMENT_SMART)
288 ar = _e_place_coverage_zone_obstacles_add(desk, ar,
289 x, yy - h,
290 w, h);
291
292 if (ar < area)
293 {
294 area = ar;
295 *rx = x;
296 *ry = yy - h;
297 if (ar == 0) return ar;
298 }
299 }
300 return area;
301}
302
212E_API int 303E_API int
213e_place_desk_region_smart(E_Desk *desk, Eina_List *skiplist, int x, int y, int w, int h, int *rx, int *ry) 304e_place_desk_region_smart(E_Desk *desk, Eina_List *skiplist, int x, int y, int w, int h, int *rx, int *ry)
214{ 305{
@@ -336,96 +427,12 @@ e_place_desk_region_smart(E_Desk *desk, Eina_List *skiplist, int x, int y, int w
336 } 427 }
337 428
338 for (j = 0; j < a_h - 1; j++) 429 for (j = 0; j < a_h - 1; j++)
339 { 430 for (i = 0; i < a_w - 1; i++)
340 for (i = 0; i < a_w - 1; i++) 431 {
341 { 432 area = _e_place_desk_region_smart_area_calc(a_x[i], a_y[j], a_x[i + 1], a_y[j + 1],
342 if ((a_x[i] <= MAX(zx, zx + (zw - w))) && 433 zx, zy, zw, zh, w, h, skiplist, desk, area, rx, ry);
343 (a_y[j] <= MAX(zy, zy + (zh - h)))) 434 if (!area) goto done;
344 { 435 }
345 int ar = 0;
346
347 ar = _e_place_coverage_client_add(skiplist, ar,
348 a_x[i], a_y[j],
349 w, h);
350
351 if (e_config->window_placement_policy == E_WINDOW_PLACEMENT_SMART)
352 ar = _e_place_coverage_zone_obstacles_add(desk, ar,
353 a_x[i], a_y[j],
354 w, h);
355
356 if (ar < area)
357 {
358 area = ar;
359 *rx = a_x[i];
360 *ry = a_y[j];
361 if (ar == 0) goto done;
362 }
363 }
364 if ((MAX(zx, a_x[i + 1] - w) > zx) && (a_y[j] <= MAX(zy, zy + (zh - h))))
365 {
366 int ar = 0;
367
368 ar = _e_place_coverage_client_add(skiplist, ar,
369 a_x[i + 1] - w, a_y[j],
370 w, h);
371
372 if (e_config->window_placement_policy == E_WINDOW_PLACEMENT_SMART)
373 ar = _e_place_coverage_zone_obstacles_add(desk, ar,
374 a_x[i + 1] - w, a_y[j],
375 w, h);
376
377 if (ar < area)
378 {
379 area = ar;
380 *rx = a_x[i + 1] - w;
381 *ry = a_y[j];
382 if (ar == 0) goto done;
383 }
384 }
385 if ((MAX(zx, a_x[i + 1] - w) > zx) && (MAX(zy, a_y[j + 1] - h) > zy))
386 {
387 int ar = 0;
388
389 ar = _e_place_coverage_client_add(skiplist, ar,
390 a_x[i + 1] - w, a_y[j + 1] - h,
391 w, h);
392
393 if (e_config->window_placement_policy == E_WINDOW_PLACEMENT_SMART)
394 ar = _e_place_coverage_zone_obstacles_add(desk, ar,
395 a_x[i + 1] - w, a_y[j + 1] - h,
396 w, h);
397
398 if (ar < area)
399 {
400 area = ar;
401 *rx = a_x[i + 1] - w;
402 *ry = a_y[j + 1] - h;
403 if (ar == 0) goto done;
404 }
405 }
406 if ((a_x[i] <= MAX(zx, zx + (zw - w))) && (MAX(zy, a_y[j + 1] - h) > zy))
407 {
408 int ar = 0;
409
410 ar = _e_place_coverage_client_add(skiplist, ar,
411 a_x[i], a_y[j + 1] - h,
412 w, h);
413
414 if (e_config->window_placement_policy == E_WINDOW_PLACEMENT_SMART)
415 ar = _e_place_coverage_zone_obstacles_add(desk, ar,
416 a_x[i], a_y[j + 1] - h,
417 w, h);
418
419 if (ar < area)
420 {
421 area = ar;
422 *rx = a_x[i];
423 *ry = a_y[j + 1] - h;
424 if (ar == 0) goto done;
425 }
426 }
427 }
428 }
429 } 436 }
430done: 437done:
431 E_FREE(a_x); 438 E_FREE(a_x);