diff options
| author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2014-04-02 17:12:16 +0200 |
|---|---|---|
| committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2014-04-02 17:12:16 +0200 |
| commit | d15ea6134966cb2a10c3d66596eeaf5077361aab (patch) | |
| tree | cecafcfb7b583d3271be1a9c05b45cbadcaaa0ce | |
| parent | 34e4bebb1b12317ba685f582bb693661f2629330 (diff) | |
DecorationsDataPool: add static Reset method that allows to reset our textures
(bzr r3748.8.1)
| -rw-r--r-- | decorations/DecorationsDataPool.cpp | 17 | ||||
| -rw-r--r-- | decorations/DecorationsDataPool.h | 1 |
2 files changed, 14 insertions, 4 deletions
diff --git a/decorations/DecorationsDataPool.cpp b/decorations/DecorationsDataPool.cpp index 9e387dc86..e89bad13f 100644 --- a/decorations/DecorationsDataPool.cpp +++ b/decorations/DecorationsDataPool.cpp @@ -32,11 +32,11 @@ namespace decoration namespace { DECLARE_LOGGER(logger, "unity.decoration.datapool"); +static DataPool::Ptr instance_; const std::string PLUGIN_NAME = "unityshell"; const int BUTTONS_SIZE = 16; const int BUTTONS_PADDING = 1; const cu::SimpleTexture::Ptr EMPTY_BUTTON; -Display* dpy = nullptr; unsigned EdgeTypeToCursorShape(Edge::Type type) { @@ -67,7 +67,6 @@ unsigned EdgeTypeToCursorShape(Edge::Type type) DataPool::DataPool() { - dpy = screen->dpy(); SetupCursors(); SetupTextures(); @@ -81,18 +80,28 @@ DataPool::DataPool() DataPool::~DataPool() { + auto* dpy = screen->dpy(); for (auto cursor : edge_cursors_) XFreeCursor(dpy, cursor); } DataPool::Ptr const& DataPool::Get() { - static DataPool::Ptr data_pool(new DataPool()); - return data_pool; + if (instance_) + return instance_; + + instance_.reset(new DataPool); + return instance_; +} + +void DataPool::Reset() +{ + instance_.reset(); } void DataPool::SetupCursors() { + auto* dpy = screen->dpy(); for (unsigned c = 0; c < edge_cursors_.size(); ++c) edge_cursors_[c] = XCreateFontCursor(dpy, EdgeTypeToCursorShape(Edge::Type(c))); } diff --git a/decorations/DecorationsDataPool.h b/decorations/DecorationsDataPool.h index 640c3e408..9eb81f4b2 100644 --- a/decorations/DecorationsDataPool.h +++ b/decorations/DecorationsDataPool.h @@ -35,6 +35,7 @@ public: typedef std::shared_ptr<DataPool> Ptr; static DataPool::Ptr const& Get(); + static void Reset(); virtual ~DataPool(); Cursor EdgeCursor(Edge::Type) const; |
