all repos — fluxbox @ 3dacf701543b52c39a39d686a97d657c47dd2e8c

custom fork of the fluxbox windowmanager

display connection from FbTk App
fluxgen fluxgen
commit

3dacf701543b52c39a39d686a97d657c47dd2e8c

parent

cf287a3fde0c8d5739412eea7a20febcace60885

2 files changed, 18 insertions(+), 21 deletions(-)

jump to
M src/BaseDisplay.ccsrc/BaseDisplay.cc

@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: BaseDisplay.cc,v 1.22 2002/11/12 14:40:26 fluxgen Exp $ +// $Id: BaseDisplay.cc,v 1.23 2002/11/26 16:05:34 fluxgen Exp $

@@ -131,9 +131,8 @@ #endif // !__EMX__

BaseDisplay *BaseDisplay::s_singleton = 0; -Display *BaseDisplay::s_display = 0; -BaseDisplay::BaseDisplay(const char *app_name, const char *dpy_name): +BaseDisplay::BaseDisplay(const char *app_name, const char *dpy_name):FbTk::App(dpy_name), m_startup(true), m_shutdown(false), m_display_name(XDisplayName(dpy_name)), m_app_name(app_name), m_server_grabs(0)

@@ -146,7 +145,7 @@

last_bad_window = None; I18n *i18n = I18n::instance(); - if (! (s_display = XOpenDisplay(dpy_name))) { + if (display() == 0) { fprintf(stderr, i18n-> getMessage(

@@ -154,7 +153,7 @@ FBNLS::BaseDisplaySet, FBNLS::BaseDisplayXConnectFail,

"BaseDisplay::BaseDisplay: connection to X server failed.\n")); throw static_cast<int>(2); //throw error 2 - } else if (fcntl(ConnectionNumber(s_display), F_SETFD, 1) == -1) { + } else if (fcntl(ConnectionNumber(display()), F_SETFD, 1) == -1) { fprintf(stderr, i18n-> getMessage(

@@ -165,10 +164,10 @@ throw static_cast<int>(2); //throw error 2

} - number_of_screens = ScreenCount(s_display); + number_of_screens = ScreenCount(display()); #ifdef SHAPE - shape.extensions = XShapeQueryExtension(s_display, &shape.event_basep, + shape.extensions = XShapeQueryExtension(display(), &shape.event_basep, &shape.error_basep); #else // !SHAPE shape.extensions = False;

@@ -191,9 +190,7 @@ ScreenInfoList::iterator it_end = screenInfoList.end();

for (; it != it_end; ++it) { delete (*it); } - - XCloseDisplay(s_display); - s_display = 0; + s_singleton = 0; }

@@ -208,9 +205,9 @@ void BaseDisplay::eventLoop() {

run(); while ((! m_shutdown) && (! internal_error)) { - if (XPending(s_display)) { + if (XPending(display())) { XEvent e; - XNextEvent(s_display, &e); + XNextEvent(display(), &e); if (last_bad_window != None && e.xany.window == last_bad_window) { #ifdef DEBUG

@@ -226,7 +223,7 @@ last_bad_window = None;

handleEvent(&e); } } else { - BTimer::updateTimers(ConnectionNumber(s_display)); //handle all timers + BTimer::updateTimers(ConnectionNumber(display())); //handle all timers } } }

@@ -234,8 +231,8 @@

bool BaseDisplay::validateWindow(Window window) { XEvent event; - if (XCheckTypedWindowEvent(s_display, window, DestroyNotify, &event)) { - XPutBackEvent(s_display, &event); + if (XCheckTypedWindowEvent(display(), window, DestroyNotify, &event)) { + XPutBackEvent(display(), &event); return false; }

@@ -245,13 +242,13 @@

void BaseDisplay::grab() { if (! m_server_grabs++) - XGrabServer(s_display); + XGrabServer(display()); } void BaseDisplay::ungrab() { if (! --m_server_grabs) - XUngrabServer(s_display); + XUngrabServer(display()); if (m_server_grabs < 0) m_server_grabs = 0; }
M src/BaseDisplay.hhsrc/BaseDisplay.hh

@@ -22,12 +22,13 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: BaseDisplay.hh,v 1.31 2002/11/15 11:57:33 fluxgen Exp $ +// $Id: BaseDisplay.hh,v 1.32 2002/11/26 16:05:34 fluxgen Exp $ #ifndef BASEDISPLAY_HH #define BASEDISPLAY_HH #include "NotCopyable.hh" +#include "App.hh" #include "EventHandler.hh" #include <X11/Xlib.h>

@@ -52,7 +53,7 @@ void bexec(const char *command, char *displaystring);

/** Singleton class to manage display connection */ -class BaseDisplay:private NotCopyable, FbTk::EventHandler<XEvent> +class BaseDisplay:public FbTk::App, private FbTk::NotCopyable, FbTk::EventHandler<XEvent> { public: BaseDisplay(const char *app_name, const char *display_name = 0);

@@ -92,7 +93,7 @@ inline bool doShutdown() const { return m_shutdown; }

inline bool isStartup() const { return m_startup; } - static Display *getXDisplay() { return s_display; } + static Display *getXDisplay() { return App::instance()->display(); } inline const char *getXDisplayName() const { return m_display_name; } inline const char *getApplicationName() const { return m_app_name; }

@@ -117,7 +118,6 @@ int event_basep, error_basep;

} shape; bool m_startup, m_shutdown; - static Display *s_display; typedef std::vector<ScreenInfo *> ScreenInfoList; ScreenInfoList screenInfoList;