From c97915f445017d36667a6ad32767fa41d14d23b1 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Mon, 13 Jan 2003 08:48:03 +0000 Subject: [PATCH] un-static otk::Display. add an operator* to it. make a global ob::display var. --- otk/application.cc | 7 +-- otk/application.hh | 1 + otk/appwidget.cc | 6 +-- otk/color.cc | 17 ++++--- otk/display.cc | 100 ++++++++++++++++++++------------------- otk/display.hh | 92 ++++++++++++++++++----------------- otk/eventdispatcher.cc | 20 ++++---- otk/eventhandler.cc | 4 +- otk/focuslabel.cc | 4 +- otk/font.cc | 12 ++--- otk/gccache.cc | 10 ++-- otk/gccache.hh | 2 +- otk/image.cc | 59 +++++++++++------------ otk/imagecontrol.cc | 24 +++++----- otk/label.cc | 4 +- otk/property.cc | 12 ++--- otk/screeninfo.cc | 23 +++++---- otk/style.cc | 26 +++++----- otk/texture.cc | 2 +- otk/timerqueuemanager.cc | 2 +- otk/widget.cc | 28 +++++------ otk/widget.hh | 6 +-- 22 files changed, 230 insertions(+), 231 deletions(-) diff --git a/otk/application.cc b/otk/application.cc index fda65dc1..1c4a32a6 100644 --- a/otk/application.cc +++ b/otk/application.cc @@ -20,15 +20,14 @@ namespace otk { Application::Application(int argc, char **argv) : EventDispatcher(), + _display(), _dockable(false), _appwidget_count(0) { (void)argc; (void)argv; - Display::initialize(0); - const ScreenInfo *s_info = - Display::screenInfo(DefaultScreen(Display::display)); + const ScreenInfo *s_info = _display.screenInfo(DefaultScreen(*_display)); _timer_manager = new TimerQueueManager(); _img_ctrl = new ImageControl(_timer_manager, s_info, True, 4, 5, 200); @@ -44,8 +43,6 @@ Application::~Application() delete _img_ctrl; delete _timer_manager; delete _style; - - Display::destroy(); } void Application::loadStyle(void) diff --git a/otk/application.hh b/otk/application.hh index 220185ad..a0795acc 100644 --- a/otk/application.hh +++ b/otk/application.hh @@ -32,6 +32,7 @@ public: private: void loadStyle(void); + Display _display; TimerQueueManager *_timer_manager; ImageControl *_img_ctrl; Configuration *_style_conf; diff --git a/otk/appwidget.cc b/otk/appwidget.cc index 7541d427..ee542883 100644 --- a/otk/appwidget.cc +++ b/otk/appwidget.cc @@ -20,14 +20,14 @@ AppWidget::AppWidget(Application *app, Direction direction, { assert(app); - _wm_protocols = XInternAtom(Display::display, "WM_PROTOCOLS", false); - _wm_delete = XInternAtom(Display::display, "WM_DELETE_WINDOW", false); + _wm_protocols = XInternAtom(**display, "WM_PROTOCOLS", false); + _wm_delete = XInternAtom(**display, "WM_DELETE_WINDOW", false); // set WM Protocols on the window Atom protocols[2]; protocols[0] = _wm_protocols; protocols[1] = _wm_delete; - XSetWMProtocols(Display::display, window(), protocols, 2); + XSetWMProtocols(**display, window(), protocols, 2); } AppWidget::~AppWidget() diff --git a/otk/color.cc b/otk/color.cc index d8c8f1d1..a05336e5 100644 --- a/otk/color.cc +++ b/otk/color.cc @@ -74,8 +74,8 @@ void Color::parseColorName(void) { } if (scrn == ~(0u)) - scrn = DefaultScreen(Display::display); - Colormap colormap = Display::screenInfo(scrn)->colormap(); + scrn = DefaultScreen(**display); + Colormap colormap = display->screenInfo(scrn)->colormap(); // get rgb values from colorname XColor xcol; @@ -84,7 +84,7 @@ void Color::parseColorName(void) { xcol.blue = 0; xcol.pixel = 0; - if (! XParseColor(Display::display, colormap, + if (! XParseColor(**display, colormap, colorname.c_str(), &xcol)) { fprintf(stderr, "Color::allocate: color parse error: \"%s\"\n", colorname.c_str()); @@ -97,8 +97,8 @@ void Color::parseColorName(void) { void Color::allocate(void) { - if (scrn == ~(0u)) scrn = DefaultScreen(Display::display); - Colormap colormap = Display::screenInfo(scrn)->colormap(); + if (scrn == ~(0u)) scrn = DefaultScreen(**display); + Colormap colormap = display->screenInfo(scrn)->colormap(); if (! isValid()) { if (colorname.empty()) { @@ -127,7 +127,7 @@ void Color::allocate(void) { xcol.blue = b | b << 8; xcol.pixel = 0; - if (! XAllocColor(Display::display, colormap, &xcol)) { + if (! XAllocColor(**display, colormap, &xcol)) { fprintf(stderr, "Color::allocate: color alloc error: rgb:%x/%x/%x\n", r, g, b); xcol.pixel = 0; @@ -187,7 +187,7 @@ void Color::doCacheCleanup(void) { int i; unsigned count; - for (i = 0; i < ScreenCount(Display::display); i++) { + for (i = 0; i < ScreenCount(**display); i++) { count = 0; it = colorcache.begin(); @@ -204,8 +204,7 @@ void Color::doCacheCleanup(void) { } if (count > 0) - XFreeColors(Display::display, - Display::screenInfo(i)->colormap(), + XFreeColors(**display, display->screenInfo(i)->colormap(), pixels, count, 0); } diff --git a/otk/display.cc b/otk/display.cc index 36c7f52f..9bacfca1 100644 --- a/otk/display.cc +++ b/otk/display.cc @@ -48,20 +48,7 @@ extern "C" { namespace otk { -::Display *Display::display = (::Display*) 0; -bool Display::_xkb = false; -int Display::_xkb_event_basep = 0; -bool Display::_shape = false; -int Display::_shape_event_basep = 0; -bool Display::_xinerama = false; -int Display::_xinerama_event_basep = 0; -unsigned int Display::_mask_list[8]; -unsigned int Display::_scrollLockMask = 0; -unsigned int Display::_numLockMask = 0; -Display::ScreenInfoList Display::_screenInfoList; -GCCache *Display::_gccache = (GCCache*) 0; -int Display::_grab_count = 0; - +Display *display = (Display*) 0; static int xerrorHandler(::Display *d, XErrorEvent *e) { @@ -84,19 +71,31 @@ static int xerrorHandler(::Display *d, XErrorEvent *e) } -void Display::initialize(char *name) +Display::Display() + : _display(0), + _xkb(false), + _xkb_event_basep(0), + _shape(false), + _shape_event_basep(0), + _xinerama(false), + _xinerama_event_basep(0), + _mask_list(), + _num_lock_mask(0), + _scroll_lock_mask(0), + _grab_count(0), + _screenInfoList(), + _gccache((GCCache*) 0) { int junk; (void)junk; // Open the X display - if (!(display = XOpenDisplay(name))) { + if (!(_display = XOpenDisplay(NULL))) { printf(_("Unable to open connection to the X server. Please set the \n\ -DISPLAY environment variable approriately, or use the '-display' command \n\ -line argument.\n\n")); +DISPLAY environment variable approriately.\n\n")); ::exit(1); } - if (fcntl(ConnectionNumber(display), F_SETFD, 1) == -1) { + if (fcntl(ConnectionNumber(_display), F_SETFD, 1) == -1) { printf(_("Couldn't mark display connection as close-on-exec.\n\n")); ::exit(1); } @@ -110,26 +109,26 @@ line argument.\n\n")); // set the DISPLAY environment variable for any lauched children, to the // display we're using, so they open in the right place. - putenv(std::string("DISPLAY=") + DisplayString(display)); + putenv(std::string("DISPLAY=") + DisplayString(_display)); // find the availability of X extensions we like to use #ifdef XKB - _xkb = XkbQueryExtension(display, &junk, &_xkb_event_basep, &junk, NULL, + _xkb = XkbQueryExtension(_display, &junk, &_xkb_event_basep, &junk, NULL, NULL); #endif #ifdef SHAPE - _shape = XShapeQueryExtension(display, &_shape_event_basep, &junk); + _shape = XShapeQueryExtension(_display, &_shape_event_basep, &junk); #endif #ifdef XINERAMA - _xinerama = XineramaQueryExtension(display, &_xinerama_event_basep, &junk); + _xinerama = XineramaQueryExtension(_display, &_xinerama_event_basep, &junk); #endif // XINERAMA // get lock masks that are defined by the display (not constant) XModifierKeymap *modmap; - modmap = XGetModifierMapping(display); + modmap = XGetModifierMapping(_display); if (modmap && modmap->max_keypermod > 0) { const int mask_table[] = { ShiftMask, LockMask, ControlMask, Mod1Mask, @@ -140,16 +139,16 @@ line argument.\n\n")); // get the values of the keyboard lock modifiers // Note: Caps lock is not retrieved the same way as Scroll and Num lock // since it doesn't need to be. - const KeyCode num_lock = XKeysymToKeycode(display, XK_Num_Lock); - const KeyCode scroll_lock = XKeysymToKeycode(display, XK_Scroll_Lock); + const KeyCode num_lock = XKeysymToKeycode(_display, XK_Num_Lock); + const KeyCode scroll_lock = XKeysymToKeycode(_display, XK_Scroll_Lock); for (size_t cnt = 0; cnt < size; ++cnt) { if (! modmap->modifiermap[cnt]) continue; if (num_lock == modmap->modifiermap[cnt]) - _numLockMask = mask_table[cnt / modmap->max_keypermod]; + _num_lock_mask = mask_table[cnt / modmap->max_keypermod]; if (scroll_lock == modmap->modifiermap[cnt]) - _scrollLockMask = mask_table[cnt / modmap->max_keypermod]; + _scroll_lock_mask = mask_table[cnt / modmap->max_keypermod]; } } @@ -157,32 +156,33 @@ line argument.\n\n")); _mask_list[0] = 0; _mask_list[1] = LockMask; - _mask_list[2] = _numLockMask; - _mask_list[3] = LockMask | _numLockMask; - _mask_list[4] = _scrollLockMask; - _mask_list[5] = _scrollLockMask | LockMask; - _mask_list[6] = _scrollLockMask | _numLockMask; - _mask_list[7] = _scrollLockMask | LockMask | _numLockMask; + _mask_list[2] = _num_lock_mask; + _mask_list[3] = LockMask | _num_lock_mask; + _mask_list[4] = _scroll_lock_mask; + _mask_list[5] = _scroll_lock_mask | LockMask; + _mask_list[6] = _scroll_lock_mask | _num_lock_mask; + _mask_list[7] = _scroll_lock_mask | LockMask | _num_lock_mask; // Get information on all the screens which are available. - _screenInfoList.reserve(ScreenCount(display)); - for (int i = 0; i < ScreenCount(display); ++i) + _screenInfoList.reserve(ScreenCount(_display)); + for (int i = 0; i < ScreenCount(_display); ++i) _screenInfoList.push_back(ScreenInfo(i)); _gccache = new GCCache(_screenInfoList.size()); } -void Display::destroy() +Display::~Display() { delete _gccache; while (_grab_count > 0) ungrab(); - XCloseDisplay(display); + XCloseDisplay(_display); } -const ScreenInfo* Display::screenInfo(int snum) { +const ScreenInfo* Display::screenInfo(int snum) +{ assert(snum >= 0); assert(snum < static_cast(_screenInfoList.size())); return &_screenInfoList[snum]; @@ -202,7 +202,7 @@ const ScreenInfo* Display::findScreen(Window root) void Display::grab() { if (_grab_count == 0) - XGrabServer(display); + XGrabServer(_display); _grab_count++; } @@ -212,7 +212,7 @@ void Display::ungrab() if (_grab_count == 0) return; _grab_count--; if (_grab_count == 0) - XUngrabServer(display); + XUngrabServer(_display); } @@ -232,11 +232,12 @@ void Display::grabButton(unsigned int button, unsigned int modifiers, Window grab_window, bool owner_events, unsigned int event_mask, int pointer_mode, int keyboard_mode, Window confine_to, - Cursor cursor, bool allow_scroll_lock) { + Cursor cursor, bool allow_scroll_lock) const +{ unsigned int length = (allow_scroll_lock) ? 8 / 2: 8; for (size_t cnt = 0; cnt < length; ++cnt) - XGrabButton(Display::display, button, modifiers | _mask_list[cnt], + XGrabButton(_display, button, modifiers | _mask_list[cnt], grab_window, owner_events, event_mask, pointer_mode, keyboard_mode, confine_to, cursor); } @@ -247,29 +248,30 @@ void Display::grabButton(unsigned int button, unsigned int modifiers, * keyboard lock keys. */ void Display::ungrabButton(unsigned int button, unsigned int modifiers, - Window grab_window) { + Window grab_window) const +{ for (size_t cnt = 0; cnt < 8; ++cnt) - XUngrabButton(Display::display, button, modifiers | _mask_list[cnt], + XUngrabButton(_display, button, modifiers | _mask_list[cnt], grab_window); } void Display::grabKey(unsigned int keycode, unsigned int modifiers, Window grab_window, bool owner_events, int pointer_mode, int keyboard_mode, - bool allow_scroll_lock) + bool allow_scroll_lock) const { unsigned int length = (allow_scroll_lock) ? 8 / 2: 8; for (size_t cnt = 0; cnt < length; ++cnt) - XGrabKey(Display::display, keycode, modifiers | _mask_list[cnt], + XGrabKey(_display, keycode, modifiers | _mask_list[cnt], grab_window, owner_events, pointer_mode, keyboard_mode); } void Display::ungrabKey(unsigned int keycode, unsigned int modifiers, - Window grab_window) + Window grab_window) const { for (size_t cnt = 0; cnt < 8; ++cnt) - XUngrabKey(Display::display, keycode, modifiers | _mask_list[cnt], + XUngrabKey(_display, keycode, modifiers | _mask_list[cnt], grab_window); } diff --git a/otk/display.hh b/otk/display.hh index 4e9b0227..0dc59481 100644 --- a/otk/display.hh +++ b/otk/display.hh @@ -13,6 +13,11 @@ namespace otk { class ScreenInfo; class GCCache; +class Display; + +//! The display instance for the library +extern Display *display; + //! Manages a single X11 display. /*! This class is static, and cannot be instantiated. @@ -22,42 +27,42 @@ class GCCache; class Display { public: - //! The X display - static ::Display *display; - //! A List of ScreenInfo instances typedef std::vector ScreenInfoList; private: + //! The X display + ::Display *_display; + //! Does the display have the XKB extension? - static bool _xkb; + bool _xkb; //! Base for events for the XKB extension - static int _xkb_event_basep; + int _xkb_event_basep; //! Does the display have the Shape extension? - static bool _shape; + bool _shape; //! Base for events for the Shape extension - static int _shape_event_basep; + int _shape_event_basep; //! Does the display have the Xinerama extension? - static bool _xinerama; + bool _xinerama; //! Base for events for the Xinerama extension - static int _xinerama_event_basep; + int _xinerama_event_basep; //! A list of all possible combinations of keyboard lock masks - static unsigned int _mask_list[8]; + unsigned int _mask_list[8]; //! The value of the mask for the NumLock modifier - static unsigned int _numLockMask; + unsigned int _num_lock_mask; //! The value of the mask for the ScrollLock modifier - static unsigned int _scrollLockMask; + unsigned int _scroll_lock_mask; //! The number of requested grabs on the display - static int _grab_count; + int _grab_count; //! A list of information for all screens on the display - static ScreenInfoList _screenInfoList; + ScreenInfoList _screenInfoList; //! A cache for re-using GCs, used by the drawing objects /*! @@ -67,30 +72,26 @@ private: @see ImageControl @see Texture */ - static GCCache *_gccache; + GCCache *_gccache; // Handles X errors on the display /* Displays the error if compiled for debugging. */ - //static int xerrorHandler(::Display *d, XErrorEvent *e); - - //! Prevents instantiation of the class - Display(); + //int xerrorHandler(::Display *d, XErrorEvent *e); public: //! Initializes the class, opens the X display /*! + The DISPLAY environment variable is used to choose the display. @see Display::display - @param name The name of the X display to open. If it is null, the DISPLAY - environment variable is used instead. */ - static void initialize(char *name); + Display(); //! Destroys the class, closes the X display - static void destroy(); + ~Display(); //! Returns the GC cache for the application - inline static GCCache *gcCache() { return _gccache; } + inline GCCache *gcCache() const { return _gccache; } //! Gets information on a specific screen /*! @@ -99,47 +100,50 @@ public: @param snum The screen number of the screen to retrieve info on @return Info on the requested screen, in a ScreenInfo class */ - static const ScreenInfo* screenInfo(int snum); + const ScreenInfo* screenInfo(int snum); //! Find a ScreenInfo based on a root window - static const ScreenInfo* findScreen(Window root); + const ScreenInfo* findScreen(Window root); //! Returns if the display has the xkb extension available - inline static bool xkb() { return _xkb; } + inline bool xkb() const { return _xkb; } //! Returns the xkb extension's event base - inline static int xkbEventBase() { return _xkb_event_basep; } + inline int xkbEventBase() const { return _xkb_event_basep; } //! Returns if the display has the shape extension available - inline static bool shape() { return _shape; } + inline bool shape() const { return _shape; } //! Returns the shape extension's event base - inline static int shapeEventBase() { return _shape_event_basep; } + inline int shapeEventBase() const { return _shape_event_basep; } //! Returns if the display has the xinerama extension available - inline static bool xinerama() { return _xinerama; } + inline bool xinerama() const { return _xinerama; } - inline static unsigned int numLockMask() { return _numLockMask; } - inline static unsigned int scrollLockMask() { return _scrollLockMask; } + inline unsigned int numLockMask() const { return _num_lock_mask; } + inline unsigned int scrollLockMask() const { return _scroll_lock_mask; } + + inline ::Display* operator*() const { return _display; } //! Grabs the display - static void grab(); + void grab(); //! Ungrabs the display - static void ungrab(); + void ungrab(); /* TEMPORARY */ - static void grabButton(unsigned int button, unsigned int modifiers, + void grabButton(unsigned int button, unsigned int modifiers, Window grab_window, bool owner_events, unsigned int event_mask, int pointer_mode, int keyboard_mode, Window confine_to, Cursor cursor, - bool allow_scroll_lock); - static void ungrabButton(unsigned int button, unsigned int modifiers, - Window grab_window); - static void grabKey(unsigned int keycode, unsigned int modifiers, - Window grab_window, bool owner_events, - int pointer_mode, int keyboard_mode, bool allow_scroll_lock); - static void ungrabKey(unsigned int keycode, unsigned int modifiers, - Window grab_window); + bool allow_scroll_lock) const; + void ungrabButton(unsigned int button, unsigned int modifiers, + Window grab_window) const; + void grabKey(unsigned int keycode, unsigned int modifiers, + Window grab_window, bool owner_events, + int pointer_mode, int keyboard_mode, + bool allow_scroll_lock) const; + void ungrabKey(unsigned int keycode, unsigned int modifiers, + Window grab_window) const; }; } diff --git a/otk/eventdispatcher.cc b/otk/eventdispatcher.cc index ff3b8b64..c5cefe2c 100644 --- a/otk/eventdispatcher.cc +++ b/otk/eventdispatcher.cc @@ -38,8 +38,8 @@ void EventDispatcher::dispatchEvents(void) { XEvent e; - while (XPending(Display::display)) { - XNextEvent(Display::display, &e); + while (XPending(**display)) { + XNextEvent(**display, &e); #if 0//defined(DEBUG) printf("Event %d window %lx\n", e.type, e.xany.window); @@ -71,17 +71,17 @@ void EventDispatcher::dispatchEvents(void) case ButtonPress: case ButtonRelease: _lasttime = e.xbutton.time; - e.xbutton.state &= ~(LockMask | Display::numLockMask() | - Display::scrollLockMask()); + e.xbutton.state &= ~(LockMask | display->numLockMask() | + display->scrollLockMask()); break; case KeyPress: - e.xkey.state &= ~(LockMask | Display::numLockMask() | - Display::scrollLockMask()); + e.xkey.state &= ~(LockMask | display->numLockMask() | + display->scrollLockMask()); break; case MotionNotify: _lasttime = e.xmotion.time; - e.xmotion.state &= ~(LockMask | Display::numLockMask() | - Display::scrollLockMask()); + e.xmotion.state &= ~(LockMask | display->numLockMask() | + display->scrollLockMask()); break; case PropertyNotify: _lasttime = e.xproperty.time; @@ -116,7 +116,7 @@ void EventDispatcher::dispatchFocus(const XEvent &e) // FocusOut events just make us look for FocusIn events. They are ignored // otherwise. XEvent fi; - if (XCheckTypedEvent(Display::display, FocusIn, &fi)) { + if (XCheckTypedEvent(**display, FocusIn, &fi)) { //printf("Found FocusIn\n"); dispatchFocus(fi); // dont unfocus the window we just focused! @@ -157,7 +157,7 @@ void EventDispatcher::dispatch(Window win, const XEvent &e) xwc.sibling = e.xconfigurerequest.above; xwc.stack_mode = e.xconfigurerequest.detail; - XConfigureWindow(otk::Display::display, e.xconfigurerequest.window, + XConfigureWindow(**display, e.xconfigurerequest.window, e.xconfigurerequest.value_mask, &xwc); } else { // grab a falback if it exists diff --git a/otk/eventhandler.cc b/otk/eventhandler.cc index e4a24df8..c867d809 100644 --- a/otk/eventhandler.cc +++ b/otk/eventhandler.cc @@ -88,11 +88,11 @@ void EventHandler::handle(const XEvent &e) return selectionRequestHandler(e.xselectionrequest); default: #ifdef SHAPE - if (e.type == Display::shapeEventBase()) + if (e.type == display->shapeEventBase()) return shapeHandler((*(XShapeEvent*)&e)); #endif // SHAPE #ifdef XKB - if (e.type == Display::xkbEventBase()) + if (e.type == display->xkbEventBase()) return xkbHandler((*(XkbEvent*)&e)); #endif // XKB ; diff --git a/otk/focuslabel.cc b/otk/focuslabel.cc index 79c1507f..b1b8c764 100644 --- a/otk/focuslabel.cc +++ b/otk/focuslabel.cc @@ -13,8 +13,8 @@ namespace otk { FocusLabel::FocusLabel(Widget *parent) : FocusWidget(parent), _text("") { - const ScreenInfo *info = Display::screenInfo(screen()); - _xftdraw = XftDrawCreate(Display::display, window(), info->visual(), + const ScreenInfo *info = display->screenInfo(screen()); + _xftdraw = XftDrawCreate(**display, window(), info->visual(), info->colormap()); } diff --git a/otk/font.cc b/otk/font.cc index 6fbdb095..a9f2fd3e 100644 --- a/otk/font.cc +++ b/otk/font.cc @@ -56,14 +56,14 @@ Font::Font(int screen_num, const std::string &fontstring, _xft_init = true; } - if ((_xftfont = XftFontOpenName(Display::display, _screen_num, + if ((_xftfont = XftFontOpenName(**display, _screen_num, _fontstring.c_str()))) return; printf(_("Unable to load font: %s\n"), _fontstring.c_str()); printf(_("Trying fallback font: %s\n"), _fallback_font.c_str()); - if ((_xftfont = XftFontOpenName(Display::display, _screen_num, + if ((_xftfont = XftFontOpenName(**display, _screen_num, _fallback_font.c_str()))) return; @@ -77,7 +77,7 @@ Font::Font(int screen_num, const std::string &fontstring, Font::~Font(void) { if (_xftfont) - XftFontClose(Display::display, _xftfont); + XftFontClose(**display, _xftfont); } @@ -92,7 +92,7 @@ void Font::drawString(XftDraw *d, int x, int y, const Color &color, c.color.green = 0; c.color.blue = 0; c.color.alpha = _tint | _tint << 8; // transparent shadow - c.pixel = BlackPixel(Display::display, _screen_num); + c.pixel = BlackPixel(**display, _screen_num); if (string.utf8()) XftDrawStringUtf8(d, &c, _xftfont, x + _offset, @@ -127,10 +127,10 @@ unsigned int Font::measureString(const ustring &string) const XGlyphInfo info; if (string.utf8()) - XftTextExtentsUtf8(Display::display, _xftfont, + XftTextExtentsUtf8(**display, _xftfont, (FcChar8*)string.c_str(), string.size(), &info); else - XftTextExtents8(Display::display, _xftfont, + XftTextExtents8(**display, _xftfont, (FcChar8*)string.c_str(), string.size(), &info); return info.xOff + (_shadow ? _offset : 0); diff --git a/otk/gccache.cc b/otk/gccache.cc index 02d3b80b..554fd143 100644 --- a/otk/gccache.cc +++ b/otk/gccache.cc @@ -19,7 +19,7 @@ namespace otk { GCCacheContext::~GCCacheContext(void) { if (gc) - XFreeGC(Display::display, gc); + XFreeGC(**display, gc); } @@ -44,7 +44,7 @@ void GCCacheContext::set(const Color &_color, fontid = 0; } - XChangeGC(Display::display, gc, mask, &gcv); + XChangeGC(**display, gc, mask, &gcv); } @@ -56,7 +56,7 @@ void GCCacheContext::set(const XFontStruct * const _font) { XGCValues gcv; fontid = gcv.font = _font->fid; - XChangeGC(Display::display, gc, GCFont, &gcv); + XChangeGC(**display, gc, GCFont, &gcv); } @@ -86,7 +86,7 @@ GCCache::~GCCache(void) { GCCacheContext *GCCache::nextContext(unsigned int scr) { - Window hd = Display::screenInfo(scr)->rootWindow(); + Window hd = display->screenInfo(scr)->rootWindow(); GCCacheContext *c; @@ -94,7 +94,7 @@ GCCacheContext *GCCache::nextContext(unsigned int scr) { c = contexts[i]; if (! c->gc) { - c->gc = XCreateGC(Display::display, hd, 0, 0); + c->gc = XCreateGC(**display, hd, 0, 0); c->used = false; c->screen = scr; } diff --git a/otk/gccache.hh b/otk/gccache.hh index 86daff0e..ff72497b 100644 --- a/otk/gccache.hh +++ b/otk/gccache.hh @@ -93,7 +93,7 @@ public: int _linewidth = 0, int _function = GXcopy, int _subwindow = ClipByChildren) : color(_color), font(_font), linewidth(_linewidth), function(_function), - subwindow(_subwindow), cache(Display::gcCache()), item(0) { } + subwindow(_subwindow), cache(display->gcCache()), item(0) { } inline ~Pen(void) { if (item) cache->release(item); } diff --git a/otk/image.cc b/otk/image.cc index 0d1c57a2..1c0ecaf0 100644 --- a/otk/image.cc +++ b/otk/image.cc @@ -62,8 +62,7 @@ Pixmap Image::render(const Texture &texture) { Pixmap Image::render_solid(const Texture &texture) { - Pixmap pixmap = XCreatePixmap(Display::display, - control->getDrawable(), width, + Pixmap pixmap = XCreatePixmap(**display, control->getDrawable(), width, height, control->getDepth()); if (pixmap == None) { fprintf(stderr, "Image::render_solid: error creating pixmap\n"); @@ -74,64 +73,64 @@ Pixmap Image::render_solid(const Texture &texture) { Pen penlight(texture.lightColor()); Pen penshadow(texture.shadowColor()); - XFillRectangle(Display::display, pixmap, pen.gc(), 0, 0, width, height); + XFillRectangle(**display, pixmap, pen.gc(), 0, 0, width, height); if (texture.texture() & Texture::Interlaced) { Pen peninterlace(texture.colorTo()); for (unsigned int i = 0; i < height; i += 2) - XDrawLine(Display::display, pixmap, peninterlace.gc(), 0, i, width, i); + XDrawLine(**display, pixmap, peninterlace.gc(), 0, i, width, i); } int left = 0, top = 0, right = width - 1, bottom = height - 1; if (texture.texture() & Texture::Border) { Pen penborder(texture.borderColor()); - XDrawRectangle(Display::display, pixmap, penborder.gc(), + XDrawRectangle(**display, pixmap, penborder.gc(), left, top, right, bottom); } if (texture.texture() & Texture::Bevel1) { if (texture.texture() & Texture::Raised) { - XDrawLine(Display::display, pixmap, penshadow.gc(), + XDrawLine(**display, pixmap, penshadow.gc(), left, bottom, right, bottom); - XDrawLine(Display::display, pixmap, penshadow.gc(), + XDrawLine(**display, pixmap, penshadow.gc(), right, bottom, right, top); - XDrawLine(Display::display, pixmap, penlight.gc(), + XDrawLine(**display, pixmap, penlight.gc(), left, top, right, top); - XDrawLine(Display::display, pixmap, penlight.gc(), + XDrawLine(**display, pixmap, penlight.gc(), left, bottom, left, top); } else if (texture.texture() & Texture::Sunken) { - XDrawLine(Display::display, pixmap, penlight.gc(), + XDrawLine(**display, pixmap, penlight.gc(), left, bottom, right, bottom); - XDrawLine(Display::display, pixmap, penlight.gc(), + XDrawLine(**display, pixmap, penlight.gc(), right, bottom, right, top); - XDrawLine(Display::display, pixmap, penshadow.gc(), + XDrawLine(**display, pixmap, penshadow.gc(), left, top, right, top); - XDrawLine(Display::display, pixmap, penshadow.gc(), + XDrawLine(**display, pixmap, penshadow.gc(), left, bottom, left, top); } } else if (texture.texture() & Texture::Bevel2) { if (texture.texture() & Texture::Raised) { - XDrawLine(Display::display, pixmap, penshadow.gc(), + XDrawLine(**display, pixmap, penshadow.gc(), left + 1, bottom - 2, right - 2, bottom - 2); - XDrawLine(Display::display, pixmap, penshadow.gc(), + XDrawLine(**display, pixmap, penshadow.gc(), right - 2, bottom - 2, right - 2, top + 1); - XDrawLine(Display::display, pixmap, penlight.gc(), + XDrawLine(**display, pixmap, penlight.gc(), left + 1, top + 1, right - 2, top + 1); - XDrawLine(Display::display, pixmap, penlight.gc(), + XDrawLine(**display, pixmap, penlight.gc(), left + 1, bottom - 2, left + 1, top + 1); } else if (texture.texture() & Texture::Sunken) { - XDrawLine(Display::display, pixmap, penlight.gc(), + XDrawLine(**display, pixmap, penlight.gc(), left + 1, bottom - 2, right - 2, bottom - 2); - XDrawLine(Display::display, pixmap, penlight.gc(), + XDrawLine(**display, pixmap, penlight.gc(), right - 2, bottom - 2, right - 2, top + 1); - XDrawLine(Display::display, pixmap, penshadow.gc(), + XDrawLine(**display, pixmap, penshadow.gc(), left + 1, top + 1, right - 2, top + 1); - XDrawLine(Display::display, pixmap, penshadow.gc(), + XDrawLine(**display, pixmap, penshadow.gc(), left + 1, bottom - 2, left + 1, top + 1); } } @@ -425,9 +424,8 @@ void Image::PseudoColorDither(int bytes_per_line, unsigned char *pixel_data) { XImage *Image::renderXImage(void) { XImage *image = - XCreateImage(Display::display, - control->getVisual(), control->getDepth(), ZPixmap, 0, 0, - width, height, 32, 0); + XCreateImage(**display, control->getVisual(), control->getDepth(), + ZPixmap, 0, 0,width, height, 32, 0); if (! image) { fprintf(stderr, "Image::renderXImage: error creating XImage\n"); @@ -539,8 +537,8 @@ XImage *Image::renderXImage(void) { Pixmap Image::renderPixmap(void) { Pixmap pixmap = - XCreatePixmap(Display::display, - control->getDrawable(), width, height, control->getDepth()); + XCreatePixmap(**display, control->getDrawable(), width, height, + control->getDepth()); if (pixmap == None) { fprintf(stderr, "Image::renderPixmap: error creating pixmap\n"); @@ -550,19 +548,18 @@ Pixmap Image::renderPixmap(void) { XImage *image = renderXImage(); if (! image) { - XFreePixmap(Display::display, pixmap); + XFreePixmap(**display, pixmap); return None; } if (! image->data) { XDestroyImage(image); - XFreePixmap(Display::display, pixmap); + XFreePixmap(**display, pixmap); return None; } - XPutImage(Display::display, pixmap, - DefaultGC(Display::display, - control->getScreenInfo()->screen()), + XPutImage(**display, pixmap, + DefaultGC(**display, control->getScreenInfo()->screen()), image, 0, 0, 0, 0, width, height); if (image->data) { diff --git a/otk/imagecontrol.cc b/otk/imagecontrol.cc index 4496c0d5..348e2343 100644 --- a/otk/imagecontrol.cc +++ b/otk/imagecontrol.cc @@ -75,7 +75,7 @@ ImageControl::ImageControl(TimerQueueManager *timermanager, colormap = screeninfo->colormap(); int count; - XPixmapFormatValues *pmv = XListPixmapFormats(Display::display, + XPixmapFormatValues *pmv = XListPixmapFormats(**display, &count); if (pmv) { bits_per_pixel = 0; @@ -168,7 +168,7 @@ ImageControl::ImageControl(TimerQueueManager *timermanager, } for (i = 0; i < ncolors; i++) { - if (! XAllocColor(Display::display, colormap, &colors[i])) { + if (! XAllocColor(**display, colormap, &colors[i])) { fprintf(stderr, "couldn't alloc color %i %i %i\n", colors[i].red, colors[i].green, colors[i].blue); colors[i].flags = 0; @@ -183,7 +183,7 @@ ImageControl::ImageControl(TimerQueueManager *timermanager, for (i = 0; i < incolors; i++) icolors[i].pixel = i; - XQueryColors(Display::display, colormap, icolors, incolors); + XQueryColors(**display, colormap, icolors, incolors); for (i = 0; i < ncolors; i++) { if (! colors[i].flags) { unsigned long chk = 0xffffffff, pixel, close = 0; @@ -205,7 +205,7 @@ ImageControl::ImageControl(TimerQueueManager *timermanager, colors[i].green = icolors[close].green; colors[i].blue = icolors[close].blue; - if (XAllocColor(Display::display, colormap, + if (XAllocColor(**display, colormap, &colors[i])) { colors[i].flags = DoRed|DoGreen|DoBlue; break; @@ -262,7 +262,7 @@ ImageControl::ImageControl(TimerQueueManager *timermanager, colors[i].blue = (i * 0xffff) / (colors_per_channel - 1);; colors[i].flags = DoRed|DoGreen|DoBlue; - if (! XAllocColor(Display::display, colormap, + if (! XAllocColor(**display, colormap, &colors[i])) { fprintf(stderr, "couldn't alloc color %i %i %i\n", colors[i].red, colors[i].green, colors[i].blue); @@ -279,7 +279,7 @@ ImageControl::ImageControl(TimerQueueManager *timermanager, for (i = 0; i < incolors; i++) icolors[i].pixel = i; - XQueryColors(Display::display, colormap, icolors, incolors); + XQueryColors(**display, colormap, icolors, incolors); for (i = 0; i < ncolors; i++) { if (! colors[i].flags) { unsigned long chk = 0xffffffff, pixel, close = 0; @@ -301,7 +301,7 @@ ImageControl::ImageControl(TimerQueueManager *timermanager, colors[i].green = icolors[close].green; colors[i].blue = icolors[close].blue; - if (XAllocColor(Display::display, colormap, + if (XAllocColor(**display, colormap, &colors[i])) { colors[i].flags = DoRed|DoGreen|DoBlue; break; @@ -335,7 +335,7 @@ ImageControl::~ImageControl(void) { for (int i = 0; i < ncolors; i++) *(pixels + i) = (*(colors + i)).pixel; - XFreeColors(Display::display, colormap, pixels, ncolors, 0); + XFreeColors(**display, colormap, pixels, ncolors, 0); delete [] colors; } @@ -348,7 +348,7 @@ ImageControl::~ImageControl(void) { CacheContainer::iterator it = cache.begin(); const CacheContainer::iterator end = cache.end(); for (; it != end; ++it) - XFreePixmap(Display::display, it->pixmap); + XFreePixmap(**display, it->pixmap); } if (timer) { timer->stop(); @@ -499,7 +499,7 @@ void ImageControl::getGradientBuffers(unsigned int w, void ImageControl::installRootColormap(void) { int ncmap = 0; Colormap *cmaps = - XListInstalledColormaps(Display::display, window, &ncmap); + XListInstalledColormaps(**display, window, &ncmap); if (cmaps) { bool install = True; @@ -508,7 +508,7 @@ void ImageControl::installRootColormap(void) { install = False; if (install) - XInstallColormap(Display::display, colormap); + XInstallColormap(**display, colormap); XFree(cmaps); } @@ -548,7 +548,7 @@ struct CacheCleaner { CacheCleaner() {} inline void operator()(const ImageControl::CachedImage& image) const { if (ref_check(image)) - XFreePixmap(Display::display, image.pixmap); + XFreePixmap(**display, image.pixmap); } }; diff --git a/otk/label.cc b/otk/label.cc index 05ed6cfa..da9edfd1 100644 --- a/otk/label.cc +++ b/otk/label.cc @@ -11,8 +11,8 @@ namespace otk { Label::Label(Widget *parent) : Widget(parent), _text("") { - const ScreenInfo *info = Display::screenInfo(screen()); - _xftdraw = XftDrawCreate(Display::display, window(), info->visual(), + const ScreenInfo *info = display->screenInfo(screen()); + _xftdraw = XftDrawCreate(**display, window(), info->visual(), info->colormap()); } diff --git a/otk/property.cc b/otk/property.cc index ab99cd89..44741083 100644 --- a/otk/property.cc +++ b/otk/property.cc @@ -17,7 +17,7 @@ namespace otk { Property::Property() { - assert(Display::display); + assert(**display); // make sure asserts fire if there is a problem memset(_atoms, 0, sizeof(_atoms)); @@ -163,7 +163,7 @@ Property::~Property() */ Atom Property::create(const char *name) const { - Atom a = XInternAtom(Display::display, name, False); + Atom a = XInternAtom(**display, name, False); assert(a); return a; } @@ -181,7 +181,7 @@ void Property::set(Window win, Atom atom, Atom type, assert(win != None); assert(atom != None); assert(type != None); assert(nelements == 0 || (nelements > 0 && data != (unsigned char *) 0)); assert(size == 8 || size == 16 || size == 32); - XChangeProperty(Display::display, win, atom, type, size, + XChangeProperty(**display, win, atom, type, size, (append ? PropModeAppend : PropModeReplace), data, nelements); } @@ -291,7 +291,7 @@ bool Property::get(Window win, Atom atom, Atom type, bool ret = False; // try get the first element - result = XGetWindowProperty(Display::display, win, atom, 0l, 1l, + result = XGetWindowProperty(**display, win, atom, 0l, 1l, False, AnyPropertyType, &ret_type, &ret_size, nelements, &ret_bytes, &c_val); ret = (result == Success && ret_type == type && ret_size == size && @@ -309,7 +309,7 @@ bool Property::get(Window win, Atom atom, Atom type, int remain = (ret_bytes - 1)/sizeof(long) + 1 + 1; if (remain > size/8 * (signed)maxread) // dont get more than the max remain = size/8 * (signed)maxread; - result = XGetWindowProperty(Display::display, win, atom, 0l, + result = XGetWindowProperty(**display, win, atom, 0l, remain, False, type, &ret_type, &ret_size, nelements, &ret_bytes, &c_val); ret = (result == Success && ret_type == type && ret_size == size && @@ -430,7 +430,7 @@ bool Property::get(Window win, Atoms atom, StringType type, void Property::erase(Window win, Atoms atom) const { assert(atom >= 0 && atom < NUM_ATOMS); - XDeleteProperty(Display::display, win, _atoms[atom]); + XDeleteProperty(**display, win, _atoms[atom]); } } diff --git a/otk/screeninfo.cc b/otk/screeninfo.cc index e4e98cba..087f4efd 100644 --- a/otk/screeninfo.cc +++ b/otk/screeninfo.cc @@ -20,11 +20,11 @@ namespace otk { ScreenInfo::ScreenInfo(unsigned int num) { _screen = num; - _root_window = RootWindow(Display::display, _screen); + _root_window = RootWindow(**display, _screen); - _rect.setSize(WidthOfScreen(ScreenOfDisplay(Display::display, + _rect.setSize(WidthOfScreen(ScreenOfDisplay(**display, _screen)), - HeightOfScreen(ScreenOfDisplay(Display::display, + HeightOfScreen(ScreenOfDisplay(**display, _screen))); /* If the default depth is at least 8 we will use that, @@ -32,9 +32,9 @@ ScreenInfo::ScreenInfo(unsigned int num) { Preference is given to 24 bit over larger depths if 24 bit is an option. */ - _depth = DefaultDepth(Display::display, _screen); - _visual = DefaultVisual(Display::display, _screen); - _colormap = DefaultColormap(Display::display, _screen); + _depth = DefaultDepth(**display, _screen); + _visual = DefaultVisual(**display, _screen); + _colormap = DefaultColormap(**display, _screen); if (_depth < 8) { // search for a TrueColor Visual... if we can't find one... @@ -46,7 +46,7 @@ ScreenInfo::ScreenInfo(unsigned int num) { vinfo_template.screen = _screen; vinfo_template.c_class = TrueColor; - vinfo_return = XGetVisualInfo(Display::display, + vinfo_return = XGetVisualInfo(**display, VisualScreenMask | VisualClassMask, &vinfo_template, &vinfo_nitems); if (vinfo_return) { @@ -65,7 +65,7 @@ ScreenInfo::ScreenInfo(unsigned int num) { if (best != -1) { _depth = vinfo_return[best].depth; _visual = vinfo_return[best].visual; - _colormap = XCreateColormap(Display::display, _root_window, _visual, + _colormap = XCreateColormap(**display, _root_window, _visual, AllocNone); } @@ -73,7 +73,7 @@ ScreenInfo::ScreenInfo(unsigned int num) { } // get the default display string and strip the screen number - string default_string = DisplayString(Display::display); + string default_string = DisplayString(**display); const string::size_type pos = default_string.rfind("."); if (pos != string::npos) default_string.resize(pos); @@ -93,7 +93,7 @@ ScreenInfo::ScreenInfo(unsigned int num) { in future versions we should be able, so the 'activeness' is checked on a pre-screen basis anyways. */ - if (XineramaIsActive(Display::display)) { + if (XineramaIsActive(**display)) { /* If Xinerama is being used, there there is only going to be one screen present. We still, of course, want to use the screen class, but that @@ -101,8 +101,7 @@ ScreenInfo::ScreenInfo(unsigned int num) { never be more than one screen present with Xinerama active. */ int num; - XineramaScreenInfo *info = XineramaQueryScreens(Display::display, - &num); + XineramaScreenInfo *info = XineramaQueryScreens(**display, &num); if (num > 0 && info) { _xinerama_areas.reserve(num); for (int i = 0; i < num; ++i) { diff --git a/otk/style.cc b/otk/style.cc index ad9cf139..20c64937 100644 --- a/otk/style.cc +++ b/otk/style.cc @@ -28,13 +28,13 @@ Style::~Style() { delete font; if (close_button.mask != None) - XFreePixmap(Display::display, close_button.mask); + XFreePixmap(**display, close_button.mask); if (max_button.mask != None) - XFreePixmap(Display::display, max_button.mask); + XFreePixmap(**display, max_button.mask); if (icon_button.mask != None) - XFreePixmap(Display::display, icon_button.mask); + XFreePixmap(**display, icon_button.mask); if (stick_button.mask != None) - XFreePixmap(Display::display, stick_button.mask); + XFreePixmap(**display, stick_button.mask); max_button.mask = None; close_button.mask = None; @@ -83,13 +83,13 @@ void Style::load(const Configuration &style) { } if (close_button.mask != None) - XFreePixmap(Display::display, close_button.mask); + XFreePixmap(**display, close_button.mask); if (max_button.mask != None) - XFreePixmap(Display::display, max_button.mask); + XFreePixmap(**display, max_button.mask); if (icon_button.mask != None) - XFreePixmap(Display::display, icon_button.mask); + XFreePixmap(**display, icon_button.mask); if (stick_button.mask != None) - XFreePixmap(Display::display, stick_button.mask); + XFreePixmap(**display, stick_button.mask); close_button.mask = max_button.mask = icon_button.mask = icon_button.mask = None; @@ -143,7 +143,7 @@ void Style::load(const Configuration &style) { // load bevel, border and handle widths - const ScreenInfo *s_info = Display::screenInfo(screen_number); + const ScreenInfo *s_info = display->screenInfo(screen_number); unsigned int width = s_info->rect().width(); if (! style.getValue("handleWidth", handle_width) || @@ -168,7 +168,7 @@ void Style::load(const Configuration &style) { void Style::readDatabaseMask(const std::string &rname, PixmapMask &pixmapMask, const Configuration &style) { - Window root_window = Display::screenInfo(screen_number)->rootWindow(); + Window root_window = display->screenInfo(screen_number)->rootWindow(); std::string s; int hx, hy; //ignored int ret = BitmapOpenFailed; //default to failure. @@ -176,17 +176,17 @@ void Style::readDatabaseMask(const std::string &rname, PixmapMask &pixmapMask, if (style.getValue(rname, s)) { if (s[0] != '/' && s[0] != '~') { std::string xbmFile = std::string("~/.openbox/buttons/") + s; - ret = XReadBitmapFile(Display::display, root_window, + ret = XReadBitmapFile(**display, root_window, expandTilde(xbmFile).c_str(), &pixmapMask.w, &pixmapMask.h, &pixmapMask.mask, &hx, &hy); if (ret != BitmapSuccess) { xbmFile = std::string(BUTTONSDIR) + "/" + s; - ret = XReadBitmapFile(Display::display, root_window, + ret = XReadBitmapFile(**display, root_window, xbmFile.c_str(), &pixmapMask.w, &pixmapMask.h, &pixmapMask.mask, &hx, &hy); } } else - ret = XReadBitmapFile(Display::display, root_window, + ret = XReadBitmapFile(**display, root_window, expandTilde(s).c_str(), &pixmapMask.w, &pixmapMask.h, &pixmapMask.mask, &hx, &hy); diff --git a/otk/texture.cc b/otk/texture.cc index 77a7192b..67addc3b 100644 --- a/otk/texture.cc +++ b/otk/texture.cc @@ -164,7 +164,7 @@ Pixmap Texture::render(const unsigned int width, const unsigned int height, return ParentRelative; if (screen() == ~(0u)) - scrn = DefaultScreen(Display::display); + scrn = DefaultScreen(**display); assert(ctrl != 0); Pixmap ret = ctrl->renderImage(width, height, *this); diff --git a/otk/timerqueuemanager.cc b/otk/timerqueuemanager.cc index 1d6b50ce..e5f0a741 100644 --- a/otk/timerqueuemanager.cc +++ b/otk/timerqueuemanager.cc @@ -14,7 +14,7 @@ void TimerQueueManager::fire(bool wait) fd_set rfds; timeval now, tm, *timeout = (timeval *) 0; - const int xfd = ConnectionNumber(Display::display); + const int xfd = ConnectionNumber(**display); FD_ZERO(&rfds); FD_SET(xfd, &rfds); // break on any x events diff --git a/otk/widget.cc b/otk/widget.cc index 604992fd..4ba2c806 100644 --- a/otk/widget.cc +++ b/otk/widget.cc @@ -65,12 +65,12 @@ Widget::~Widget() if (_parent) _parent->removeChild(this); - XDestroyWindow(Display::display, _window); + XDestroyWindow(**display, _window); } void Widget::create(bool override_redirect) { - const ScreenInfo *scr_info = Display::screenInfo(_screen); + const ScreenInfo *scr_info = display->screenInfo(_screen); Window p_window = _parent ? _parent->window() : scr_info->rootWindow(); _rect.setRect(0, 0, 1, 1); // just some initial values @@ -93,7 +93,7 @@ void Widget::create(bool override_redirect) attrib_create.cursor = _cursor; } - _window = XCreateWindow(Display::display, p_window, _rect.x(), + _window = XCreateWindow(**display, p_window, _rect.x(), _rect.y(), _rect.width(), _rect.height(), 0, scr_info->depth(), InputOutput, scr_info->visual(), create_mask, &attrib_create); @@ -122,7 +122,7 @@ void Widget::move(const Point &to) void Widget::move(int x, int y) { _rect.setPos(x, y); - XMoveWindow(Display::display, _window, x, y); + XMoveWindow(**display, _window, x, y); _ignore_config++; } @@ -153,7 +153,7 @@ void Widget::setGeometry(int x, int y, int width, int height) _rect = Rect(x, y, width, height); _dirty = true; - XMoveResizeWindow(Display::display, _window, x, y, width, height); + XMoveResizeWindow(**display, _window, x, y, width, height); _ignore_config++; } @@ -172,7 +172,7 @@ void Widget::show(bool recursive) (*it)->show(); } - XMapWindow(Display::display, _window); + XMapWindow(**display, _window); _visible = true; } @@ -187,7 +187,7 @@ void Widget::hide(bool recursive) (*it)->hide(); } - XUnmapWindow(Display::display, _window); + XUnmapWindow(**display, _window); _visible = false; } @@ -213,7 +213,7 @@ void Widget::unfocus(void) bool Widget::grabMouse(void) { - Status ret = XGrabPointer(Display::display, _window, True, + Status ret = XGrabPointer(**display, _window, True, (ButtonPressMask | ButtonReleaseMask | ButtonMotionMask | EnterWindowMask | LeaveWindowMask | PointerMotionMask), @@ -228,13 +228,13 @@ void Widget::ungrabMouse(void) if (! _grabbed_mouse) return; - XUngrabPointer(Display::display, CurrentTime); + XUngrabPointer(**display, CurrentTime); _grabbed_mouse = false; } bool Widget::grabKeyboard(void) { - Status ret = XGrabKeyboard(Display::display, _window, True, + Status ret = XGrabKeyboard(**display, _window, True, GrabModeSync, GrabModeAsync, CurrentTime); _grabbed_keyboard = (ret == GrabSuccess); return _grabbed_keyboard; @@ -246,7 +246,7 @@ void Widget::ungrabKeyboard(void) if (! _grabbed_keyboard) return; - XUngrabKeyboard(Display::display, CurrentTime); + XUngrabKeyboard(**display, CurrentTime); _grabbed_keyboard = false; } @@ -257,13 +257,13 @@ void Widget::render(void) _bg_pixmap = _texture->render(_rect.width(), _rect.height(), _bg_pixmap); if (_bg_pixmap) { - XSetWindowBackgroundPixmap(Display::display, _window, _bg_pixmap); + XSetWindowBackgroundPixmap(**display, _window, _bg_pixmap); _bg_pixel = None; } else { unsigned int pix = _texture->color().pixel(); if (pix != _bg_pixel) { _bg_pixel = pix; - XSetWindowBackground(Display::display, _window, pix); + XSetWindowBackground(**display, _window, pix); } } } @@ -395,7 +395,7 @@ void Widget::update(void) if (_dirty) { adjust(); render(); - XClearWindow(Display::display, _window); + XClearWindow(**display, _window); } WidgetList::iterator it = _children.begin(), end = _children.end(); diff --git a/otk/widget.hh b/otk/widget.hh index 5583faca..7f2d926c 100644 --- a/otk/widget.hh +++ b/otk/widget.hh @@ -83,13 +83,13 @@ public: inline const Color *borderColor(void) const { return _bcolor; } virtual void setBorderColor(const Color *color) { assert(color); _bcolor = color; - XSetWindowBorder(Display::display, _window, color->pixel()); + XSetWindowBorder(**display, _window, color->pixel()); } inline int borderWidth(void) const { return _bwidth; } void setBorderWidth(int width) { _bwidth = width; - XSetWindowBorderWidth(Display::display, _window, width); + XSetWindowBorderWidth(**display, _window, width); } virtual void addChild(Widget *child, bool front = false); @@ -104,7 +104,7 @@ public: inline Cursor cursor(void) const { return _cursor; } void setCursor(Cursor cursor) { _cursor = cursor; - XDefineCursor(Display::display, _window, _cursor); + XDefineCursor(**display, _window, _cursor); } inline int bevelWidth(void) const { return _bevel_width; } -- 2.45.2