summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Spilsbury <sam.spilsbury@canonical.com>2011-06-25 10:31:02 +0800
committerSam Spilsbury <sam.spilsbury@canonical.com>2011-06-25 10:31:02 +0800
commitee11a63700fb426c53bf2cc40dbccece797d93d4 (patch)
tree585351751f12fd399156a0105b900b7ed5ac34f0 /src
parente5e522c540c7b7802c2ceb1fbf9386739525b833 (diff)
downloadmobilebling-ee11a63700fb426c53bf2cc40dbccece797d93d4.tar.gz
mobilebling-ee11a63700fb426c53bf2cc40dbccece797d93d4.tar.bz2
Abstract out CompPrivate storage from CompScreen so we can make it testable
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/privatescreen.h5
-rw-r--r--src/screen.cpp40
3 files changed, 11 insertions, 35 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 5c2385f..093599a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -52,6 +52,7 @@ add_executable (compiz
modifierhandler.cpp
propertywriter.cpp
eventsource.cpp
+ valueholder.cpp
${_bcop_sources}
)
diff --git a/src/privatescreen.h b/src/privatescreen.h
index 850e6ec..0a940e0 100644
--- a/src/privatescreen.h
+++ b/src/privatescreen.h
@@ -175,7 +175,10 @@ class CompEventSource:
int mConnectionFD;
};
-class PrivateScreen : public CoreOptions {
+class PrivateScreen :
+ public ValueHolder,
+ public CoreOptions
+{
public:
class KeyGrab {
diff --git a/src/screen.cpp b/src/screen.cpp
index 9005411..183fee0 100644
--- a/src/screen.cpp
+++ b/src/screen.cpp
@@ -302,43 +302,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
@@ -377,13 +353,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
@@ -4773,6 +4743,8 @@ PrivateScreen::PrivateScreen (CompScreen *screen) :
xdndWindow (None),
initialized (false)
{
+ ValueHolder::SetDefault (static_cast<ValueHolder *> (this));
+
gettimeofday (&lastTimeout, 0);
pingTimer.setCallback (