diff options
author | fluxgen <fluxgen> | 2002-08-14 21:53:07 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2002-08-14 21:53:07 (GMT) |
commit | 238526bd48a9318672f8e2c20e8a3b3dbf16927d (patch) | |
tree | 56ce0148613c5b938b793966870dc9f61817ff45 /src/FbAtoms.cc | |
parent | 1d14c6ff8afb5776d7f66e46dcbef76a178edc88 (diff) | |
download | fluxbox-238526bd48a9318672f8e2c20e8a3b3dbf16927d.zip fluxbox-238526bd48a9318672f8e2c20e8a3b3dbf16927d.tar.bz2 |
singleton
Diffstat (limited to 'src/FbAtoms.cc')
-rw-r--r-- | src/FbAtoms.cc | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/FbAtoms.cc b/src/FbAtoms.cc index e19ba21..4e2c7f5 100644 --- a/src/FbAtoms.cc +++ b/src/FbAtoms.cc | |||
@@ -19,24 +19,36 @@ | |||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. | 20 | // DEALINGS IN THE SOFTWARE. |
21 | 21 | ||
22 | // $Id: FbAtoms.cc,v 1.2 2002/03/18 20:29:16 fluxgen Exp $ | 22 | // $Id: FbAtoms.cc,v 1.3 2002/08/14 21:53:07 fluxgen Exp $ |
23 | 23 | ||
24 | #include "FbAtoms.hh" | 24 | #include "FbAtoms.hh" |
25 | 25 | ||
26 | #include <string> | ||
27 | using namespace std; | ||
28 | |||
29 | FbAtoms *FbAtoms::s_singleton = 0; | ||
30 | |||
26 | FbAtoms::FbAtoms(Display *display):m_init(false) { | 31 | FbAtoms::FbAtoms(Display *display):m_init(false) { |
27 | if (display) | 32 | if (s_singleton != 0) |
28 | initAtoms(display); | 33 | throw string("You can only create one instance of FbAtoms"); |
34 | |||
35 | if (display == 0) | ||
36 | throw string("Must supply FbAtoms with an valid display connection"); | ||
37 | |||
38 | s_singleton = this; | ||
39 | initAtoms(display); | ||
29 | } | 40 | } |
30 | 41 | ||
31 | FbAtoms::~FbAtoms() { | 42 | FbAtoms::~FbAtoms() { |
32 | 43 | ||
33 | } | 44 | } |
34 | 45 | ||
46 | FbAtoms *FbAtoms::instance() { | ||
47 | assert(s_singleton); | ||
48 | return s_singleton; | ||
49 | } | ||
50 | |||
35 | void FbAtoms::initAtoms(Display *display) { | 51 | void FbAtoms::initAtoms(Display *display) { |
36 | if (m_init) //already done init? | ||
37 | return; | ||
38 | else | ||
39 | m_init = true; | ||
40 | 52 | ||
41 | xa_wm_colormap_windows = | 53 | xa_wm_colormap_windows = |
42 | XInternAtom(display, "WM_COLORMAP_WINDOWS", False); | 54 | XInternAtom(display, "WM_COLORMAP_WINDOWS", False); |