aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/App.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-11-26 16:01:28 (GMT)
committerfluxgen <fluxgen>2002-11-26 16:01:28 (GMT)
commitac4420cdc50b7d7410781bc1bbbd1e89e18f256d (patch)
tree5c18c5497d42fafdd962269aa42f2efe80a2afdf /src/FbTk/App.cc
parent031edc36acb3957046d0836ec0ac17cd1c323b22 (diff)
downloadfluxbox-ac4420cdc50b7d7410781bc1bbbd1e89e18f256d.zip
fluxbox-ac4420cdc50b7d7410781bc1bbbd1e89e18f256d.tar.bz2
initial import
Diffstat (limited to 'src/FbTk/App.cc')
-rw-r--r--src/FbTk/App.cc51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/FbTk/App.cc b/src/FbTk/App.cc
new file mode 100644
index 0000000..89b5921
--- /dev/null
+++ b/src/FbTk/App.cc
@@ -0,0 +1,51 @@
1// App.cc
2// Copyright (c) 2002 Henrik Kinnunen (fluxgen at linuxmail.org)
3//
4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation
7// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8// and/or sell copies of the Software, and to permit persons to whom the
9// Software is furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE.
21
22#include "App.hh"
23#include <cassert>
24#include <string>
25
26namespace FbTk {
27
28App *App::s_app = 0;
29
30App *App::instance() {
31 if (s_app == 0)
32 throw std::string("You must create an instance of FbTk::App first!");
33 return s_app;
34}
35
36App::App(const char *displayname) {
37 if (s_app != 0)
38 throw std::string("Can't create more than one instance of FbTk::App");
39 s_app = this;
40 m_display = XOpenDisplay(displayname);
41}
42
43App::~App() {
44 if (m_display != 0) {
45 XCloseDisplay(m_display);
46 m_display = 0;
47 }
48 s_app = 0;
49}
50
51}; // end namespace FbTk