handle resolution changes much mroe gracefully for windows - temporarily

resize/move but store their info BEFORE res change and always TRY and restore
it until an app or u ser asks to move/resize a window explicitly (if you
leave them alone they will be happy)


SVN revision: 23457
This commit is contained in:
Carsten Haitzler 2006-06-16 08:50:42 +00:00
parent 0c8af50544
commit c2d5976dc4
4 changed files with 231 additions and 180 deletions

13
TODO
View File

@ -59,19 +59,6 @@ Some of the things (in very short form) that need to be done to E17...
is not to hard - it's the xml jungle of the system menus that is sucky. the is not to hard - it's the xml jungle of the system menus that is sucky. the
real problems are where to find the icons for the .desktop files. real problems are where to find the icons for the .desktop files.
* middle mouse on gadgets as a quick move/resize thing? * middle mouse on gadgets as a quick move/resize thing?
* on xrandr screen res change e moves and resizes windows to fit in the new
resolution. this is good and bad. if some other app temporarily changes
res this means everything gets squeezed. we need a "temporary resize due to
res change" geometry state for apps where they get resized to a new pos/size
and the old size/pos stored. on a move or resize etc. by a user this old
geom is freed, but on a res change, e takes the old geom, if there, and
tries to use it (then limiting geom to the new screen res as it cuurently
does) otherwise it creates a new saved geom for the cur geom before
limiting it. maximized windows are reset to their old size/pos then
re-maximized too. old szie from unmaximize needs to have this check too
on unmaximize as do fullscreen windows. NB: what if app moves/resizes
itself during this - i assume for now all bets are off with prior geometry
then.
* language packs: need to have a tool to load/setup a language pack (which * language packs: need to have a tool to load/setup a language pack (which
means .mo compiled files from a .po, an optional font and a config file that means .mo compiled files from a .po, an optional font and a config file that
specifies the locale and font) and then install the font(s) either as a user specifies the locale and font) and then install the font(s) either as a user

View File

@ -473,6 +473,90 @@ e_border_new(E_Container *con, Ecore_X_Window win, int first_map, int internal)
return bd; return bd;
} }
EAPI void
e_border_res_change_geometry_save(E_Border *bd)
{
E_OBJECT_CHECK(bd);
E_OBJECT_TYPE_CHECK(bd, E_BORDER_TYPE);
if (bd->pre_res_change.valid) return;
bd->pre_res_change.valid = 1;
bd->pre_res_change.x = bd->x;
bd->pre_res_change.y = bd->y;
bd->pre_res_change.w = bd->w;
bd->pre_res_change.h = bd->h;
bd->pre_res_change.saved.x = bd->saved.x;
bd->pre_res_change.saved.y = bd->saved.y;
bd->pre_res_change.saved.w = bd->saved.w;
bd->pre_res_change.saved.h = bd->saved.h;
}
EAPI void
e_border_res_change_geometry_restore(E_Border *bd)
{
struct {
unsigned char valid : 1;
int x, y, w, h;
struct {
int x, y, w, h;
} saved;
} pre_res_change;
E_OBJECT_CHECK(bd);
E_OBJECT_TYPE_CHECK(bd, E_BORDER_TYPE);
if (!bd->pre_res_change.valid) return ;
memcpy(&pre_res_change, &bd->pre_res_change, sizeof(pre_res_change));
if (bd->fullscreen)
{
e_border_unfullscreen(bd);
e_border_fullscreen(bd, e_config->fullscreen_policy);
}
else if (bd->maximized != E_MAXIMIZE_NONE)
{
E_Maximize max;
max = bd->maximized;
e_border_unmaximize(bd, E_MAXIMIZE_BOTH);
e_border_maximize(bd, max);
}
else
{
int x, y, w, h;
bd->saved.x = bd->pre_res_change.saved.x;
bd->saved.y = bd->pre_res_change.saved.y;
bd->saved.w = bd->pre_res_change.saved.w;
bd->saved.h = bd->pre_res_change.saved.h;
if (bd->saved.w > bd->zone->w)
bd->saved.w = bd->zone->w;
if ((bd->saved.x + bd->saved.w) > (bd->zone->x + bd->zone->w))
bd->saved.x = bd->zone->x + bd->zone->w - bd->saved.w;
if (bd->saved.h > bd->zone->h)
bd->saved.h = bd->zone->h;
if ((bd->saved.y + bd->saved.h) > (bd->zone->y + bd->zone->h))
bd->saved.y = bd->zone->y + bd->zone->h - bd->saved.h;
x = bd->pre_res_change.x;
y = bd->pre_res_change.y;
w = bd->pre_res_change.w;
h = bd->pre_res_change.h;
if (w > bd->zone->w)
w = bd->zone->w;
if (h > bd->zone->h)
h = bd->zone->h;
if ((x + w) > (bd->zone->x + bd->zone->w))
x = bd->zone->x + bd->zone->w - w;
if ((y + h) > (bd->zone->y + bd->zone->h))
y = bd->zone->y + bd->zone->h - h;
e_border_move_resize(bd, x, y, w, h);
}
memcpy(&bd->pre_res_change, &pre_res_change, sizeof(pre_res_change));
}
EAPI void EAPI void
e_border_zone_set(E_Border *bd, E_Zone *zone) e_border_zone_set(E_Border *bd, E_Zone *zone)
{ {
@ -687,6 +771,7 @@ e_border_move(E_Border *bd, int x, int y)
return; return;
} }
if ((x == bd->x) && (y == bd->y)) return; if ((x == bd->x) && (y == bd->y)) return;
bd->pre_res_change.valid = 0;
bd->x = x; bd->x = x;
bd->y = y; bd->y = y;
bd->changed = 1; bd->changed = 1;
@ -740,6 +825,7 @@ e_border_resize(E_Border *bd, int w, int h)
return; return;
} }
if ((w == bd->w) && (h == bd->h)) return; if ((w == bd->w) && (h == bd->h)) return;
bd->pre_res_change.valid = 0;
bd->w = w; bd->w = w;
bd->h = h; bd->h = h;
bd->client.w = bd->w - (bd->client_inset.l + bd->client_inset.r); bd->client.w = bd->w - (bd->client_inset.l + bd->client_inset.r);
@ -801,6 +887,7 @@ e_border_move_resize(E_Border *bd, int x, int y, int w, int h)
return; return;
} }
if ((x == bd->x) && (y == bd->y) && (w == bd->w) && (h == bd->h)) return; if ((x == bd->x) && (y == bd->y) && (w == bd->w) && (h == bd->h)) return;
bd->pre_res_change.valid = 0;
bd->x = x; bd->x = x;
bd->y = y; bd->y = y;
bd->w = w; bd->w = w;
@ -1556,6 +1643,7 @@ e_border_maximize(E_Border *bd, E_Maximize max)
int x1, y1, x2, y2; int x1, y1, x2, y2;
int w, h; int w, h;
bd->pre_res_change.valid = 0;
if (!(bd->maximized & E_MAXIMIZE_HORIZONTAL)) if (!(bd->maximized & E_MAXIMIZE_HORIZONTAL))
{ {
/* Horisontal hasn't been set */ /* Horisontal hasn't been set */
@ -1690,6 +1778,7 @@ e_border_unmaximize(E_Border *bd, E_Maximize max)
E_Maximize dir; E_Maximize dir;
int signal; int signal;
bd->pre_res_change.valid = 0;
/* Get the resulting directions */ /* Get the resulting directions */
dir = (bd->maximized & E_MAXIMIZE_DIRECTION); dir = (bd->maximized & E_MAXIMIZE_DIRECTION);
dir &= ~max; dir &= ~max;
@ -1806,6 +1895,7 @@ e_border_fullscreen(E_Border *bd, E_Fullscreen policy)
#if 0 #if 0
int x, y, w, h; int x, y, w, h;
#endif #endif
bd->pre_res_change.valid = 0;
bd->saved.x = bd->x; bd->saved.x = bd->x;
bd->saved.y = bd->y; bd->saved.y = bd->y;
@ -1901,6 +1991,7 @@ e_border_unfullscreen(E_Border *bd)
if ((bd->shaded) || (bd->shading)) return; if ((bd->shaded) || (bd->shading)) return;
if (bd->fullscreen) if (bd->fullscreen)
{ {
bd->pre_res_change.valid = 0;
// printf("UNFULLSCREEEN!\n"); // printf("UNFULLSCREEEN!\n");
bd->fullscreen = 0; bd->fullscreen = 0;
bd->need_fullscreen = 0; bd->need_fullscreen = 0;

View File

@ -380,6 +380,14 @@ struct _E_Border
int x, y, w, h; int x, y, w, h;
} saved; } saved;
struct {
unsigned char valid : 1;
int x, y, w, h;
struct {
int x, y, w, h;
} saved;
} pre_res_change;
struct { struct {
double start; double start;
double val; double val;
@ -534,6 +542,9 @@ EAPI E_Border *e_border_new(E_Container *con, Ecore_X_Window win, int first_map,
EAPI void e_border_free(E_Border *bd); EAPI void e_border_free(E_Border *bd);
EAPI void e_border_ref(E_Border *bd); EAPI void e_border_ref(E_Border *bd);
EAPI void e_border_unref(E_Border *bd); EAPI void e_border_unref(E_Border *bd);
EAPI void e_border_res_change_geometry_save(E_Border *bd);
EAPI void e_border_res_change_geometry_restore(E_Border *bd);
EAPI void e_border_zone_set(E_Border *bd, E_Zone *zone); EAPI void e_border_zone_set(E_Border *bd, E_Zone *zone);
EAPI void e_border_desk_set(E_Border *bd, E_Desk *desk); EAPI void e_border_desk_set(E_Border *bd, E_Desk *desk);
EAPI void e_border_show(E_Border *bd); EAPI void e_border_show(E_Border *bd);

View File

@ -1141,17 +1141,14 @@ _e_container_resize_handle(E_Container *con)
{ {
E_Event_Container_Resize *ev; E_Event_Container_Resize *ev;
Evas_List *l, *screens; Evas_List *l, *screens;
#if 1
int i; int i;
#endif
ev = calloc(1, sizeof(E_Event_Container_Resize)); ev = calloc(1, sizeof(E_Event_Container_Resize));
ev->container = con; ev->container = con;
e_object_ref(E_OBJECT(con));
e_gadman_all_save(con->gadman); e_gadman_all_save(con->gadman);
e_xinerama_update(); e_xinerama_update();
screens = (Evas_List *)e_xinerama_screens_get(); screens = (Evas_List *)e_xinerama_screens_get();
if (screens) if (screens)
{ {
@ -1169,9 +1166,12 @@ _e_container_resize_handle(E_Container *con)
} }
else else
zone = e_zone_new(con, scr->screen, scr->x, scr->y, scr->w, scr->h); zone = e_zone_new(con, scr->screen, scr->x, scr->y, scr->w, scr->h);
/* FIXME: what if a zone exists for a screen that doesn't exist? }
* not sure this will ever happen... if (evas_list_count(con->zones) != evas_list_count(screens))
*/ {
/* xinerama screens where deleted! eek! */
/* FIXME: handle deletion of a zone! */
printf("FIXME: handle deletion of xinerama screens\n");
} }
} }
else else
@ -1184,12 +1184,9 @@ _e_container_resize_handle(E_Container *con)
} }
e_gadman_container_resize(con->gadman); e_gadman_container_resize(con->gadman);
e_object_ref(E_OBJECT(con));
ecore_event_add(E_EVENT_CONTAINER_RESIZE, ev, _e_container_event_container_resize_free, NULL); ecore_event_add(E_EVENT_CONTAINER_RESIZE, ev, _e_container_event_container_resize_free, NULL);
#if 1
/* FIXME: This is wrong, we should only move/resize to save things from
* disappearing!
*/
for (i = 0; i < 7; i++) for (i = 0; i < 7; i++)
{ {
for (l = con->layers[i].clients; l; l = l->next) for (l = con->layers[i].clients; l; l = l->next)
@ -1197,45 +1194,10 @@ _e_container_resize_handle(E_Container *con)
E_Border *bd; E_Border *bd;
bd = l->data; bd = l->data;
e_border_res_change_geometry_save(bd);
if (bd->saved.w > bd->zone->w) e_border_res_change_geometry_restore(bd);
bd->saved.w = bd->zone->w;
if ((bd->saved.x + bd->saved.w) > (bd->zone->x + bd->zone->w))
bd->saved.x = bd->zone->x + bd->zone->w - bd->saved.w;
if (bd->saved.h > bd->zone->h)
bd->saved.h = bd->zone->h;
if ((bd->saved.y + bd->saved.h) > (bd->zone->y + bd->zone->h))
bd->saved.y = bd->zone->y + bd->zone->h - bd->saved.h;
if (bd->fullscreen)
{
e_border_unfullscreen(bd);
e_border_fullscreen(bd, e_config->fullscreen_policy);
}
else if (bd->maximized != E_MAXIMIZE_NONE)
{
E_Maximize max;
max = bd->maximized;
e_border_unmaximize(bd, E_MAXIMIZE_BOTH);
e_border_maximize(bd, max);
}
else
{
if (bd->w > bd->zone->w)
e_border_resize(bd, bd->zone->w, bd->h);
if ((bd->x + bd->w) > (bd->zone->x + bd->zone->w))
e_border_move(bd, bd->zone->x + bd->zone->w - bd->w, bd->y);
if (bd->h > bd->zone->h)
e_border_resize(bd, bd->w, bd->zone->h);
if ((bd->y + bd->h) > (bd->zone->y + bd->zone->h))
e_border_move(bd, bd->x, bd->zone->y + bd->zone->h - bd->h);
} }
} }
}
#endif
} }
static void static void