more api cleanups
This commit is contained in:
parent
723739dafe
commit
06de24ec66
12 changed files with 64 additions and 66 deletions
|
@ -75,7 +75,7 @@ void BColor::parseColorName(void) {
|
||||||
|
|
||||||
if (scrn == ~(0u))
|
if (scrn == ~(0u))
|
||||||
scrn = DefaultScreen(OBDisplay::display);
|
scrn = DefaultScreen(OBDisplay::display);
|
||||||
Colormap colormap = OBDisplay::screenInfo(scrn)->getColormap();
|
Colormap colormap = OBDisplay::screenInfo(scrn)->colormap();
|
||||||
|
|
||||||
// get rgb values from colorname
|
// get rgb values from colorname
|
||||||
XColor xcol;
|
XColor xcol;
|
||||||
|
@ -98,7 +98,7 @@ void BColor::parseColorName(void) {
|
||||||
|
|
||||||
void BColor::allocate(void) {
|
void BColor::allocate(void) {
|
||||||
if (scrn == ~(0u)) scrn = DefaultScreen(OBDisplay::display);
|
if (scrn == ~(0u)) scrn = DefaultScreen(OBDisplay::display);
|
||||||
Colormap colormap = OBDisplay::screenInfo(scrn)->getColormap();
|
Colormap colormap = OBDisplay::screenInfo(scrn)->colormap();
|
||||||
|
|
||||||
if (! isValid()) {
|
if (! isValid()) {
|
||||||
if (colorname.empty()) {
|
if (colorname.empty()) {
|
||||||
|
@ -205,7 +205,7 @@ void BColor::doCacheCleanup(void) {
|
||||||
|
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
XFreeColors(OBDisplay::display,
|
XFreeColors(OBDisplay::display,
|
||||||
OBDisplay::screenInfo(i)->getColormap(),
|
OBDisplay::screenInfo(i)->colormap(),
|
||||||
pixels, count, 0);
|
pixels, count, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@ OtkFocusLabel::OtkFocusLabel(OtkWidget *parent)
|
||||||
: OtkFocusWidget(parent), _text("")
|
: OtkFocusWidget(parent), _text("")
|
||||||
{
|
{
|
||||||
const ScreenInfo *info = OBDisplay::screenInfo(screen());
|
const ScreenInfo *info = OBDisplay::screenInfo(screen());
|
||||||
_xftdraw = XftDrawCreate(OBDisplay::display, window(), info->getVisual(),
|
_xftdraw = XftDrawCreate(OBDisplay::display, window(), info->visual(),
|
||||||
info->getColormap());
|
info->colormap());
|
||||||
}
|
}
|
||||||
|
|
||||||
OtkFocusLabel::~OtkFocusLabel()
|
OtkFocusLabel::~OtkFocusLabel()
|
||||||
|
|
|
@ -86,7 +86,7 @@ BGCCache::~BGCCache(void) {
|
||||||
|
|
||||||
|
|
||||||
BGCCacheContext *BGCCache::nextContext(unsigned int scr) {
|
BGCCacheContext *BGCCache::nextContext(unsigned int scr) {
|
||||||
Window hd = OBDisplay::screenInfo(scr)->getRootWindow();
|
Window hd = OBDisplay::screenInfo(scr)->rootWindow();
|
||||||
|
|
||||||
BGCCacheContext *c;
|
BGCCacheContext *c;
|
||||||
|
|
||||||
|
|
|
@ -562,7 +562,7 @@ Pixmap BImage::renderPixmap(void) {
|
||||||
|
|
||||||
XPutImage(OBDisplay::display, pixmap,
|
XPutImage(OBDisplay::display, pixmap,
|
||||||
DefaultGC(OBDisplay::display,
|
DefaultGC(OBDisplay::display,
|
||||||
control->getScreenInfo()->getScreenNumber()),
|
control->getScreenInfo()->screen()),
|
||||||
image, 0, 0, 0, 0, width, height);
|
image, 0, 0, 0, 0, width, height);
|
||||||
|
|
||||||
if (image->data) {
|
if (image->data) {
|
||||||
|
|
|
@ -88,7 +88,7 @@ public:
|
||||||
|
|
||||||
inline Window getDrawable(void) const { return window; }
|
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 getBitsPerPixel(void) const { return bits_per_pixel; }
|
||||||
inline int getDepth(void) const { return screen_depth; }
|
inline int getDepth(void) const { return screen_depth; }
|
||||||
|
|
|
@ -69,10 +69,10 @@ BImageControl::BImageControl(OBTimerQueueManager *timermanager,
|
||||||
|
|
||||||
sqrt_table = (unsigned long *) 0;
|
sqrt_table = (unsigned long *) 0;
|
||||||
|
|
||||||
screen_depth = screeninfo->getDepth();
|
screen_depth = screeninfo->depth();
|
||||||
window = screeninfo->getRootWindow();
|
window = screeninfo->rootWindow();
|
||||||
screen_number = screeninfo->getScreenNumber();
|
screen_number = screeninfo->screen();
|
||||||
colormap = screeninfo->getColormap();
|
colormap = screeninfo->colormap();
|
||||||
|
|
||||||
int count;
|
int count;
|
||||||
XPixmapFormatValues *pmv = XListPixmapFormats(OBDisplay::display,
|
XPixmapFormatValues *pmv = XListPixmapFormats(OBDisplay::display,
|
||||||
|
|
|
@ -12,8 +12,8 @@ OtkLabel::OtkLabel(OtkWidget *parent)
|
||||||
: OtkWidget(parent), _text("")
|
: OtkWidget(parent), _text("")
|
||||||
{
|
{
|
||||||
const ScreenInfo *info = OBDisplay::screenInfo(screen());
|
const ScreenInfo *info = OBDisplay::screenInfo(screen());
|
||||||
_xftdraw = XftDrawCreate(OBDisplay::display, window(), info->getVisual(),
|
_xftdraw = XftDrawCreate(OBDisplay::display, window(), info->visual(),
|
||||||
info->getColormap());
|
info->colormap());
|
||||||
}
|
}
|
||||||
|
|
||||||
OtkLabel::~OtkLabel()
|
OtkLabel::~OtkLabel()
|
||||||
|
|
|
@ -18,32 +18,32 @@ using std::string;
|
||||||
namespace otk {
|
namespace otk {
|
||||||
|
|
||||||
ScreenInfo::ScreenInfo(unsigned int num) {
|
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,
|
_rect.setSize(WidthOfScreen(ScreenOfDisplay(OBDisplay::display,
|
||||||
screen_number)),
|
_screen)),
|
||||||
HeightOfScreen(ScreenOfDisplay(OBDisplay::display,
|
HeightOfScreen(ScreenOfDisplay(OBDisplay::display,
|
||||||
screen_number)));
|
_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,
|
||||||
otherwise we try to find the largest TrueColor visual.
|
otherwise we try to find the largest TrueColor visual.
|
||||||
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(OBDisplay::display, screen_number);
|
_depth = DefaultDepth(OBDisplay::display, _screen);
|
||||||
visual = DefaultVisual(OBDisplay::display, screen_number);
|
_visual = DefaultVisual(OBDisplay::display, _screen);
|
||||||
colormap = DefaultColormap(OBDisplay::display, screen_number);
|
_colormap = DefaultColormap(OBDisplay::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...
|
||||||
// we will use the default visual for the screen
|
// we will use the default visual for the screen
|
||||||
XVisualInfo vinfo_template, *vinfo_return;
|
XVisualInfo vinfo_template, *vinfo_return;
|
||||||
int vinfo_nitems;
|
int vinfo_nitems;
|
||||||
int best = -1;
|
int best = -1;
|
||||||
|
|
||||||
vinfo_template.screen = screen_number;
|
vinfo_template.screen = _screen;
|
||||||
vinfo_template.c_class = TrueColor;
|
vinfo_template.c_class = TrueColor;
|
||||||
|
|
||||||
vinfo_return = XGetVisualInfo(OBDisplay::display,
|
vinfo_return = XGetVisualInfo(OBDisplay::display,
|
||||||
|
@ -59,14 +59,14 @@ ScreenInfo::ScreenInfo(unsigned int num) {
|
||||||
best = i;
|
best = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (max_depth < depth) best = -1;
|
if (max_depth < _depth) best = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
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(OBDisplay::display, root_window, visual,
|
_colormap = XCreateColormap(OBDisplay::display, _root_window, _visual,
|
||||||
AllocNone);
|
AllocNone);
|
||||||
}
|
}
|
||||||
|
|
||||||
XFree(vinfo_return);
|
XFree(vinfo_return);
|
||||||
|
@ -78,11 +78,11 @@ ScreenInfo::ScreenInfo(unsigned int num) {
|
||||||
if (pos != string::npos)
|
if (pos != string::npos)
|
||||||
default_string.resize(pos);
|
default_string.resize(pos);
|
||||||
|
|
||||||
display_string = string("DISPLAY=") + default_string + '.' +
|
_display_string = string("DISPLAY=") + default_string + '.' +
|
||||||
otk::itostring(static_cast<unsigned long>(screen_number));
|
otk::itostring(static_cast<unsigned long>(_screen));
|
||||||
|
|
||||||
#ifdef XINERAMA
|
#ifdef XINERAMA
|
||||||
xinerama_active = False;
|
_xinerama_active = False;
|
||||||
|
|
||||||
if (d->hasXineramaExtensions()) {
|
if (d->hasXineramaExtensions()) {
|
||||||
if (d->getXineramaMajorVersion() == 1) {
|
if (d->getXineramaMajorVersion() == 1) {
|
||||||
|
@ -104,16 +104,16 @@ ScreenInfo::ScreenInfo(unsigned int num) {
|
||||||
XineramaScreenInfo *info = XineramaQueryScreens(OBDisplay::display,
|
XineramaScreenInfo *info = XineramaQueryScreens(OBDisplay::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) {
|
||||||
xinerama_areas.push_back(Rect(info[i].x_org, info[i].y_org,
|
_xinerama_areas.push_back(Rect(info[i].x_org, info[i].y_org,
|
||||||
info[i].width, info[i].height));
|
info[i].width, info[i].height));
|
||||||
}
|
}
|
||||||
XFree(info);
|
XFree(info);
|
||||||
|
|
||||||
// if we can't find any xinerama regions, then we act as if it is not
|
// if we can't find any xinerama regions, then we act as if it is not
|
||||||
// active, even though it said it was
|
// active, even though it said it was
|
||||||
xinerama_active = True;
|
_xinerama_active = True;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,36 +14,34 @@ namespace otk {
|
||||||
|
|
||||||
class ScreenInfo {
|
class ScreenInfo {
|
||||||
private:
|
private:
|
||||||
Visual *visual;
|
Visual *_visual;
|
||||||
Window root_window;
|
Window _root_window;
|
||||||
Colormap colormap;
|
Colormap _colormap;
|
||||||
|
|
||||||
int depth;
|
int _depth;
|
||||||
unsigned int screen_number;
|
unsigned int _screen;
|
||||||
std::string display_string;
|
std::string _display_string;
|
||||||
Rect rect;
|
Rect _rect;
|
||||||
#ifdef XINERAMA
|
#ifdef XINERAMA
|
||||||
RectList xinerama_areas;
|
RectList _xinerama_areas;
|
||||||
bool xinerama_active;
|
bool _xinerama_active;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ScreenInfo(unsigned int num);
|
ScreenInfo(unsigned int num);
|
||||||
|
|
||||||
inline Visual *getVisual(void) const { return visual; }
|
inline Visual *visual() const { return _visual; }
|
||||||
inline Window getRootWindow(void) const { return root_window; }
|
inline Window rootWindow() const { return _root_window; }
|
||||||
inline Colormap getColormap(void) const { return colormap; }
|
inline Colormap colormap() const { return _colormap; }
|
||||||
inline int getDepth(void) const { return depth; }
|
inline int depth() const { return _depth; }
|
||||||
inline unsigned int getScreenNumber(void) const
|
inline unsigned int screen() const { return _screen; }
|
||||||
{ return screen_number; }
|
inline const Rect& rect() const { return _rect; }
|
||||||
inline const Rect& getRect(void) const { return rect; }
|
inline unsigned int width() const { return _rect.width(); }
|
||||||
inline unsigned int getWidth(void) const { return rect.width(); }
|
inline unsigned int height() const { return _rect.height(); }
|
||||||
inline unsigned int getHeight(void) const { return rect.height(); }
|
inline const std::string& displayString() const { return _display_string; }
|
||||||
inline const std::string& displayString(void) const
|
|
||||||
{ return display_string; }
|
|
||||||
#ifdef XINERAMA
|
#ifdef XINERAMA
|
||||||
inline const RectList &getXineramaAreas(void) const { return xinerama_areas; }
|
inline const RectList &xineramaAreas() const { return _xinerama_areas; }
|
||||||
inline bool isXineramaActive(void) const { return xinerama_active; }
|
inline bool isXineramaActive() const { return _xinerama_active; }
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ Style::Style() : font(NULL)
|
||||||
|
|
||||||
Style::Style(BImageControl *ctrl)
|
Style::Style(BImageControl *ctrl)
|
||||||
: image_control(ctrl), font(0),
|
: 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
|
// load bevel, border and handle widths
|
||||||
|
|
||||||
const ScreenInfo *s_info = OBDisplay::screenInfo(screen_number);
|
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) ||
|
if (! style.getValue("handleWidth", handle_width) ||
|
||||||
handle_width > width/2 || handle_width == 0)
|
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,
|
void Style::readDatabaseMask(const std::string &rname, PixmapMask &pixmapMask,
|
||||||
const Configuration &style) {
|
const Configuration &style) {
|
||||||
Window root_window = OBDisplay::screenInfo(screen_number)->getRootWindow();
|
Window root_window = OBDisplay::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.
|
||||||
|
|
|
@ -137,7 +137,7 @@ public:
|
||||||
|
|
||||||
inline void setImageControl(BImageControl *c) {
|
inline void setImageControl(BImageControl *c) {
|
||||||
image_control = c;
|
image_control = c;
|
||||||
screen_number = c->getScreenInfo()->getScreenNumber();
|
screen_number = c->getScreenInfo()->screen();
|
||||||
}
|
}
|
||||||
inline unsigned int getScreen(void) { return screen_number; }
|
inline unsigned int getScreen(void) { return screen_number; }
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ OtkWidget::~OtkWidget()
|
||||||
void OtkWidget::create(void)
|
void OtkWidget::create(void)
|
||||||
{
|
{
|
||||||
const ScreenInfo *scr_info = otk::OBDisplay::screenInfo(_screen);
|
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
|
_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;
|
unsigned long create_mask = CWBackPixmap | CWBorderPixel | CWEventMask;
|
||||||
|
|
||||||
attrib_create.background_pixmap = None;
|
attrib_create.background_pixmap = None;
|
||||||
attrib_create.colormap = scr_info->getColormap();
|
attrib_create.colormap = scr_info->colormap();
|
||||||
attrib_create.event_mask = ButtonPressMask | ButtonReleaseMask |
|
attrib_create.event_mask = ButtonPressMask | ButtonReleaseMask |
|
||||||
ButtonMotionMask | ExposureMask | StructureNotifyMask;
|
ButtonMotionMask | ExposureMask | StructureNotifyMask;
|
||||||
|
|
||||||
|
@ -89,8 +89,8 @@ void OtkWidget::create(void)
|
||||||
|
|
||||||
_window = XCreateWindow(otk::OBDisplay::display, p_window, _rect.x(),
|
_window = XCreateWindow(otk::OBDisplay::display, p_window, _rect.x(),
|
||||||
_rect.y(), _rect.width(), _rect.height(), 0,
|
_rect.y(), _rect.width(), _rect.height(), 0,
|
||||||
scr_info->getDepth(), InputOutput,
|
scr_info->depth(), InputOutput,
|
||||||
scr_info->getVisual(), create_mask, &attrib_create);
|
scr_info->visual(), create_mask, &attrib_create);
|
||||||
_ignore_config++;
|
_ignore_config++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue