aboutsummaryrefslogtreecommitdiff
path: root/src/FbAtoms.cc
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2010-09-08 20:09:06 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2010-09-08 20:09:06 (GMT)
commit8a08110f194170cff462d292d5851735aa5f19ed (patch)
tree6047d4ea2b95fef762c0dfb31c8fa90cc77aab5b /src/FbAtoms.cc
parentdc5a105c3e79e8ede296e22217e7406cf24e9495 (diff)
downloadfluxbox-8a08110f194170cff462d292d5851735aa5f19ed.zip
fluxbox-8a08110f194170cff462d292d5851735aa5f19ed.tar.bz2
simpler way of expressing 'Singleton' for 'FbAtoms'
Diffstat (limited to 'src/FbAtoms.cc')
-rw-r--r--src/FbAtoms.cc44
1 files changed, 19 insertions, 25 deletions
diff --git a/src/FbAtoms.cc b/src/FbAtoms.cc
index 13b1703..409a99f 100644
--- a/src/FbAtoms.cc
+++ b/src/FbAtoms.cc
@@ -22,42 +22,36 @@
22#include "FbAtoms.hh" 22#include "FbAtoms.hh"
23#include "FbTk/App.hh" 23#include "FbTk/App.hh"
24 24
25#include <string> 25namespace {
26 26
27using std::string; 27FbAtoms* s_singleton = 0;
28 28
29FbAtoms *FbAtoms::s_singleton = 0; 29} // end of anonymous namespace
30 30
31FbAtoms::FbAtoms():m_init(false) { 31FbAtoms::FbAtoms() {
32 if (s_singleton != 0) 32
33 throw string("You can only create one instance of FbAtoms"); 33 Display* dpy = FbTk::App::instance()->display();
34
35 xa_wm_protocols = XInternAtom(dpy, "WM_PROTOCOLS", False);
36 xa_wm_state = XInternAtom(dpy, "WM_STATE", False);
37 xa_wm_change_state = XInternAtom(dpy, "WM_CHANGE_STATE", False);
38 xa_wm_delete_window = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
39 xa_wm_take_focus = XInternAtom(dpy, "WM_TAKE_FOCUS", False);
40 motif_wm_hints = XInternAtom(dpy, "_MOTIF_WM_HINTS", False);
41
42 blackbox_attributes = XInternAtom(dpy, "_BLACKBOX_ATTRIBUTES", False);
34 43
35 s_singleton = this; 44 s_singleton = this;
36 initAtoms();
37} 45}
38 46
39FbAtoms::~FbAtoms() { 47FbAtoms::~FbAtoms() {
40 48 s_singleton = 0;
41} 49}
42 50
43FbAtoms *FbAtoms::instance() { 51FbAtoms *FbAtoms::instance() {
44 if (s_singleton == 0) 52 if (s_singleton == 0) {
45 throw string("Create one instance of FbAtoms first!"); 53 s_singleton = new FbAtoms();
54 }
46 return s_singleton; 55 return s_singleton;
47} 56}
48 57
49void FbAtoms::initAtoms() {
50 Display *display = FbTk::App::instance()->display();
51 if (display == 0)
52 return;
53
54 xa_wm_protocols = XInternAtom(display, "WM_PROTOCOLS", False);
55 xa_wm_state = XInternAtom(display, "WM_STATE", False);
56 xa_wm_change_state = XInternAtom(display, "WM_CHANGE_STATE", False);
57 xa_wm_delete_window = XInternAtom(display, "WM_DELETE_WINDOW", False);
58 xa_wm_take_focus = XInternAtom(display, "WM_TAKE_FOCUS", False);
59 motif_wm_hints = XInternAtom(display, "_MOTIF_WM_HINTS", False);
60
61 blackbox_attributes = XInternAtom(display, "_BLACKBOX_ATTRIBUTES", False);
62
63}