From: Enlightenment S. <no-...@en...> - 2008-11-08 15:47:18
|
Log: Fix handling of windows in multiple groups after restart. Author: kwo Date: 2008-11-08 07:47:09 -0800 (Sat, 08 Nov 2008) New Revision: 37551 Modified: trunk/E16/e/src/groups.c trunk/E16/e/src/groups.h trunk/E16/e/src/snaps.c Modified: trunk/E16/e/src/groups.c =================================================================== --- trunk/E16/e/src/groups.c 2008-11-08 15:17:13 UTC (rev 37550) +++ trunk/E16/e/src/groups.c 2008-11-08 15:47:09 UTC (rev 37551) @@ -33,6 +33,13 @@ #include "timers.h" #include <math.h> +#define DEBUG_GROUPS 0 +#if DEBUG_GROUPS +#define Dprintf(fmt, ...) Eprintf("%s: " fmt, __func__, __VA_ARGS__) +#else +#define Dprintf(fmt...) +#endif + #define USE_GROUP_SHOWHIDE 0 /* Don't think this is useful. */ #define SET_OFF 0 @@ -94,6 +101,7 @@ g->cfg.shade = Conf_groups.dflt.shade; g->cfg.mirror = Conf_groups.dflt.mirror; + Dprintf("grp=%p gid=%d\n", g, g->index); return g; } @@ -103,6 +111,7 @@ if (!g) return; + Dprintf("grp=%p gid=%d\n", g, g->index); ecore_list_node_remove(group_list, g); if (g == Mode_groups.current) @@ -169,6 +178,7 @@ EWin *ewin2; Group *g2; + Dprintf("ewin=%p group=%p gid=%d\n", ewin, g, g->index); if (!ewin || !ewin->groups) return; @@ -265,40 +275,54 @@ } static void -AddEwinToGroup(EWin * ewin, Group * g) +_GroupAddEwin(Group * g, EWin * ewin) { int i; - if (ewin && g) - { - for (i = 0; i < ewin->num_groups; i++) - if (ewin->groups[i] == g) - return; - ewin->num_groups++; - ewin->groups = EREALLOC(Group *, ewin->groups, ewin->num_groups); - ewin->groups[ewin->num_groups - 1] = g; - g->num_members++; - g->members = EREALLOC(EWin *, g->members, g->num_members); - g->members[g->num_members - 1] = ewin; - SnapshotEwinUpdate(ewin, SNAP_USE_GROUPS); - } + for (i = 0; i < ewin->num_groups; i++) + if (ewin->groups[i] == g) + return; + + ewin->num_groups++; + ewin->groups = EREALLOC(Group *, ewin->groups, ewin->num_groups); + ewin->groups[ewin->num_groups - 1] = g; + g->num_members++; + g->members = EREALLOC(EWin *, g->members, g->num_members); + g->members[g->num_members - 1] = ewin; } +static void +AddEwinToGroup(EWin * ewin, Group * g) +{ + if (!ewin || !g) + return; + + _GroupAddEwin(g, ewin); + SnapshotEwinUpdate(ewin, SNAP_USE_GROUPS); +} + void -GroupsEwinAdd(EWin * ewin, int gid) +GroupsEwinAdd(EWin * ewin, const int *pgid, int ngid) { - Group *group; + Group *g; + int i, gid; - group = GroupFind(gid); - if (!group) + for (i = 0; i < ngid; i++) { - /* This should not happen, but may if group/snap configs are corrupted */ - BuildWindowGroup(&ewin, 1, gid); + gid = pgid[i]; + g = GroupFind(gid); + Dprintf("ewin=%p gid=%d grp=%p\n", ewin, gid, g); + if (!g) + { + /* This should not happen, but may if group/snap configs are corrupted */ + BuildWindowGroup(&ewin, 1, gid); + } + else + { + _GroupAddEwin(g, ewin); + } } - else - { - AddEwinToGroup(ewin, group); - } + SnapshotEwinUpdate(ewin, SNAP_USE_GROUPS); } static int Modified: trunk/E16/e/src/groups.h =================================================================== --- trunk/E16/e/src/groups.h 2008-11-08 15:17:13 UTC (rev 37550) +++ trunk/E16/e/src/groups.h 2008-11-08 15:47:09 UTC (rev 37551) @@ -66,7 +66,7 @@ /* groups.c */ Group *const *EwinGetGroups(const EWin * ewin, int *num); Group *EwinsInGroup(const EWin * ewin1, const EWin * ewin2); -void GroupsEwinAdd(EWin * ewin, int gid); +void GroupsEwinAdd(EWin * ewin, const int *pgid, int ngid); void GroupsEwinRemove(EWin * ewin); void GroupsLoad(void); void GroupsSave(void); Modified: trunk/E16/e/src/snaps.c =================================================================== --- trunk/E16/e/src/snaps.c 2008-11-08 15:17:13 UTC (rev 37550) +++ trunk/E16/e/src/snaps.c 2008-11-08 15:47:09 UTC (rev 37551) @@ -1405,7 +1405,7 @@ SnapshotEwinApply(EWin * ewin) { Snapshot *sn; - int i, ax, ay; + int ax, ay; unsigned int use_flags; _SnapEwinFind(ewin); /* Find a saved settings match */ @@ -1476,8 +1476,8 @@ if (use_flags & SNAP_USE_BORDER) EwinSetBorderByName(ewin, sn->border_name); - for (i = 0; i < sn->num_groups; i++) - GroupsEwinAdd(ewin, sn->groups[i]); + if (use_flags & SNAP_USE_GROUPS) + GroupsEwinAdd(ewin, sn->groups, sn->num_groups); #if USE_COMPOSITE if (use_flags & SNAP_USE_OPACITY) |