e17/illume: more work on tablet policy

SVN revision: 63102
This commit is contained in:
Hannes Janetzek 2011-09-03 02:20:14 +00:00
parent 8a58f8f3d2
commit ff8c5b60ec
1 changed files with 146 additions and 156 deletions

View File

@ -95,7 +95,7 @@ _policy_border_move(E_Border *bd, int x, int y)
/* NB: Seems something similar happens with elementary windows also /* NB: Seems something similar happens with elementary windows also
* so for now just set bd->placed on all windows until this * so for now just set bd->placed on all windows until this
* gets investigated */ * gets investigated */
bd->placed = 1; /* bd->placed = 1; */
bd->x = x; bd->x = x;
bd->y = y; bd->y = y;
bd->changes.pos = 1; bd->changes.pos = 1;
@ -121,7 +121,7 @@ _policy_border_hide_below(E_Border *bd)
int pos = 0, i; int pos = 0, i;
return; return;
// printf("Hide Borders Below: %s %d %d\n", // printf("Hide Borders Below: %s %d %d\n",
// bd->client.icccm.name, bd->x, bd->y); // bd->client.icccm.name, bd->x, bd->y);
@ -362,10 +362,10 @@ _border_geometry_set(E_Border *bd, int x, int y, int w, int h, int layer)
{ {
if ((bd->w != w) || (bd->h != h)) if ((bd->w != w) || (bd->h != h))
_policy_border_resize(bd, w, h); _policy_border_resize(bd, w, h);
if ((bd->x != x) || (bd->y != y)) if ((bd->x != x) || (bd->y != y))
_policy_border_move(bd, x, y); _policy_border_move(bd, x, y);
if (bd->layer != layer) e_border_layer_set(bd, layer); if (bd->layer != layer) e_border_layer_set(bd, layer);
} }
@ -445,16 +445,11 @@ _policy_zone_layout_keyboard(E_Border *bd, E_Illume_Config_Zone *cz)
layer = POL_KEYBOARD_LAYER; layer = POL_KEYBOARD_LAYER;
_border_geometry_set(bd, x, ny, w, cz->vkbd.size, layer); _border_geometry_set(bd, x, ny, w, cz->vkbd.size, layer);
} }
static void static void
_policy_zone_layout_home_single(E_Border *bd, E_Illume_Config_Zone *cz) _policy_zone_layout_home_single(E_Border *bd, E_Illume_Config_Zone *cz)
{ {
/* int ny, nh; */
/* int indsz = 0, sftsz = 0; */
/* E_Border *ind, *sft; */
if ((!bd) || (!cz) || (!bd->visible)) return; if ((!bd) || (!cz) || (!bd->visible)) return;
ZONE_GEOMETRY; ZONE_GEOMETRY;
@ -462,41 +457,79 @@ _policy_zone_layout_home_single(E_Border *bd, E_Illume_Config_Zone *cz)
_border_geometry_set(bd, x, y, w, h, POL_HOME_LAYER); _border_geometry_set(bd, x, y, w, h, POL_HOME_LAYER);
} }
#define MIN_HEIGHT 100
static Eina_Bool
_policy_layout_app_check(E_Border *bd)
{
if (!bd)
return EINA_FALSE;
if (!bd->visible)
return EINA_FALSE;
if ((bd->desk != e_desk_current_get(bd->zone)) && (!bd->sticky))
return EINA_FALSE;
return EINA_TRUE;
}
static void static void
_policy_zone_layout_fullscreen(E_Border *bd) _policy_keyboard_restrict(E_Border *bd, int *h)
{ {
int kh; int kh;
if (!bd) return; if (bd->client.vkbd.state > ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF)
{
e_illume_keyboard_safe_app_region_get(bd->zone, NULL, NULL, NULL, &kh);
kh -= bd->zone->h - *h;
if ((kh < *h) && (kh > MIN_HEIGHT))
*h = kh;
}
}
static void
_policy_indicator_restrict(E_Illume_Config_Zone *cz, int *y, int *h)
{
if ((cz->indicator.size) && (*y < cz->indicator.size))
{
*h -= cz->indicator.size;
*y = cz->indicator.size;
}
}
static void
_policy_softkey_restrict(E_Illume_Config_Zone *cz, int *y, int *h)
{
if ((cz->softkey.size) && ((*y + *h) > cz->softkey.size))
*h -= (*y + *h) - cz->softkey.size;
}
static void
_policy_zone_layout_fullscreen(E_Border *bd)
{
if (!_policy_layout_app_check(bd)) return;
ZONE_GEOMETRY; ZONE_GEOMETRY;
e_illume_keyboard_safe_app_region_get(bd->zone, NULL, NULL, NULL, &kh);
if (kh < h) h = kh;
_border_geometry_set(bd, x, y, w, kh, POL_FULLSCREEN_LAYER); _policy_keyboard_restrict(bd, &h);
_border_geometry_set(bd, x, y, w, h, POL_FULLSCREEN_LAYER);
} }
static void static void
_policy_zone_layout_app_single(E_Border *bd, E_Illume_Config_Zone *cz) _policy_zone_layout_app_single(E_Border *bd, E_Illume_Config_Zone *cz)
{ {
int ky, kh, ny, nh; if (!_policy_layout_app_check(bd)) return;
if ((!bd) || (!cz)) return;
if ((!bd->new_client) && (!bd->visible)) return;
ZONE_GEOMETRY; ZONE_GEOMETRY;
e_illume_keyboard_safe_app_region_get(bd->zone, NULL, &ky, NULL, &kh); _policy_keyboard_restrict(bd, &h);
_policy_indicator_restrict(cz, &y, &h);
if (kh >= h) _policy_softkey_restrict(cz, &y, &h);
nh = (kh - cz->indicator.size - cz->softkey.size);
else
nh = (kh - cz->indicator.size);
if (h > nh) h = nh;
ny = (bd->zone->y + cz->indicator.size);
if (y < ny) y = ny;
_border_geometry_set(bd, x, y, w, h, POL_APP_LAYER); _border_geometry_set(bd, x, y, w, h, POL_APP_LAYER);
} }
@ -505,51 +538,25 @@ static void
_policy_zone_layout_app_dual_top(E_Border *bd, E_Illume_Config_Zone *cz) _policy_zone_layout_app_dual_top(E_Border *bd, E_Illume_Config_Zone *cz)
{ {
E_Border *bd2; E_Border *bd2;
int kh, ny, nh;
if ((!bd) || (!cz)) return; if (!_policy_layout_app_check(bd)) return;
if ((!bd->new_client) && (!bd->visible)) return;
ZONE_GEOMETRY; ZONE_GEOMETRY;
ny = (bd->zone->y + cz->indicator.size); _policy_keyboard_restrict(bd, &h);
_policy_indicator_restrict(cz, &y, &h);
_policy_softkey_restrict(cz, &y, &h);
if ((bd->focused) && bd2 = e_illume_border_at_xy_get(bd->zone, x, y);
(bd->client.vkbd.state > ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF))
{
e_illume_keyboard_safe_app_region_get(bd->zone, NULL, NULL, NULL, &kh);
nh = (kh - cz->indicator.size);
}
else
{
nh = ((bd->zone->h - cz->indicator.size - cz->softkey.size) / 2);
}
/* see if there is a border already there. if so, check placement based on
* virtual keyboard usage */
bd2 = e_illume_border_at_xy_get(bd->zone, x, ny);
if ((bd2) && (bd2 != bd)) if ((bd2) && (bd2 != bd))
{ {
/* does this border need keyboard ? */ if ((bd->focused) && (bd->client.vkbd.state > ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF))
if ((bd->focused) && _border_geometry_set(bd2, x, h/2 + y, w, h/2, POL_APP_LAYER);
(bd->client.vkbd.state > ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF))
{
int hh;
/* move existing border to bottom if needed */
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 ((bd2->w != w) || (bd2->h != hh))
_policy_border_resize(bd2, bd2->zone->w, hh);
}
else else
ny = bd2->y + nh; y += h/2;
} }
_border_geometry_set(bd, x, ny, w, nh, POL_APP_LAYER); _border_geometry_set(bd, x, y, w, h/2, POL_APP_LAYER);
} }
static void static void
@ -558,8 +565,7 @@ _policy_zone_layout_app_dual_custom(E_Border *bd, E_Illume_Config_Zone *cz)
E_Border *app; E_Border *app;
int iy, ny, nh; int iy, ny, nh;
if ((!bd) || (!cz)) return; if (!_policy_layout_app_check(bd)) return;
if ((!bd->new_client) && (!bd->visible)) return;
ZONE_GEOMETRY; ZONE_GEOMETRY;
@ -584,8 +590,7 @@ _policy_zone_layout_app_dual_left(E_Border *bd, E_Illume_Config_Zone *cz, Eina_B
E_Border *bd2; E_Border *bd2;
int ky, kh, nx, nw; int ky, kh, nx, nw;
if ((!bd) || (!cz)) return; if (!_policy_layout_app_check(bd)) return;
if ((!bd->new_client) && (!bd->visible)) return;
ZONE_GEOMETRY; ZONE_GEOMETRY;
@ -605,7 +610,7 @@ _policy_zone_layout_app_dual_left(E_Border *bd, E_Illume_Config_Zone *cz, Eina_B
bd2 = e_illume_border_at_xy_get(bd->zone, nx, y); bd2 = e_illume_border_at_xy_get(bd->zone, nx, y);
if ((bd2) && (bd != bd2)) nx = x + nw; if ((bd2) && (bd != bd2)) nx = x + nw;
} }
_border_geometry_set(bd, nx, y, nw, kh, POL_APP_LAYER); _border_geometry_set(bd, nx, y, nw, kh, POL_APP_LAYER);
} }
@ -615,7 +620,9 @@ _policy_zone_layout_dialog(E_Border *bd, E_Illume_Config_Zone *cz)
E_Border *parent; E_Border *parent;
int mw, mh, nx, ny; int mw, mh, nx, ny;
/* if (!_policy_layout_app_check(bd)) return; */
if ((!bd) || (!cz)) return; if ((!bd) || (!cz)) return;
printf("place dialog %d - %dx%d\n", bd->placed, bd->w, bd->h);
if (bd->placed) if (bd->placed)
return; return;
@ -625,8 +632,19 @@ _policy_zone_layout_dialog(E_Border *bd, E_Illume_Config_Zone *cz)
mw = bd->w; mw = bd->w;
mh = bd->h; mh = bd->h;
if (mw > w) mw = w; if (e_illume_border_is_fixed_size(bd))
if (mh > h) mh = h; {
if (mw > w) mw = w;
if (mh > h) mh = h;
}
else
{
if (w * 2/3 > bd->w)
mw = w * 2/3;
if (h * 2/3 > bd->h)
mh = h * 2/3;
}
parent = e_illume_border_parent_get(bd); parent = e_illume_border_parent_get(bd);
@ -644,9 +662,10 @@ _policy_zone_layout_dialog(E_Border *bd, E_Illume_Config_Zone *cz)
ny = (parent->y + ((parent->h - mh) / 2)); ny = (parent->y + ((parent->h - mh) / 2));
} }
_border_geometry_set(bd, nx, ny, mw, mh, POL_DIALOG_LAYER);
bd->placed = 1; bd->placed = 1;
_border_geometry_set(bd, nx, ny, mw, mh, POL_DIALOG_LAYER);
printf("set geom %d %d\n", mw, mh);
} }
static void static void
@ -660,72 +679,13 @@ _policy_zone_layout_splash(E_Border *bd, E_Illume_Config_Zone *cz)
static void static void
_policy_zone_layout_conformant_single(E_Border *bd, E_Illume_Config_Zone *cz) _policy_zone_layout_conformant_single(E_Border *bd, E_Illume_Config_Zone *cz)
{ {
if ((!bd) || (!cz)) return; if (!_policy_layout_app_check(bd)) return;
if ((!bd->new_client) && (!bd->visible)) return;
_border_geometry_set(bd, bd->zone->x, bd->zone->y, _border_geometry_set(bd, bd->zone->x, bd->zone->y,
bd->zone->w, bd->zone->h, bd->zone->w, bd->zone->h,
POL_CONFORMANT_LAYER); POL_CONFORMANT_LAYER);
} }
#if 0
static void
_policy_zone_layout_conformant_dual_top(E_Border *bd, E_Illume_Config_Zone *cz)
{
int nh, ny;
/* according to the docs I have, conformant windows are always on the
* bottom in dual-top mode */
if ((!bd) || (!cz)) return;
if ((!bd->new_client) && (!bd->visible)) return;
nh = ((bd->zone->h - cz->indicator.size - cz->softkey.size) / 2);
ny = (bd->zone->y + cz->indicator.size) + nh;
nh += cz->softkey.size;
_border_geometry_set(bd, bd->zone->x, ny,
bd->zone->w, nh,
POL_CONFORMANT_LAYER);
}
static void
_policy_zone_layout_conformant_dual_custom(E_Border *bd, E_Illume_Config_Zone *cz)
{
int iy, nh;
if ((!bd) || (!cz)) return;
if ((!bd->new_client) && (!bd->visible)) return;
ZONE_GEOMETRY;
e_illume_border_indicator_pos_get(bd->zone, NULL, &iy);
nh = ((bd->zone->y + bd->zone->h) - iy);
_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)
{
int nw, nx;
/* according to the docs I have, conformant windows are always on the
* left in dual-left mode */
if ((!bd) || (!cz)) return;
if ((!bd->new_client) && (!bd->visible)) return;
ZONE_GEOMETRY;
nw = w/2;
nx = x;
_border_geometry_set(bd, x, y, nw, h, POL_CONFORMANT_LAYER);
}
#endif
#if 0 #if 0
typedef struct _App_Desk App_Desk; typedef struct _App_Desk App_Desk;
@ -744,7 +704,7 @@ static Eina_List *desks = NULL;
EINA_LIST_FOREACH(_list, _l, _item) \ EINA_LIST_FOREACH(_list, _l, _item) \
if (_match) break; \ if (_match) break; \
} }
#endif #endif
/* policy functions */ /* policy functions */
@ -765,6 +725,9 @@ _policy_border_add(E_Border *bd)
* to it's current zone */ * to it's current zone */
ecore_x_e_illume_zone_set(bd->client.win, bd->zone->black_win); ecore_x_e_illume_zone_set(bd->client.win, bd->zone->black_win);
if (e_illume_border_is_keyboard(bd))
e_hints_window_sticky_set(bd, 1);
/* ignore stolen borders. These are typically quickpanel or keyboards */ /* ignore stolen borders. These are typically quickpanel or keyboards */
if (bd->stolen) return; if (bd->stolen) return;
@ -787,31 +750,30 @@ _policy_border_add(E_Border *bd)
e_illume_border_hide(sft); e_illume_border_hide(sft);
else if (!sft->visible) else if (!sft->visible)
e_illume_border_show(sft); e_illume_border_show(sft);
} }
} }
} }
#if 0 #if 0
if (bd->client.icccm.class) if (bd->client.icccm.class)
{ {
Eina_List *l; Eina_List *l;
App_Desk *d; App_Desk *d;
EINA_LIST_FIND(desks, d, (d->class == bd->client.icccm.class)); EINA_LIST_FIND(desks, d, (d->class == bd->client.icccm.class));
if (!d) if (!d)
{ {
d = E_NEW(App_Desk, 1); d = E_NEW(App_Desk, 1);
d->desk d->desk
} }
d->borders = eina_list_append(d->borders, bd); d->borders = eina_list_append(d->borders, bd);
e_border_desk_set(bd, d->desk); e_border_desk_set(bd, d->desk);
} }
#endif #endif
/* Add this border to our focus stack if it can accept or take focus */ /* Add this border to our focus stack if it can accept or take focus */
if ((bd->client.icccm.accepts_focus) || (bd->client.icccm.take_focus)) if ((bd->client.icccm.accepts_focus) || (bd->client.icccm.take_focus))
_pol_focus_stack = eina_list_append(_pol_focus_stack, bd); _pol_focus_stack = eina_list_append(_pol_focus_stack, bd);
@ -842,13 +804,12 @@ _policy_border_del(E_Border *bd)
/* try to get the Indicator on this zone */ /* try to get the Indicator on this zone */
if ((ind = e_illume_border_indicator_get(bd->zone))) if ((ind = e_illume_border_indicator_get(bd->zone)))
{ {
/* we have the indicator, show it if needed */
if (!ind->visible) e_illume_border_show(ind); if (!ind->visible) e_illume_border_show(ind);
} }
_policy_zone_layout_update(bd->zone); _policy_zone_layout_update(bd->zone);
} }
/* remove from our focus stack */ /* remove from focus stack */
if ((bd->client.icccm.accepts_focus) || (bd->client.icccm.take_focus)) if ((bd->client.icccm.accepts_focus) || (bd->client.icccm.take_focus))
_pol_focus_stack = eina_list_remove(_pol_focus_stack, bd); _pol_focus_stack = eina_list_remove(_pol_focus_stack, bd);
@ -856,7 +817,6 @@ _policy_border_del(E_Border *bd)
{ {
E_Illume_Config_Zone *cz; E_Illume_Config_Zone *cz;
/* get the config for this zone */
cz = e_illume_zone_config_get(bd->zone->id); cz = e_illume_zone_config_get(bd->zone->id);
cz->softkey.size = 0; cz->softkey.size = 0;
_policy_zone_layout_update(bd->zone); _policy_zone_layout_update(bd->zone);
@ -865,16 +825,14 @@ _policy_border_del(E_Border *bd)
{ {
E_Illume_Config_Zone *cz; E_Illume_Config_Zone *cz;
/* get the config for this zone */
cz = e_illume_zone_config_get(bd->zone->id); cz = e_illume_zone_config_get(bd->zone->id);
cz->indicator.size = 0; cz->indicator.size = 0;
_policy_zone_layout_update(bd->zone); _policy_zone_layout_update(bd->zone);
} }
else /* else
{ * {
/* show the border below this one */ * _policy_border_show_below(bd);
_policy_border_show_below(bd); * } */
}
} }
void void
@ -954,6 +912,8 @@ _policy_border_activate(E_Border *bd)
/* NB: We cannot use our set_focus function here because it does, /* NB: We cannot use our set_focus function here because it does,
* occasionally fall through wrt E's focus policy, so cherry pick the good * occasionally fall through wrt E's focus policy, so cherry pick the good
* parts and use here :) */ * parts and use here :) */
if (bd->desk != e_desk_current_get(bd->zone))
e_desk_show(bd->desk);
/* if the border is iconified then uniconify if allowed */ /* if the border is iconified then uniconify if allowed */
if ((bd->iconic) && (!bd->lock_user_iconify)) if ((bd->iconic) && (!bd->lock_user_iconify))
@ -985,6 +945,30 @@ _policy_border_activate(E_Border *bd)
e_focus_event_focus_in(bd); e_focus_event_focus_in(bd);
*/ */
} }
static Eina_Bool
_policy_border_is_dialog(E_Border *bd)
{
if (e_illume_border_is_dialog(bd))
return EINA_TRUE;
if (bd->client.e.state.centered)
return EINA_TRUE;
if (bd->internal)
{
if (bd->client.icccm.class)
{
if (!strncmp(bd->client.icccm.class, "e_fwin", 6))
return EINA_FALSE;
if (!strncmp(bd->client.icccm.class, "every", 5))
return EINA_FALSE;
}
return EINA_TRUE;
}
return EINA_FALSE;
}
void void
_policy_border_post_fetch(E_Border *bd) _policy_border_post_fetch(E_Border *bd)
@ -995,7 +979,7 @@ _policy_border_post_fetch(E_Border *bd)
if (bd->remember) e_remember_del(bd->remember); if (bd->remember) e_remember_del(bd->remember);
bd->remember = NULL; bd->remember = NULL;
if (e_illume_border_is_dialog(bd)) if (_policy_border_is_dialog(bd))
{ {
return; return;
} }
@ -1003,7 +987,7 @@ _policy_border_post_fetch(E_Border *bd)
{ {
return; return;
} }
else else if (!bd->borderless)
{ {
bd->borderless = 1; bd->borderless = 1;
bd->client.border.changed = 1; bd->client.border.changed = 1;
@ -1017,7 +1001,7 @@ _policy_border_post_assign(E_Border *bd)
bd->internal_no_remember = 1; bd->internal_no_remember = 1;
if (e_illume_border_is_dialog(bd) || if (_policy_border_is_dialog(bd) ||
e_illume_border_is_fixed_size(bd)) e_illume_border_is_fixed_size(bd))
return; return;
@ -1108,7 +1092,7 @@ _policy_zone_layout(E_Zone *zone)
else if (e_illume_border_is_splash(bd)) else if (e_illume_border_is_splash(bd))
_policy_zone_layout_splash(bd, cz); _policy_zone_layout_splash(bd, cz);
else if (e_illume_border_is_dialog(bd)) else if (_policy_border_is_dialog(bd))
_policy_zone_layout_dialog(bd, cz); _policy_zone_layout_dialog(bd, cz);
else if (e_illume_border_is_conformant(bd)) else if (e_illume_border_is_conformant(bd))
@ -1116,14 +1100,20 @@ _policy_zone_layout(E_Zone *zone)
else if (e_illume_border_is_fixed_size(bd)) else if (e_illume_border_is_fixed_size(bd))
_policy_zone_layout_dialog(bd, cz); _policy_zone_layout_dialog(bd, cz);
else if (bd->internal && bd->client.icccm.class && else if (bd->internal && bd->client.icccm.class &&
(!strcmp(bd->client.icccm.class, "everything-window"))) (!strcmp(bd->client.icccm.class, "everything-window")))
{ {
if (bd->client.vkbd.state == ECORE_X_VIRTUAL_KEYBOARD_STATE_ON) if (bd->client.vkbd.state == ECORE_X_VIRTUAL_KEYBOARD_STATE_ON)
_policy_zone_layout_app_single(bd, cz); _policy_zone_layout_app_single(bd, cz);
else /* else
_policy_zone_layout_app_dual_left(bd, cz, EINA_TRUE); * _policy_zone_layout_app_dual_left(bd, cz, EINA_TRUE); */
if (bd->layer != POL_SPLASH_LAYER)
e_border_layer_set(bd, POL_SPLASH_LAYER);
} }
else if (bd->client.e.state.centered)
_policy_zone_layout_dialog(bd, cz);
else if (!cz->mode.dual) else if (!cz->mode.dual)
_policy_zone_layout_app_single(bd, cz); _policy_zone_layout_app_single(bd, cz);
else else