diff options
-rw-r--r-- | include/compplugin.h | 11 | ||||
-rw-r--r-- | include/compscreen.h | 3 | ||||
-rw-r--r-- | include/compwindow.h | 4 | ||||
-rw-r--r-- | src/plugin.cpp | 22 | ||||
-rw-r--r-- | src/privatescreen.h | 1 | ||||
-rw-r--r-- | src/screen.cpp | 19 | ||||
-rw-r--r-- | src/window.cpp | 2 |
7 files changed, 52 insertions, 10 deletions
diff --git a/include/compplugin.h b/include/compplugin.h index 39d6859..9c067a3 100644 --- a/include/compplugin.h +++ b/include/compplugin.h @@ -29,6 +29,8 @@ #include <compiz.h> #include <compoption.h> +#include <map> + #define __GET_PLUGIN_OBJECT_OPTIONS__(name, object) #define __GET_PLUGIN_OBJECT_OPTIONS_X(name, object) \ return name::get(object)->getOptions (); @@ -188,6 +190,15 @@ class CompPlugin { CompOption::Value &value); }; + struct cmpStr + { + bool operator() (const char *a, const char *b) const + { + return strcmp (a, b) < 0; + } + }; + + typedef std::map<const char *, CompPlugin *, cmpStr> Map; typedef std::list<CompPlugin *> List; public: diff --git a/include/compscreen.h b/include/compscreen.h index 3bfe308..1846d7f 100644 --- a/include/compscreen.h +++ b/include/compscreen.h @@ -172,6 +172,9 @@ class CompScreen : void unhookWindow (CompWindow *w); + void + eraseWindowFromMap (Window id); + grabHandle pushGrab (Cursor cursor, const char *name); diff --git a/include/compwindow.h b/include/compwindow.h index 8686fd3..b28a5cf 100644 --- a/include/compwindow.h +++ b/include/compwindow.h @@ -16,6 +16,8 @@ #include <compwrapsystem.h> +#include <map> + class CompWindow; class CompIcon; class PrivateWindow; @@ -261,6 +263,8 @@ class CompWindow : typedef boost::function<void (CompWindow *)> ForEach; + + typedef std::map<Window, CompWindow *> Map; public: CompWindow *next; diff --git a/src/plugin.cpp b/src/plugin.cpp index d1e2e4a..287d5a9 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -36,6 +36,7 @@ #include <compiz-core.h> #include <compobject.h> +CompPlugin::Map pluginsMap; std::list<CompPlugin *> plugins; class CorePluginVTable : public CompPlugin::VTable @@ -444,11 +445,10 @@ CompPlugin::objectFiniPlugins (CompObject *o) CompPlugin * CompPlugin::find (const char *name) { - foreach (CompPlugin *p, plugins) - { - if (strcmp (p->vTable->name (), name) == 0) - return p; - } + CompPlugin::Map::iterator it = pluginsMap.find (name); + + if (it != pluginsMap.end ()) + return it->second; return NULL; } @@ -507,7 +507,12 @@ CompPlugin::load (const char *name) bool CompPlugin::push (CompPlugin *p) { - if (find (p->vTable->name ())) + const char *name = p->vTable->name (); + + std::pair<CompPlugin::Map::iterator, bool> insertRet = + pluginsMap.insert (std::pair<const char *, CompPlugin *> (name, p)); + + if (!insertRet.second) { compLogMessage (NULL, "core", CompLogLevelWarn, "Plugin '%s' already active", @@ -521,8 +526,9 @@ CompPlugin::push (CompPlugin *p) if (!initPlugin (p)) { compLogMessage (NULL, "core", CompLogLevelError, - "Couldn't activate plugin '%s'", p->vTable->name ()); + "Couldn't activate plugin '%s'", name); + pluginsMap.erase (name); plugins.pop_front (); return false; @@ -542,6 +548,8 @@ CompPlugin::pop (void) if (!p) return 0; + pluginsMap.erase (p->vTable->name ()); + finiPlugin (p); plugins.pop_front (); diff --git a/src/privatescreen.h b/src/privatescreen.h index 028af17..1932eec 100644 --- a/src/privatescreen.h +++ b/src/privatescreen.h @@ -150,6 +150,7 @@ class PrivateScreen { CompScreen *screen; CompDisplay *display; CompWindowList windows; + CompWindow::Map windowsMap; Colormap colormap; int screenNum; diff --git a/src/screen.cpp b/src/screen.cpp index c855ef4..cc99d4f 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -1396,9 +1396,10 @@ CompScreen::findWindow (Window id) } else { - foreach (CompWindow *w, priv->windows) - if (w->id () == id) - return (lastFoundWindow = w); + CompWindow::Map::iterator it = priv->windowsMap.find (id); + + if (it != priv->windowsMap.end ()) + return (lastFoundWindow = it->second); } return 0; @@ -1445,6 +1446,8 @@ CompScreen::insertWindow (CompWindow *w, Window aboveId) w->next = priv->windows.front (); } priv->windows.push_front (w); + if (w->id () != 1) + priv->windowsMap[w->id ()] = w; return; } @@ -1476,6 +1479,15 @@ CompScreen::insertWindow (CompWindow *w, Window aboveId) } priv->windows.insert (++it, w); + if (w->id () != 1) + priv->windowsMap[w->id ()] = w; +} + +void +CompScreen::eraseWindowFromMap (Window id) +{ + if (id != 1) + priv->windowsMap.erase (id); } void @@ -1485,6 +1497,7 @@ CompScreen::unhookWindow (CompWindow *w) std::find (priv->windows.begin (), priv->windows.end (), w); priv->windows.erase (it); + eraseWindowFromMap (w->id ()); if (w->next) w->next->prev = w->prev; diff --git a/src/window.cpp b/src/window.cpp index 5a442b7..d495087 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -1056,6 +1056,8 @@ setDefaultWindowAttributes (XWindowAttributes *wa) void CompWindow::destroy () { + screen ()->eraseWindowFromMap (id ()); + priv->id = 1; priv->mapNum = 0; |