Remove e_mod_border (dead file).

Rework layout code for all modes:
       - Better layout code for dual modes.
       - Don't set focus if the border is already focused.
       - No need to call the 'back' method on border_delete.
       - Don't call focus_latest_set on border_focus_in.
         (not needed as it turns out).
Cleanup e_illume_border.c: 
        - Free lists when done with them.
        - Check zones are valid.
        - Reduce variable usage.



SVN revision: 45503
This commit is contained in:
Christopher Michael 2010-01-23 21:31:06 +00:00
parent 10fb34ad03
commit f92311b2a9
3 changed files with 67 additions and 570 deletions

View File

@ -197,7 +197,6 @@ e_illume_border_valid_borders_get(E_Zone *zone)
if (!(bds = e_border_client_list())) return NULL;
EINA_LIST_FOREACH(bds, l, bd)
{
if (!bd) continue;
if (bd->zone != zone) continue;
if (!e_illume_border_is_valid(bd)) continue;
ret = eina_list_append(ret, bd);
@ -214,7 +213,6 @@ e_illume_border_valid_border_get(E_Zone *zone)
if (!(bds = e_border_client_list())) return NULL;
EINA_LIST_FOREACH(bds, l, bd)
{
if (!bd) continue;
if (bd->zone != zone) continue;
if (!e_illume_border_is_valid(bd)) continue;
return bd;
@ -230,7 +228,7 @@ e_illume_border_valid_count_get(E_Zone *zone)
if (!(l = e_illume_border_valid_borders_get(zone))) return 0;
count = eina_list_count(l);
eina_list_free(l);
l = eina_list_free(l);
return count;
}
@ -243,7 +241,6 @@ e_illume_border_quickpanel_borders_get(E_Zone *zone)
if (!(bds = e_border_client_list())) return NULL;
EINA_LIST_FOREACH(bds, l, bd)
{
if (!bd) continue;
if (bd->zone != zone) continue;
if (!e_illume_border_is_quickpanel(bd)) continue;
ret = eina_list_append(ret, bd);
@ -259,7 +256,7 @@ e_illume_border_quickpanel_count_get(E_Zone *zone)
if (!(l = e_illume_border_quickpanel_borders_get(zone))) return 0;
count = eina_list_count(l);
eina_list_free(l);
l = eina_list_free(l);
return count;
}
@ -267,20 +264,16 @@ EAPI E_Border *
e_illume_border_at_xy_get(E_Zone *zone, int x, int y)
{
Eina_List *bds, *l;
E_Border *bd, *b = NULL;
E_Border *bd;
if (!(bds = e_illume_border_valid_borders_get(zone))) return NULL;
EINA_LIST_FOREACH(bds, l, bd)
if (!(bds = e_border_client_list())) return NULL;
EINA_LIST_REVERSE_FOREACH(bds, l, bd)
{
if (((bd->fx.x == x) && (bd->fx.y == y)) ||
((bd->x == x) && (bd->y == y)))
{
b = bd;
break;
}
if (bd->zone != zone) continue;
if (!e_illume_border_is_valid(bd)) continue;
if ((bd->x == x) && (bd->y == y)) return bd;
}
eina_list_free(bds);
return b;
return NULL;
}
EAPI E_Border *
@ -292,13 +285,14 @@ e_illume_border_in_region_get(E_Zone *zone, int x, int y, int w, int h)
if (!(bds = e_illume_border_valid_borders_get(zone))) return NULL;
EINA_LIST_FOREACH(bds, l, bd)
{
if (bd->zone != zone) continue;
if (E_INSIDE(bd->x, bd->fx.y, x, y, w, h))
{
b = bd;
break;
}
}
eina_list_free(bds);
bds = eina_list_free(bds);
return b;
}

View File

@ -1,476 +0,0 @@
#include "E_Illume.h"
#include "e_kbd.h"
//////////////////////////////////////////////////////////////////////////////
// :: Convenience routines to make it easy to write layout logic code ::
// activate a window - meant for main app and home app windows
void
e_illume_border_activate(E_Border *bd)
{
e_desk_show(bd->desk);
e_border_uniconify(bd);
e_border_raise(bd);
e_border_show(bd);
e_border_focus_set(bd, 1, 1);
}
// activate a window that isnt meant to get the focus - like panels, kbd etc.
void
e_illume_border_show(E_Border *bd)
{
e_desk_show(bd->desk);
e_border_uniconify(bd);
e_border_raise(bd);
e_border_show(bd);
}
// get a window away from being visile (but maintain it)
void
e_illume_border_deactivate(E_Border *bd)
{
e_border_iconify(bd);
}
// get window info - is this one a dialog?
EAPI int
e_illume_border_is_dialog(E_Border *bd)
{
int isdialog = 0, i;
if (bd->client.icccm.transient_for != 0) isdialog = 1;
if (bd->client.netwm.type == ECORE_X_WINDOW_TYPE_DIALOG)
{
isdialog = 1;
if (bd->client.netwm.extra_types)
{
for (i = 0; i < bd->client.netwm.extra_types_num; i++)
{
if (bd->client.netwm.extra_types[i] ==
ECORE_X_WINDOW_TYPE_UNKNOWN) continue;
if ((bd->client.netwm.extra_types[i] !=
ECORE_X_WINDOW_TYPE_DIALOG) &&
(bd->client.netwm.extra_types[i] !=
ECORE_X_WINDOW_TYPE_SPLASH))
{
return 0;
}
}
}
}
return isdialog;
}
// get window info - is this a vkbd window
EAPI int
e_illume_border_is_keyboard(E_Border *bd)
{
if (bd->client.vkbd.vkbd) return 1;
if (il_cfg->policy.vkbd.match.title)
{
if ((bd->client.icccm.title) &&
(!strcmp(bd->client.icccm.title, il_cfg->policy.vkbd.title)))
return 1;
}
if (il_cfg->policy.vkbd.match.name)
{
if ((bd->client.icccm.name) &&
(!strcmp(bd->client.icccm.name, il_cfg->policy.vkbd.name)))
return 1;
}
if (il_cfg->policy.vkbd.match.class)
{
if ((bd->client.icccm.class) &&
(!strcmp(bd->client.icccm.class, il_cfg->policy.vkbd.class)))
return 1;
}
if ((bd->client.icccm.name) &&
((!strcmp(bd->client.icccm.name, "multitap-pad")))
&& (bd->client.netwm.state.skip_taskbar)
&& (bd->client.netwm.state.skip_pager))
return 1;
return 0;
}
// get window info - is it a bottom app panel window (eg qtopia softmenu)
EAPI int
e_illume_border_is_bottom_panel(E_Border *bd)
{
if (il_cfg->policy.softkey.match.title)
{
if ((bd->client.icccm.title) &&
(!strcmp(bd->client.icccm.title, il_cfg->policy.softkey.title)))
return 1;
}
if (il_cfg->policy.softkey.match.name)
{
if ((bd->client.icccm.name) &&
(!strcmp(bd->client.icccm.name, il_cfg->policy.softkey.name)))
return 1;
}
if (il_cfg->policy.softkey.match.class)
{
if ((bd->client.icccm.class) &&
(!strcmp(bd->client.icccm.class, il_cfg->policy.softkey.class)))
return 1;
}
if (((bd->client.netwm.type == ECORE_X_WINDOW_TYPE_DOCK) ||
(bd->client.qtopia.soft_menu)))
return 1;
return 0;
}
// get window info - is it a top shelf window
EAPI int
e_illume_border_is_top_shelf(E_Border *bd)
{
if (il_cfg->policy.indicator.match.title)
{
if ((bd->client.icccm.title) &&
(!strcmp(bd->client.icccm.title, il_cfg->policy.indicator.title)))
return 1;
}
if (il_cfg->policy.indicator.match.name)
{
if ((bd->client.icccm.name) &&
(!strcmp(bd->client.icccm.name, il_cfg->policy.indicator.name)))
return 1;
}
if (il_cfg->policy.indicator.match.class)
{
if ((bd->client.icccm.class) &&
(!strcmp(bd->client.icccm.class, il_cfg->policy.indicator.class)))
return 1;
}
return 0;
}
// get window info - is it a home window
EAPI int
e_illume_border_is_home(E_Border *bd)
{
if (il_cfg->policy.home.match.title)
{
if ((bd->client.icccm.title) &&
(!strcmp(bd->client.icccm.title, il_cfg->policy.home.title)))
return 1;
}
if (il_cfg->policy.home.match.name)
{
if ((bd->client.icccm.name) &&
(!strcmp(bd->client.icccm.name, il_cfg->policy.home.name)))
return 1;
}
if (il_cfg->policy.home.match.class)
{
if ((bd->client.icccm.class) &&
(!strcmp(bd->client.icccm.class, il_cfg->policy.home.class)))
return 1;
}
return 0;
}
EAPI int
e_illume_border_is_conformant(E_Border *bd)
{
if ((bd->client.icccm.class) &&
(strstr(bd->client.icccm.class, "config"))) return EINA_FALSE;
return bd->client.illume.conformant.conformant;
}
EAPI int
e_illume_border_is_quickpanel(E_Border *bd)
{
if ((bd->client.icccm.class) &&
(strstr(bd->client.icccm.class, "config"))) return EINA_FALSE;
return bd->client.illume.quickpanel.quickpanel;
// return ecore_x_e_illume_quickpanel_get(bd->client.win);
}
EAPI int
e_illume_border_is_valid(E_Border *bd)
{
if (!bd) return EINA_FALSE;
if (e_illume_border_is_dialog(bd)) return EINA_FALSE;
if (e_illume_border_is_keyboard(bd)) return EINA_FALSE;
if (e_illume_border_is_bottom_panel(bd)) return EINA_FALSE;
if (e_illume_border_is_top_shelf(bd)) return EINA_FALSE;
if (e_illume_border_is_quickpanel(bd)) return EINA_FALSE;
return EINA_TRUE;
}
EAPI Eina_List *
e_illume_border_valid_borders_get(E_Zone *zone)
{
Eina_List *bds, *l, *ret = NULL;
E_Border *bd;
bds = e_border_client_list();
EINA_LIST_FOREACH(bds, l, bd)
{
if (!bd) continue;
if (bd->zone != zone) continue;
if (e_illume_border_is_top_shelf(bd)) continue;
if (e_illume_border_is_bottom_panel(bd)) continue;
if (e_illume_border_is_keyboard(bd)) continue;
if (e_illume_border_is_dialog(bd)) continue;
if (e_illume_border_is_quickpanel(bd)) continue;
ret = eina_list_append(ret, bd);
}
return ret;
}
EAPI E_Border *
e_illume_border_valid_border_get(E_Zone *zone)
{
Eina_List *bds, *l;
E_Border *bd, *ret = NULL;
bds = e_border_client_list();
EINA_LIST_FOREACH(bds, l, bd)
{
if (!bd) continue;
if (bd->zone != zone) continue;
if (e_illume_border_is_top_shelf(bd)) continue;
if (e_illume_border_is_bottom_panel(bd)) continue;
if (e_illume_border_is_keyboard(bd)) continue;
if (e_illume_border_is_dialog(bd)) continue;
if (e_illume_border_is_quickpanel(bd)) continue;
ret = bd;
break;
}
return ret;
}
EAPI int
e_illume_border_valid_count_get(E_Zone *zone)
{
Eina_List *l;
int count;
l = e_illume_border_valid_borders_get(zone);
count = eina_list_count(l);
eina_list_free(l);
return count;
}
EAPI Eina_List *
e_illume_border_quickpanel_borders_get(E_Zone *zone)
{
Eina_List *bds, *l, *ret = NULL;
E_Border *bd;
bds = e_border_client_list();
EINA_LIST_FOREACH(bds, l, bd)
{
if (!bd) continue;
if (bd->zone != zone) continue;
if (!e_illume_border_is_quickpanel(bd)) continue;
ret = eina_list_append(ret, bd);
}
return ret;
}
EAPI int
e_illume_border_quickpanel_count_get(E_Zone *zone)
{
Eina_List *l;
int count;
l = e_illume_border_quickpanel_borders_get(zone);
count = eina_list_count(l);
eina_list_free(l);
return count;
}
EAPI E_Border *
e_illume_border_at_xy_get(E_Zone *zone, int x, int y)
{
Eina_List *bds, *l;
E_Border *bd, *b = NULL;
bds = e_illume_border_valid_borders_get(zone);
EINA_LIST_FOREACH(bds, l, bd)
{
if (((bd->fx.x == x) && (bd->fx.y == y)) ||
((bd->x == x) && (bd->y == y)))
{
b = bd;
break;
}
}
eina_list_free(bds);
return b;
}
EAPI E_Border *
e_illume_border_in_region_get(E_Zone *zone, int x, int y, int w, int h)
{
Eina_List *bds, *l;
E_Border *bd, *b = NULL;
bds = e_illume_border_valid_borders_get(zone);
EINA_LIST_FOREACH(bds, l, bd)
{
if (E_INSIDE(bd->x, bd->fx.y, x, y, w, h))
{
b = bd;
break;
}
}
eina_list_free(bds);
return b;
}
EAPI E_Border *
e_illume_border_top_shelf_get(E_Zone *zone)
{
Eina_List *bds, *l;
E_Border *bd, *b = NULL;
bds = e_border_client_list();
EINA_LIST_FOREACH(bds, l, bd)
{
if (bd->zone != zone) continue;
if (!e_illume_border_is_top_shelf(bd)) continue;
b = bd;
break;
}
return b;
}
EAPI E_Border *
e_illume_border_bottom_panel_get(E_Zone *zone)
{
Eina_List *bds, *l;
E_Border *bd, *b = NULL;
bds = e_border_client_list();
EINA_LIST_FOREACH(bds, l, bd)
{
if (bd->zone != zone) continue;
if (!e_illume_border_is_bottom_panel(bd)) continue;
b = bd;
break;
}
return b;
}
EAPI void
e_illume_border_top_shelf_pos_get(E_Zone *zone, int *x, int *y)
{
E_Border *bd;
if (!(bd = e_illume_border_top_shelf_get(zone))) return;
if (x) *x = bd->x;
if (y) *y = bd->y;
}
EAPI void
e_illume_border_top_shelf_size_get(E_Zone *zone, int *w, int *h)
{
E_Border *bd;
if (!(bd = e_illume_border_top_shelf_get(zone))) return;
if (w) *w = bd->w;
if (h) *h = bd->h;
}
EAPI void
e_illume_border_bottom_panel_pos_get(E_Zone *zone, int *x, int *y)
{
E_Border *bd;
if (!(bd = e_illume_border_bottom_panel_get(zone))) return;
if (x) *x = bd->x;
if (y) *y = bd->y;
}
EAPI void
e_illume_border_bottom_panel_size_get(E_Zone *zone, int *w, int *h)
{
E_Border *bd;
if (!(bd = e_illume_border_bottom_panel_get(zone))) return;
if (w) *w = bd->w;
if (h) *h = bd->h;
}
EAPI void
e_illume_border_slide_to(E_Border *bd, int x, int y, E_Illume_Animation_Class aclass)
{
// FIXME: do
// 1. if an existing slide exists, use is current offset x,y as current border pos, new x,y as new pos and start slide again
}
EAPI void
e_illume_border_min_get(E_Border *bd, int *mw, int *mh)
{
if (mw)
{
if (bd->client.icccm.base_w > bd->client.icccm.min_w)
*mw = bd->client.icccm.base_w;
else
*mw = bd->client.icccm.min_w;
}
if (mh)
{
if (bd->client.icccm.base_h > bd->client.icccm.min_h)
*mh = bd->client.icccm.base_h;
else
*mh = bd->client.icccm.min_h;
}
}
EAPI void
e_illume_border_max_get(E_Border *bd, int *mw, int *mh)
{
if (mw)
{
if (bd->client.icccm.base_w > bd->client.icccm.max_w)
*mw = bd->client.icccm.base_w;
else
*mw = bd->client.icccm.max_w;
}
if (mh)
{
if (bd->client.icccm.base_h > bd->client.icccm.max_h)
*mh = bd->client.icccm.base_h;
else
*mh = bd->client.icccm.max_h;
}
}
EAPI void
e_illume_border_app1_safe_region_get(E_Zone *zone, int *x, int *y, int *w, int *h)
{
int ty, nx, ny, nw, nh;
if (!zone) return;
e_illume_kbd_safe_app_region_get(zone, &nx, &ny, &nw, &nh);
e_illume_border_top_shelf_pos_get(zone, NULL, &ty);
if (nh >= zone->h) nh = (ny + ty);
if (x) *x = nx;
if (y) *y = ny;
if (w) *w = nw;
if (h) *h = nh;
}
EAPI void
e_illume_border_app2_safe_region_get(E_Zone *zone, int *x, int *y, int *w, int *h)
{
int ty, th, bh;
int nx, ny, nw, nh;
if (!zone) return;
e_illume_kbd_safe_app_region_get(zone, &nx, NULL, &nw, &nh);
e_illume_border_top_shelf_pos_get(zone, NULL, &ty);
e_illume_border_top_shelf_size_get(zone, NULL, &th);
e_illume_border_bottom_panel_size_get(zone, NULL, &bh);
ny = (ty + th);
nh = (nh - ny - bh);
if (x) *x = nx;
if (y) *y = ny;
if (w) *w = nw;
if (h) *h = nh;
}

View File

@ -36,7 +36,7 @@ _layout_border_add(E_Border *bd)
bd->lock_user_stacking = 1;
}
if ((bd->client.icccm.accepts_focus) && (bd->client.icccm.take_focus)
&& (!bd->lock_focus_out))
&& (!bd->lock_focus_out) && (!bd->focused))
e_border_focus_set(bd, 1, 1);
}
@ -51,14 +51,12 @@ _layout_border_del(E_Border *bd)
b = e_illume_border_top_shelf_get(bd->zone);
if (b) e_border_show(b);
}
ecore_x_e_illume_back_send(bd->zone->black_win);
}
void
_layout_border_focus_in(E_Border *bd)
{
/* Do something if focus enters a window */
e_border_focus_latest_set(bd);
}
void
@ -178,7 +176,6 @@ _layout_zone_layout(E_Zone *zone)
(bd->y != (zone->y + zone->h - kbdsize)))
_zone_layout_border_move(bd, zone->x,
(zone->y + zone->h - kbdsize));
// e_border_stick(bd);
if (bd->layer != IL_KEYBOARD_LAYER)
e_border_layer_set(bd, IL_KEYBOARD_LAYER);
}
@ -326,59 +323,50 @@ _zone_layout_dual_top(E_Border *bd)
else
{
E_Border *b;
int bx, by, bw, bh;
int by, bh;
/* more than one valid border */
bx = kx;
by = (ky + ss);
bw = kw;
bh = (kh - ss - ps);
bh = ((kh - ss - ps) / 2);
/* grab the border at this location */
b = e_illume_border_at_xy_get(bd->zone, kx, shelfsize);
b = e_illume_border_at_xy_get(bd->zone, kx, by);
if ((b) && (bd != b))
{
/* we have a border there, and it's not the current one */
if (!e_illume_border_is_conformant(b))
if (e_illume_border_is_home(b))
{
/* border in this location is not conformant */
bh = ((kh - ss - ps) / 2);
by = (b->y + b->h); // b->fx.y
if (e_illume_border_is_home(bd))
by = (b->y + b->h);
}
else if (!e_illume_border_is_conformant(b))
by = (b->y + b->h);
else
{
if (conform)
{
/* current border is conformant, divide zone in half */
bh = ((bd->zone->h - ss) / 2);
by = by + bh;
}
else
{
/* current border is not conformant */
by = (b->y + b->h);
bh = (kh - by - ps);
}
}
}
else if (b)
{
/* border at this location and it's the current border */
by = bd->y;
bh = ((kh - ss - ps) / 2);
}
by = bd->y;
else
{
/* no border at this location */
b = e_illume_border_valid_border_get(bd->zone);
by = ky + ss;
bh = (ky - b->h);
}
if ((bd->w != bw) || (bd->h != bh))
_zone_layout_border_resize(bd, bw, bh);
if ((bd->x != bx) || (bd->y != by))
_zone_layout_border_move(bd, bx, by);
if ((bd->w != kw) || (bd->h != bh))
_zone_layout_border_resize(bd, kw, bh);
if ((bd->x != kx) || (bd->y != by))
_zone_layout_border_move(bd, kx, by);
}
}
@ -386,16 +374,9 @@ static void
_zone_layout_dual_top_custom(E_Border *bd)
{
int kx, kw;
int count, conform;
int ax, ay, aw, ah;
int zx, zy, zw, zh;
/* get count of valid borders */
count = e_illume_border_valid_count_get(bd->zone);
/* fetch if this border is conformant */
conform = e_illume_border_is_conformant(bd);
/* grab the 'safe' region. Safe region is space not occupied by keyboard */
e_illume_kbd_safe_app_region_get(bd->zone, &kx, NULL, &kw, NULL);
@ -403,7 +384,7 @@ _zone_layout_dual_top_custom(E_Border *bd)
e_illume_border_app2_safe_region_get(bd->zone, &zx, &zy, &zw, &zh);
/* if there are no other borders, than give this one all available space */
if (count < 2)
if (e_illume_border_valid_count_get(bd->zone) < 2)
{
if (ah >= zh)
{
@ -419,71 +400,71 @@ _zone_layout_dual_top_custom(E_Border *bd)
}
else
{
E_Border *bt, *bb;
int bh, by;
/* more than one valid border */
bh = ah;
by = ay;
if (bd->client.vkbd.state == ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF)
if (bd->client.vkbd.state <= ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF)
{
bh = ah;
by = ay;
}
else
{
/* grab the border at this location */
E_Border *bt;
/* grab the border at the top */
bt = e_illume_border_at_xy_get(bd->zone, kx, ay);
if ((bt) && (bd != bt))
if ((bt) && (bd != bt))
{
/* is there a border in the bottom section */
E_Border *bb;
/* have border @ top, check for border @ bottom */
bb = e_illume_border_at_xy_get(bd->zone, kx, zy);
if (!bb)
if ((bb) && (bd != bb))
{
bh = zh;
by = zy;
}
else if ((bb) && (bd != bb))
{
if (bt == e_border_focused_get())
/* have border @ top & bottom; neither is current */
/* if top border is !home, check bottom */
if (!e_illume_border_is_home(bt))
{
if (bd->client.vkbd.state == ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF)
if (e_illume_border_is_home(bb))
{
bh = zh;
by = zy;
}
else
{
/* potential hole */
bh = ah;
by = ay;
}
}
else if (bb = e_border_focused_get())
else
{
if (bd->client.vkbd.state == ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF)
{
bh = ah;
by = ay;
}
else
{
bh = zh;
by = zy;
}
bh = ah;
by = ay;
}
}
else if (bb)
{
bh = zh;
by = bd->y;
}
else
{
bh = zh;
by = zy;
}
}
else if (bt)
{
bh = ah;
by = bd->y;
}
else
{
bh = ah;
by = ay;
}
}
if ((bd->w != kw) || (bd->h != bh))
_zone_layout_border_resize(bd, kw, bh);
if ((bd->x != kx) || (bd->y != by))
@ -529,19 +510,21 @@ _zone_layout_dual_left(E_Border *bd)
/* more than one valid border */
bx = kx;
by = (ky + ss);
bw = kw;
bw = (kw / 2);
bh = (kh - ss - ps);
/* grab the border at this location */
b = e_illume_border_at_xy_get(bd->zone, kx, shelfsize);
b = e_illume_border_at_xy_get(bd->zone, kx, by);
if ((b) && (bd != b))
{
/* we have a border there, and it's not the current one */
if (!e_illume_border_is_conformant(b))
if (e_illume_border_is_home(b))
{
if (e_illume_border_is_home(bd))
bx = (b->x + b->w);
}
else if (!e_illume_border_is_conformant(b))
{
/* border in this location is not conformant */
bw = (kw / 2);
bx = (b->x + b->w);
}
else
@ -562,11 +545,7 @@ _zone_layout_dual_left(E_Border *bd)
}
}
else if (b)
{
/* border at this location and it's the current border */
bx = bd->x;
bw = (kw / 2);
}
bx = bd->x;
else
{
/* no border at this location */