Add some safety checks.

Refactor some if statements to be simplier.



SVN revision: 50899
This commit is contained in:
Christopher Michael 2010-08-08 12:44:04 +00:00
parent 1f672ba9cf
commit b64b865ff4
2 changed files with 59 additions and 63 deletions

View File

@ -85,7 +85,6 @@ e_mod_quickpanel_new(E_Zone *zone)
/* set quickpanel zone */
qp->zone = zone;
qp->vert.dir = 0;
qp->mouse_hdl = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP,
_e_mod_quickpanel_cb_mouse_up, qp);
@ -98,6 +97,8 @@ e_mod_quickpanel_show(E_Illume_Quickpanel *qp)
E_Illume_Config_Zone *cz;
int duration;
if (!qp) return;
/* delete the animator if it exists */
if (qp->animator) ecore_animator_del(qp->animator);
qp->animator = NULL;
@ -218,7 +219,7 @@ _e_mod_quickpanel_cb_mouse_up(void *data, int type __UNUSED__, void *event)
E_Illume_Quickpanel *qp;
ev = event;
qp = data;
if (!(qp = data)) return ECORE_CALLBACK_PASS_ON;
if (ev->event_window != qp->clickwin) return ECORE_CALLBACK_PASS_ON;
if (qp->visible) e_mod_quickpanel_hide(qp);
return ECORE_CALLBACK_PASS_ON;
@ -236,7 +237,7 @@ _e_mod_quickpanel_cb_border_add(void *data __UNUSED__, int type __UNUSED__, void
if (!ev->border->client.illume.quickpanel.quickpanel)
return ECORE_CALLBACK_PASS_ON;
zone = ev->border->zone;
if (!(zone = ev->border->zone)) return ECORE_CALLBACK_PASS_ON;
/* if this border should be on a different zone, get requested zone */
if (zone->num != ev->border->client.illume.quickpanel.zone)
@ -245,10 +246,12 @@ _e_mod_quickpanel_cb_border_add(void *data __UNUSED__, int type __UNUSED__, void
int zn = 0;
/* find this zone */
con = e_container_current_get(e_manager_current_get());
if (!(con = e_container_current_get(e_manager_current_get())))
return ECORE_CALLBACK_PASS_ON;
zn = ev->border->client.illume.quickpanel.zone;
zone = e_util_container_zone_number_get(con->num, zn);
if (!zone) zone = e_util_container_zone_number_get(con->num, 0);
if (!zone) return ECORE_CALLBACK_PASS_ON;
}
if (!(qp = e_illume_quickpanel_by_zone_get(zone)))
@ -285,7 +288,7 @@ _e_mod_quickpanel_cb_border_remove(void *data __UNUSED__, int type __UNUSED__, v
if (!ev->border->client.illume.quickpanel.quickpanel)
return ECORE_CALLBACK_PASS_ON;
zone = ev->border->zone;
if (!(zone = ev->border->zone)) return ECORE_CALLBACK_PASS_ON;
/* if this border should be on a different zone, get requested zone */
if (zone->num != ev->border->client.illume.quickpanel.zone)
@ -294,17 +297,20 @@ _e_mod_quickpanel_cb_border_remove(void *data __UNUSED__, int type __UNUSED__, v
int zn = 0;
/* find this zone */
con = e_container_current_get(e_manager_current_get());
if (!(con = e_container_current_get(e_manager_current_get())))
return ECORE_CALLBACK_PASS_ON;
zn = ev->border->client.illume.quickpanel.zone;
zone = e_util_container_zone_number_get(con->num, zn);
if (!zone) zone = e_util_container_zone_number_get(con->num, 0);
if (!zone) return ECORE_CALLBACK_PASS_ON;
}
if (!(qp = e_illume_quickpanel_by_zone_get(zone)))
return ECORE_CALLBACK_PASS_ON;
/* add this border to QP border collection */
qp->borders = eina_list_remove(qp->borders, ev->border);
if (qp->borders)
qp->borders = eina_list_remove(qp->borders, ev->border);
qp->vert.size = 0;
EINA_LIST_FOREACH(qp->borders, l, bd)
@ -386,6 +392,7 @@ _e_mod_quickpanel_cb_delay_hide(void *data)
static void
_e_mod_quickpanel_slide(E_Illume_Quickpanel *qp, int visible, double len)
{
if (!qp) return;
qp->start = ecore_loop_time_get();
qp->len = len;
qp->vert.adjust_start = qp->vert.adjust;
@ -408,6 +415,8 @@ _e_mod_quickpanel_hide(E_Illume_Quickpanel *qp)
{
int duration;
if (!qp) return;
/* delete the animator if it exists */
if (qp->animator) ecore_animator_del(qp->animator);
qp->animator = NULL;
@ -490,7 +499,9 @@ _e_mod_quickpanel_position_update(E_Illume_Quickpanel *qp)
E_Border *bd;
int iy = 0;
if (!qp) return;
_e_mod_quickpanel_hide(qp);
if (!qp->zone) return;
e_illume_border_indicator_pos_get(qp->zone, NULL, &iy);
EINA_LIST_FOREACH(qp->borders, l, bd)
e_border_move(bd, qp->zone->x, iy);
@ -506,6 +517,7 @@ _e_mod_quickpanel_animate_down(E_Illume_Quickpanel *qp)
E_Border *bd;
int pbh = 0;
if (!qp) return;
pbh = (qp->vert.isize - qp->vert.size);
EINA_LIST_FOREACH(qp->borders, l, bd)
{
@ -539,6 +551,7 @@ _e_mod_quickpanel_animate_up(E_Illume_Quickpanel *qp)
E_Border *bd;
int pbh = 0;
if (!qp) return;
pbh = qp->vert.size;
EINA_LIST_FOREACH(qp->borders, l, bd)
{
@ -570,8 +583,11 @@ _e_mod_quickpanel_clickwin_show(E_Illume_Quickpanel *qp)
{
E_Border *ind;
if (!qp->borders) return;
if ((!qp) || (!qp->borders) || (!qp->zone)) return;
if (!(ind = eina_list_nth(qp->borders, 0))) return;
if (qp->clickwin) ecore_x_window_free(qp->clickwin);
qp->clickwin = 0;
qp->clickwin = ecore_x_window_input_new(qp->zone->container->win,
qp->zone->x, qp->zone->y,
qp->zone->w, qp->zone->h);
@ -589,6 +605,7 @@ _e_mod_quickpanel_clickwin_show(E_Illume_Quickpanel *qp)
static void
_e_mod_quickpanel_clickwin_hide(E_Illume_Quickpanel *qp)
{
if (!qp) return;
if (qp->clickwin) ecore_x_window_free(qp->clickwin);
qp->clickwin = 0;
}

View File

@ -172,7 +172,8 @@ _policy_border_hide_below(E_Border *bd)
else
{
/* we need to check x/y position */
if (E_CONTAINS(bd->x, bd->y, bd->w, bd->h, b->x, b->y, b->w, b->h))
if (E_CONTAINS(bd->x, bd->y, bd->w, bd->h,
b->x, b->y, b->w, b->h))
{
if (b->visible) e_illume_border_hide(b);
}
@ -417,12 +418,12 @@ _policy_zone_layout_keyboard(E_Border *bd, E_Illume_Config_Zone *cz)
if ((!bd) || (!cz)) return;
/* grab minimum keyboard size */
e_illume_border_min_get(bd, NULL, &cz->vkbd.size);
/* no point in adjusting size or position if it's not visible */
if (!bd->visible) return;
/* grab minimum keyboard size */
e_illume_border_min_get(bd, NULL, &cz->vkbd.size);
/* make sure it's the required width & height */
if ((bd->w != bd->zone->w) || (bd->h != cz->vkbd.size))
_policy_border_resize(bd, bd->zone->w, cz->vkbd.size);
@ -524,13 +525,10 @@ _policy_zone_layout_home_dual_custom(E_Border *bd, E_Illume_Config_Zone *cz)
/* see if there are any other home windows */
home = e_illume_border_home_get(bd->zone);
if (home)
if ((home) && (bd != home))
{
if (bd != home)
{
ny = (iy + cz->indicator.size);
nh = ((bd->zone->y + bd->zone->h) - ny - cz->softkey.size);
}
ny = (iy + cz->indicator.size);
nh = ((bd->zone->y + bd->zone->h) - ny - cz->softkey.size);
}
/* make sure it's the required width & height */
@ -566,10 +564,7 @@ _policy_zone_layout_home_dual_left(E_Border *bd, E_Illume_Config_Zone *cz)
/* see if there are any other home windows */
home = e_illume_border_home_get(bd->zone);
if (home)
{
if (bd != home) nx = (home->x + nw);
}
if ((home) && (bd != home)) nx = (home->x + nw);
/* make sure it's the required width & height */
if ((bd->w != nw) || (bd->h != nh))
@ -656,7 +651,6 @@ _policy_zone_layout_app_dual_top(E_Border *bd, E_Illume_Config_Zone *cz)
{
/* grab keyboard safe region */
e_illume_keyboard_safe_app_region_get(bd->zone, NULL, NULL, NULL, &kh);
nh = (kh - cz->indicator.size);
}
else
@ -668,28 +662,25 @@ _policy_zone_layout_app_dual_top(E_Border *bd, E_Illume_Config_Zone *cz)
/* see if there is a border already there. if so, check placement based on
* virtual keyboard usage */
b = e_illume_border_at_xy_get(bd->zone, bd->zone->x, ny);
if (b)
if ((b) && (b != bd))
{
if (b != bd)
/* does this border need keyboard ? */
if ((bd->focused) &&
(bd->client.vkbd.state > ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF))
{
/* does this border need keyboard ? */
if ((bd->focused) &&
(bd->client.vkbd.state > ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF))
{
int h;
int h;
/* move existing border to bottom if needed */
h = ((bd->zone->h - cz->indicator.size - cz->softkey.size) / 2);
if ((b->x != b->zone->x) || (b->y != (ny + h)))
_policy_border_move(b, b->zone->x, (ny + h));
/* move existing border to bottom if needed */
h = ((bd->zone->h - cz->indicator.size - cz->softkey.size) / 2);
if ((b->x != b->zone->x) || (b->y != (ny + h)))
_policy_border_move(b, b->zone->x, (ny + h));
/* resize existing border if needed */
if ((b->w != b->zone->w) || (b->h != h))
_policy_border_resize(b, b->zone->w, h);
}
else
ny = b->y + nh;
/* resize existing border if needed */
if ((b->w != b->zone->w) || (b->h != h))
_policy_border_resize(b, b->zone->w, h);
}
else
ny = b->y + nh;
}
/* resize if needed */
@ -723,13 +714,10 @@ _policy_zone_layout_app_dual_custom(E_Border *bd, E_Illume_Config_Zone *cz)
nh = iy;
app = e_illume_border_at_xy_get(bd->zone, bd->zone->x, bd->zone->y);
if (app)
if ((app) && (bd != app))
{
if (bd != app)
{
ny = (iy + cz->indicator.size);
nh = ((bd->zone->y + bd->zone->h) - ny - cz->softkey.size);
}
ny = (iy + cz->indicator.size);
nh = ((bd->zone->y + bd->zone->h) - ny - cz->softkey.size);
}
/* make sure it's the required width & height */
@ -769,10 +757,7 @@ _policy_zone_layout_app_dual_left(E_Border *bd, E_Illume_Config_Zone *cz)
/* see if there is a border already there. if so, place at right */
b = e_illume_border_at_xy_get(bd->zone, nx, (ky + cz->indicator.size));
if (b)
{
if (bd != b) nx = b->x + nw;
}
if ((b) && (bd != b)) nx = b->x + nw;
/* resize if needed */
if ((bd->w != nw) || (bd->h != kh))
@ -1054,11 +1039,8 @@ _policy_border_add(E_Border *bd)
if ((bd->client.icccm.accepts_focus) || (bd->client.icccm.take_focus))
_pol_focus_stack = eina_list_append(_pol_focus_stack, bd);
if ((e_illume_border_is_softkey(bd)) ||
(e_illume_border_is_indicator(bd)))
{
_policy_zone_layout_update(bd->zone);
}
if ((e_illume_border_is_softkey(bd)) || (e_illume_border_is_indicator(bd)))
_policy_zone_layout_update(bd->zone);
else
{
/* set focus on new border if we can */
@ -1139,8 +1121,8 @@ _policy_border_focus_out(E_Border *bd)
{
E_Border *parent;
parent = e_illume_border_parent_get(bd);
if (parent) _policy_border_set_focus(parent);
if (parent = e_illume_border_parent_get(bd))
_policy_border_set_focus(parent);
}
}
}
@ -1174,12 +1156,9 @@ _policy_border_activate(E_Border *bd)
* occasionally fall through wrt E's focus policy, so cherry pick the good
* parts and use here :) */
/* if the border is iconified then uniconify */
if (bd->iconic)
{
/* if the user is allowed to uniconify, then do it */
if (!bd->lock_user_iconify) e_border_uniconify(bd);
}
/* if the border is iconified then uniconify if allowed */
if ((bd->iconic) && (!bd->lock_user_iconify))
e_border_uniconify(bd);
/* set very high layer for this window as it needs attention and thus
* should show above everything */