Make fbsetroot set one screen at a time
This commit is contained in:
parent
9be4311798
commit
7d4546ba5b
3 changed files with 115 additions and 137 deletions
|
@ -1,6 +1,8 @@
|
|||
(Format: Year/Month/Day)
|
||||
Changes for 1.0rc2:
|
||||
*06/06/29:
|
||||
* Make fbsetroot set one screen at a time (Mark)
|
||||
util/fbsetroot.cc/hh
|
||||
* Fix fbsetroot segfault when DISPLAY is unset (Mark)
|
||||
util/fbsetroot.cc
|
||||
*06/06/28:
|
||||
|
|
|
@ -55,18 +55,16 @@ using namespace std;
|
|||
fbsetroot::fbsetroot(int argc, char **argv, char *dpy_name)
|
||||
: FbTk::App(dpy_name), m_app_name(argv[0]) {
|
||||
|
||||
pixmaps = (Pixmap *) 0;
|
||||
pixmap = (Pixmap *) 0;
|
||||
screen = DefaultScreen(FbTk::App::instance()->display());
|
||||
grad = fore = back = (char *) 0;
|
||||
|
||||
bool mod = false, sol = false, grd = false;
|
||||
int mod_x = 0, mod_y = 0, i = 0;
|
||||
int mod_x = 0, mod_y = 0, i = 1;
|
||||
|
||||
img_ctrl = new FbTk::ImageControl*[ScreenCount(display())];
|
||||
for (; i < ScreenCount(display()); i++) {
|
||||
img_ctrl[i] = new FbTk::ImageControl(i, true);
|
||||
}
|
||||
img_ctrl = new FbTk::ImageControl(screen);
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
for (; i < argc; i++) {
|
||||
if (! strcmp("-help", argv[i])) {
|
||||
usage();
|
||||
|
||||
|
@ -127,8 +125,6 @@ fbsetroot::fbsetroot(int argc, char **argv, char *dpy_name)
|
|||
exit(2);
|
||||
}
|
||||
|
||||
num_screens = ScreenCount(display());
|
||||
|
||||
if (sol && fore)
|
||||
solid();
|
||||
else if (mod && mod_x && mod_y && fore && back)
|
||||
|
@ -144,18 +140,13 @@ fbsetroot::fbsetroot(int argc, char **argv, char *dpy_name)
|
|||
fbsetroot::~fbsetroot() {
|
||||
XKillClient(display(), AllTemporary);
|
||||
|
||||
if (pixmaps) { // should always be true
|
||||
if (pixmap) { // should always be true
|
||||
XSetCloseDownMode(display(), RetainTemporary);
|
||||
|
||||
delete [] pixmaps;
|
||||
delete pixmap;
|
||||
}
|
||||
|
||||
if (img_ctrl != 0) {
|
||||
for (int i=0; i < num_screens; i++)
|
||||
delete img_ctrl[i];
|
||||
|
||||
delete [] img_ctrl;
|
||||
}
|
||||
delete img_ctrl;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -209,12 +200,6 @@ void fbsetroot::setRootAtoms(Pixmap pixmap, int screen) {
|
|||
Draws pixmaps with a single color
|
||||
*/
|
||||
void fbsetroot::solid() {
|
||||
register int screen = 0;
|
||||
|
||||
pixmaps = new Pixmap[ScreenCount(display())];
|
||||
|
||||
for (; screen < ScreenCount(display()); screen++) {
|
||||
|
||||
FbTk::Color c(fore, screen);
|
||||
if (! c.isAllocated())
|
||||
c.setPixel(BlackPixel(display(), screen));
|
||||
|
@ -224,20 +209,19 @@ void fbsetroot::solid() {
|
|||
FbTk::GContext gc(root);
|
||||
gc.setForeground(c);
|
||||
|
||||
pixmaps[screen] = XCreatePixmap(display(),
|
||||
pixmap = new Pixmap(XCreatePixmap(display(),
|
||||
root.window(),
|
||||
root.width(), root.height(),
|
||||
root.depth());
|
||||
root.depth()));
|
||||
|
||||
XFillRectangle(display(), pixmaps[screen], gc.gc(), 0, 0,
|
||||
XFillRectangle(display(), *pixmap, gc.gc(), 0, 0,
|
||||
root.width(), root.height());
|
||||
|
||||
setRootAtoms(pixmaps[screen], screen);
|
||||
setRootAtoms(*pixmap, screen);
|
||||
|
||||
root.setBackgroundPixmap(pixmaps[screen]);
|
||||
root.setBackgroundPixmap(*pixmap);
|
||||
root.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Draws pixmaps with an 16x16 pattern with
|
||||
|
@ -245,13 +229,10 @@ void fbsetroot::solid() {
|
|||
*/
|
||||
void fbsetroot::modula(int x, int y) {
|
||||
char data[32];
|
||||
long pattern;
|
||||
long pattern = 0;
|
||||
|
||||
register int screen, i;
|
||||
register int i;
|
||||
|
||||
pixmaps = new Pixmap[ScreenCount(display())];
|
||||
|
||||
for (pattern = 0, screen = 0; screen < ScreenCount(display()); screen++) {
|
||||
FbRootWindow root(screen);
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
|
@ -301,22 +282,21 @@ void fbsetroot::modula(int x, int y) {
|
|||
gc.setTile(r_bitmap);
|
||||
gc.setFillStyle(FillTiled);
|
||||
|
||||
pixmaps[screen] = XCreatePixmap(display(),
|
||||
pixmap = new Pixmap(XCreatePixmap(display(),
|
||||
root.window(),
|
||||
root.width(), root.height(),
|
||||
root.depth());
|
||||
root.depth()));
|
||||
|
||||
XFillRectangle(display(), pixmaps[screen], gc.gc(), 0, 0,
|
||||
XFillRectangle(display(), *pixmap, gc.gc(), 0, 0,
|
||||
root.width(), root.height());
|
||||
|
||||
setRootAtoms(pixmaps[screen], screen);
|
||||
root.setBackgroundPixmap(pixmaps[screen]);
|
||||
setRootAtoms(*pixmap, screen);
|
||||
root.setBackgroundPixmap(*pixmap);
|
||||
root.clear();
|
||||
|
||||
XFreePixmap(display(), bitmap);
|
||||
XFreePixmap(display(), r_bitmap);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
draws pixmaps with a fluxbox texure
|
||||
|
@ -326,14 +306,12 @@ void fbsetroot::gradient() {
|
|||
// get crashed somewhere on the way causing apps like XChat chrashing
|
||||
// as the pixmap has been destroyed
|
||||
Pixmap tmp;
|
||||
pixmaps = new Pixmap[ScreenCount(display())];
|
||||
// we must insert gradient text
|
||||
string texture_value = grad ? grad : "solid";
|
||||
texture_value.insert(0, "gradient ");
|
||||
FbTk::Texture texture;
|
||||
texture.setFromString(texture_value.c_str());
|
||||
|
||||
for (int screen = 0; screen < ScreenCount(display()); screen++) {
|
||||
FbRootWindow root(screen);
|
||||
|
||||
|
||||
|
@ -348,31 +326,29 @@ void fbsetroot::gradient() {
|
|||
if (! texture.colorTo().isAllocated())
|
||||
texture.colorTo().setPixel(BlackPixel(display(), screen));
|
||||
|
||||
tmp = img_ctrl[screen]->renderImage(root.width(), root.height(),
|
||||
texture);
|
||||
tmp = img_ctrl->renderImage(root.width(), root.height(), texture);
|
||||
|
||||
pixmaps[screen] = XCreatePixmap(display(),
|
||||
pixmap = new Pixmap(XCreatePixmap(display(),
|
||||
root.window(),
|
||||
root.width(), root.height(),
|
||||
root.depth());
|
||||
root.depth()));
|
||||
|
||||
|
||||
XCopyArea(display(), tmp, pixmaps[screen], gc.gc(), 0, 0,
|
||||
XCopyArea(display(), tmp, *pixmap, gc.gc(), 0, 0,
|
||||
root.width(), root.height(),
|
||||
0, 0);
|
||||
|
||||
setRootAtoms(pixmaps[screen], screen);
|
||||
setRootAtoms(*pixmap, screen);
|
||||
|
||||
root.setBackgroundPixmap(pixmaps[screen]);
|
||||
root.setBackgroundPixmap(*pixmap);
|
||||
root.clear();
|
||||
|
||||
if (! (root.visual()->c_class & 1)) {
|
||||
img_ctrl[screen]->removeImage(tmp);
|
||||
img_ctrl[screen]->cleanCache();
|
||||
img_ctrl->removeImage(tmp);
|
||||
img_ctrl->cleanCache();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Shows information about usage
|
||||
|
|
|
@ -43,11 +43,11 @@ public:
|
|||
void setRootAtoms(Pixmap pixmap, int screen);
|
||||
|
||||
private:
|
||||
FbTk::ImageControl **img_ctrl;
|
||||
Pixmap *pixmaps;
|
||||
FbTk::ImageControl *img_ctrl;
|
||||
Pixmap *pixmap;
|
||||
int screen;
|
||||
|
||||
char *fore, *back, *grad;
|
||||
int num_screens;
|
||||
char *m_app_name;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue