e17/illume/tablet: cleanup policy, refactor, remove poinless comments

SVN revision: 62922
This commit is contained in:
Hannes Janetzek 2011-08-28 16:18:26 +00:00
parent b3cb06d0c1
commit cebc3fe7e3
1 changed files with 704 additions and 826 deletions

View File

@ -2,13 +2,6 @@
#include "policy.h"
#include "e.h"
/* NB: DIALOG_USES_PIXEL_BORDER is an experiment in setting dialog windows
* to use the 'pixel' type border. This is done because some dialogs,
* when shown, blend into other windows too much. Pixel border adds a
* little distinction between the dialog window and an app window.
* Disable if this is not wanted */
#define DIALOG_USES_PIXEL_BORDER 1
/* local function prototypes */
static void _policy_border_set_focus(E_Border *bd);
static void _policy_border_move(E_Border *bd, int x, int y);
@ -29,9 +22,11 @@ static void _policy_zone_layout_app_dual_left(E_Border *bd, E_Illume_Config_Zone
static void _policy_zone_layout_dialog(E_Border *bd, E_Illume_Config_Zone *cz);
static void _policy_zone_layout_splash(E_Border *bd, E_Illume_Config_Zone *cz);
static void _policy_zone_layout_conformant_single(E_Border *bd, E_Illume_Config_Zone *cz);
#if 0
static void _policy_zone_layout_conformant_dual_top(E_Border *bd, E_Illume_Config_Zone *cz);
static void _policy_zone_layout_conformant_dual_custom(E_Border *bd, E_Illume_Config_Zone *cz);
static void _policy_zone_layout_conformant_dual_left(E_Border *bd, E_Illume_Config_Zone *cz);
#endif
static Eina_List *_pol_focus_stack;
@ -61,7 +56,6 @@ _policy_border_set_focus(E_Border *bd)
e_border_uniconify(bd);
if (!bd->lock_user_stacking) e_border_raise(bd);
printf("illume set focus %s\n", e_border_name_get(bd));
/* focus the border */
e_border_focus_set(bd, 1, 1);
@ -355,6 +349,25 @@ _policy_zone_layout_indicator(E_Border *bd, E_Illume_Config_Zone *cz)
e_border_layer_set(bd, POL_INDICATOR_LAYER);
}
#define ZONE_GEOMETRY \
int x, y, w, h; \
e_zone_useful_geometry_get(bd->zone, &x, &y, &w, &h); \
x += bd->zone->x; \
y += bd->zone->y; \
static void
_border_geometry_set(E_Border *bd, int x, int y, int w, int h, int layer)
{
if ((bd->w != w) || (bd->h != h))
_policy_border_resize(bd, w, h);
if ((bd->x != x) || (bd->y != y))
_policy_border_move(bd, x, y);
if (bd->layer != layer) e_border_layer_set(bd, layer);
}
static void
_policy_zone_layout_quickpanel(E_Border *bd)
{
@ -371,13 +384,6 @@ _policy_zone_layout_quickpanel(E_Border *bd)
e_border_layer_set(bd, POL_QUICKPANEL_LAYER);
}
#define ZONE_GEOMETRY \
int x, y, w, h; \
e_zone_useful_geometry_get(bd->zone, &x, &y, &w, &h); \
x += bd->zone->x; \
y += bd->zone->y; \
static void
_policy_zone_layout_softkey(E_Border *bd, E_Illume_Config_Zone *cz)
{
@ -410,6 +416,8 @@ _policy_zone_layout_softkey(E_Border *bd, E_Illume_Config_Zone *cz)
if ((bd->x != x) || (bd->y != ny))
_policy_border_move(bd, x, ny);
/* _border_geometry_set(bd, x, ny, nw, nh, bd, POL_CONFORMANT_LAYER); */
ecore_x_e_illume_softkey_geometry_set(bd->zone->black_win,
bd->x, bd->y,
bd->w, bd->h);
@ -422,47 +430,35 @@ _policy_zone_layout_keyboard(E_Border *bd, E_Illume_Config_Zone *cz)
{
int ny, layer;
if ((!bd) || (!cz)) return;
if (!bd->visible) return;
if ((!bd) || (!cz) || (!bd->visible)) return;
ZONE_GEOMETRY;
e_illume_border_min_get(bd, NULL, &cz->vkbd.size);
if ((bd->w != w) || (bd->h != cz->vkbd.size))
_policy_border_resize(bd, w, cz->vkbd.size);
ny = ((bd->zone->y + bd->zone->h) - cz->vkbd.size);
if ((bd->x != x) || (bd->y != ny))
_policy_border_move(bd, x, ny);
ny = ((bd->zone->y + h) - cz->vkbd.size);
if ((bd->fullscreen) || (bd->need_fullscreen))
layer = POL_FULLSCREEN_LAYER;
else
layer = POL_KEYBOARD_LAYER;
/* if ((int)bd->layer != layer) e_border_layer_set(bd, layer); */
_border_geometry_set(bd, x, ny, w, cz->vkbd.size, layer);
}
static void
_policy_zone_layout_home_single(E_Border *bd, E_Illume_Config_Zone *cz)
{
int ny, nh, indsz = 0, sftsz = 0;
E_Border *ind, *sft;
/* int ny, nh; */
/* int indsz = 0, sftsz = 0; */
/* E_Border *ind, *sft; */
if ((!bd) || (!cz)) return;
if (!bd->visible) return;
if ((!bd) || (!cz) || (!bd->visible)) return;
ZONE_GEOMETRY;
if ((bd->w != w) || (bd->h != h))
_policy_border_resize(bd, w, h);
if ((bd->x != x) || (bd->y != y))
_policy_border_move(bd, x, y);
if (bd->layer != POL_HOME_LAYER) e_border_layer_set(bd, POL_HOME_LAYER);
_border_geometry_set(bd, x, y, w, h, POL_HOME_LAYER);
}
static void
@ -477,14 +473,7 @@ _policy_zone_layout_fullscreen(E_Border *bd)
e_illume_keyboard_safe_app_region_get(bd->zone, NULL, NULL, NULL, &kh);
if (kh < h) h = kh;
if ((bd->w != w) || (bd->h != h))
_policy_border_resize(bd, w, kh);
if ((bd->x != x) || (bd->y != y))
_policy_border_move(bd, x, y);
/* if (bd->layer != POL_FULLSCREEN_LAYER)
* e_border_layer_set(bd, POL_FULLSCREEN_LAYER); */
_border_geometry_set(bd, x, y, w, kh, POL_FULLSCREEN_LAYER);
}
static void
@ -504,27 +493,23 @@ _policy_zone_layout_app_single(E_Border *bd, E_Illume_Config_Zone *cz)
else
nh = (kh - cz->indicator.size);
if ((bd->w != w) || (bd->h != nh))
_policy_border_resize(bd, w, nh);
ny = (bd->zone->y + cz->indicator.size);
if (ny > y) y = ny;
if ((bd->x != x) || (bd->y != y))
_policy_border_move(bd, x, y);
/* if (bd->layer != POL_APP_LAYER) e_border_layer_set(bd, POL_APP_LAYER); */
_border_geometry_set(bd, x, ny, w, nh, POL_APP_LAYER);
}
static void
_policy_zone_layout_app_dual_top(E_Border *bd, E_Illume_Config_Zone *cz)
{
E_Border *b;
E_Border *bd2;
int kh, ny, nh;
if ((!bd) || (!cz)) return;
if ((!bd->new_client) && (!bd->visible)) return;
ZONE_GEOMETRY;
ny = (bd->zone->y + cz->indicator.size);
if ((bd->focused) &&
@ -540,35 +525,29 @@ _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) && (b != bd))
bd2 = e_illume_border_at_xy_get(bd->zone, x, ny);
if ((bd2) && (bd2 != bd))
{
/* does this border need keyboard ? */
if ((bd->focused) &&
(bd->client.vkbd.state > ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF))
{
int h;
int hh;
/* 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));
hh = ((h - cz->indicator.size - cz->softkey.size) / 2);
if ((bd2->x != x) || (bd2->y != (ny + hh)))
_policy_border_move(bd2, x, (ny + hh));
/* resize existing border if needed */
if ((b->w != b->zone->w) || (b->h != h))
_policy_border_resize(b, b->zone->w, h);
if ((bd2->w != w) || (bd2->h != hh))
_policy_border_resize(bd2, bd2->zone->w, hh);
}
else
ny = b->y + nh;
ny = bd2->y + nh;
}
if ((bd->w != bd->zone->w) || (bd->h != nh))
_policy_border_resize(bd, bd->zone->w, nh);
if ((bd->x != bd->zone->x) || (bd->y != ny))
_policy_border_move(bd, bd->zone->x, ny);
/* if (bd->layer != POL_APP_LAYER) e_border_layer_set(bd, POL_APP_LAYER); */
_border_geometry_set(bd, x, ny, w, nh, POL_APP_LAYER);
}
static void
@ -594,13 +573,7 @@ _policy_zone_layout_app_dual_custom(E_Border *bd, E_Illume_Config_Zone *cz)
nh = ((bd->zone->y + bd->zone->h) - ny - cz->softkey.size);
}
if ((bd->w != w) || (bd->h != nh))
_policy_border_resize(bd, w, nh);
if ((bd->x != x) || (bd->y != ny))
_policy_border_move(bd, x, ny);
/* if (bd->layer != POL_APP_LAYER) e_border_layer_set(bd, POL_APP_LAYER); */
_border_geometry_set(bd, x, ny, w, nh, POL_APP_LAYER);
}
static void
@ -628,13 +601,7 @@ _policy_zone_layout_app_dual_left(E_Border *bd, E_Illume_Config_Zone *cz)
bd2 = e_illume_border_at_xy_get(bd->zone, nx, y);
if ((bd2) && (bd != bd2)) nx = x + nw;
if ((bd->w != nw) || (bd->h != kh))
_policy_border_resize(bd, nw, kh);
if ((bd->x != nx) || (bd->y != y))
_policy_border_move(bd, nx, y);
/* if (bd->layer != POL_APP_LAYER) e_border_layer_set(bd, POL_APP_LAYER); */
_border_geometry_set(bd, nx, y, nw, kh, POL_APP_LAYER);
}
static void
@ -643,111 +610,44 @@ _policy_zone_layout_dialog(E_Border *bd, E_Illume_Config_Zone *cz)
E_Border *parent;
int mw, mh, nx, ny;
// printf("\tLayout Dialog: %s\n", bd->client.icccm.name);
/* NB: This policy ignores any ICCCM requested positions and centers the
* dialog on it's parent (if it exists) or on the zone */
if ((!bd) || (!cz)) return;
if (bd->placed)
return;
ZONE_GEOMETRY;
mw = bd->w;
mh = bd->h;
if (mw > bd->zone->w) mw = bd->zone->w;
if (mh > bd->zone->h) mh = bd->zone->h;
if (mw > w) mw = w;
if (mh > h) mh = h;
/* try to get this dialog's parent if it exists */
parent = e_illume_border_parent_get(bd);
/* if we have no parent, or we are in dual mode, then center on zone */
/* NB: we check dual mode because if we are in dual mode, dialogs tend to
* be too small to be useful when positioned on the parent, so center
* on zone. We could check their size first here tho */
if ((!parent) || (cz->mode.dual == 1))
{
/* no parent or dual mode, center on screen */
nx = (bd->zone->x + ((bd->zone->w - mw) / 2));
ny = (bd->zone->y + ((bd->zone->h - mh) / 2));
nx = (x + ((w - mw) / 2));
ny = (y + ((h - mh) / 2));
}
else
{
/* NB: there is an assumption here that the parent has already been
* laid out on screen. This could be bad. Needs Testing */
if (mw > parent->w) mw = parent->w;
if (mh > parent->h) mh = parent->h;
/* center on parent */
nx = (parent->x + ((parent->w - mw) / 2));
ny = (parent->y + ((parent->h - mh) / 2));
}
if ((bd->w != mw) || (bd->h != mh))
_policy_border_resize(bd, mw, mh);
if ((bd->x != nx) || (bd->y != ny))
_policy_border_move(bd, nx, ny);
_border_geometry_set(bd, nx, ny, mw, mh, POL_DIALOG_LAYER);
bd->placed = 1;
/* if (bd->layer != POL_DIALOG_LAYER)
* e_border_layer_set(bd, POL_DIALOG_LAYER); */
}
static void
_policy_zone_layout_splash(E_Border *bd, E_Illume_Config_Zone *cz)
{
E_Border *parent = NULL;
int mw, mh, nx, ny;
/* NB: This code is almost exactly the same as the dialog layout code
* (_policy_zone_layout_dialog) except for setting a different layer */
// printf("\tLayout Splash: %s\n", bd->client.icccm.name);
/* NB: This policy ignores any ICCCM requested positions and centers the
* splash screen on it's parent (if it exists) or on the zone */
if ((!bd) || (!cz)) return;
if (!bd->visible) return;
e_illume_border_min_get(bd, &mw, &mh);
if (mw > bd->zone->w) mw = bd->zone->w;
if (mh > bd->zone->h) mh = bd->zone->h;
/* if we have no parent, or we are in dual mode, then center on zone */
/* NB: we check dual mode because if we are in dual mode, dialogs tend to
* be too small to be useful when positioned on the parent,
* so center on zone instead */
if ((!parent) || (cz->mode.dual == 1))
{
/* no parent or in dual mode, center on screen */
nx = (bd->zone->x + ((bd->zone->w - mw) / 2));
ny = (bd->zone->y + ((bd->zone->h - mh) / 2));
}
else
{
/* NB: there is an assumption here that the parent has already been
* laid out on screen. This could be bad. Needs Testing */
if (mw > parent->w) mw = parent->w;
if (mh > parent->h) mh = parent->h;
/* center on parent */
nx = (parent->x + ((parent->w - mw) / 2));
ny = (parent->y + ((parent->h - mh) / 2));
}
if ((bd->w != mw) || (bd->h != mh))
_policy_border_resize(bd, mw, mh);
if ((bd->x != nx) || (bd->y != ny))
_policy_border_move(bd, nx, ny);
_policy_zone_layout_dialog(bd, cz);
if (bd->layer != POL_SPLASH_LAYER) e_border_layer_set(bd, POL_SPLASH_LAYER);
}
@ -758,16 +658,12 @@ _policy_zone_layout_conformant_single(E_Border *bd, E_Illume_Config_Zone *cz)
if ((!bd) || (!cz)) return;
if ((!bd->new_client) && (!bd->visible)) return;
if ((bd->w != bd->zone->w) || (bd->h != bd->zone->h))
_policy_border_resize(bd, bd->zone->w, bd->zone->h);
if ((bd->x != bd->zone->x) || (bd->y != bd->zone->y))
_policy_border_move(bd, bd->zone->x, bd->zone->y);
if (bd->layer != POL_CONFORMANT_LAYER)
e_border_layer_set(bd, POL_CONFORMANT_LAYER);
_border_geometry_set(bd, bd->zone->x, bd->zone->y,
bd->zone->w, bd->zone->h,
POL_CONFORMANT_LAYER);
}
#if 0
static void
_policy_zone_layout_conformant_dual_top(E_Border *bd, E_Illume_Config_Zone *cz)
{
@ -783,14 +679,9 @@ _policy_zone_layout_conformant_dual_top(E_Border *bd, E_Illume_Config_Zone *cz)
ny = (bd->zone->y + cz->indicator.size) + nh;
nh += cz->softkey.size;
if ((bd->w != bd->zone->w) || (bd->h != nh))
_policy_border_resize(bd, bd->zone->w, nh);
if ((bd->x != bd->zone->x) || (bd->y != ny))
_policy_border_move(bd, bd->zone->x, ny);
if (bd->layer != POL_CONFORMANT_LAYER)
e_border_layer_set(bd, POL_CONFORMANT_LAYER);
_border_geometry_set(bd, bd->zone->x, ny,
bd->zone->w, nh,
POL_CONFORMANT_LAYER);
}
static void
@ -798,27 +689,19 @@ _policy_zone_layout_conformant_dual_custom(E_Border *bd, E_Illume_Config_Zone *c
{
int iy, nh;
// printf("\tLayout Conformant Dual Custom: %s\n", bd->client.icccm.class);
if ((!bd) || (!cz)) return;
if ((!bd->new_client) && (!bd->visible)) return;
/* grab indicator position */
e_illume_border_indicator_pos_get(bd->zone, NULL, &iy);
ZONE_GEOMETRY;
e_illume_border_indicator_pos_get(bd->zone, NULL, &iy);
nh = ((bd->zone->y + bd->zone->h) - iy);
if ((bd->w != bd->zone->w) || (bd->h != nh))
_policy_border_resize(bd, bd->zone->w, nh);
if ((bd->x != bd->zone->x) || (bd->y != iy))
_policy_border_move(bd, bd->zone->x, iy);
if (bd->layer != POL_CONFORMANT_LAYER)
e_border_layer_set(bd, POL_CONFORMANT_LAYER);
_border_geometry_set(bd, x, iy, w, nh, POL_CONFORMANT_LAYER);
}
static void
_policy_zone_layout_conformant_dual_left(E_Border *bd, E_Illume_Config_Zone *cz)
{
@ -829,19 +712,14 @@ _policy_zone_layout_conformant_dual_left(E_Border *bd, E_Illume_Config_Zone *cz)
if ((!bd) || (!cz)) return;
if ((!bd->new_client) && (!bd->visible)) return;
nw = (bd->zone->w / 2);
nx = (bd->zone->x);
ZONE_GEOMETRY;
if ((bd->w != nw) || (bd->h != bd->zone->h))
_policy_border_resize(bd, nw, bd->zone->h);
nw = w/2;
nx = x;
if ((bd->x != nx) || (bd->y != bd->zone->y))
_policy_border_move(bd, nx, bd->zone->y);
if (bd->layer != POL_CONFORMANT_LAYER)
e_border_layer_set(bd, POL_CONFORMANT_LAYER);
_border_geometry_set(bd, x, y, nw, h, POL_CONFORMANT_LAYER);
}
#endif
/* policy functions */
void
@ -1108,9 +986,9 @@ _policy_border_post_assign(E_Border *bd)
bd->lock_client_stacking = 1;
/* do not allow the user to change these properties */
bd->lock_user_location = 1;
bd->lock_user_size = 1;
bd->lock_user_shade = 1;
/* bd->lock_user_location = 1;
* bd->lock_user_size = 1;
* bd->lock_user_shade = 1; */
/* clear any centered states */
/* NB: this is mainly needed for E's main config dialog */