summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core.cpp50
-rw-r--r--src/plugin.cpp2
-rw-r--r--src/privatecore.h4
-rw-r--r--src/privatescreen.h6
-rw-r--r--src/screen.cpp40
5 files changed, 44 insertions, 58 deletions
diff --git a/src/core.cpp b/src/core.cpp
index 327d0eb..890787d 100644
--- a/src/core.cpp
+++ b/src/core.cpp
@@ -28,6 +28,9 @@
#include <assert.h>
#include <algorithm>
+#include <boost/foreach.hpp>
+#define foreach BOOST_FOREACH
+
#include <compiz-core.h>
#include "privatecore.h"
@@ -95,10 +98,13 @@ CompCore::init ()
CompCore::~CompCore ()
{
- CompPlugin *p;
+ CompPlugin *p;
- while (priv->displays)
- removeDisplay (priv->displays);
+ while (!priv->displays.empty ())
+ {
+ removeDisplay (priv->displays.front ());
+ priv->displays.pop_front ();
+ }
if (priv->watchPollFds)
free (priv->watchPollFds);
@@ -115,7 +121,7 @@ CompCore::name ()
}
-CompDisplay *
+CompDisplayList &
CompCore::displays()
{
return priv->displays;
@@ -124,26 +130,16 @@ CompCore::displays()
bool
CompCore::addDisplay (const char *name)
{
-
- CompDisplay *prev;
CompDisplay *d = new CompDisplay();
if (!d)
return false;
- for (prev = priv->displays; prev && prev->next; prev = prev->next);
-
- if (prev)
- prev->next = d;
- else
- priv->displays = d;
+ priv->displays.push_back (d);
if (!d->init (name))
{
- if (prev)
- prev->next = NULL;
- else
- priv->displays = NULL;
+ priv->displays.pop_back ();
delete d;
return false;
}
@@ -153,16 +149,9 @@ CompCore::addDisplay (const char *name)
void
CompCore::removeDisplay (CompDisplay *d)
{
- CompDisplay *p;
-
- for (p = priv->displays; p; p = p->next)
- if (p->next == d)
- break;
-
- if (p)
- p->next = d->next;
- else
- priv->displays = NULL;
+ CompDisplayList::iterator it;
+ it = std::find (priv->displays.begin (), priv->displays.end (), d);
+ priv->displays.erase (it);
delete d;
}
@@ -171,11 +160,10 @@ void
CompCore::eventLoop ()
{
struct timeval tv;
- CompDisplay *d;
CompCore::Timer *t;
int time;
- for (d = priv->displays; d; d = d->next)
+ foreach (CompDisplay *d, priv->displays)
d->setWatchFdHandle (addWatchFd (ConnectionNumber (d->dpy()),
POLLIN, NULL, NULL));
@@ -184,10 +172,8 @@ CompCore::eventLoop ()
if (restartSignal || shutDown)
break;
- for (d = priv->displays; d; d = d->next)
- {
+ foreach (CompDisplay *d, priv->displays)
d->processEvents ();
- }
if (!priv->timers.empty())
{
@@ -220,7 +206,7 @@ CompCore::eventLoop ()
}
}
- for (d = priv->displays; d; d = d->next)
+ foreach (CompDisplay *d, priv->displays)
removeWatchFd (d->getWatchFdHandle());
}
diff --git a/src/plugin.cpp b/src/plugin.cpp
index 7ebcd05..88e0cbf 100644
--- a/src/plugin.cpp
+++ b/src/plugin.cpp
@@ -683,7 +683,7 @@ getPluginABI (const char *name)
/* MULTIDPYERROR: ABI options should be moved into core */
CompOption::Vector &options =
- p->vTable->getObjectOptions (core->displays());
+ p->vTable->getObjectOptions (core->displays().front ());
return CompOption::getIntOptionNamed (options, "abi");
}
diff --git a/src/privatecore.h b/src/privatecore.h
index 3f0ef01..b21f483 100644
--- a/src/privatecore.h
+++ b/src/privatecore.h
@@ -24,8 +24,8 @@ class PrivateCore {
public:
- CompCore *core;
- CompDisplay *displays;
+ CompCore *core;
+ CompDisplayList displays;
std::list<CompFileWatch *> fileWatch;
CompFileWatchHandle lastFileWatchHandle;
diff --git a/src/privatescreen.h b/src/privatescreen.h
index 151cb13..3f46b88 100644
--- a/src/privatescreen.h
+++ b/src/privatescreen.h
@@ -227,9 +227,9 @@ class PrivateScreen {
CompScreenEdge screenEdge[SCREEN_EDGE_NUM];
- SnMonitorContext *snContext;
- CompStartupSequence *startupSequences;
- CompCore::Timer startupSequenceTimer;
+ SnMonitorContext *snContext;
+ std::list<CompStartupSequence *> startupSequences;
+ CompCore::Timer startupSequenceTimer;
CompTexture::Filter filter[3];
diff --git a/src/screen.cpp b/src/screen.cpp
index 742459e..8a929b4 100644
--- a/src/screen.cpp
+++ b/src/screen.cpp
@@ -513,7 +513,7 @@ const CompMetadata::OptionInfo coreScreenOptionInfo[COMP_SCREEN_OPTION_NUM] = {
void
PrivateScreen::updateStartupFeedback ()
{
- if (startupSequences)
+ if (!startupSequences.empty ())
XDefineCursor (display->dpy (), root, busyCursor);
else
XDefineCursor (display->dpy (), root, normalCursor);
@@ -530,7 +530,7 @@ PrivateScreen::handleStartupSequenceTimeout()
gettimeofday (&now, NULL);
- for (s = startupSequences; s; s = s->next)
+ foreach (CompStartupSequence *s, startupSequences)
{
sn_startup_sequence_get_last_active_time (s->sequence,
&active.tv_sec,
@@ -551,18 +551,17 @@ PrivateScreen::addSequence (SnStartupSequence *sequence)
{
CompStartupSequence *s;
- s = (CompStartupSequence *) malloc (sizeof (CompStartupSequence));
+ s = new CompStartupSequence ();
if (!s)
return;
sn_startup_sequence_ref (sequence);
- s->next = startupSequences;
s->sequence = sequence;
s->viewportX = vp.x ();
s->viewportY = vp.y ();
- startupSequences = s;
+ startupSequences.push_front (s);
if (!startupSequenceTimer.active ())
startupSequenceTimer.start (
@@ -575,14 +574,17 @@ PrivateScreen::addSequence (SnStartupSequence *sequence)
void
PrivateScreen::removeSequence (SnStartupSequence *sequence)
{
- CompStartupSequence *s, *p = NULL;
+ CompStartupSequence *s = NULL;
- for (s = startupSequences; s; s = s->next)
+ std::list<CompStartupSequence *>::iterator it = startupSequences.begin ();
+
+ while (it != startupSequences.end ())
{
- if (s->sequence == sequence)
+ if ((*it)->sequence == sequence)
+ {
+ s = (*it);
break;
-
- p = s;
+ }
}
if (!s)
@@ -590,14 +592,9 @@ PrivateScreen::removeSequence (SnStartupSequence *sequence)
sn_startup_sequence_unref (sequence);
- if (p)
- p->next = s->next;
- else
- startupSequences = NULL;
+ startupSequences.erase (it);
- free (s);
-
- if (!startupSequences && startupSequenceTimer.active ())
+ if (startupSequences.empty () && startupSequenceTimer.active ())
startupSequenceTimer.stop ();
updateStartupFeedback ();
@@ -3391,7 +3388,7 @@ CompScreen::findGroup (Window id)
void
CompScreen::applyStartupProperties (CompWindow *window)
{
- CompStartupSequence *s;
+ CompStartupSequence *s = NULL;
const char *startupId = window->startupId ();
if (!startupId)
@@ -3406,13 +3403,16 @@ CompScreen::applyStartupProperties (CompWindow *window)
return;
}
- for (s = priv->startupSequences; s; s = s->next)
+ foreach (CompStartupSequence *ss, priv->startupSequences)
{
const char *id;
- id = sn_startup_sequence_get_id (s->sequence);
+ id = sn_startup_sequence_get_id (ss->sequence);
if (strcmp (id, startupId) == 0)
+ {
+ s = ss;
break;
+ }
}
if (s)