summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDennis Kasprzyk <onestone@compiz-fusion.org>2008-08-20 17:21:40 +0200
committerDennis kasprzyk <onestone@compiz-fusion.org>2008-08-20 17:21:40 +0200
commitefd69ec9e805e2e54cdbcff2de126a94ad87ea7a (patch)
tree0861556d92f71a7d4c88e095fff33d34fa9ad1bb /src
parent89f41a715064c746ab5f73acd34e14f834379d0a (diff)
downloadcompiz-with-glib-mainloop-efd69ec9e805e2e54cdbcff2de126a94ad87ea7a.tar.gz
compiz-with-glib-mainloop-efd69ec9e805e2e54cdbcff2de126a94ad87ea7a.tar.bz2
Store CompGroups in a list.
Diffstat (limited to 'src')
-rw-r--r--src/privatescreen.h2
-rw-r--r--src/screen.cpp35
2 files changed, 10 insertions, 27 deletions
diff --git a/src/privatescreen.h b/src/privatescreen.h
index d6a48e4..151cb13 100644
--- a/src/privatescreen.h
+++ b/src/privatescreen.h
@@ -233,7 +233,7 @@ class PrivateScreen {
CompTexture::Filter filter[3];
- CompGroup *groups;
+ std::list<CompGroup *> groups;
CompIcon *defaultIcon;
diff --git a/src/screen.cpp b/src/screen.cpp
index 926c03b..742459e 100644
--- a/src/screen.cpp
+++ b/src/screen.cpp
@@ -3350,17 +3350,12 @@ CompScreen::moveViewport (int tx, int ty, bool sync)
CompGroup *
CompScreen::addGroup (Window id)
{
- CompGroup *group;
+ CompGroup *group = new CompGroup ();
- group = (CompGroup *) malloc (sizeof (CompGroup));
- if (!group)
- return NULL;
-
- group->next = priv->groups;
group->refCnt = 1;
group->id = id;
- priv->groups = group;
+ priv->groups.push_back (group);
return group;
}
@@ -3372,33 +3367,21 @@ CompScreen::removeGroup (CompGroup *group)
if (group->refCnt)
return;
- if (group == priv->groups)
- {
- priv->groups = group->next;
- }
- else
- {
- CompGroup *g;
+ std::list<CompGroup *>::iterator it =
+ std::find (priv->groups.begin (), priv->groups.end (), group);
- for (g = priv->groups; g; g = g->next)
- {
- if (g->next == group)
- {
- g->next = group->next;
- break;
- }
- }
+ if (it != priv->groups.end ())
+ {
+ priv->groups.erase (it);
}
- free (group);
+ delete group;
}
CompGroup *
CompScreen::findGroup (Window id)
{
- CompGroup *g;
-
- for (g = priv->groups; g; g = g->next)
+ foreach (CompGroup *g, priv->groups)
if (g->id == id)
return g;