summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/compcore.h3
-rw-r--r--include/compiz-core.h47
-rw-r--r--include/compscreen.h46
-rw-r--r--include/compwindow.h1
-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
9 files changed, 93 insertions, 106 deletions
diff --git a/include/compcore.h b/include/compcore.h
index 9b2af78..e2e0f48 100644
--- a/include/compcore.h
+++ b/include/compcore.h
@@ -11,6 +11,7 @@
class PrivateCore;
class CompCore;
class CompDisplay;
+typedef std::list<CompDisplay *> CompDisplayList;
#define NOTIFY_CREATE_MASK (1 << 0)
#define NOTIFY_DELETE_MASK (1 << 1)
@@ -139,7 +140,7 @@ class CompCore : public WrapableHandler<CoreInterface>, public CompObject {
void
eventLoop ();
- CompDisplay *
+ CompDisplayList &
displays();
CompFileWatchHandle
diff --git a/include/compiz-core.h b/include/compiz-core.h
index 873a2b2..b07916f 100644
--- a/include/compiz-core.h
+++ b/include/compiz-core.h
@@ -278,53 +278,6 @@ struct _CompWalker {
/* screen.c */
-#define MAX_DEPTH 32
-
-
-typedef struct _CompStartupSequence {
- struct _CompStartupSequence *next;
- SnStartupSequence *sequence;
- unsigned int viewportX;
- unsigned int viewportY;
-} CompStartupSequence;
-
-typedef struct _CompFBConfig {
- GLXFBConfig fbConfig;
- int yInverted;
- int mipmap;
- int textureFormat;
- int textureTargets;
-} CompFBConfig;
-
-#define NOTHING_TRANS_FILTER 0
-#define SCREEN_TRANS_FILTER 1
-#define WINDOW_TRANS_FILTER 2
-
-#define SCREEN_EDGE_LEFT 0
-#define SCREEN_EDGE_RIGHT 1
-#define SCREEN_EDGE_TOP 2
-#define SCREEN_EDGE_BOTTOM 3
-#define SCREEN_EDGE_TOPLEFT 4
-#define SCREEN_EDGE_TOPRIGHT 5
-#define SCREEN_EDGE_BOTTOMLEFT 6
-#define SCREEN_EDGE_BOTTOMRIGHT 7
-#define SCREEN_EDGE_NUM 8
-
-typedef struct _CompScreenEdge {
- Window id;
- unsigned int count;
-} CompScreenEdge;
-
-
-#define ACTIVE_WINDOW_HISTORY_SIZE 64
-#define ACTIVE_WINDOW_HISTORY_NUM 32
-
-typedef struct _CompActiveWindowHistory {
- Window id[ACTIVE_WINDOW_HISTORY_SIZE];
- int x;
- int y;
- int activeNum;
-} CompActiveWindowHistory;
/* window.c */
diff --git a/include/compscreen.h b/include/compscreen.h
index 1218cbc..09854ea 100644
--- a/include/compscreen.h
+++ b/include/compscreen.h
@@ -140,6 +140,52 @@ struct CompGroup {
Window id;
};
+struct CompStartupSequence {
+ SnStartupSequence *sequence;
+ unsigned int viewportX;
+ unsigned int viewportY;
+};
+
+#define MAX_DEPTH 32
+
+struct CompFBConfig {
+ GLXFBConfig fbConfig;
+ int yInverted;
+ int mipmap;
+ int textureFormat;
+ int textureTargets;
+};
+
+#define NOTHING_TRANS_FILTER 0
+#define SCREEN_TRANS_FILTER 1
+#define WINDOW_TRANS_FILTER 2
+
+#define SCREEN_EDGE_LEFT 0
+#define SCREEN_EDGE_RIGHT 1
+#define SCREEN_EDGE_TOP 2
+#define SCREEN_EDGE_BOTTOM 3
+#define SCREEN_EDGE_TOPLEFT 4
+#define SCREEN_EDGE_TOPRIGHT 5
+#define SCREEN_EDGE_BOTTOMLEFT 6
+#define SCREEN_EDGE_BOTTOMRIGHT 7
+#define SCREEN_EDGE_NUM 8
+
+struct CompScreenEdge {
+ Window id;
+ unsigned int count;
+};
+
+
+#define ACTIVE_WINDOW_HISTORY_SIZE 64
+#define ACTIVE_WINDOW_HISTORY_NUM 32
+
+struct CompActiveWindowHistory {
+ Window id[ACTIVE_WINDOW_HISTORY_SIZE];
+ int x;
+ int y;
+ int activeNum;
+};
+
class ScreenInterface : public WrapableInterface<CompScreen> {
public:
ScreenInterface ();
diff --git a/include/compwindow.h b/include/compwindow.h
index 19cf159..d0009bb 100644
--- a/include/compwindow.h
+++ b/include/compwindow.h
@@ -9,6 +9,7 @@
class CompWindow;
class PrivateWindow;
+struct CompStartupSequence;
#define GET_CORE_WINDOW(object) (dynamic_cast<CompWindow *> (object))
#define CORE_WINDOW(object) CompWindow *w = GET_CORE_WINDOW (object)
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)