use arrays instead of vectors for the screeninfos and rendercontrols.

This commit is contained in:
Dana Jansens 2003-01-19 23:27:59 +00:00
parent 6871cff3fa
commit d953cfe73c
2 changed files with 28 additions and 23 deletions

View file

@ -84,8 +84,8 @@ Display::Display()
_num_lock_mask(0), _num_lock_mask(0),
_scroll_lock_mask(0), _scroll_lock_mask(0),
_grab_count(0), _grab_count(0),
_screenInfoList(), _screeninfo_list(0),
_renderControlList(), _rendercontrol_list(0),
_gccache((GCCache*) 0) _gccache((GCCache*) 0)
{ {
int junk; int junk;
@ -167,16 +167,16 @@ DISPLAY environment variable approriately.\n\n"));
_mask_list[6] = _scroll_lock_mask | _num_lock_mask; _mask_list[6] = _scroll_lock_mask | _num_lock_mask;
_mask_list[7] = _scroll_lock_mask | LockMask | _num_lock_mask; _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, and create their
_screenInfoList.reserve(ScreenCount(_display)); // RenderControl
for (int i = 0; i < ScreenCount(_display); ++i) _screeninfo_list = new ScreenInfo*[ScreenCount(_display)];
_screenInfoList.push_back(i); _rendercontrol_list = new RenderControl*[ScreenCount(_display)];
for (int i = 0; i < ScreenCount(_display); ++i) {
_screeninfo_list[i] = new ScreenInfo(i);
_rendercontrol_list[i] = RenderControl::getRenderControl(i);
}
_renderControlList.reserve(ScreenCount(_display)); _gccache = new GCCache(ScreenCount(_display));
for (int i = 0; i < ScreenCount(_display); ++i)
_renderControlList.push_back(RenderControl::getRenderControl(i));
_gccache = new GCCache(_screenInfoList.size());
} }
@ -185,6 +185,14 @@ Display::~Display()
delete _gccache; delete _gccache;
while (_grab_count > 0) while (_grab_count > 0)
ungrab(); ungrab();
for (int i = 0; i < ScreenCount(_display); ++i) {
delete _rendercontrol_list[i];
delete _screeninfo_list[i];
}
delete [] _rendercontrol_list;
delete [] _screeninfo_list;
XCloseDisplay(_display); XCloseDisplay(_display);
} }
@ -192,17 +200,16 @@ Display::~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 < (signed) ScreenCount(_display));
return &_screenInfoList[snum]; return _screeninfo_list[snum];
} }
const ScreenInfo* Display::findScreen(Window root) const ScreenInfo* Display::findScreen(Window root)
{ {
std::vector<ScreenInfo>::iterator it, end = _screenInfoList.end(); for (int i = 0; i < ScreenCount(_display); ++i)
for (it = _screenInfoList.begin(); it != end; ++it) if (_screeninfo_list[i]->rootWindow() == root)
if (it->rootWindow() == root) return _screeninfo_list[i];
return &(*it);
return 0; return 0;
} }
@ -210,8 +217,8 @@ const ScreenInfo* Display::findScreen(Window root)
const RenderControl *Display::renderControl(int snum) const RenderControl *Display::renderControl(int snum)
{ {
assert(snum >= 0); assert(snum >= 0);
assert(snum < (signed) _renderControlList.size()); assert(snum < (signed) ScreenCount(_display));
return _renderControlList[snum]; return _rendercontrol_list[snum];
} }

View file

@ -6,8 +6,6 @@ extern "C" {
#include <X11/Xlib.h> #include <X11/Xlib.h>
} }
#include <vector>
namespace otk { namespace otk {
class ScreenInfo; class ScreenInfo;
@ -54,11 +52,11 @@ private:
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
std::vector<ScreenInfo> _screenInfoList; ScreenInfo** _screeninfo_list;
//! A list of RenderControl objects, which are used for all graphics on a //! A list of RenderControl objects, which are used for all graphics on a
//! screen //! screen
std::vector<RenderControl*> _renderControlList; RenderControl** _rendercontrol_list;
//! A cache for re-using GCs, used by the drawing objects //! A cache for re-using GCs, used by the drawing objects
/*! /*!