diff options
author | fluxgen <fluxgen> | 2002-11-26 16:05:34 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2002-11-26 16:05:34 (GMT) |
commit | 3dacf701543b52c39a39d686a97d657c47dd2e8c (patch) | |
tree | 9a2af20b44eaaa9a7e7b1f875cf5fd372509ff57 /src/BaseDisplay.cc | |
parent | cf287a3fde0c8d5739412eea7a20febcace60885 (diff) | |
download | fluxbox_pavel-3dacf701543b52c39a39d686a97d657c47dd2e8c.zip fluxbox_pavel-3dacf701543b52c39a39d686a97d657c47dd2e8c.tar.bz2 |
display connection from FbTk App
Diffstat (limited to 'src/BaseDisplay.cc')
-rw-r--r-- | src/BaseDisplay.cc | 31 |
1 files changed, 14 insertions, 17 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 | ||
133 | BaseDisplay *BaseDisplay::s_singleton = 0; | 133 | BaseDisplay *BaseDisplay::s_singleton = 0; |
134 | Display *BaseDisplay::s_display = 0; | ||
135 | 134 | ||
136 | BaseDisplay::BaseDisplay(const char *app_name, const char *dpy_name): | 135 | BaseDisplay::BaseDisplay(const char *app_name, const char *dpy_name):FbTk::App(dpy_name), |
137 | m_startup(true), m_shutdown(false), | 136 | m_startup(true), m_shutdown(false), |
138 | m_display_name(XDisplayName(dpy_name)), m_app_name(app_name), | 137 | m_display_name(XDisplayName(dpy_name)), m_app_name(app_name), |
139 | m_server_grabs(0) | 138 | m_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 | ||
235 | bool BaseDisplay::validateWindow(Window window) { | 232 | bool 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 | ||
246 | void BaseDisplay::grab() { | 243 | void 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 | ||
252 | void BaseDisplay::ungrab() { | 249 | void 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 | } |