From 183472fb394e52efbf2832b241ad1bc8a4b2177a Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Sat, 21 Apr 2012 01:13:34 +0000 Subject: [PATCH] fix placement code to respect desktop given not current visible stuff, and add latent disabled feature to keep everythng on same screen/desk off for now until config added. SVN revision: 70370 --- src/bin/e_border.c | 52 +++++++++++++++++++++++++++++++++++++--- src/bin/e_place.c | 59 +++++++++++++++++++++++++++------------------- src/bin/e_place.h | 1 + 3 files changed, 85 insertions(+), 27 deletions(-) diff --git a/src/bin/e_border.c b/src/bin/e_border.c index 129bd242e..c1e45c82d 100644 --- a/src/bin/e_border.c +++ b/src/bin/e_border.c @@ -7321,6 +7321,47 @@ _e_border_eval0(E_Border *bd) if (zone) e_border_zone_set(bd, zone); desk = e_desk_at_xy_get(bd->zone, inst->desk_x, inst->desk_y); if (desk) e_border_desk_set(bd, desk); + printf("bd->placed = %i\n", bd->placed); + } + + if (0) // keep all windows of one app/group on the same screen/desk + { + E_Border *bdl = NULL; + + bdl = bd->parent; + if (!bdl) + { + if (bd->leader) bdl = bd->leader; + } + if (!bdl) + { + E_Border *child; + E_Border_List *bl; + + bl = e_container_border_list_first(bd->zone->container); + while ((child = e_container_border_list_next(bl))) + { + if (child == bd) continue; + if (e_object_is_del(E_OBJECT(child))) continue; + if ((bd->client.icccm.client_leader) && + (child->client.icccm.client_leader == + bd->client.icccm.client_leader)) + { + bdl = child; + break; + } + } + e_container_border_list_free(bl); + } + if (bdl) + { + if (bdl->zone) + e_border_zone_set(bd, bdl->zone); + if (bdl->desk) + e_border_desk_set(bd, bdl->desk); + else + e_border_stick(bd); + } } } @@ -7722,9 +7763,14 @@ _e_border_eval(E_Border *bd) if ((e_config->window_placement_policy == E_WINDOW_PLACEMENT_SMART) || (e_config->window_placement_policy == E_WINDOW_PLACEMENT_ANTIGADGET)) { skiplist = eina_list_append(skiplist, bd); - e_place_zone_region_smart(bd->zone, skiplist, - bd->x, bd->y, bd->w, bd->h, - &new_x, &new_y); + if (bd->desk) + e_place_desk_region_smart(bd->desk, skiplist, + bd->x, bd->y, bd->w, bd->h, + &new_x, &new_y); + else + e_place_zone_region_smart(bd->zone, skiplist, + bd->x, bd->y, bd->w, bd->h, + &new_x, &new_y); eina_list_free(skiplist); } else if (e_config->window_placement_policy == E_WINDOW_PLACEMENT_MANUAL) diff --git a/src/bin/e_place.c b/src/bin/e_place.c index f0ab0ddb0..d23ab9a7d 100644 --- a/src/bin/e_place.c +++ b/src/bin/e_place.c @@ -59,7 +59,7 @@ _e_place_cb_sort_cmp(const void *v1, const void *v2) } static int -_e_place_coverage_border_add(E_Zone *zone, Eina_List *skiplist, int ar, int x, int y, int w, int h) +_e_place_coverage_border_add(E_Desk *desk, Eina_List *skiplist, int ar, int x, int y, int w, int h) { Eina_List *ll; E_Border_List *bl; @@ -69,11 +69,11 @@ _e_place_coverage_border_add(E_Zone *zone, Eina_List *skiplist, int ar, int x, i int iw, ih; int x0, x00, y0, y00; - bl = e_container_border_list_first(zone->container); + bl = e_container_border_list_first(desk->zone->container); while ((bd = e_container_border_list_next(bl))) { ok = 1; - x2 = (bd->x - zone->x); y2 = (bd->y - zone->y); w2 = bd->w; h2 = bd->h; + x2 = (bd->x - desk->zone->x); y2 = (bd->y - desk->zone->y); w2 = bd->w; h2 = bd->h; EINA_LIST_FOREACH(skiplist, ll, bd2) { if (bd2 == bd) @@ -82,7 +82,9 @@ _e_place_coverage_border_add(E_Zone *zone, Eina_List *skiplist, int ar, int x, i break; } } - if ((ok) && (bd->visible) && E_INTERSECTS(x, y, w, h, x2, y2, w2, h2)) + if ((ok) && + E_INTERSECTS(x, y, w, h, x2, y2, w2, h2) && + ((bd->sticky) || (bd->desk == desk))) { x0 = x; if (x < x2) x0 = x2; @@ -135,7 +137,7 @@ _e_place_coverage_shelf_add(E_Zone *zone, int ar, int x, int y, int w, int h) } EAPI int -e_place_zone_region_smart(E_Zone *zone, Eina_List *skiplist, int x, int y, int w, int h, int *rx, int *ry) +e_place_desk_region_smart(E_Desk *desk, Eina_List *skiplist, int x, int y, int w, int h, int *rx, int *ry) { int a_w = 0, a_h = 0, a_alloc_w = 0, a_alloc_h = 0; int *a_x = NULL, *a_y = NULL; @@ -166,8 +168,8 @@ e_place_zone_region_smart(E_Zone *zone, Eina_List *skiplist, int x, int y, int w a_alloc_w = 2; a_alloc_h = 2; - zw = zone->w; - zh = zone->h; + zw = desk->zone->w; + zh = desk->zone->h; u_x = calloc(zw + 1, sizeof(char)); u_y = calloc(zh + 1, sizeof(char)); @@ -191,7 +193,7 @@ e_place_zone_region_smart(E_Zone *zone, Eina_List *skiplist, int x, int y, int w { int bx, by, bw, bh; - if (es->zone != zone) continue; + if (es->zone != desk->zone) continue; bx = es->x; by = es->y; @@ -260,7 +262,7 @@ e_place_zone_region_smart(E_Zone *zone, Eina_List *skiplist, int x, int y, int w } } - bl = e_container_border_list_first(zone->container); + bl = e_container_border_list_first(desk->zone->container); while ((bd = e_container_border_list_next(bl))) { int ok; @@ -275,10 +277,12 @@ e_place_zone_region_smart(E_Zone *zone, Eina_List *skiplist, int x, int y, int w break; } } - if ((!ok) || (!bd->visible)) continue; + if (!ok) continue; - bx = bd->x - zone->x; - by = bd->y - zone->y; + if (!((bd->sticky) || (bd->desk == desk))) continue; + + bx = bd->x - desk->zone->x; + by = bd->y - desk->zone->y; bw = bd->w; bh = bd->h; @@ -363,11 +367,11 @@ e_place_zone_region_smart(E_Zone *zone, Eina_List *skiplist, int x, int y, int w { int ar = 0; - ar = _e_place_coverage_border_add(zone, skiplist, ar, + ar = _e_place_coverage_border_add(desk, skiplist, ar, a_x[i], a_y[j], w, h); if (e_config->window_placement_policy == E_WINDOW_PLACEMENT_SMART) - ar = _e_place_coverage_shelf_add(zone, ar, + ar = _e_place_coverage_shelf_add(desk->zone, ar, a_x[i], a_y[j], w, h); if (ar < area) @@ -382,11 +386,11 @@ e_place_zone_region_smart(E_Zone *zone, Eina_List *skiplist, int x, int y, int w { int ar = 0; - ar = _e_place_coverage_border_add(zone, skiplist, ar, + ar = _e_place_coverage_border_add(desk, skiplist, ar, a_x[i + 1] - w, a_y[j], w, h); if (e_config->window_placement_policy == E_WINDOW_PLACEMENT_SMART) - ar = _e_place_coverage_shelf_add(zone, ar, + ar = _e_place_coverage_shelf_add(desk->zone, ar, a_x[i + 1] - w, a_y[j], w, h); if (ar < area) @@ -401,11 +405,11 @@ e_place_zone_region_smart(E_Zone *zone, Eina_List *skiplist, int x, int y, int w { int ar = 0; - ar = _e_place_coverage_border_add(zone, skiplist, ar, + ar = _e_place_coverage_border_add(desk, skiplist, ar, a_x[i + 1] - w, a_y[j + 1] - h, w, h); if (e_config->window_placement_policy == E_WINDOW_PLACEMENT_SMART) - ar = _e_place_coverage_shelf_add(zone, ar, + ar = _e_place_coverage_shelf_add(desk->zone, ar, a_x[i + 1] - w, a_y[j + 1] - h, w, h); if (ar < area) @@ -420,11 +424,11 @@ e_place_zone_region_smart(E_Zone *zone, Eina_List *skiplist, int x, int y, int w { int ar = 0; - ar = _e_place_coverage_border_add(zone, skiplist, ar, + ar = _e_place_coverage_border_add(desk, skiplist, ar, a_x[i], a_y[j + 1] - h, w, h); if (e_config->window_placement_policy == E_WINDOW_PLACEMENT_SMART) - ar = _e_place_coverage_shelf_add(zone, ar, + ar = _e_place_coverage_shelf_add(desk->zone, ar, a_x[i], a_y[j + 1] - h, w, h); if (ar < area) @@ -442,18 +446,25 @@ e_place_zone_region_smart(E_Zone *zone, Eina_List *skiplist, int x, int y, int w E_FREE(a_x); E_FREE(a_y); - if ((*rx + w) > zone->w) *rx = zone->w - w; + if ((*rx + w) > desk->zone->w) *rx = desk->zone->w - w; if (*rx < 0) *rx = 0; - if ((*ry + h) > zone->h) *ry = zone->h - h; + if ((*ry + h) > desk->zone->h) *ry = desk->zone->h - h; if (*ry < 0) *ry = 0; // printf("0 - PLACE %i %i | %ix%i\n", *rx, *ry, w, h); - *rx += zone->x; - *ry += zone->y; + *rx += desk->zone->x; + *ry += desk->zone->y; return 1; } +EAPI int +e_place_zone_region_smart(E_Zone *zone, Eina_List *skiplist, int x, int y, int w, int h, int *rx, int *ry) +{ + return e_place_desk_region_smart(e_desk_current_get(zone), skiplist, + x, y, w, h, rx, ry); +} + EAPI int e_place_zone_cursor(E_Zone *zone, int x __UNUSED__, int y __UNUSED__, int w, int h, int it, int *rx, int *ry) { diff --git a/src/bin/e_place.h b/src/bin/e_place.h index b7e35e6b5..f6b6a8402 100644 --- a/src/bin/e_place.h +++ b/src/bin/e_place.h @@ -5,6 +5,7 @@ EAPI void e_place_zone_region_smart_cleanup(E_Zone *zone); EAPI int e_place_zone_region_smart(E_Zone *zone, Eina_List *skiplist, int x, int y, int w, int h, int *rx, int *ry); +EAPI int e_place_desk_region_smart(E_Desk *desk, Eina_List *skiplist, int x, int y, int w, int h, int *rx, int *ry); EAPI int e_place_zone_cursor(E_Zone *zone, int x, int y, int w, int h, int it, int *rx, int *ry); EAPI int e_place_zone_manual(E_Zone *zone, int w, int h, int *rx, int *ry);