summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Spilsbury <sam.spilsbury@canonical.com>2011-07-07 03:52:01 +0800
committerSam Spilsbury <sam.spilsbury@canonical.com>2011-07-07 03:52:01 +0800
commitee98496d5d7042d4aba10d822901aac6d3b85111 (patch)
tree26319e47d850dd53e72255ff674a591a848547a3 /src
parent0550e0941017c2c7ce027ba8ba9b5e47b17e409a (diff)
parentb9d6583b26e46c6e502129d3c550a18b5a7bd4d0 (diff)
downloadmobilebling-ee98496d5d7042d4aba10d822901aac6d3b85111.tar.gz
mobilebling-ee98496d5d7042d4aba10d822901aac6d3b85111.tar.bz2
Merge in lp:~unity-team/compiz-core/compiz-core.fix_706918 and hook
PluginClassHandler tests into make test
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/logmessage.cpp85
-rw-r--r--src/privatescreen.h5
-rw-r--r--src/screen.cpp94
-rw-r--r--src/valueholder.cpp110
-rw-r--r--src/valueholder.h41
6 files changed, 247 insertions, 90 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2d3ee63..97101f6 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -53,6 +53,8 @@ add_executable (compiz
propertywriter.cpp
eventsource.cpp
timeouthandler.cpp
+ valueholder.cpp
+ logmessage.cpp
${_bcop_sources}
)
diff --git a/src/logmessage.cpp b/src/logmessage.cpp
new file mode 100644
index 0000000..9087455
--- /dev/null
+++ b/src/logmessage.cpp
@@ -0,0 +1,85 @@
+/*
+ * Copyright © 2005 Novell, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Novell, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * Novell, Inc. makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECI<<<<<fAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: David Reveman <davidr@novell.com>
+ */
+
+#include <compiz.h>
+#include <cstdio>
+
+const char *
+logLevelToString (CompLogLevel level)
+{
+ switch (level) {
+ case CompLogLevelFatal:
+ return "Fatal";
+ case CompLogLevelError:
+ return "Error";
+ case CompLogLevelWarn:
+ return "Warn";
+ case CompLogLevelInfo:
+ return "Info";
+ case CompLogLevelDebug:
+ return "Debug";
+ default:
+ break;
+ }
+
+ return "Unknown";
+}
+
+void
+logMessage (const char *componentName,
+ CompLogLevel level,
+ const char *message)
+{
+ if (!debugOutput && level >= CompLogLevelDebug)
+ return;
+
+ fprintf (stderr, "%s (%s) - %s: %s\n",
+ programName, componentName,
+ logLevelToString (level), message);
+}
+
+void
+compLogMessage (const char *componentName,
+ CompLogLevel level,
+ const char *format,
+ ...)
+{
+ va_list args;
+ char message[2048];
+
+ va_start (args, format);
+
+ vsnprintf (message, 2048, format, args);
+
+ /* FIXME: That's wrong */
+#if 0
+ if (screen)
+ screen->logMessage (componentName, level, message);
+ else
+#endif
+ logMessage (componentName, level, message);
+
+ va_end (args);
+}
diff --git a/src/privatescreen.h b/src/privatescreen.h
index 2f5dfc4..b6cd6b6 100644
--- a/src/privatescreen.h
+++ b/src/privatescreen.h
@@ -100,7 +100,10 @@ struct CompStartupSequence {
unsigned int viewportY;
};
-class PrivateScreen : public CoreOptions {
+class PrivateScreen :
+ public ValueHolder,
+ public CoreOptions
+{
public:
class KeyGrab {
diff --git a/src/screen.cpp b/src/screen.cpp
index 2050b0e..2ab2b02 100644
--- a/src/screen.cpp
+++ b/src/screen.cpp
@@ -267,43 +267,19 @@ CompScreen::removeWatchFd (CompWatchFdHandle handle)
void
CompScreen::storeValue (CompString key, CompPrivate value)
{
- std::map<CompString,CompPrivate>::iterator it;
-
- it = priv->valueMap.find (key);
-
- if (it != priv->valueMap.end ())
- {
- it->second = value;
- }
- else
- {
- priv->valueMap.insert (std::pair<CompString,CompPrivate> (key, value));
- }
+ ValueHolder::Default ()->storeValue (key, value);
}
bool
CompScreen::hasValue (CompString key)
{
- return (priv->valueMap.find (key) != priv->valueMap.end ());
+ return ValueHolder::Default ()->hasValue (key);
}
CompPrivate
CompScreen::getValue (CompString key)
{
- CompPrivate p;
-
- std::map<CompString,CompPrivate>::iterator it;
- it = priv->valueMap.find (key);
-
- if (it != priv->valueMap.end ())
- {
- return it->second;
- }
- else
- {
- p.uval = 0;
- return p;
- }
+ return ValueHolder::Default ()->getValue (key);
}
bool
@@ -342,13 +318,7 @@ CompWatchFd::internalCallback (Glib::IOCondition events)
void
CompScreen::eraseValue (CompString key)
{
- std::map<CompString,CompPrivate>::iterator it;
- it = priv->valueMap.find (key);
-
- if (it != priv->valueMap.end ())
- {
- priv->valueMap.erase (key);
- }
+ ValueHolder::Default ()->eraseValue (key);
}
void
@@ -1130,40 +1100,6 @@ CompScreen::imageToFile (CompString &path,
return false;
}
-const char *
-logLevelToString (CompLogLevel level)
-{
- switch (level) {
- case CompLogLevelFatal:
- return "Fatal";
- case CompLogLevelError:
- return "Error";
- case CompLogLevelWarn:
- return "Warn";
- case CompLogLevelInfo:
- return "Info";
- case CompLogLevelDebug:
- return "Debug";
- default:
- break;
- }
-
- return "Unknown";
-}
-
-static void
-logMessage (const char *componentName,
- CompLogLevel level,
- const char *message)
-{
- if (!debugOutput && level >= CompLogLevelDebug)
- return;
-
- fprintf (stderr, "%s (%s) - %s: %s\n",
- programName, componentName,
- logLevelToString (level), message);
-}
-
void
CompScreen::logMessage (const char *componentName,
CompLogLevel level,
@@ -1173,27 +1109,6 @@ CompScreen::logMessage (const char *componentName,
::logMessage (componentName, level, message);
}
-void
-compLogMessage (const char *componentName,
- CompLogLevel level,
- const char *format,
- ...)
-{
- va_list args;
- char message[2048];
-
- va_start (args, format);
-
- vsnprintf (message, 2048, format, args);
-
- if (screen)
- screen->logMessage (componentName, level, message);
- else
- logMessage (componentName, level, message);
-
- va_end (args);
-}
-
int
PrivateScreen::getWmState (Window id)
{
@@ -4739,6 +4654,7 @@ PrivateScreen::PrivateScreen (CompScreen *screen) :
initialized (false)
{
TimeoutHandler *dTimeoutHandler = new TimeoutHandler ();
+ ValueHolder::SetDefault (static_cast<ValueHolder *> (this));
pingTimer.setCallback (
boost::bind (&PrivateScreen::handlePingTimeout, this));
diff --git a/src/valueholder.cpp b/src/valueholder.cpp
new file mode 100644
index 0000000..14405b4
--- /dev/null
+++ b/src/valueholder.cpp
@@ -0,0 +1,110 @@
+/*
+ * Copyright © 2010 Canonical Ltd.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Canonical Ltd. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * Canonical Ltd. makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
+ */
+
+#include <core/valueholder.h>
+#include <map>
+
+namespace
+{
+ static ValueHolder *gDefault;
+}
+
+class PrivateValueHolder
+{
+ public:
+
+ std::map<CompString, CompPrivate> valueMap;
+};
+
+ValueHolder::ValueHolder () :
+ priv (new PrivateValueHolder)
+{
+}
+
+ValueHolder *
+ValueHolder::Default ()
+{
+ return gDefault;
+}
+
+void
+ValueHolder::SetDefault (ValueHolder *v)
+{
+ gDefault = v;
+}
+
+void
+ValueHolder::storeValue (CompString key, CompPrivate value)
+{
+ std::map<CompString,CompPrivate>::iterator it;
+
+ it = priv->valueMap.find (key);
+
+ if (it != priv->valueMap.end ())
+ {
+ it->second = value;
+ }
+ else
+ {
+ priv->valueMap.insert (std::pair<CompString,CompPrivate> (key, value));
+ }
+}
+
+void
+ValueHolder::eraseValue (CompString key)
+{
+ std::map<CompString,CompPrivate>::iterator it;
+ it = priv->valueMap.find (key);
+
+ if (it != priv->valueMap.end ())
+ {
+ priv->valueMap.erase (key);
+ }
+}
+
+bool
+ValueHolder::hasValue (CompString key)
+{
+ return (priv->valueMap.find (key) != priv->valueMap.end ());
+}
+
+CompPrivate
+ValueHolder::getValue (CompString key)
+{
+ CompPrivate p;
+
+ std::map<CompString,CompPrivate>::iterator it;
+ it = priv->valueMap.find (key);
+
+ if (it != priv->valueMap.end ())
+ {
+ return it->second;
+ }
+ else
+ {
+ p.uval = 0;
+ return p;
+ }
+}
diff --git a/src/valueholder.h b/src/valueholder.h
new file mode 100644
index 0000000..e50a6da
--- /dev/null
+++ b/src/valueholder.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright © 2010 Canonical Ltd.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Canonical Ltd. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * Canonical Ltd. makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
+ */
+
+class PrivateValueHolder;
+
+class ValueHolder
+{
+ public:
+
+ ValueHolder ();
+
+ void hasValue (CompString key);
+ void storeValue (CompString key, CompPrivate value);
+ CompPrivate getValue (CompString key);
+
+ private:
+
+ PrivateValueHolder *priv;
+};