aboutsummaryrefslogtreecommitdiff
path: root/src/BaseDisplay.cc
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-08-17 22:11:23 (GMT)
committerfluxgen <fluxgen>2002-08-17 22:11:23 (GMT)
commitf1dc9179f068dda1e9bc09b1408157967732847f (patch)
tree148cead2aeede9bc361e50a6158659d656241796 /src/BaseDisplay.cc
parent8e00a92e403451362ce8845148e5558706e5eedd (diff)
downloadfluxbox_pavel-f1dc9179f068dda1e9bc09b1408157967732847f.zip
fluxbox_pavel-f1dc9179f068dda1e9bc09b1408157967732847f.tar.bz2
removed cursor functions, changed to singleton and changed to FbTk EventHandler
Diffstat (limited to 'src/BaseDisplay.cc')
-rw-r--r--src/BaseDisplay.cc73
1 files changed, 40 insertions, 33 deletions
diff --git a/src/BaseDisplay.cc b/src/BaseDisplay.cc
index 1c29179..d38e2e9 100644
--- a/src/BaseDisplay.cc
+++ b/src/BaseDisplay.cc
@@ -22,26 +22,27 @@
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.18 2002/08/14 21:41:21 fluxgen Exp $ 25// $Id: BaseDisplay.cc,v 1.19 2002/08/17 22:11:23 fluxgen Exp $
26 26
27// use GNU extensions
28#ifndef _GNU_SOURCE
29#define _GNU_SOURCE
30#endif // _GNU_SOURCE
31 27
32#ifdef HAVE_CONFIG_H
33# include "../config.h"
34#endif // HAVE_CONFIG_H
35 28
36#include "BaseDisplay.hh" 29#include "BaseDisplay.hh"
37#include "i18n.hh" 30#include "i18n.hh"
38#include "Timer.hh" 31#include "Timer.hh"
39 32
33#ifdef HAVE_CONFIG_H
34#include "../config.h"
35#endif // HAVE_CONFIG_H
36
37// use GNU extensions
38#ifndef _GNU_SOURCE
39#define _GNU_SOURCE
40#endif // _GNU_SOURCE
41
40#include <X11/Xutil.h> 42#include <X11/Xutil.h>
41#include <X11/cursorfont.h>
42 43
43#ifdef SHAPE 44#ifdef SHAPE
44# include <X11/extensions/shape.h> 45#include <X11/extensions/shape.h>
45#endif // SHAPE 46#endif // SHAPE
46 47
47#ifdef HAVE_FCNTL_H 48#ifdef HAVE_FCNTL_H
@@ -87,17 +88,14 @@
87# include <process.h> 88# include <process.h>
88#endif // HAVE_PROCESS_H __EMX__ 89#endif // HAVE_PROCESS_H __EMX__
89 90
90#ifdef DEBUG
91#include <iostream> 91#include <iostream>
92using namespace std; 92using namespace std;
93#endif 93
94// X error handler to handle any and all X errors while the application is 94// X error handler to handle any and all X errors while the application is
95// running 95// running
96static Bool internal_error = False; 96static Bool internal_error = False;
97static Window last_bad_window = None; 97static Window last_bad_window = None;
98 98
99BaseDisplay *base_display;
100
101#ifdef DEBUG 99#ifdef DEBUG
102static int handleXErrors(Display *d, XErrorEvent *e) { 100static int handleXErrors(Display *d, XErrorEvent *e) {
103 char errtxt[128]; 101 char errtxt[128];
@@ -108,7 +106,7 @@ static int handleXErrors(Display *d, XErrorEvent *e) {
108 getMessage( 106 getMessage(
109 FBNLS::BaseDisplaySet, FBNLS::BaseDisplayXError, 107 FBNLS::BaseDisplaySet, FBNLS::BaseDisplayXError,
110 "%s: X error: %s(%d) opcodes %d/%d\n resource 0x%lx\n"), 108 "%s: X error: %s(%d) opcodes %d/%d\n resource 0x%lx\n"),
111 base_display->getApplicationName(), errtxt, e->error_code, 109 BaseDisplay::instance()->getApplicationName(), errtxt, e->error_code,
112 e->request_code, e->minor_code, e->resourceid); 110 e->request_code, e->minor_code, e->resourceid);
113 111
114#else // !DEBUG 112#else // !DEBUG
@@ -137,15 +135,20 @@ void bexec(const char *command, char *displaystring) {
137#endif // !__EMX__ 135#endif // !__EMX__
138 136
139 137
138BaseDisplay *BaseDisplay::s_singleton = 0;
139
140BaseDisplay::BaseDisplay(const char *app_name, const char *dpy_name): 140BaseDisplay::BaseDisplay(const char *app_name, const char *dpy_name):
141m_startup(true), m_shutdown(false), 141m_startup(true), m_shutdown(false),
142m_display_name(XDisplayName(dpy_name)), m_app_name(app_name), 142m_display_name(XDisplayName(dpy_name)), m_app_name(app_name),
143m_server_grabs(0) 143m_server_grabs(0)
144{ 144{
145 145 if (s_singleton != 0)
146 throw string("Can't create more than one instance of BaseDisplay!");
147
148 s_singleton = this;
149
146 last_bad_window = None; 150 last_bad_window = None;
147 I18n *i18n = I18n::instance(); 151 I18n *i18n = I18n::instance();
148 ::base_display = this;
149 152
150 if (! (m_display = XOpenDisplay(dpy_name))) { 153 if (! (m_display = XOpenDisplay(dpy_name))) {
151 fprintf(stderr, 154 fprintf(stderr,
@@ -175,33 +178,37 @@ m_server_grabs(0)
175 shape.extensions = False; 178 shape.extensions = False;
176#endif // SHAPE 179#endif // SHAPE
177 180
178 cursor.session = XCreateFontCursor(m_display, XC_left_ptr); 181
179 cursor.move = XCreateFontCursor(m_display, XC_fleur);
180 cursor.ll_angle = XCreateFontCursor(m_display, XC_ll_angle);
181 cursor.lr_angle = XCreateFontCursor(m_display, XC_lr_angle);
182
183 XSetErrorHandler((XErrorHandler) handleXErrors); 182 XSetErrorHandler((XErrorHandler) handleXErrors);
184 183
185 int i; 184 for (int i = 0; i < number_of_screens; i++) {
186 for (i = 0; i < number_of_screens; i++) {
187 ScreenInfo *screeninfo = new ScreenInfo(this, i); 185 ScreenInfo *screeninfo = new ScreenInfo(this, i);
188 screenInfoList.push_back(screeninfo); 186 screenInfoList.push_back(screeninfo);
189 } 187 }
190} 188}
191 189
192 190
193BaseDisplay::~BaseDisplay(void) { 191BaseDisplay::~BaseDisplay() {
194 192
195 ScreenInfoList::iterator it = screenInfoList.begin(); 193 ScreenInfoList::iterator it = screenInfoList.begin();
196 ScreenInfoList::iterator it_end = screenInfoList.end(); 194 ScreenInfoList::iterator it_end = screenInfoList.end();
197 for (; it != it_end; ++it) { 195 for (; it != it_end; ++it) {
198 delete (*it); 196 delete (*it);
199 } 197 }
200 198
201 XCloseDisplay(m_display); 199 XCloseDisplay(m_display);
200
201 s_singleton = 0;
202}
203
204BaseDisplay *BaseDisplay::instance() {
205 if (s_singleton == 0)
206 throw string("BaseDisplay not created!");
207
208 return s_singleton;
202} 209}
203 210
204void BaseDisplay::eventLoop(void) { 211void BaseDisplay::eventLoop() {
205 run(); 212 run();
206 213
207 while ((! m_shutdown) && (! internal_error)) { 214 while ((! m_shutdown) && (! internal_error)) {
@@ -210,17 +217,17 @@ void BaseDisplay::eventLoop(void) {
210 XNextEvent(m_display, &e); 217 XNextEvent(m_display, &e);
211 218
212 if (last_bad_window != None && e.xany.window == last_bad_window) { 219 if (last_bad_window != None && e.xany.window == last_bad_window) {
213 #ifdef DEBUG 220#ifdef DEBUG
214 fprintf(stderr, 221 fprintf(stderr,
215 I18n::instance()-> 222 I18n::instance()->
216 getMessage( 223 getMessage(
217 FBNLS::BaseDisplaySet, FBNLS::BaseDisplayBadWindowRemove, 224 FBNLS::BaseDisplaySet, FBNLS::BaseDisplayBadWindowRemove,
218 "BaseDisplay::eventLoop(): removing bad window " 225 "BaseDisplay::eventLoop(): removing bad window "
219 "from event queue\n")); 226 "from event queue\n"));
220 #endif // DEBUG 227#endif // DEBUG
221 } else { 228 } else {
222 last_bad_window = None; 229 last_bad_window = None;
223 process_event(&e); 230 handleEvent(&e);
224 } 231 }
225 } else { 232 } else {
226 BTimer::updateTimers(ConnectionNumber(m_display)); //handle all timers 233 BTimer::updateTimers(ConnectionNumber(m_display)); //handle all timers
@@ -240,13 +247,13 @@ bool BaseDisplay::validateWindow(Window window) {
240} 247}
241 248
242 249
243void BaseDisplay::grab(void) { 250void BaseDisplay::grab() {
244 if (! m_server_grabs++) 251 if (! m_server_grabs++)
245 XGrabServer(m_display); 252 XGrabServer(m_display);
246} 253}
247 254
248 255
249void BaseDisplay::ungrab(void) { 256void BaseDisplay::ungrab() {
250 if (! --m_server_grabs) 257 if (! --m_server_grabs)
251 XUngrabServer(m_display); 258 XUngrabServer(m_display);
252 if (m_server_grabs < 0) 259 if (m_server_grabs < 0)