Skip to content

Commit

Permalink
fixed the DISPLAY variable for real and properly. Toolbar weirdness s…
Browse files Browse the repository at this point in the history
…olved by adding a setImageControl() method to BTexture.
  • Loading branch information
shaleh committed Apr 13, 2002
1 parent 8fdb9f5 commit 48742a0
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 34 deletions.
13 changes: 8 additions & 5 deletions src/BaseDisplay.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ extern "C" {
#endif // HAVE_SYS_WAIT_H
}

#include <strstream>
#include <sstream>
using std::string;

#include "i18n.hh"
#include "BaseDisplay.hh"
Expand Down Expand Up @@ -448,10 +449,12 @@ ScreenInfo::ScreenInfo(BaseDisplay *d, unsigned int num) {
}

// get the default display string and strip the screen number
std::string default_string = DisplayString(basedisplay->getXDisplay());
default_string.replace(default_string.rfind("."), std::string::npos, "");

std::ostrstream formatter;
string default_string = DisplayString(basedisplay->getXDisplay());
string::size_type pos = default_string.rfind(".");
if (pos != string::npos)
default_string.resize(pos);

std::ostringstream formatter;
formatter << "DISPLAY=" << default_string << '.' << screen_number;
display_string = formatter.str();
}
4 changes: 2 additions & 2 deletions src/BaseDisplay.hh
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ public:
{ return screen_number; }
inline unsigned short getWidth(void) const { return rect.width; }
inline unsigned short getHeight(void) const { return rect.height; }
inline const char* displayString(void) const
{ return display_string.c_str(); }
inline const std::string& displayString(void) const
{ return display_string; }
};


Expand Down
4 changes: 1 addition & 3 deletions src/Color.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,7 @@ void BColor::deallocate(void)
RGB rgb(display(), scrn, r, g, b);
ColorCache::iterator it = colorcache.find(rgb);
if (it != colorcache.end()) {
if ((*it).second.count < 1)
(*it).second.count = 0;
else
if ((*it).second.count >= 1)
(*it).second.count--;
}

Expand Down
3 changes: 2 additions & 1 deletion src/ImageControl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,8 @@ BImageControl::~BImageControl(void) {
}


Pixmap BImageControl::searchCache(const unsigned int width, const unsigned int height,
Pixmap BImageControl::searchCache(const unsigned int width,
const unsigned int height,
const unsigned long texture,
const BColor &c1, const BColor &c2) {
if (cache.empty())
Expand Down
7 changes: 5 additions & 2 deletions src/Screen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1788,7 +1788,8 @@ void BScreen::toggleFocusModel(FocusModel model) {
std::mem_fun(&Workspace::updateFocusModel));
}

BTexture BScreen::readDatabaseTexture(const string &rname, const string &rclass,
BTexture BScreen::readDatabaseTexture(const string &rname,
const string &rclass,
const string &default_color) {
BTexture texture;
XrmValue value;
Expand All @@ -1802,6 +1803,7 @@ BTexture BScreen::readDatabaseTexture(const string &rname, const string &rclass,

// associate this texture with this screen
texture.setDisplay(getBaseDisplay(), getScreenNumber());
texture.setImageControl(image_control);

if (texture.texture() & BTexture::Solid) {
texture.setColor(readDatabaseColor(rname + ".color",
Expand Down Expand Up @@ -1836,7 +1838,8 @@ BColor BScreen::readDatabaseColor(const string &rname, const string &rclass,
return color;
}

XFontSet BScreen::readDatabaseFontSet(const string &rname, const string &rclass)
XFontSet BScreen::readDatabaseFontSet(const string &rname,
const string &rclass)
{
static char *defaultFont = "fixed";

Expand Down
16 changes: 11 additions & 5 deletions src/Screen.hh
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,17 @@ private:
protected:
Bool parseMenuFile(FILE *file, Rootmenu *menu);

BTexture readDatabaseTexture(const string &, const string &, const string &);
BColor readDatabaseColor(const string &, const string &, const string &);
XFontSet readDatabaseFontSet(const string &, const string &);
XFontStruct *readDatabaseFont(const string &, const string &);
XFontSet createFontSet(const string &);
BTexture readDatabaseTexture(const std::string &rname,
const std::string &rclass,
const std::string &default_color);
BColor readDatabaseColor(const std::string &rname,
const std::string &rclass,
const std::string &default_color);
XFontSet readDatabaseFontSet(const std::string &rname,
const std::string &rclass);
XFontStruct *readDatabaseFont(const std::string &rname,
const std::string &rclass);
XFontSet createFontSet(const std::string &fontname);

void InitMenu(void);
void LoadStyle(void);
Expand Down
20 changes: 13 additions & 7 deletions src/Texture.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,22 @@ extern "C" {
#include "Screen.hh"
#include "blackbox.hh"

BTexture::BTexture(const BaseDisplay * const _display, unsigned int _screen)
using std::string;

BTexture::BTexture(const BaseDisplay * const _display,
unsigned int _screen, BImageControl* _ctrl)
: c(_display, _screen), ct(_display, _screen),
lc(_display, _screen), sc(_display, _screen), t(0),
dpy(_display), scrn(_screen)
dpy(_display), ctrl(_ctrl), scrn(_screen)
{
}

BTexture::BTexture(const string &d,
const BaseDisplay * const _display, unsigned int _screen)
const BaseDisplay * const _display,
unsigned int _screen, BImageControl* _ctrl)
: c(_display, _screen), ct(_display, _screen),
lc(_display, _screen), sc(_display, _screen), t(0),
dpy(_display), scrn(_screen)
dpy(_display), ctrl(_ctrl), scrn(_screen)
{
setDescription(d);
}
Expand Down Expand Up @@ -166,7 +170,8 @@ void BTexture::setDisplay(const BaseDisplay * const _display,
sc.setDisplay(_display, _screen);
}

BTexture &BTexture::operator=(const BTexture &tt)

BTexture& BTexture::operator=(const BTexture &tt)
{
c = tt.c;
ct = tt.ct;
Expand All @@ -176,6 +181,8 @@ BTexture &BTexture::operator=(const BTexture &tt)
t = tt.t;
dpy = tt.dpy;
scrn = tt.scrn;
ctrl = tt.ctrl;

return *this;
}

Expand All @@ -193,8 +200,7 @@ Pixmap BTexture::render(const unsigned int width, const unsigned int height,
if (screen() == ~(0u))
scrn = DefaultScreen(display()->getXDisplay());

extern BImageControl *ctrl; // HACK!
// BImageControl *ctrl = blackbox->getScreen(screen())->getImageControl();
assert(ctrl != 0);
Pixmap ret = ctrl->renderImage(width, height, *this);

if (old)
Expand Down
17 changes: 10 additions & 7 deletions src/Texture.hh
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

#include "Color.hh"
#include "Util.hh"
class BImageControl;

#include <string>
using std::string;

class BTexture {
public:
Expand Down Expand Up @@ -60,9 +60,11 @@ public:
Interlaced = (1l<<17)
};

BTexture(const BaseDisplay * const _display = 0, unsigned int _screen = ~(0u));
BTexture(const string &_description,
const BaseDisplay * const _display = 0, unsigned int _screen = ~(0u));
BTexture(const BaseDisplay * const _display = 0,
unsigned int _screen = ~(0u), BImageControl* _ctrl = 0);
BTexture(const std::string &_description,
const BaseDisplay * const _display = 0,
unsigned int _screen = ~(0u), BImageControl* _ctrl = 0);
~BTexture(void);

void setColor(const BColor &_color);
Expand All @@ -87,19 +89,20 @@ public:
unsigned int screen(void) const { return scrn; }
void setDisplay(const BaseDisplay * const _display,
const unsigned int _screen);

void setImageControl(BImageControl* _ctrl) { ctrl = _ctrl; }
const std::string &description(void) const { return descr; }
void setDescription(const std::string &);
void setDescription(const std::string &d);

// Pixmap render(const Size &, Pixmap old = 0);
Pixmap render(const unsigned int width, const unsigned int height,
const Pixmap old = 0);

private:
BColor c, ct, lc, sc;
string descr;
std::string descr;
unsigned long t;
const BaseDisplay *dpy;
BImageControl *ctrl;
unsigned int scrn;
};

Expand Down
3 changes: 2 additions & 1 deletion src/Util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ void bexec(const string& command, const string& displaystring) {
#ifndef __EMX__
if (! fork()) {
setsid();
putenv(const_cast<char *>(displaystring.c_str()));
int ret = putenv(const_cast<char *>(displaystring.c_str()));
assert(ret != -1);
string cmd = "exec ";
cmd += command;
execl("/bin/sh", "/bin/sh", "-c", cmd.c_str(), NULL);
Expand Down
2 changes: 2 additions & 0 deletions src/blackbox.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ extern "C" {
}

#include <algorithm>
#include <string>
using std::string;

#include "i18n.hh"
#include "blackbox.hh"
Expand Down
2 changes: 1 addition & 1 deletion util/bsetroot.cc
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ void bsetroot::modula(int x, int y) {

void bsetroot::gradient(void) {
for (unsigned int screen = 0; screen < getNumberOfScreens(); screen++) {
BTexture texture(grad, this, screen);
BTexture texture(grad, this, screen, img_ctrl[screen]);
const ScreenInfo *screen_info = getScreenInfo(screen);

texture.setColor(BColor(fore, this, screen));
Expand Down

0 comments on commit 48742a0

Please sign in to comment.