|
From: Enlightenment S. <no-...@en...> - 2008-10-18 16:10:12
|
Log:
Fix breakage when group in snapshot is unknown.
Author: kwo
Date: 2008-10-18 09:10:11 -0700 (Sat, 18 Oct 2008)
New Revision: 36785
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-10-18 16:05:04 UTC (rev 36784)
+++ trunk/E16/e/src/groups.c 2008-10-18 16:10:11 UTC (rev 36785)
@@ -50,6 +50,7 @@
Group *current;
} Mode_groups;
+static void AddEwinToGroup(EWin * ewin, Group * g);
static void RemoveEwinFromGroup(EWin * ewin, Group * g);
int
@@ -59,7 +60,7 @@
}
static Group *
-GroupCreate(void)
+GroupCreate(int gid)
{
Group *g;
double t;
@@ -72,10 +73,18 @@
group_list = ecore_list_new();
ecore_list_append(group_list, g);
- t = GetTime();
- g->index = (int)((GetTime() - (floor(t / 1000) * 1000)) * 10000);
- /* g->index = (int)(GetTime() * 100); */
-
+ if (gid == -1)
+ {
+ /* Create new group id */
+ t = GetTime();
+ g->index = (int)((GetTime() - (floor(t / 1000) * 1000)) * 10000);
+ /* g->index = (int)(GetTime() * 100); */
+ }
+ else
+ {
+ /* Use given group id */
+ g->index = gid;
+ }
g->cfg.iconify = Conf_groups.dflt.iconify;
g->cfg.kill = Conf_groups.dflt.kill;
g->cfg.move = Conf_groups.dflt.move;
@@ -111,7 +120,7 @@
return ((const Group *)data)->index != (int)(long)match;
}
-Group *
+static Group *
GroupFind(int gid)
{
return (Group *) ecore_list_find(group_list, GroupMatchId,
@@ -134,12 +143,6 @@
return GroupFind(gid);
}
-void
-GroupSetId(Group * group, int gid)
-{
- group->index = gid;
-}
-
static void
CopyGroupConfig(GroupConfig * src, GroupConfig * dest)
{
@@ -175,18 +178,16 @@
}
}
-Group *
-BuildWindowGroup(EWin ** ewins, int num)
+static void
+BuildWindowGroup(EWin ** ewins, int num, int gid)
{
int i;
Group *group;
- Mode_groups.current = group = GroupCreate();
+ Mode_groups.current = group = GroupCreate(gid);
for (i = 0; i < num; i++)
AddEwinToGroup(ewins[i], group);
-
- return group;
}
Group **
@@ -247,7 +248,7 @@
return groups;
}
-void
+static void
AddEwinToGroup(EWin * ewin, Group * g)
{
int i;
@@ -267,6 +268,23 @@
}
}
+void
+GroupsEwinAdd(EWin * ewin, int gid)
+{
+ Group *group;
+
+ group = GroupFind(gid);
+ if (!group)
+ {
+ /* This should not happen, but may if group/snap configs are corrupted */
+ BuildWindowGroup(&ewin, 1, gid);
+ }
+ else
+ {
+ AddEwinToGroup(ewin, group);
+ }
+}
+
static int
EwinInGroup(const EWin * ewin, const Group * g)
{
@@ -544,9 +562,7 @@
if (!strcmp(ss, "NEW:"))
{
- g = GroupCreate();
- if (g)
- g->index = ii;
+ g = GroupCreate(ii);
continue;
}
if (!g)
@@ -1150,7 +1166,7 @@
if (!strcmp(operation, "start"))
{
- BuildWindowGroup(&ewin, 1);
+ BuildWindowGroup(&ewin, 1, -1);
IpcPrintf("start %8x", win);
}
else if (!strcmp(operation, "add"))
Modified: trunk/E16/e/src/groups.h
===================================================================
--- trunk/E16/e/src/groups.h 2008-10-18 16:05:04 UTC (rev 36784)
+++ trunk/E16/e/src/groups.h 2008-10-18 16:10:11 UTC (rev 36785)
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
- * Copyright (C) 2004-2007 Kim Woelders
+ * Copyright (C) 2004-2008 Kim Woelders
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
@@ -63,11 +63,8 @@
char nogroup, int *num);
/* groups.c */
-Group *BuildWindowGroup(EWin ** ewins, int num);
Group *EwinsInGroup(const EWin * ewin1, const EWin * ewin2);
-void AddEwinToGroup(EWin * ewin, Group * g);
-Group *GroupFind(int gid);
-void GroupSetId(Group * group, int gid);
+void GroupsEwinAdd(EWin * ewin, int gid);
void GroupsEwinRemove(EWin * ewin);
void SaveGroups(void);
Group **GroupsGetList(int *pnum);
Modified: trunk/E16/e/src/snaps.c
===================================================================
--- trunk/E16/e/src/snaps.c 2008-10-18 16:05:04 UTC (rev 36784)
+++ trunk/E16/e/src/snaps.c 2008-10-18 16:10:11 UTC (rev 36785)
@@ -1473,23 +1473,9 @@
if (use_flags & SNAP_USE_BORDER)
EwinSetBorderByName(ewin, sn->border_name);
- if (sn->groups)
- {
- for (i = 0; i < sn->num_groups; i++)
- {
- Group *group;
+ for (i = 0; i < sn->num_groups; i++)
+ GroupsEwinAdd(ewin, sn->groups[i]);
- group = GroupFind(sn->groups[i]);
- if (!group)
- {
- group = BuildWindowGroup(&ewin, 1);
- GroupSetId(group, sn->groups[i]);
- }
- else
- AddEwinToGroup(ewin, group);
- }
- }
-
#if USE_COMPOSITE
if (use_flags & SNAP_USE_OPACITY)
{
|