un-static otk::Display. add an operator* to it. make a global ob::display var.

This commit is contained in:
Dana Jansens 2003-01-13 08:48:03 +00:00
parent 9e77a88d26
commit c97915f445
22 changed files with 230 additions and 231 deletions

View file

@ -20,15 +20,14 @@ namespace otk {
Application::Application(int argc, char **argv) Application::Application(int argc, char **argv)
: EventDispatcher(), : EventDispatcher(),
_display(),
_dockable(false), _dockable(false),
_appwidget_count(0) _appwidget_count(0)
{ {
(void)argc; (void)argc;
(void)argv; (void)argv;
Display::initialize(0); const ScreenInfo *s_info = _display.screenInfo(DefaultScreen(*_display));
const ScreenInfo *s_info =
Display::screenInfo(DefaultScreen(Display::display));
_timer_manager = new TimerQueueManager(); _timer_manager = new TimerQueueManager();
_img_ctrl = new ImageControl(_timer_manager, s_info, True, 4, 5, 200); _img_ctrl = new ImageControl(_timer_manager, s_info, True, 4, 5, 200);
@ -44,8 +43,6 @@ Application::~Application()
delete _img_ctrl; delete _img_ctrl;
delete _timer_manager; delete _timer_manager;
delete _style; delete _style;
Display::destroy();
} }
void Application::loadStyle(void) void Application::loadStyle(void)

View file

@ -32,6 +32,7 @@ public:
private: private:
void loadStyle(void); void loadStyle(void);
Display _display;
TimerQueueManager *_timer_manager; TimerQueueManager *_timer_manager;
ImageControl *_img_ctrl; ImageControl *_img_ctrl;
Configuration *_style_conf; Configuration *_style_conf;

View file

@ -20,14 +20,14 @@ AppWidget::AppWidget(Application *app, Direction direction,
{ {
assert(app); assert(app);
_wm_protocols = XInternAtom(Display::display, "WM_PROTOCOLS", false); _wm_protocols = XInternAtom(**display, "WM_PROTOCOLS", false);
_wm_delete = XInternAtom(Display::display, "WM_DELETE_WINDOW", false); _wm_delete = XInternAtom(**display, "WM_DELETE_WINDOW", false);
// set WM Protocols on the window // set WM Protocols on the window
Atom protocols[2]; Atom protocols[2];
protocols[0] = _wm_protocols; protocols[0] = _wm_protocols;
protocols[1] = _wm_delete; protocols[1] = _wm_delete;
XSetWMProtocols(Display::display, window(), protocols, 2); XSetWMProtocols(**display, window(), protocols, 2);
} }
AppWidget::~AppWidget() AppWidget::~AppWidget()

View file

@ -74,8 +74,8 @@ void Color::parseColorName(void) {
} }
if (scrn == ~(0u)) if (scrn == ~(0u))
scrn = DefaultScreen(Display::display); scrn = DefaultScreen(**display);
Colormap colormap = Display::screenInfo(scrn)->colormap(); Colormap colormap = display->screenInfo(scrn)->colormap();
// get rgb values from colorname // get rgb values from colorname
XColor xcol; XColor xcol;
@ -84,7 +84,7 @@ void Color::parseColorName(void) {
xcol.blue = 0; xcol.blue = 0;
xcol.pixel = 0; xcol.pixel = 0;
if (! XParseColor(Display::display, colormap, if (! XParseColor(**display, colormap,
colorname.c_str(), &xcol)) { colorname.c_str(), &xcol)) {
fprintf(stderr, "Color::allocate: color parse error: \"%s\"\n", fprintf(stderr, "Color::allocate: color parse error: \"%s\"\n",
colorname.c_str()); colorname.c_str());
@ -97,8 +97,8 @@ void Color::parseColorName(void) {
void Color::allocate(void) { void Color::allocate(void) {
if (scrn == ~(0u)) scrn = DefaultScreen(Display::display); if (scrn == ~(0u)) scrn = DefaultScreen(**display);
Colormap colormap = Display::screenInfo(scrn)->colormap(); Colormap colormap = display->screenInfo(scrn)->colormap();
if (! isValid()) { if (! isValid()) {
if (colorname.empty()) { if (colorname.empty()) {
@ -127,7 +127,7 @@ void Color::allocate(void) {
xcol.blue = b | b << 8; xcol.blue = b | b << 8;
xcol.pixel = 0; 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", fprintf(stderr, "Color::allocate: color alloc error: rgb:%x/%x/%x\n",
r, g, b); r, g, b);
xcol.pixel = 0; xcol.pixel = 0;
@ -187,7 +187,7 @@ void Color::doCacheCleanup(void) {
int i; int i;
unsigned count; unsigned count;
for (i = 0; i < ScreenCount(Display::display); i++) { for (i = 0; i < ScreenCount(**display); i++) {
count = 0; count = 0;
it = colorcache.begin(); it = colorcache.begin();
@ -204,8 +204,7 @@ void Color::doCacheCleanup(void) {
} }
if (count > 0) if (count > 0)
XFreeColors(Display::display, XFreeColors(**display, display->screenInfo(i)->colormap(),
Display::screenInfo(i)->colormap(),
pixels, count, 0); pixels, count, 0);
} }

View file

@ -48,20 +48,7 @@ extern "C" {
namespace otk { namespace otk {
::Display *Display::display = (::Display*) 0; 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;
static int xerrorHandler(::Display *d, XErrorEvent *e) 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; int junk;
(void)junk; (void)junk;
// Open the X display // 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\ printf(_("Unable to open connection to the X server. Please set the \n\
DISPLAY environment variable approriately, or use the '-display' command \n\ DISPLAY environment variable approriately.\n\n"));
line argument.\n\n"));
::exit(1); ::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")); printf(_("Couldn't mark display connection as close-on-exec.\n\n"));
::exit(1); ::exit(1);
} }
@ -110,26 +109,26 @@ line argument.\n\n"));
// set the DISPLAY environment variable for any lauched children, to the // set the DISPLAY environment variable for any lauched children, to the
// display we're using, so they open in the right place. // 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 // find the availability of X extensions we like to use
#ifdef XKB #ifdef XKB
_xkb = XkbQueryExtension(display, &junk, &_xkb_event_basep, &junk, NULL, _xkb = XkbQueryExtension(_display, &junk, &_xkb_event_basep, &junk, NULL,
NULL); NULL);
#endif #endif
#ifdef SHAPE #ifdef SHAPE
_shape = XShapeQueryExtension(display, &_shape_event_basep, &junk); _shape = XShapeQueryExtension(_display, &_shape_event_basep, &junk);
#endif #endif
#ifdef XINERAMA #ifdef XINERAMA
_xinerama = XineramaQueryExtension(display, &_xinerama_event_basep, &junk); _xinerama = XineramaQueryExtension(_display, &_xinerama_event_basep, &junk);
#endif // XINERAMA #endif // XINERAMA
// get lock masks that are defined by the display (not constant) // get lock masks that are defined by the display (not constant)
XModifierKeymap *modmap; XModifierKeymap *modmap;
modmap = XGetModifierMapping(display); modmap = XGetModifierMapping(_display);
if (modmap && modmap->max_keypermod > 0) { if (modmap && modmap->max_keypermod > 0) {
const int mask_table[] = { const int mask_table[] = {
ShiftMask, LockMask, ControlMask, Mod1Mask, ShiftMask, LockMask, ControlMask, Mod1Mask,
@ -140,16 +139,16 @@ line argument.\n\n"));
// get the values of the keyboard lock modifiers // get the values of the keyboard lock modifiers
// Note: Caps lock is not retrieved the same way as Scroll and Num lock // Note: Caps lock is not retrieved the same way as Scroll and Num lock
// since it doesn't need to be. // since it doesn't need to be.
const KeyCode num_lock = XKeysymToKeycode(display, XK_Num_Lock); const KeyCode num_lock = XKeysymToKeycode(_display, XK_Num_Lock);
const KeyCode scroll_lock = XKeysymToKeycode(display, XK_Scroll_Lock); const KeyCode scroll_lock = XKeysymToKeycode(_display, XK_Scroll_Lock);
for (size_t cnt = 0; cnt < size; ++cnt) { for (size_t cnt = 0; cnt < size; ++cnt) {
if (! modmap->modifiermap[cnt]) continue; if (! modmap->modifiermap[cnt]) continue;
if (num_lock == modmap->modifiermap[cnt]) 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]) 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[0] = 0;
_mask_list[1] = LockMask; _mask_list[1] = LockMask;
_mask_list[2] = _numLockMask; _mask_list[2] = _num_lock_mask;
_mask_list[3] = LockMask | _numLockMask; _mask_list[3] = LockMask | _num_lock_mask;
_mask_list[4] = _scrollLockMask; _mask_list[4] = _scroll_lock_mask;
_mask_list[5] = _scrollLockMask | LockMask; _mask_list[5] = _scroll_lock_mask | LockMask;
_mask_list[6] = _scrollLockMask | _numLockMask; _mask_list[6] = _scroll_lock_mask | _num_lock_mask;
_mask_list[7] = _scrollLockMask | LockMask | _numLockMask; _mask_list[7] = _scroll_lock_mask | LockMask | _num_lock_mask;
// Get information on all the screens which are available. // Get information on all the screens which are available.
_screenInfoList.reserve(ScreenCount(display)); _screenInfoList.reserve(ScreenCount(_display));
for (int i = 0; i < ScreenCount(display); ++i) for (int i = 0; i < ScreenCount(_display); ++i)
_screenInfoList.push_back(ScreenInfo(i)); _screenInfoList.push_back(ScreenInfo(i));
_gccache = new GCCache(_screenInfoList.size()); _gccache = new GCCache(_screenInfoList.size());
} }
void Display::destroy() Display::~Display()
{ {
delete _gccache; delete _gccache;
while (_grab_count > 0) while (_grab_count > 0)
ungrab(); ungrab();
XCloseDisplay(display); XCloseDisplay(_display);
} }
const ScreenInfo* Display::screenInfo(int snum) { const ScreenInfo* Display::screenInfo(int snum)
{
assert(snum >= 0); assert(snum >= 0);
assert(snum < static_cast<int>(_screenInfoList.size())); assert(snum < static_cast<int>(_screenInfoList.size()));
return &_screenInfoList[snum]; return &_screenInfoList[snum];
@ -202,7 +202,7 @@ const ScreenInfo* Display::findScreen(Window root)
void Display::grab() void Display::grab()
{ {
if (_grab_count == 0) if (_grab_count == 0)
XGrabServer(display); XGrabServer(_display);
_grab_count++; _grab_count++;
} }
@ -212,7 +212,7 @@ void Display::ungrab()
if (_grab_count == 0) return; if (_grab_count == 0) return;
_grab_count--; _grab_count--;
if (_grab_count == 0) 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, Window grab_window, bool owner_events,
unsigned int event_mask, int pointer_mode, unsigned int event_mask, int pointer_mode,
int keyboard_mode, Window confine_to, 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: unsigned int length = (allow_scroll_lock) ? 8 / 2:
8; 8;
for (size_t cnt = 0; cnt < length; ++cnt) 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, grab_window, owner_events, event_mask, pointer_mode,
keyboard_mode, confine_to, cursor); keyboard_mode, confine_to, cursor);
} }
@ -247,29 +248,30 @@ void Display::grabButton(unsigned int button, unsigned int modifiers,
* keyboard lock keys. * keyboard lock keys.
*/ */
void Display::ungrabButton(unsigned int button, unsigned int modifiers, void Display::ungrabButton(unsigned int button, unsigned int modifiers,
Window grab_window) { Window grab_window) const
{
for (size_t cnt = 0; cnt < 8; ++cnt) 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); grab_window);
} }
void Display::grabKey(unsigned int keycode, unsigned int modifiers, void Display::grabKey(unsigned int keycode, unsigned int modifiers,
Window grab_window, bool owner_events, Window grab_window, bool owner_events,
int pointer_mode, int keyboard_mode, int pointer_mode, int keyboard_mode,
bool allow_scroll_lock) bool allow_scroll_lock) const
{ {
unsigned int length = (allow_scroll_lock) ? 8 / 2: unsigned int length = (allow_scroll_lock) ? 8 / 2:
8; 8;
for (size_t cnt = 0; cnt < length; ++cnt) 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); grab_window, owner_events, pointer_mode, keyboard_mode);
} }
void Display::ungrabKey(unsigned int keycode, unsigned int modifiers, void Display::ungrabKey(unsigned int keycode, unsigned int modifiers,
Window grab_window) Window grab_window) const
{ {
for (size_t cnt = 0; cnt < 8; ++cnt) 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); grab_window);
} }

View file

@ -13,6 +13,11 @@ namespace otk {
class ScreenInfo; class ScreenInfo;
class GCCache; class GCCache;
class Display;
//! The display instance for the library
extern Display *display;
//! Manages a single X11 display. //! Manages a single X11 display.
/*! /*!
This class is static, and cannot be instantiated. This class is static, and cannot be instantiated.
@ -22,42 +27,42 @@ class GCCache;
class Display class Display
{ {
public: public:
//! The X display
static ::Display *display;
//! A List of ScreenInfo instances //! A List of ScreenInfo instances
typedef std::vector<ScreenInfo> ScreenInfoList; typedef std::vector<ScreenInfo> ScreenInfoList;
private: private:
//! The X display
::Display *_display;
//! Does the display have the XKB extension? //! Does the display have the XKB extension?
static bool _xkb; bool _xkb;
//! Base for events for the XKB extension //! Base for events for the XKB extension
static int _xkb_event_basep; int _xkb_event_basep;
//! Does the display have the Shape extension? //! Does the display have the Shape extension?
static bool _shape; bool _shape;
//! Base for events for the Shape extension //! Base for events for the Shape extension
static int _shape_event_basep; int _shape_event_basep;
//! Does the display have the Xinerama extension? //! Does the display have the Xinerama extension?
static bool _xinerama; bool _xinerama;
//! Base for events for the Xinerama extension //! 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 //! 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 //! 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 //! 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 //! 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 //! 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 //! A cache for re-using GCs, used by the drawing objects
/*! /*!
@ -67,30 +72,26 @@ private:
@see ImageControl @see ImageControl
@see Texture @see Texture
*/ */
static GCCache *_gccache; GCCache *_gccache;
// Handles X errors on the display // Handles X errors on the display
/* /*
Displays the error if compiled for debugging. Displays the error if compiled for debugging.
*/ */
//static int xerrorHandler(::Display *d, XErrorEvent *e); //int xerrorHandler(::Display *d, XErrorEvent *e);
//! Prevents instantiation of the class
Display();
public: public:
//! Initializes the class, opens the X display //! Initializes the class, opens the X display
/*! /*!
The DISPLAY environment variable is used to choose the display.
@see Display::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 //! Destroys the class, closes the X display
static void destroy(); ~Display();
//! Returns the GC cache for the application //! 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 //! Gets information on a specific screen
/*! /*!
@ -99,47 +100,50 @@ public:
@param snum The screen number of the screen to retrieve info on @param snum The screen number of the screen to retrieve info on
@return Info on the requested screen, in a ScreenInfo class @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 //! 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 //! 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 //! 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 //! 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 //! 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 //! 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 unsigned int numLockMask() const { return _num_lock_mask; }
inline static unsigned int scrollLockMask() { return _scrollLockMask; } inline unsigned int scrollLockMask() const { return _scroll_lock_mask; }
inline ::Display* operator*() const { return _display; }
//! Grabs the display //! Grabs the display
static void grab(); void grab();
//! Ungrabs the display //! Ungrabs the display
static void ungrab(); void ungrab();
/* TEMPORARY */ /* TEMPORARY */
static void grabButton(unsigned int button, unsigned int modifiers, void grabButton(unsigned int button, unsigned int modifiers,
Window grab_window, bool owner_events, Window grab_window, bool owner_events,
unsigned int event_mask, int pointer_mode, unsigned int event_mask, int pointer_mode,
int keyboard_mode, Window confine_to, Cursor cursor, int keyboard_mode, Window confine_to, Cursor cursor,
bool allow_scroll_lock); bool allow_scroll_lock) const;
static void ungrabButton(unsigned int button, unsigned int modifiers, void ungrabButton(unsigned int button, unsigned int modifiers,
Window grab_window); Window grab_window) const;
static void grabKey(unsigned int keycode, unsigned int modifiers, void grabKey(unsigned int keycode, unsigned int modifiers,
Window grab_window, bool owner_events, Window grab_window, bool owner_events,
int pointer_mode, int keyboard_mode, bool allow_scroll_lock); int pointer_mode, int keyboard_mode,
static void ungrabKey(unsigned int keycode, unsigned int modifiers, bool allow_scroll_lock) const;
Window grab_window); void ungrabKey(unsigned int keycode, unsigned int modifiers,
Window grab_window) const;
}; };
} }

View file

@ -38,8 +38,8 @@ void EventDispatcher::dispatchEvents(void)
{ {
XEvent e; XEvent e;
while (XPending(Display::display)) { while (XPending(**display)) {
XNextEvent(Display::display, &e); XNextEvent(**display, &e);
#if 0//defined(DEBUG) #if 0//defined(DEBUG)
printf("Event %d window %lx\n", e.type, e.xany.window); printf("Event %d window %lx\n", e.type, e.xany.window);
@ -71,17 +71,17 @@ void EventDispatcher::dispatchEvents(void)
case ButtonPress: case ButtonPress:
case ButtonRelease: case ButtonRelease:
_lasttime = e.xbutton.time; _lasttime = e.xbutton.time;
e.xbutton.state &= ~(LockMask | Display::numLockMask() | e.xbutton.state &= ~(LockMask | display->numLockMask() |
Display::scrollLockMask()); display->scrollLockMask());
break; break;
case KeyPress: case KeyPress:
e.xkey.state &= ~(LockMask | Display::numLockMask() | e.xkey.state &= ~(LockMask | display->numLockMask() |
Display::scrollLockMask()); display->scrollLockMask());
break; break;
case MotionNotify: case MotionNotify:
_lasttime = e.xmotion.time; _lasttime = e.xmotion.time;
e.xmotion.state &= ~(LockMask | Display::numLockMask() | e.xmotion.state &= ~(LockMask | display->numLockMask() |
Display::scrollLockMask()); display->scrollLockMask());
break; break;
case PropertyNotify: case PropertyNotify:
_lasttime = e.xproperty.time; _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 // FocusOut events just make us look for FocusIn events. They are ignored
// otherwise. // otherwise.
XEvent fi; XEvent fi;
if (XCheckTypedEvent(Display::display, FocusIn, &fi)) { if (XCheckTypedEvent(**display, FocusIn, &fi)) {
//printf("Found FocusIn\n"); //printf("Found FocusIn\n");
dispatchFocus(fi); dispatchFocus(fi);
// dont unfocus the window we just focused! // 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.sibling = e.xconfigurerequest.above;
xwc.stack_mode = e.xconfigurerequest.detail; xwc.stack_mode = e.xconfigurerequest.detail;
XConfigureWindow(otk::Display::display, e.xconfigurerequest.window, XConfigureWindow(**display, e.xconfigurerequest.window,
e.xconfigurerequest.value_mask, &xwc); e.xconfigurerequest.value_mask, &xwc);
} else { } else {
// grab a falback if it exists // grab a falback if it exists

View file

@ -88,11 +88,11 @@ void EventHandler::handle(const XEvent &e)
return selectionRequestHandler(e.xselectionrequest); return selectionRequestHandler(e.xselectionrequest);
default: default:
#ifdef SHAPE #ifdef SHAPE
if (e.type == Display::shapeEventBase()) if (e.type == display->shapeEventBase())
return shapeHandler((*(XShapeEvent*)&e)); return shapeHandler((*(XShapeEvent*)&e));
#endif // SHAPE #endif // SHAPE
#ifdef XKB #ifdef XKB
if (e.type == Display::xkbEventBase()) if (e.type == display->xkbEventBase())
return xkbHandler((*(XkbEvent*)&e)); return xkbHandler((*(XkbEvent*)&e));
#endif // XKB #endif // XKB
; ;

View file

@ -13,8 +13,8 @@ namespace otk {
FocusLabel::FocusLabel(Widget *parent) FocusLabel::FocusLabel(Widget *parent)
: FocusWidget(parent), _text("") : FocusWidget(parent), _text("")
{ {
const ScreenInfo *info = Display::screenInfo(screen()); const ScreenInfo *info = display->screenInfo(screen());
_xftdraw = XftDrawCreate(Display::display, window(), info->visual(), _xftdraw = XftDrawCreate(**display, window(), info->visual(),
info->colormap()); info->colormap());
} }

View file

@ -56,14 +56,14 @@ Font::Font(int screen_num, const std::string &fontstring,
_xft_init = true; _xft_init = true;
} }
if ((_xftfont = XftFontOpenName(Display::display, _screen_num, if ((_xftfont = XftFontOpenName(**display, _screen_num,
_fontstring.c_str()))) _fontstring.c_str())))
return; return;
printf(_("Unable to load font: %s\n"), _fontstring.c_str()); printf(_("Unable to load font: %s\n"), _fontstring.c_str());
printf(_("Trying fallback font: %s\n"), _fallback_font.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()))) _fallback_font.c_str())))
return; return;
@ -77,7 +77,7 @@ Font::Font(int screen_num, const std::string &fontstring,
Font::~Font(void) Font::~Font(void)
{ {
if (_xftfont) 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.green = 0;
c.color.blue = 0; c.color.blue = 0;
c.color.alpha = _tint | _tint << 8; // transparent shadow c.color.alpha = _tint | _tint << 8; // transparent shadow
c.pixel = BlackPixel(Display::display, _screen_num); c.pixel = BlackPixel(**display, _screen_num);
if (string.utf8()) if (string.utf8())
XftDrawStringUtf8(d, &c, _xftfont, x + _offset, XftDrawStringUtf8(d, &c, _xftfont, x + _offset,
@ -127,10 +127,10 @@ unsigned int Font::measureString(const ustring &string) const
XGlyphInfo info; XGlyphInfo info;
if (string.utf8()) if (string.utf8())
XftTextExtentsUtf8(Display::display, _xftfont, XftTextExtentsUtf8(**display, _xftfont,
(FcChar8*)string.c_str(), string.size(), &info); (FcChar8*)string.c_str(), string.size(), &info);
else else
XftTextExtents8(Display::display, _xftfont, XftTextExtents8(**display, _xftfont,
(FcChar8*)string.c_str(), string.size(), &info); (FcChar8*)string.c_str(), string.size(), &info);
return info.xOff + (_shadow ? _offset : 0); return info.xOff + (_shadow ? _offset : 0);

View file

@ -19,7 +19,7 @@ namespace otk {
GCCacheContext::~GCCacheContext(void) { GCCacheContext::~GCCacheContext(void) {
if (gc) if (gc)
XFreeGC(Display::display, gc); XFreeGC(**display, gc);
} }
@ -44,7 +44,7 @@ void GCCacheContext::set(const Color &_color,
fontid = 0; 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; XGCValues gcv;
fontid = gcv.font = _font->fid; 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) { GCCacheContext *GCCache::nextContext(unsigned int scr) {
Window hd = Display::screenInfo(scr)->rootWindow(); Window hd = display->screenInfo(scr)->rootWindow();
GCCacheContext *c; GCCacheContext *c;
@ -94,7 +94,7 @@ GCCacheContext *GCCache::nextContext(unsigned int scr) {
c = contexts[i]; c = contexts[i];
if (! c->gc) { if (! c->gc) {
c->gc = XCreateGC(Display::display, hd, 0, 0); c->gc = XCreateGC(**display, hd, 0, 0);
c->used = false; c->used = false;
c->screen = scr; c->screen = scr;
} }

View file

@ -93,7 +93,7 @@ public:
int _linewidth = 0, int _function = GXcopy, int _linewidth = 0, int _function = GXcopy,
int _subwindow = ClipByChildren) int _subwindow = ClipByChildren)
: color(_color), font(_font), linewidth(_linewidth), function(_function), : 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); } inline ~Pen(void) { if (item) cache->release(item); }

View file

@ -62,8 +62,7 @@ Pixmap Image::render(const Texture &texture) {
Pixmap Image::render_solid(const Texture &texture) { Pixmap Image::render_solid(const Texture &texture) {
Pixmap pixmap = XCreatePixmap(Display::display, Pixmap pixmap = XCreatePixmap(**display, control->getDrawable(), width,
control->getDrawable(), width,
height, control->getDepth()); height, control->getDepth());
if (pixmap == None) { if (pixmap == None) {
fprintf(stderr, "Image::render_solid: error creating pixmap\n"); 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 penlight(texture.lightColor());
Pen penshadow(texture.shadowColor()); 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) { if (texture.texture() & Texture::Interlaced) {
Pen peninterlace(texture.colorTo()); Pen peninterlace(texture.colorTo());
for (unsigned int i = 0; i < height; i += 2) 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; int left = 0, top = 0, right = width - 1, bottom = height - 1;
if (texture.texture() & Texture::Border) { if (texture.texture() & Texture::Border) {
Pen penborder(texture.borderColor()); Pen penborder(texture.borderColor());
XDrawRectangle(Display::display, pixmap, penborder.gc(), XDrawRectangle(**display, pixmap, penborder.gc(),
left, top, right, bottom); left, top, right, bottom);
} }
if (texture.texture() & Texture::Bevel1) { if (texture.texture() & Texture::Bevel1) {
if (texture.texture() & Texture::Raised) { if (texture.texture() & Texture::Raised) {
XDrawLine(Display::display, pixmap, penshadow.gc(), XDrawLine(**display, pixmap, penshadow.gc(),
left, bottom, right, bottom); left, bottom, right, bottom);
XDrawLine(Display::display, pixmap, penshadow.gc(), XDrawLine(**display, pixmap, penshadow.gc(),
right, bottom, right, top); right, bottom, right, top);
XDrawLine(Display::display, pixmap, penlight.gc(), XDrawLine(**display, pixmap, penlight.gc(),
left, top, right, top); left, top, right, top);
XDrawLine(Display::display, pixmap, penlight.gc(), XDrawLine(**display, pixmap, penlight.gc(),
left, bottom, left, top); left, bottom, left, top);
} else if (texture.texture() & Texture::Sunken) { } else if (texture.texture() & Texture::Sunken) {
XDrawLine(Display::display, pixmap, penlight.gc(), XDrawLine(**display, pixmap, penlight.gc(),
left, bottom, right, bottom); left, bottom, right, bottom);
XDrawLine(Display::display, pixmap, penlight.gc(), XDrawLine(**display, pixmap, penlight.gc(),
right, bottom, right, top); right, bottom, right, top);
XDrawLine(Display::display, pixmap, penshadow.gc(), XDrawLine(**display, pixmap, penshadow.gc(),
left, top, right, top); left, top, right, top);
XDrawLine(Display::display, pixmap, penshadow.gc(), XDrawLine(**display, pixmap, penshadow.gc(),
left, bottom, left, top); left, bottom, left, top);
} }
} else if (texture.texture() & Texture::Bevel2) { } else if (texture.texture() & Texture::Bevel2) {
if (texture.texture() & Texture::Raised) { if (texture.texture() & Texture::Raised) {
XDrawLine(Display::display, pixmap, penshadow.gc(), XDrawLine(**display, pixmap, penshadow.gc(),
left + 1, bottom - 2, right - 2, bottom - 2); 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); 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); 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); left + 1, bottom - 2, left + 1, top + 1);
} else if (texture.texture() & Texture::Sunken) { } 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); 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); 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); 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); 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::renderXImage(void) {
XImage *image = XImage *image =
XCreateImage(Display::display, XCreateImage(**display, control->getVisual(), control->getDepth(),
control->getVisual(), control->getDepth(), ZPixmap, 0, 0, ZPixmap, 0, 0,width, height, 32, 0);
width, height, 32, 0);
if (! image) { if (! image) {
fprintf(stderr, "Image::renderXImage: error creating XImage\n"); fprintf(stderr, "Image::renderXImage: error creating XImage\n");
@ -539,8 +537,8 @@ XImage *Image::renderXImage(void) {
Pixmap Image::renderPixmap(void) { Pixmap Image::renderPixmap(void) {
Pixmap pixmap = Pixmap pixmap =
XCreatePixmap(Display::display, XCreatePixmap(**display, control->getDrawable(), width, height,
control->getDrawable(), width, height, control->getDepth()); control->getDepth());
if (pixmap == None) { if (pixmap == None) {
fprintf(stderr, "Image::renderPixmap: error creating pixmap\n"); fprintf(stderr, "Image::renderPixmap: error creating pixmap\n");
@ -550,19 +548,18 @@ Pixmap Image::renderPixmap(void) {
XImage *image = renderXImage(); XImage *image = renderXImage();
if (! image) { if (! image) {
XFreePixmap(Display::display, pixmap); XFreePixmap(**display, pixmap);
return None; return None;
} }
if (! image->data) { if (! image->data) {
XDestroyImage(image); XDestroyImage(image);
XFreePixmap(Display::display, pixmap); XFreePixmap(**display, pixmap);
return None; return None;
} }
XPutImage(Display::display, pixmap, XPutImage(**display, pixmap,
DefaultGC(Display::display, DefaultGC(**display, control->getScreenInfo()->screen()),
control->getScreenInfo()->screen()),
image, 0, 0, 0, 0, width, height); image, 0, 0, 0, 0, width, height);
if (image->data) { if (image->data) {

View file

@ -75,7 +75,7 @@ ImageControl::ImageControl(TimerQueueManager *timermanager,
colormap = screeninfo->colormap(); colormap = screeninfo->colormap();
int count; int count;
XPixmapFormatValues *pmv = XListPixmapFormats(Display::display, XPixmapFormatValues *pmv = XListPixmapFormats(**display,
&count); &count);
if (pmv) { if (pmv) {
bits_per_pixel = 0; bits_per_pixel = 0;
@ -168,7 +168,7 @@ ImageControl::ImageControl(TimerQueueManager *timermanager,
} }
for (i = 0; i < ncolors; i++) { 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", fprintf(stderr, "couldn't alloc color %i %i %i\n",
colors[i].red, colors[i].green, colors[i].blue); colors[i].red, colors[i].green, colors[i].blue);
colors[i].flags = 0; colors[i].flags = 0;
@ -183,7 +183,7 @@ ImageControl::ImageControl(TimerQueueManager *timermanager,
for (i = 0; i < incolors; i++) for (i = 0; i < incolors; i++)
icolors[i].pixel = i; icolors[i].pixel = i;
XQueryColors(Display::display, colormap, icolors, incolors); XQueryColors(**display, colormap, icolors, incolors);
for (i = 0; i < ncolors; i++) { for (i = 0; i < ncolors; i++) {
if (! colors[i].flags) { if (! colors[i].flags) {
unsigned long chk = 0xffffffff, pixel, close = 0; unsigned long chk = 0xffffffff, pixel, close = 0;
@ -205,7 +205,7 @@ ImageControl::ImageControl(TimerQueueManager *timermanager,
colors[i].green = icolors[close].green; colors[i].green = icolors[close].green;
colors[i].blue = icolors[close].blue; colors[i].blue = icolors[close].blue;
if (XAllocColor(Display::display, colormap, if (XAllocColor(**display, colormap,
&colors[i])) { &colors[i])) {
colors[i].flags = DoRed|DoGreen|DoBlue; colors[i].flags = DoRed|DoGreen|DoBlue;
break; break;
@ -262,7 +262,7 @@ ImageControl::ImageControl(TimerQueueManager *timermanager,
colors[i].blue = (i * 0xffff) / (colors_per_channel - 1);; colors[i].blue = (i * 0xffff) / (colors_per_channel - 1);;
colors[i].flags = DoRed|DoGreen|DoBlue; colors[i].flags = DoRed|DoGreen|DoBlue;
if (! XAllocColor(Display::display, colormap, if (! XAllocColor(**display, colormap,
&colors[i])) { &colors[i])) {
fprintf(stderr, "couldn't alloc color %i %i %i\n", fprintf(stderr, "couldn't alloc color %i %i %i\n",
colors[i].red, colors[i].green, colors[i].blue); colors[i].red, colors[i].green, colors[i].blue);
@ -279,7 +279,7 @@ ImageControl::ImageControl(TimerQueueManager *timermanager,
for (i = 0; i < incolors; i++) for (i = 0; i < incolors; i++)
icolors[i].pixel = i; icolors[i].pixel = i;
XQueryColors(Display::display, colormap, icolors, incolors); XQueryColors(**display, colormap, icolors, incolors);
for (i = 0; i < ncolors; i++) { for (i = 0; i < ncolors; i++) {
if (! colors[i].flags) { if (! colors[i].flags) {
unsigned long chk = 0xffffffff, pixel, close = 0; unsigned long chk = 0xffffffff, pixel, close = 0;
@ -301,7 +301,7 @@ ImageControl::ImageControl(TimerQueueManager *timermanager,
colors[i].green = icolors[close].green; colors[i].green = icolors[close].green;
colors[i].blue = icolors[close].blue; colors[i].blue = icolors[close].blue;
if (XAllocColor(Display::display, colormap, if (XAllocColor(**display, colormap,
&colors[i])) { &colors[i])) {
colors[i].flags = DoRed|DoGreen|DoBlue; colors[i].flags = DoRed|DoGreen|DoBlue;
break; break;
@ -335,7 +335,7 @@ ImageControl::~ImageControl(void) {
for (int i = 0; i < ncolors; i++) for (int i = 0; i < ncolors; i++)
*(pixels + i) = (*(colors + i)).pixel; *(pixels + i) = (*(colors + i)).pixel;
XFreeColors(Display::display, colormap, pixels, ncolors, 0); XFreeColors(**display, colormap, pixels, ncolors, 0);
delete [] colors; delete [] colors;
} }
@ -348,7 +348,7 @@ ImageControl::~ImageControl(void) {
CacheContainer::iterator it = cache.begin(); CacheContainer::iterator it = cache.begin();
const CacheContainer::iterator end = cache.end(); const CacheContainer::iterator end = cache.end();
for (; it != end; ++it) for (; it != end; ++it)
XFreePixmap(Display::display, it->pixmap); XFreePixmap(**display, it->pixmap);
} }
if (timer) { if (timer) {
timer->stop(); timer->stop();
@ -499,7 +499,7 @@ void ImageControl::getGradientBuffers(unsigned int w,
void ImageControl::installRootColormap(void) { void ImageControl::installRootColormap(void) {
int ncmap = 0; int ncmap = 0;
Colormap *cmaps = Colormap *cmaps =
XListInstalledColormaps(Display::display, window, &ncmap); XListInstalledColormaps(**display, window, &ncmap);
if (cmaps) { if (cmaps) {
bool install = True; bool install = True;
@ -508,7 +508,7 @@ void ImageControl::installRootColormap(void) {
install = False; install = False;
if (install) if (install)
XInstallColormap(Display::display, colormap); XInstallColormap(**display, colormap);
XFree(cmaps); XFree(cmaps);
} }
@ -548,7 +548,7 @@ struct CacheCleaner {
CacheCleaner() {} CacheCleaner() {}
inline void operator()(const ImageControl::CachedImage& image) const { inline void operator()(const ImageControl::CachedImage& image) const {
if (ref_check(image)) if (ref_check(image))
XFreePixmap(Display::display, image.pixmap); XFreePixmap(**display, image.pixmap);
} }
}; };

View file

@ -11,8 +11,8 @@ namespace otk {
Label::Label(Widget *parent) Label::Label(Widget *parent)
: Widget(parent), _text("") : Widget(parent), _text("")
{ {
const ScreenInfo *info = Display::screenInfo(screen()); const ScreenInfo *info = display->screenInfo(screen());
_xftdraw = XftDrawCreate(Display::display, window(), info->visual(), _xftdraw = XftDrawCreate(**display, window(), info->visual(),
info->colormap()); info->colormap());
} }

View file

@ -17,7 +17,7 @@ namespace otk {
Property::Property() Property::Property()
{ {
assert(Display::display); assert(**display);
// make sure asserts fire if there is a problem // make sure asserts fire if there is a problem
memset(_atoms, 0, sizeof(_atoms)); memset(_atoms, 0, sizeof(_atoms));
@ -163,7 +163,7 @@ Property::~Property()
*/ */
Atom Property::create(const char *name) const Atom Property::create(const char *name) const
{ {
Atom a = XInternAtom(Display::display, name, False); Atom a = XInternAtom(**display, name, False);
assert(a); assert(a);
return 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(win != None); assert(atom != None); assert(type != None);
assert(nelements == 0 || (nelements > 0 && data != (unsigned char *) 0)); assert(nelements == 0 || (nelements > 0 && data != (unsigned char *) 0));
assert(size == 8 || size == 16 || size == 32); assert(size == 8 || size == 16 || size == 32);
XChangeProperty(Display::display, win, atom, type, size, XChangeProperty(**display, win, atom, type, size,
(append ? PropModeAppend : PropModeReplace), (append ? PropModeAppend : PropModeReplace),
data, nelements); data, nelements);
} }
@ -291,7 +291,7 @@ bool Property::get(Window win, Atom atom, Atom type,
bool ret = False; bool ret = False;
// try get the first element // 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, False, AnyPropertyType, &ret_type, &ret_size,
nelements, &ret_bytes, &c_val); nelements, &ret_bytes, &c_val);
ret = (result == Success && ret_type == type && ret_size == size && 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; int remain = (ret_bytes - 1)/sizeof(long) + 1 + 1;
if (remain > size/8 * (signed)maxread) // dont get more than the max if (remain > size/8 * (signed)maxread) // dont get more than the max
remain = size/8 * (signed)maxread; 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, remain, False, type, &ret_type, &ret_size,
nelements, &ret_bytes, &c_val); nelements, &ret_bytes, &c_val);
ret = (result == Success && ret_type == type && ret_size == size && 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 void Property::erase(Window win, Atoms atom) const
{ {
assert(atom >= 0 && atom < NUM_ATOMS); assert(atom >= 0 && atom < NUM_ATOMS);
XDeleteProperty(Display::display, win, _atoms[atom]); XDeleteProperty(**display, win, _atoms[atom]);
} }
} }

View file

@ -20,11 +20,11 @@ namespace otk {
ScreenInfo::ScreenInfo(unsigned int num) { ScreenInfo::ScreenInfo(unsigned int num) {
_screen = 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)), _screen)),
HeightOfScreen(ScreenOfDisplay(Display::display, HeightOfScreen(ScreenOfDisplay(**display,
_screen))); _screen)));
/* /*
If the default depth is at least 8 we will use that, 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. Preference is given to 24 bit over larger depths if 24 bit is an option.
*/ */
_depth = DefaultDepth(Display::display, _screen); _depth = DefaultDepth(**display, _screen);
_visual = DefaultVisual(Display::display, _screen); _visual = DefaultVisual(**display, _screen);
_colormap = DefaultColormap(Display::display, _screen); _colormap = DefaultColormap(**display, _screen);
if (_depth < 8) { if (_depth < 8) {
// search for a TrueColor Visual... if we can't find one... // 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.screen = _screen;
vinfo_template.c_class = TrueColor; vinfo_template.c_class = TrueColor;
vinfo_return = XGetVisualInfo(Display::display, vinfo_return = XGetVisualInfo(**display,
VisualScreenMask | VisualClassMask, VisualScreenMask | VisualClassMask,
&vinfo_template, &vinfo_nitems); &vinfo_template, &vinfo_nitems);
if (vinfo_return) { if (vinfo_return) {
@ -65,7 +65,7 @@ ScreenInfo::ScreenInfo(unsigned int num) {
if (best != -1) { if (best != -1) {
_depth = vinfo_return[best].depth; _depth = vinfo_return[best].depth;
_visual = vinfo_return[best].visual; _visual = vinfo_return[best].visual;
_colormap = XCreateColormap(Display::display, _root_window, _visual, _colormap = XCreateColormap(**display, _root_window, _visual,
AllocNone); AllocNone);
} }
@ -73,7 +73,7 @@ ScreenInfo::ScreenInfo(unsigned int num) {
} }
// get the default display string and strip the screen number // 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("."); const string::size_type pos = default_string.rfind(".");
if (pos != string::npos) if (pos != string::npos)
default_string.resize(pos); 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 in future versions we should be able, so the 'activeness' is checked
on a pre-screen basis anyways. 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 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 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. never be more than one screen present with Xinerama active.
*/ */
int num; int num;
XineramaScreenInfo *info = XineramaQueryScreens(Display::display, XineramaScreenInfo *info = XineramaQueryScreens(**display, &num);
&num);
if (num > 0 && info) { if (num > 0 && info) {
_xinerama_areas.reserve(num); _xinerama_areas.reserve(num);
for (int i = 0; i < num; ++i) { for (int i = 0; i < num; ++i) {

View file

@ -28,13 +28,13 @@ Style::~Style() {
delete font; delete font;
if (close_button.mask != None) if (close_button.mask != None)
XFreePixmap(Display::display, close_button.mask); XFreePixmap(**display, close_button.mask);
if (max_button.mask != None) if (max_button.mask != None)
XFreePixmap(Display::display, max_button.mask); XFreePixmap(**display, max_button.mask);
if (icon_button.mask != None) if (icon_button.mask != None)
XFreePixmap(Display::display, icon_button.mask); XFreePixmap(**display, icon_button.mask);
if (stick_button.mask != None) if (stick_button.mask != None)
XFreePixmap(Display::display, stick_button.mask); XFreePixmap(**display, stick_button.mask);
max_button.mask = None; max_button.mask = None;
close_button.mask = None; close_button.mask = None;
@ -83,13 +83,13 @@ void Style::load(const Configuration &style) {
} }
if (close_button.mask != None) if (close_button.mask != None)
XFreePixmap(Display::display, close_button.mask); XFreePixmap(**display, close_button.mask);
if (max_button.mask != None) if (max_button.mask != None)
XFreePixmap(Display::display, max_button.mask); XFreePixmap(**display, max_button.mask);
if (icon_button.mask != None) if (icon_button.mask != None)
XFreePixmap(Display::display, icon_button.mask); XFreePixmap(**display, icon_button.mask);
if (stick_button.mask != None) 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 close_button.mask = max_button.mask = icon_button.mask
= icon_button.mask = None; = icon_button.mask = None;
@ -143,7 +143,7 @@ void Style::load(const Configuration &style) {
// load bevel, border and handle widths // 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(); unsigned int width = s_info->rect().width();
if (! style.getValue("handleWidth", handle_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, void Style::readDatabaseMask(const std::string &rname, PixmapMask &pixmapMask,
const Configuration &style) { const Configuration &style) {
Window root_window = Display::screenInfo(screen_number)->rootWindow(); Window root_window = display->screenInfo(screen_number)->rootWindow();
std::string s; std::string s;
int hx, hy; //ignored int hx, hy; //ignored
int ret = BitmapOpenFailed; //default to failure. 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 (style.getValue(rname, s)) {
if (s[0] != '/' && s[0] != '~') { if (s[0] != '/' && s[0] != '~') {
std::string xbmFile = std::string("~/.openbox/buttons/") + s; 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, expandTilde(xbmFile).c_str(), &pixmapMask.w,
&pixmapMask.h, &pixmapMask.mask, &hx, &hy); &pixmapMask.h, &pixmapMask.mask, &hx, &hy);
if (ret != BitmapSuccess) { if (ret != BitmapSuccess) {
xbmFile = std::string(BUTTONSDIR) + "/" + s; xbmFile = std::string(BUTTONSDIR) + "/" + s;
ret = XReadBitmapFile(Display::display, root_window, ret = XReadBitmapFile(**display, root_window,
xbmFile.c_str(), &pixmapMask.w, xbmFile.c_str(), &pixmapMask.w,
&pixmapMask.h, &pixmapMask.mask, &hx, &hy); &pixmapMask.h, &pixmapMask.mask, &hx, &hy);
} }
} else } else
ret = XReadBitmapFile(Display::display, root_window, ret = XReadBitmapFile(**display, root_window,
expandTilde(s).c_str(), &pixmapMask.w, expandTilde(s).c_str(), &pixmapMask.w,
&pixmapMask.h, &pixmapMask.mask, &hx, &hy); &pixmapMask.h, &pixmapMask.mask, &hx, &hy);

View file

@ -164,7 +164,7 @@ Pixmap Texture::render(const unsigned int width, const unsigned int height,
return ParentRelative; return ParentRelative;
if (screen() == ~(0u)) if (screen() == ~(0u))
scrn = DefaultScreen(Display::display); scrn = DefaultScreen(**display);
assert(ctrl != 0); assert(ctrl != 0);
Pixmap ret = ctrl->renderImage(width, height, *this); Pixmap ret = ctrl->renderImage(width, height, *this);

View file

@ -14,7 +14,7 @@ void TimerQueueManager::fire(bool wait)
fd_set rfds; fd_set rfds;
timeval now, tm, *timeout = (timeval *) 0; timeval now, tm, *timeout = (timeval *) 0;
const int xfd = ConnectionNumber(Display::display); const int xfd = ConnectionNumber(**display);
FD_ZERO(&rfds); FD_ZERO(&rfds);
FD_SET(xfd, &rfds); // break on any x events FD_SET(xfd, &rfds); // break on any x events

View file

@ -65,12 +65,12 @@ Widget::~Widget()
if (_parent) if (_parent)
_parent->removeChild(this); _parent->removeChild(this);
XDestroyWindow(Display::display, _window); XDestroyWindow(**display, _window);
} }
void Widget::create(bool override_redirect) 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(); Window p_window = _parent ? _parent->window() : scr_info->rootWindow();
_rect.setRect(0, 0, 1, 1); // just some initial values _rect.setRect(0, 0, 1, 1); // just some initial values
@ -93,7 +93,7 @@ void Widget::create(bool override_redirect)
attrib_create.cursor = _cursor; 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, _rect.y(), _rect.width(), _rect.height(), 0,
scr_info->depth(), InputOutput, scr_info->depth(), InputOutput,
scr_info->visual(), create_mask, &attrib_create); scr_info->visual(), create_mask, &attrib_create);
@ -122,7 +122,7 @@ void Widget::move(const Point &to)
void Widget::move(int x, int y) void Widget::move(int x, int y)
{ {
_rect.setPos(x, y); _rect.setPos(x, y);
XMoveWindow(Display::display, _window, x, y); XMoveWindow(**display, _window, x, y);
_ignore_config++; _ignore_config++;
} }
@ -153,7 +153,7 @@ void Widget::setGeometry(int x, int y, int width, int height)
_rect = Rect(x, y, width, height); _rect = Rect(x, y, width, height);
_dirty = true; _dirty = true;
XMoveResizeWindow(Display::display, _window, x, y, width, height); XMoveResizeWindow(**display, _window, x, y, width, height);
_ignore_config++; _ignore_config++;
} }
@ -172,7 +172,7 @@ void Widget::show(bool recursive)
(*it)->show(); (*it)->show();
} }
XMapWindow(Display::display, _window); XMapWindow(**display, _window);
_visible = true; _visible = true;
} }
@ -187,7 +187,7 @@ void Widget::hide(bool recursive)
(*it)->hide(); (*it)->hide();
} }
XUnmapWindow(Display::display, _window); XUnmapWindow(**display, _window);
_visible = false; _visible = false;
} }
@ -213,7 +213,7 @@ void Widget::unfocus(void)
bool Widget::grabMouse(void) bool Widget::grabMouse(void)
{ {
Status ret = XGrabPointer(Display::display, _window, True, Status ret = XGrabPointer(**display, _window, True,
(ButtonPressMask | ButtonReleaseMask | (ButtonPressMask | ButtonReleaseMask |
ButtonMotionMask | EnterWindowMask | ButtonMotionMask | EnterWindowMask |
LeaveWindowMask | PointerMotionMask), LeaveWindowMask | PointerMotionMask),
@ -228,13 +228,13 @@ void Widget::ungrabMouse(void)
if (! _grabbed_mouse) if (! _grabbed_mouse)
return; return;
XUngrabPointer(Display::display, CurrentTime); XUngrabPointer(**display, CurrentTime);
_grabbed_mouse = false; _grabbed_mouse = false;
} }
bool Widget::grabKeyboard(void) bool Widget::grabKeyboard(void)
{ {
Status ret = XGrabKeyboard(Display::display, _window, True, Status ret = XGrabKeyboard(**display, _window, True,
GrabModeSync, GrabModeAsync, CurrentTime); GrabModeSync, GrabModeAsync, CurrentTime);
_grabbed_keyboard = (ret == GrabSuccess); _grabbed_keyboard = (ret == GrabSuccess);
return _grabbed_keyboard; return _grabbed_keyboard;
@ -246,7 +246,7 @@ void Widget::ungrabKeyboard(void)
if (! _grabbed_keyboard) if (! _grabbed_keyboard)
return; return;
XUngrabKeyboard(Display::display, CurrentTime); XUngrabKeyboard(**display, CurrentTime);
_grabbed_keyboard = false; _grabbed_keyboard = false;
} }
@ -257,13 +257,13 @@ void Widget::render(void)
_bg_pixmap = _texture->render(_rect.width(), _rect.height(), _bg_pixmap); _bg_pixmap = _texture->render(_rect.width(), _rect.height(), _bg_pixmap);
if (_bg_pixmap) { if (_bg_pixmap) {
XSetWindowBackgroundPixmap(Display::display, _window, _bg_pixmap); XSetWindowBackgroundPixmap(**display, _window, _bg_pixmap);
_bg_pixel = None; _bg_pixel = None;
} else { } else {
unsigned int pix = _texture->color().pixel(); unsigned int pix = _texture->color().pixel();
if (pix != _bg_pixel) { if (pix != _bg_pixel) {
_bg_pixel = pix; _bg_pixel = pix;
XSetWindowBackground(Display::display, _window, pix); XSetWindowBackground(**display, _window, pix);
} }
} }
} }
@ -395,7 +395,7 @@ void Widget::update(void)
if (_dirty) { if (_dirty) {
adjust(); adjust();
render(); render();
XClearWindow(Display::display, _window); XClearWindow(**display, _window);
} }
WidgetList::iterator it = _children.begin(), end = _children.end(); WidgetList::iterator it = _children.begin(), end = _children.end();

View file

@ -83,13 +83,13 @@ public:
inline const Color *borderColor(void) const { return _bcolor; } inline const Color *borderColor(void) const { return _bcolor; }
virtual void setBorderColor(const Color *color) { virtual void setBorderColor(const Color *color) {
assert(color); _bcolor = color; assert(color); _bcolor = color;
XSetWindowBorder(Display::display, _window, color->pixel()); XSetWindowBorder(**display, _window, color->pixel());
} }
inline int borderWidth(void) const { return _bwidth; } inline int borderWidth(void) const { return _bwidth; }
void setBorderWidth(int width) { void setBorderWidth(int width) {
_bwidth = width; _bwidth = width;
XSetWindowBorderWidth(Display::display, _window, width); XSetWindowBorderWidth(**display, _window, width);
} }
virtual void addChild(Widget *child, bool front = false); virtual void addChild(Widget *child, bool front = false);
@ -104,7 +104,7 @@ public:
inline Cursor cursor(void) const { return _cursor; } inline Cursor cursor(void) const { return _cursor; }
void setCursor(Cursor cursor) { void setCursor(Cursor cursor) {
_cursor = cursor; _cursor = cursor;
XDefineCursor(Display::display, _window, _cursor); XDefineCursor(**display, _window, _cursor);
} }
inline int bevelWidth(void) const { return _bevel_width; } inline int bevelWidth(void) const { return _bevel_width; }