aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-08-14 21:53:07 (GMT)
committerfluxgen <fluxgen>2002-08-14 21:53:07 (GMT)
commit238526bd48a9318672f8e2c20e8a3b3dbf16927d (patch)
tree56ce0148613c5b938b793966870dc9f61817ff45 /src
parent1d14c6ff8afb5776d7f66e46dcbef76a178edc88 (diff)
downloadfluxbox-238526bd48a9318672f8e2c20e8a3b3dbf16927d.zip
fluxbox-238526bd48a9318672f8e2c20e8a3b3dbf16927d.tar.bz2
singleton
Diffstat (limited to 'src')
-rw-r--r--src/FbAtoms.cc26
-rw-r--r--src/FbAtoms.hh10
2 files changed, 25 insertions, 11 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>
27using namespace std;
28
29FbAtoms *FbAtoms::s_singleton = 0;
30
26FbAtoms::FbAtoms(Display *display):m_init(false) { 31FbAtoms::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
31FbAtoms::~FbAtoms() { 42FbAtoms::~FbAtoms() {
32 43
33} 44}
34 45
46FbAtoms *FbAtoms::instance() {
47 assert(s_singleton);
48 return s_singleton;
49}
50
35void FbAtoms::initAtoms(Display *display) { 51void 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);
diff --git a/src/FbAtoms.hh b/src/FbAtoms.hh
index 63882e2..3fb8b2b 100644
--- a/src/FbAtoms.hh
+++ b/src/FbAtoms.hh
@@ -19,21 +19,21 @@
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.hh,v 1.5 2002/08/12 19:25:35 fluxgen Exp $ 22// $Id: FbAtoms.hh,v 1.6 2002/08/14 21:53:07 fluxgen Exp $
23#ifndef FBATOMS_HH 23#ifndef FBATOMS_HH
24#define FBATOMS_HH 24#define FBATOMS_HH
25 25
26#include <X11/Xlib.h> 26#include <X11/Xlib.h>
27#include <X11/Xatom.h> 27#include <X11/Xatom.h>
28
28/** 29/**
29 atom handler, should probably be a singleton 30 atom handler, should probably be a singleton
30*/ 31*/
31class FbAtoms 32class FbAtoms {
32{
33public: 33public:
34 explicit FbAtoms(Display *display); 34 explicit FbAtoms(Display *display);
35 virtual ~FbAtoms(); 35 virtual ~FbAtoms();
36 void initAtoms(Display *display); 36 static FbAtoms *instance();
37 37
38#ifdef GNOME 38#ifdef GNOME
39 inline Atom getGnomeProtAtom() const { return gnome_wm_prot; } 39 inline Atom getGnomeProtAtom() const { return gnome_wm_prot; }
@@ -125,6 +125,7 @@ public:
125#endif // NEWWMSPEC 125#endif // NEWWMSPEC
126 126
127private: 127private:
128 void initAtoms(Display *disp);
128// NETAttributes 129// NETAttributes
129 Atom blackbox_attributes, blackbox_change_attributes, blackbox_hints; 130 Atom blackbox_attributes, blackbox_change_attributes, blackbox_hints;
130 131
@@ -177,6 +178,7 @@ private:
177 xa_wm_delete_window, xa_wm_take_focus, xa_wm_change_state, 178 xa_wm_delete_window, xa_wm_take_focus, xa_wm_change_state,
178 motif_wm_hints; 179 motif_wm_hints;
179 bool m_init; 180 bool m_init;
181 static FbAtoms *s_singleton;
180}; 182};
181 183
182#endif //FBATOMS_HH 184#endif //FBATOMS_HH