summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Kasprzyk <onestone@compiz-fusion.org>2008-08-20 18:11:09 +0200
committerDennis kasprzyk <onestone@compiz-fusion.org>2008-08-20 18:11:09 +0200
commit5c7a3b43ea2f387754d182a2eb6b64cad918ed16 (patch)
tree85ab76c199d9b4cac1782bbe6ce77e4b301049b8
parent29762204b911f983b05acbcc77a3363a3b66012e (diff)
downloadzcomp-5c7a3b43ea2f387754d182a2eb6b64cad918ed16.tar.gz
zcomp-5c7a3b43ea2f387754d182a2eb6b64cad918ed16.tar.bz2
Store Screens in a STL list.
-rw-r--r--include/compdisplay.h4
-rw-r--r--src/display.cpp78
-rw-r--r--src/event.cpp10
-rw-r--r--src/match.cpp3
-rw-r--r--src/metadata.cpp12
-rw-r--r--src/option.cpp26
-rw-r--r--src/privatedisplay.h2
7 files changed, 54 insertions, 81 deletions
diff --git a/include/compdisplay.h b/include/compdisplay.h
index 5a224fb..aace93b 100644
--- a/include/compdisplay.h
+++ b/include/compdisplay.h
@@ -9,6 +9,7 @@
class CompDisplay;
class CompScreen;
class PrivateDisplay;
+typedef std::list<CompScreen *> CompScreenList;
#define GET_CORE_DISPLAY(object) (dynamic_cast<CompDisplay *> (object))
#define CORE_DISPLAY(object) CompDisplay *d = GET_CORE_DISPLAY (object)
@@ -37,7 +38,6 @@ class DisplayInterface : public WrapableInterface<CompDisplay> {
class CompDisplay : public WrapableHandler<DisplayInterface>, public CompObject {
public:
- CompDisplay *next;
class Atoms {
public:
@@ -189,7 +189,7 @@ class CompDisplay : public WrapableHandler<DisplayInterface>, public CompObject
Display *
dpy();
- CompScreen *
+ CompScreenList &
screens();
GLenum
diff --git a/src/display.cpp b/src/display.cpp
index e9df259..18188eb 100644
--- a/src/display.cpp
+++ b/src/display.cpp
@@ -707,8 +707,7 @@ CompDisplay::addScreenActions (CompScreen *s)
}
CompDisplay::CompDisplay () :
- CompObject (COMP_OBJECT_TYPE_DISPLAY, "display", &displayPrivateIndices),
- next (0)
+ CompObject (COMP_OBJECT_TYPE_DISPLAY, "display", &displayPrivateIndices)
{
WRAPABLE_INIT_HND(handleEvent);
WRAPABLE_INIT_HND(handleCompizEvent);
@@ -726,8 +725,11 @@ CompDisplay::CompDisplay () :
CompDisplay::~CompDisplay ()
{
- while (priv->screens)
- removeScreen (priv->screens);
+ while (!priv->screens.empty ())
+ {
+ removeScreen (priv->screens.front ());
+ priv->screens.pop_front ();
+ }
objectFiniPlugins (this);
@@ -908,7 +910,7 @@ CompDisplay::init (const char *name)
addScreen (i);
}
- if (!priv->screens)
+ if (priv->screens.empty ())
{
compLogMessage (this, "core", CompLogLevelFatal,
"No manageable screens found on display %s",
@@ -923,12 +925,12 @@ CompDisplay::init (const char *name)
/* move input focus to root window so that we get a FocusIn event when
moving it to the default window */
- XSetInputFocus (priv->dpy, priv->screens->root (), RevertToPointerRoot,
- CurrentTime);
+ XSetInputFocus (priv->dpy, priv->screens.front ()->root (),
+ RevertToPointerRoot, CurrentTime);
if (focus == None || focus == PointerRoot)
{
- priv->screens->focusDefaultWindow ();
+ priv->screens.front ()->focusDefaultWindow ();
}
else
{
@@ -940,7 +942,7 @@ CompDisplay::init (const char *name)
w->moveInputFocusTo ();
}
else
- priv->screens->focusDefaultWindow ();
+ priv->screens.front ()->focusDefaultWindow ();
}
priv->pingTimer.start (
@@ -969,7 +971,7 @@ CompDisplay::dpy ()
return priv->dpy;
}
-CompScreen *
+CompScreenList &
CompDisplay::screens ()
{
return priv->screens;
@@ -1084,7 +1086,7 @@ CompDisplay::updateScreenInfo ()
bool
CompDisplay::addScreen (int screenNum)
{
- CompScreen *s, *prev;
+ CompScreen *s;
Window rootDummy, childDummy;
int x, y, dummy;
unsigned int uDummy;
@@ -1093,21 +1095,14 @@ CompDisplay::addScreen (int screenNum)
if (!s)
return false;
- for (prev = priv->screens; prev && prev->next; prev = prev->next);
-
- if (prev)
- prev->next = s;
- else
- priv->screens = s;
+ priv->screens.push_back (s);
if (!s->init (this, screenNum))
{
compLogMessage (this, "core", CompLogLevelError,
"Failed to manage screen: %d", screenNum);
- if (prev)
- prev->next = NULL;
- else
- priv->screens = NULL;
+
+ priv->screens.pop_back ();
}
if (XQueryPointer (priv->dpy, XRootWindow (priv->dpy, screenNum),
@@ -1123,16 +1118,10 @@ CompDisplay::addScreen (int screenNum)
void
CompDisplay::removeScreen (CompScreen *s)
{
- CompScreen *p;
+ CompScreenList::iterator it =
+ std::find (priv->screens.begin (), priv->screens.end (), s);
- for (p = priv->screens; p; p = p->next)
- if (p->next == s)
- break;
-
- if (p)
- p->next = s->next;
- else
- priv->screens = NULL;
+ priv->screens.erase (it);
delete s;
}
@@ -1150,7 +1139,6 @@ PrivateDisplay::setAudibleBell (bool audible)
bool
PrivateDisplay::handlePingTimeout ()
{
- CompScreen *s;
CompWindow *w;
XEvent ev;
int ping = lastPing + 1;
@@ -1165,7 +1153,7 @@ PrivateDisplay::handlePingTimeout ()
ev.xclient.data.l[3] = 0;
ev.xclient.data.l[4] = 0;
- for (s = screens; s; s = s->next)
+ foreach (CompScreen *s, screens)
{
for (w = s->windows (); w; w = w->next)
{
@@ -1208,9 +1196,7 @@ CompDisplay::setOption (const char *name,
case COMP_DISPLAY_OPTION_TEXTURE_FILTER:
if (o->set (value))
{
- CompScreen *s;
-
- for (s = priv->screens; s; s = s->next)
+ foreach (CompScreen *s, priv->screens)
s->damageScreen ();
if (!o->value ().i ())
@@ -1330,15 +1316,13 @@ CompDisplay::updateModifierMappings ()
if (memcmp (modMask, priv->modMask, sizeof (modMask)))
{
- CompScreen *s;
-
memcpy (priv->modMask, modMask, sizeof (modMask));
priv->ignoredModMask = LockMask |
(modMask[CompModNumLock] & ~CompNoMask) |
(modMask[CompModScrollLock] & ~CompNoMask);
- for (s = priv->screens; s; s = s->next)
+ foreach (CompScreen *s, priv->screens)
s->updatePassiveGrabs ();
}
}
@@ -1529,9 +1513,7 @@ PrivateDisplay::updatePlugins ()
CompScreen *
CompDisplay::findScreen (Window root)
{
- CompScreen *s;
-
- for (s = priv->screens; s; s = s->next)
+ foreach (CompScreen *s, priv->screens)
{
if (s->root () == root)
return s;
@@ -1544,19 +1526,16 @@ void
CompDisplay::forEachWindow (ForEachWindowProc proc,
void *closure)
{
- CompScreen *s;
-
- for (s = priv->screens; s; s = s->next)
+ foreach (CompScreen *s, priv->screens)
s->forEachWindow (proc, closure);
}
CompWindow *
CompDisplay::findWindow (Window id)
{
- CompScreen *s;
CompWindow *w;
- for (s = priv->screens; s; s = s->next)
+ foreach (CompScreen *s, priv->screens)
{
w = s->findWindow (id);
if (w)
@@ -1569,10 +1548,9 @@ CompDisplay::findWindow (Window id)
CompWindow *
CompDisplay::findTopLevelWindow (Window id)
{
- CompScreen *s;
CompWindow *w;
- for (s = priv->screens; s; s = s->next)
+ foreach (CompScreen *s, priv->screens)
{
w = s->findTopLevelWindow (id);
if (w)
@@ -1587,9 +1565,7 @@ findScreenForSelection (CompDisplay *display,
Window owner,
Atom selection)
{
- CompScreen *s;
-
- for (s = display->screens(); s; s = s->next)
+ foreach (CompScreen *s, display->screens ())
{
if (s->selectionWindow () == owner && s->selectionAtom () == selection)
return s;
diff --git a/src/event.cpp b/src/event.cpp
index fa7ed96..1af011d 100644
--- a/src/event.cpp
+++ b/src/event.cpp
@@ -1075,7 +1075,7 @@ CompDisplay::handleEvent (XEvent *event)
if (priv->handleActionEvent (event))
{
- if (!priv->screens->hasGrab ())
+ if (!priv->screens.front ()->hasGrab ())
XAllowEvents (priv->dpy, AsyncPointer, event->xbutton.time);
return;
@@ -1083,7 +1083,7 @@ CompDisplay::handleEvent (XEvent *event)
switch (event->type) {
case Expose:
- for (s = priv->screens; s; s = s->next)
+ foreach (s, priv->screens)
s->handleExposeEvent (&event->xexpose);
break;
case SelectionRequest:
@@ -1615,7 +1615,7 @@ CompDisplay::handleEvent (XEvent *event)
}
else if (event->xclient.message_type == priv->atoms.showingDesktop)
{
- for (s = priv->screens; s; s = s->next)
+ foreach (s, priv->screens)
{
if (event->xclient.window == s->root () ||
event->xclient.window == None)
@@ -1799,7 +1799,7 @@ CompDisplay::handleEvent (XEvent *event)
}
break;
case EnterNotify:
- if (!priv->screens->hasGrab () &&
+ if (!priv->screens.front ()->hasGrab () &&
event->xcrossing.mode != NotifyGrab &&
event->xcrossing.mode != NotifyUngrab &&
event->xcrossing.detail != NotifyInferior)
@@ -1916,7 +1916,7 @@ CompDisplay::handleEvent (XEvent *event)
sa = (XSyncAlarmNotifyEvent *) event;
- for (s = priv->screens; s; s = s->next)
+ foreach (s, priv->screens)
{
for (w = s->windows (); w; w = w->next)
{
diff --git a/src/match.cpp b/src/match.cpp
index 39efad6..60f2747 100644
--- a/src/match.cpp
+++ b/src/match.cpp
@@ -136,7 +136,6 @@ CompDisplay::matchExpHandlerChanged ()
WRAPABLE_HND_FUNC(matchExpHandlerChanged)
CompPlugin *p;
- CompScreen *s;
for (p = getPlugins (); p; p = p->next)
{
@@ -144,7 +143,7 @@ CompDisplay::matchExpHandlerChanged ()
matchUpdateMatchOptions (options);
}
- for (s = priv->screens; s; s = s->next)
+ foreach (CompScreen *s, priv->screens)
{
for (p = getPlugins (); p; p = p->next)
{
diff --git a/src/metadata.cpp b/src/metadata.cpp
index bdcd37a..c9f319f 100644
--- a/src/metadata.cpp
+++ b/src/metadata.cpp
@@ -392,9 +392,7 @@ initKeyValue (CompDisplay *d,
if (state & CompAction::StateAutoGrab)
{
- CompScreen *s;
-
- for (s = d->screens (); s; s = s->next)
+ foreach (CompScreen *s, d->screens ())
s->addAction (&v.action ());
}
}
@@ -431,9 +429,7 @@ initButtonValue (CompDisplay *d,
if (state & CompAction::StateAutoGrab)
{
- CompScreen *s;
-
- for (s = d->screens (); s; s = s->next)
+ foreach (CompScreen *s, d->screens ())
s->addAction (&v.action ());
}
}
@@ -476,9 +472,7 @@ initEdgeValue (CompDisplay *d,
if (state & CompAction::StateAutoGrab)
{
- CompScreen *s;
-
- for (s = d->screens (); s; s = s->next)
+ foreach (CompScreen *s, d->screens ())
s->addAction (&v.action ());
}
}
diff --git a/src/option.cpp b/src/option.cpp
index bfda243..c8d5a80 100644
--- a/src/option.cpp
+++ b/src/option.cpp
@@ -764,25 +764,31 @@ CompOption::setDisplayOption (CompDisplay *d,
if (o.isAction () &&
o.value ().action ().state () & CompAction::StateAutoGrab)
{
- CompScreen *s;
+ CompScreen *s = NULL;
- for (s = d->screens (); s; s = s->next)
- if (!s->addAction (&value.action ()))
+ foreach (CompScreen *ss, d->screens ())
+ if (!ss->addAction (&value.action ()))
+ {
+ s = ss;
break;
+ }
if (s)
{
- CompScreen *failed = s;
- for (s = d->screens (); s && s != failed; s = s->next)
- s->removeAction (&value.action ());
+ foreach (CompScreen *ss, d->screens ())
+ {
+ if (s == ss)
+ break;
+ ss->removeAction (&value.action ());
+ }
return false;
}
else
{
- for (s = d->screens (); s; s = s->next)
- s->removeAction (&o.value ().action ());
+ foreach (CompScreen *ss, d->screens ())
+ ss->removeAction (&o.value ().action ());
}
return o.set (value);
@@ -818,8 +824,6 @@ finiDisplayOptionValue (CompDisplay *d,
CompOption::Value &v,
CompOption::Type type)
{
- CompScreen *s;
-
switch (type) {
case CompOption::TypeAction:
case CompOption::TypeKey:
@@ -827,7 +831,7 @@ finiDisplayOptionValue (CompDisplay *d,
case CompOption::TypeEdge:
case CompOption::TypeBell:
if (v.action ().state () & CompAction::StateAutoGrab)
- for (s = d->screens (); s; s = s->next)
+ foreach (CompScreen *s, d->screens ())
s->removeAction (&v.action ());
break;
case CompOption::TypeList:
diff --git a/src/privatedisplay.h b/src/privatedisplay.h
index 76c11f5..70800d6 100644
--- a/src/privatedisplay.h
+++ b/src/privatedisplay.h
@@ -151,7 +151,7 @@ class PrivateDisplay {
xcb_connection_t *connection;
Display *dpy;
- CompScreen *screens;
+ CompScreenList screens;
CompWatchFdHandle watchFdHandle;