aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-11-26 16:05:34 (GMT)
committerfluxgen <fluxgen>2002-11-26 16:05:34 (GMT)
commit3dacf701543b52c39a39d686a97d657c47dd2e8c (patch)
tree9a2af20b44eaaa9a7e7b1f875cf5fd372509ff57
parentcf287a3fde0c8d5739412eea7a20febcace60885 (diff)
downloadfluxbox-3dacf701543b52c39a39d686a97d657c47dd2e8c.zip
fluxbox-3dacf701543b52c39a39d686a97d657c47dd2e8c.tar.bz2
display connection from FbTk App
-rw-r--r--src/BaseDisplay.cc31
-rw-r--r--src/BaseDisplay.hh8
2 files changed, 18 insertions, 21 deletions
diff --git a/src/BaseDisplay.cc b/src/BaseDisplay.cc
index 507aaf1..34ee484 100644
--- a/src/BaseDisplay.cc
+++ b/src/BaseDisplay.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: BaseDisplay.cc,v 1.22 2002/11/12 14:40:26 fluxgen Exp $ 25// $Id: BaseDisplay.cc,v 1.23 2002/11/26 16:05:34 fluxgen Exp $
26 26
27 27
28 28
@@ -131,9 +131,8 @@ void bexec(const char *command, char *displaystring) {
131 131
132 132
133BaseDisplay *BaseDisplay::s_singleton = 0; 133BaseDisplay *BaseDisplay::s_singleton = 0;
134Display *BaseDisplay::s_display = 0;
135 134
136BaseDisplay::BaseDisplay(const char *app_name, const char *dpy_name): 135BaseDisplay::BaseDisplay(const char *app_name, const char *dpy_name):FbTk::App(dpy_name),
137m_startup(true), m_shutdown(false), 136m_startup(true), m_shutdown(false),
138m_display_name(XDisplayName(dpy_name)), m_app_name(app_name), 137m_display_name(XDisplayName(dpy_name)), m_app_name(app_name),
139m_server_grabs(0) 138m_server_grabs(0)
@@ -146,7 +145,7 @@ m_server_grabs(0)
146 last_bad_window = None; 145 last_bad_window = None;
147 I18n *i18n = I18n::instance(); 146 I18n *i18n = I18n::instance();
148 147
149 if (! (s_display = XOpenDisplay(dpy_name))) { 148 if (display() == 0) {
150 fprintf(stderr, 149 fprintf(stderr,
151 i18n-> 150 i18n->
152 getMessage( 151 getMessage(
@@ -154,7 +153,7 @@ m_server_grabs(0)
154 "BaseDisplay::BaseDisplay: connection to X server failed.\n")); 153 "BaseDisplay::BaseDisplay: connection to X server failed.\n"));
155 154
156 throw static_cast<int>(2); //throw error 2 155 throw static_cast<int>(2); //throw error 2
157 } else if (fcntl(ConnectionNumber(s_display), F_SETFD, 1) == -1) { 156 } else if (fcntl(ConnectionNumber(display()), F_SETFD, 1) == -1) {
158 fprintf(stderr, 157 fprintf(stderr,
159 i18n-> 158 i18n->
160 getMessage( 159 getMessage(
@@ -165,10 +164,10 @@ m_server_grabs(0)
165 } 164 }
166 165
167 166
168 number_of_screens = ScreenCount(s_display); 167 number_of_screens = ScreenCount(display());
169 168
170#ifdef SHAPE 169#ifdef SHAPE
171 shape.extensions = XShapeQueryExtension(s_display, &shape.event_basep, 170 shape.extensions = XShapeQueryExtension(display(), &shape.event_basep,
172 &shape.error_basep); 171 &shape.error_basep);
173#else // !SHAPE 172#else // !SHAPE
174 shape.extensions = False; 173 shape.extensions = False;
@@ -191,9 +190,7 @@ BaseDisplay::~BaseDisplay() {
191 for (; it != it_end; ++it) { 190 for (; it != it_end; ++it) {
192 delete (*it); 191 delete (*it);
193 } 192 }
194 193
195 XCloseDisplay(s_display);
196 s_display = 0;
197 s_singleton = 0; 194 s_singleton = 0;
198} 195}
199 196
@@ -208,9 +205,9 @@ void BaseDisplay::eventLoop() {
208 run(); 205 run();
209 206
210 while ((! m_shutdown) && (! internal_error)) { 207 while ((! m_shutdown) && (! internal_error)) {
211 if (XPending(s_display)) { 208 if (XPending(display())) {
212 XEvent e; 209 XEvent e;
213 XNextEvent(s_display, &e); 210 XNextEvent(display(), &e);
214 211
215 if (last_bad_window != None && e.xany.window == last_bad_window) { 212 if (last_bad_window != None && e.xany.window == last_bad_window) {
216#ifdef DEBUG 213#ifdef DEBUG
@@ -226,7 +223,7 @@ void BaseDisplay::eventLoop() {
226 handleEvent(&e); 223 handleEvent(&e);
227 } 224 }
228 } else { 225 } else {
229 BTimer::updateTimers(ConnectionNumber(s_display)); //handle all timers 226 BTimer::updateTimers(ConnectionNumber(display())); //handle all timers
230 } 227 }
231 } 228 }
232} 229}
@@ -234,8 +231,8 @@ void BaseDisplay::eventLoop() {
234 231
235bool BaseDisplay::validateWindow(Window window) { 232bool BaseDisplay::validateWindow(Window window) {
236 XEvent event; 233 XEvent event;
237 if (XCheckTypedWindowEvent(s_display, window, DestroyNotify, &event)) { 234 if (XCheckTypedWindowEvent(display(), window, DestroyNotify, &event)) {
238 XPutBackEvent(s_display, &event); 235 XPutBackEvent(display(), &event);
239 return false; 236 return false;
240 } 237 }
241 238
@@ -245,13 +242,13 @@ bool BaseDisplay::validateWindow(Window window) {
245 242
246void BaseDisplay::grab() { 243void BaseDisplay::grab() {
247 if (! m_server_grabs++) 244 if (! m_server_grabs++)
248 XGrabServer(s_display); 245 XGrabServer(display());
249} 246}
250 247
251 248
252void BaseDisplay::ungrab() { 249void BaseDisplay::ungrab() {
253 if (! --m_server_grabs) 250 if (! --m_server_grabs)
254 XUngrabServer(s_display); 251 XUngrabServer(display());
255 if (m_server_grabs < 0) 252 if (m_server_grabs < 0)
256 m_server_grabs = 0; 253 m_server_grabs = 0;
257} 254}
diff --git a/src/BaseDisplay.hh b/src/BaseDisplay.hh
index cc39063..8a3b464 100644
--- a/src/BaseDisplay.hh
+++ b/src/BaseDisplay.hh
@@ -22,12 +22,13 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: BaseDisplay.hh,v 1.31 2002/11/15 11:57:33 fluxgen Exp $ 25// $Id: BaseDisplay.hh,v 1.32 2002/11/26 16:05:34 fluxgen Exp $
26 26
27#ifndef BASEDISPLAY_HH 27#ifndef BASEDISPLAY_HH
28#define BASEDISPLAY_HH 28#define BASEDISPLAY_HH
29 29
30#include "NotCopyable.hh" 30#include "NotCopyable.hh"
31#include "App.hh"
31#include "EventHandler.hh" 32#include "EventHandler.hh"
32 33
33#include <X11/Xlib.h> 34#include <X11/Xlib.h>
@@ -52,7 +53,7 @@ void bexec(const char *command, char *displaystring);
52/** 53/**
53 Singleton class to manage display connection 54 Singleton class to manage display connection
54*/ 55*/
55class BaseDisplay:private NotCopyable, FbTk::EventHandler<XEvent> 56class BaseDisplay:public FbTk::App, private FbTk::NotCopyable, FbTk::EventHandler<XEvent>
56{ 57{
57public: 58public:
58 BaseDisplay(const char *app_name, const char *display_name = 0); 59 BaseDisplay(const char *app_name, const char *display_name = 0);
@@ -92,7 +93,7 @@ public:
92 inline bool isStartup() const { return m_startup; } 93 inline bool isStartup() const { return m_startup; }
93 94
94 95
95 static Display *getXDisplay() { return s_display; } 96 static Display *getXDisplay() { return App::instance()->display(); }
96 97
97 inline const char *getXDisplayName() const { return m_display_name; } 98 inline const char *getXDisplayName() const { return m_display_name; }
98 inline const char *getApplicationName() const { return m_app_name; } 99 inline const char *getApplicationName() const { return m_app_name; }
@@ -117,7 +118,6 @@ private:
117 } shape; 118 } shape;
118 119
119 bool m_startup, m_shutdown; 120 bool m_startup, m_shutdown;
120 static Display *s_display;
121 121
122 typedef std::vector<ScreenInfo *> ScreenInfoList; 122 typedef std::vector<ScreenInfo *> ScreenInfoList;
123 ScreenInfoList screenInfoList; 123 ScreenInfoList screenInfoList;