more api cleanups

This commit is contained in:
Dana Jansens 2002-12-20 15:33:58 +00:00
parent 723739dafe
commit 06de24ec66
12 changed files with 64 additions and 66 deletions

View file

@ -75,7 +75,7 @@ void BColor::parseColorName(void) {
if (scrn == ~(0u))
scrn = DefaultScreen(OBDisplay::display);
Colormap colormap = OBDisplay::screenInfo(scrn)->getColormap();
Colormap colormap = OBDisplay::screenInfo(scrn)->colormap();
// get rgb values from colorname
XColor xcol;
@ -98,7 +98,7 @@ void BColor::parseColorName(void) {
void BColor::allocate(void) {
if (scrn == ~(0u)) scrn = DefaultScreen(OBDisplay::display);
Colormap colormap = OBDisplay::screenInfo(scrn)->getColormap();
Colormap colormap = OBDisplay::screenInfo(scrn)->colormap();
if (! isValid()) {
if (colorname.empty()) {
@ -205,7 +205,7 @@ void BColor::doCacheCleanup(void) {
if (count > 0)
XFreeColors(OBDisplay::display,
OBDisplay::screenInfo(i)->getColormap(),
OBDisplay::screenInfo(i)->colormap(),
pixels, count, 0);
}

View file

@ -14,8 +14,8 @@ OtkFocusLabel::OtkFocusLabel(OtkWidget *parent)
: OtkFocusWidget(parent), _text("")
{
const ScreenInfo *info = OBDisplay::screenInfo(screen());
_xftdraw = XftDrawCreate(OBDisplay::display, window(), info->getVisual(),
info->getColormap());
_xftdraw = XftDrawCreate(OBDisplay::display, window(), info->visual(),
info->colormap());
}
OtkFocusLabel::~OtkFocusLabel()

View file

@ -86,7 +86,7 @@ BGCCache::~BGCCache(void) {
BGCCacheContext *BGCCache::nextContext(unsigned int scr) {
Window hd = OBDisplay::screenInfo(scr)->getRootWindow();
Window hd = OBDisplay::screenInfo(scr)->rootWindow();
BGCCacheContext *c;

View file

@ -562,7 +562,7 @@ Pixmap BImage::renderPixmap(void) {
XPutImage(OBDisplay::display, pixmap,
DefaultGC(OBDisplay::display,
control->getScreenInfo()->getScreenNumber()),
control->getScreenInfo()->screen()),
image, 0, 0, 0, 0, width, height);
if (image->data) {

View file

@ -88,7 +88,7 @@ public:
inline Window getDrawable(void) const { return window; }
inline Visual *getVisual(void) { return screeninfo->getVisual(); }
inline Visual *getVisual(void) { return screeninfo->visual(); }
inline int getBitsPerPixel(void) const { return bits_per_pixel; }
inline int getDepth(void) const { return screen_depth; }

View file

@ -69,10 +69,10 @@ BImageControl::BImageControl(OBTimerQueueManager *timermanager,
sqrt_table = (unsigned long *) 0;
screen_depth = screeninfo->getDepth();
window = screeninfo->getRootWindow();
screen_number = screeninfo->getScreenNumber();
colormap = screeninfo->getColormap();
screen_depth = screeninfo->depth();
window = screeninfo->rootWindow();
screen_number = screeninfo->screen();
colormap = screeninfo->colormap();
int count;
XPixmapFormatValues *pmv = XListPixmapFormats(OBDisplay::display,

View file

@ -12,8 +12,8 @@ OtkLabel::OtkLabel(OtkWidget *parent)
: OtkWidget(parent), _text("")
{
const ScreenInfo *info = OBDisplay::screenInfo(screen());
_xftdraw = XftDrawCreate(OBDisplay::display, window(), info->getVisual(),
info->getColormap());
_xftdraw = XftDrawCreate(OBDisplay::display, window(), info->visual(),
info->colormap());
}
OtkLabel::~OtkLabel()

View file

@ -18,32 +18,32 @@ using std::string;
namespace otk {
ScreenInfo::ScreenInfo(unsigned int num) {
screen_number = num;
_screen = num;
root_window = RootWindow(OBDisplay::display, screen_number);
_root_window = RootWindow(OBDisplay::display, _screen);
rect.setSize(WidthOfScreen(ScreenOfDisplay(OBDisplay::display,
screen_number)),
_rect.setSize(WidthOfScreen(ScreenOfDisplay(OBDisplay::display,
_screen)),
HeightOfScreen(ScreenOfDisplay(OBDisplay::display,
screen_number)));
_screen)));
/*
If the default depth is at least 8 we will use that,
otherwise we try to find the largest TrueColor visual.
Preference is given to 24 bit over larger depths if 24 bit is an option.
*/
depth = DefaultDepth(OBDisplay::display, screen_number);
visual = DefaultVisual(OBDisplay::display, screen_number);
colormap = DefaultColormap(OBDisplay::display, screen_number);
_depth = DefaultDepth(OBDisplay::display, _screen);
_visual = DefaultVisual(OBDisplay::display, _screen);
_colormap = DefaultColormap(OBDisplay::display, _screen);
if (depth < 8) {
if (_depth < 8) {
// search for a TrueColor Visual... if we can't find one...
// we will use the default visual for the screen
XVisualInfo vinfo_template, *vinfo_return;
int vinfo_nitems;
int best = -1;
vinfo_template.screen = screen_number;
vinfo_template.screen = _screen;
vinfo_template.c_class = TrueColor;
vinfo_return = XGetVisualInfo(OBDisplay::display,
@ -59,14 +59,14 @@ ScreenInfo::ScreenInfo(unsigned int num) {
best = i;
}
}
if (max_depth < depth) best = -1;
if (max_depth < _depth) best = -1;
}
if (best != -1) {
depth = vinfo_return[best].depth;
visual = vinfo_return[best].visual;
colormap = XCreateColormap(OBDisplay::display, root_window, visual,
AllocNone);
_depth = vinfo_return[best].depth;
_visual = vinfo_return[best].visual;
_colormap = XCreateColormap(OBDisplay::display, _root_window, _visual,
AllocNone);
}
XFree(vinfo_return);
@ -78,11 +78,11 @@ ScreenInfo::ScreenInfo(unsigned int num) {
if (pos != string::npos)
default_string.resize(pos);
display_string = string("DISPLAY=") + default_string + '.' +
otk::itostring(static_cast<unsigned long>(screen_number));
_display_string = string("DISPLAY=") + default_string + '.' +
otk::itostring(static_cast<unsigned long>(_screen));
#ifdef XINERAMA
xinerama_active = False;
_xinerama_active = False;
if (d->hasXineramaExtensions()) {
if (d->getXineramaMajorVersion() == 1) {
@ -104,16 +104,16 @@ ScreenInfo::ScreenInfo(unsigned int num) {
XineramaScreenInfo *info = XineramaQueryScreens(OBDisplay::display,
&num);
if (num > 0 && info) {
xinerama_areas.reserve(num);
_xinerama_areas.reserve(num);
for (int i = 0; i < num; ++i) {
xinerama_areas.push_back(Rect(info[i].x_org, info[i].y_org,
info[i].width, info[i].height));
_xinerama_areas.push_back(Rect(info[i].x_org, info[i].y_org,
info[i].width, info[i].height));
}
XFree(info);
// if we can't find any xinerama regions, then we act as if it is not
// active, even though it said it was
xinerama_active = True;
_xinerama_active = True;
}
}
}

View file

@ -14,36 +14,34 @@ namespace otk {
class ScreenInfo {
private:
Visual *visual;
Window root_window;
Colormap colormap;
Visual *_visual;
Window _root_window;
Colormap _colormap;
int depth;
unsigned int screen_number;
std::string display_string;
Rect rect;
int _depth;
unsigned int _screen;
std::string _display_string;
Rect _rect;
#ifdef XINERAMA
RectList xinerama_areas;
bool xinerama_active;
RectList _xinerama_areas;
bool _xinerama_active;
#endif
public:
ScreenInfo(unsigned int num);
inline Visual *getVisual(void) const { return visual; }
inline Window getRootWindow(void) const { return root_window; }
inline Colormap getColormap(void) const { return colormap; }
inline int getDepth(void) const { return depth; }
inline unsigned int getScreenNumber(void) const
{ return screen_number; }
inline const Rect& getRect(void) const { return rect; }
inline unsigned int getWidth(void) const { return rect.width(); }
inline unsigned int getHeight(void) const { return rect.height(); }
inline const std::string& displayString(void) const
{ return display_string; }
inline Visual *visual() const { return _visual; }
inline Window rootWindow() const { return _root_window; }
inline Colormap colormap() const { return _colormap; }
inline int depth() const { return _depth; }
inline unsigned int screen() const { return _screen; }
inline const Rect& rect() const { return _rect; }
inline unsigned int width() const { return _rect.width(); }
inline unsigned int height() const { return _rect.height(); }
inline const std::string& displayString() const { return _display_string; }
#ifdef XINERAMA
inline const RectList &getXineramaAreas(void) const { return xinerama_areas; }
inline bool isXineramaActive(void) const { return xinerama_active; }
inline const RectList &xineramaAreas() const { return _xinerama_areas; }
inline bool isXineramaActive() const { return _xinerama_active; }
#endif
};

View file

@ -19,7 +19,7 @@ Style::Style() : font(NULL)
Style::Style(BImageControl *ctrl)
: image_control(ctrl), font(0),
screen_number(ctrl->getScreenInfo()->getScreenNumber())
screen_number(ctrl->getScreenInfo()->screen())
{
}
@ -136,7 +136,7 @@ void Style::load(const Configuration &style) {
// load bevel, border and handle widths
const ScreenInfo *s_info = OBDisplay::screenInfo(screen_number);
unsigned int width = s_info->getRect().width();
unsigned int width = s_info->rect().width();
if (! style.getValue("handleWidth", handle_width) ||
handle_width > width/2 || handle_width == 0)
@ -160,7 +160,7 @@ void Style::load(const Configuration &style) {
void Style::readDatabaseMask(const std::string &rname, PixmapMask &pixmapMask,
const Configuration &style) {
Window root_window = OBDisplay::screenInfo(screen_number)->getRootWindow();
Window root_window = OBDisplay::screenInfo(screen_number)->rootWindow();
std::string s;
int hx, hy; //ignored
int ret = BitmapOpenFailed; //default to failure.

View file

@ -137,7 +137,7 @@ public:
inline void setImageControl(BImageControl *c) {
image_control = c;
screen_number = c->getScreenInfo()->getScreenNumber();
screen_number = c->getScreenInfo()->screen();
}
inline unsigned int getScreen(void) { return screen_number; }

View file

@ -70,7 +70,7 @@ OtkWidget::~OtkWidget()
void OtkWidget::create(void)
{
const ScreenInfo *scr_info = otk::OBDisplay::screenInfo(_screen);
Window p_window = _parent ? _parent->window() : scr_info->getRootWindow();
Window p_window = _parent ? _parent->window() : scr_info->rootWindow();
_rect.setRect(0, 0, 1, 1); // just some initial values
@ -78,7 +78,7 @@ void OtkWidget::create(void)
unsigned long create_mask = CWBackPixmap | CWBorderPixel | CWEventMask;
attrib_create.background_pixmap = None;
attrib_create.colormap = scr_info->getColormap();
attrib_create.colormap = scr_info->colormap();
attrib_create.event_mask = ButtonPressMask | ButtonReleaseMask |
ButtonMotionMask | ExposureMask | StructureNotifyMask;
@ -89,8 +89,8 @@ void OtkWidget::create(void)
_window = XCreateWindow(otk::OBDisplay::display, p_window, _rect.x(),
_rect.y(), _rect.width(), _rect.height(), 0,
scr_info->getDepth(), InputOutput,
scr_info->getVisual(), create_mask, &attrib_create);
scr_info->depth(), InputOutput,
scr_info->visual(), create_mask, &attrib_create);
_ignore_config++;
}