add rough support for non-default depth pixmaps. Saves us having ghost

holes in windows
This commit is contained in:
simonb 2005-04-27 17:45:56 +00:00
parent 9970dd11c7
commit 690030444b
5 changed files with 36 additions and 14 deletions

View file

@ -1,6 +1,10 @@
(Format: Year/Month/Day)
Changes for 0.9.13
*05/04/27:
* Add some extremely basic handling for icon pixmaps that aren't
the same depth as the screen (treat all as 1-bit, easy to handle)
(Simon)
FbTk/FbPixmap.hh/cc FbTk/ImageImlib2.cc IconButton.cc
* Fix a bunch more issues with recent patches (Simon)
- Clock text colour on start
- Resizing not updating in some cases

View file

@ -139,7 +139,8 @@ void FbPixmap::copy(const FbPixmap &the_copy) {
}
}
void FbPixmap::copy(Pixmap pm) {
// screen doesn't count if depth is "zero"...
void FbPixmap::copy(Pixmap pm, int depth, int screen_num) {
free();
if (pm == 0)
return;
@ -157,15 +158,28 @@ void FbPixmap::copy(Pixmap pm) {
&new_width, &new_height,
&border_width,
&bpp);
if (depth == 0)
depth = bpp;
// create new pixmap and copy area
create(root, new_width, new_height, bpp);
create(root, new_width, new_height, depth);
GC gc = XCreateGC(display(), drawable(), 0, 0);
XCopyArea(display(), pm, drawable(), gc,
0, 0,
width(), height(),
0, 0);
if (depth == bpp) {
XCopyArea(display(), pm, drawable(), gc,
0, 0,
width(), height(),
0, 0);
} else {
XSetForeground(display(), gc, Color("black", screen_num).pixel());
XSetBackground(display(), gc, Color("white", screen_num).pixel());
XCopyPlane(display(), pm, drawable(), gc,
0, 0,
width(), height(),
0, 0, 1);
}
XFreeGC(display(), gc);
}
@ -254,7 +268,7 @@ void FbPixmap::tile(unsigned int dest_width, unsigned int dest_height) {
FbPixmap new_pm(drawable(), width(), height(), depth());
new_pm.copy(m_pm);
new_pm.copy(m_pm, 0, 0);
resize(dest_width, dest_height);

View file

@ -48,7 +48,7 @@ public:
virtual ~FbPixmap();
void copy(const FbPixmap &the_copy);
void copy(Pixmap pixmap);
void copy(Pixmap pixmap, int depth_convert, int screen_num);
/// rotates the pixmap 90 deg, not implemented!
void rotate();
/// scales the pixmap to specified size

View file

@ -147,8 +147,8 @@ PixmapWithMask *ImageImlib2::load(const std::string &filename, int screen_num) c
// pm and mask belong to imlib2,
// so we have to copy them
PixmapWithMask* result = new PixmapWithMask();
result->pixmap().copy(pm);
result->mask().copy(mask);
result->pixmap().copy(pm, 0, 0);
result->mask().copy(mask, 0, 0);
// mark pm and mask as freeable in imlib
imlib_free_image_and_decache();

View file

@ -226,10 +226,14 @@ void IconButton::update(FbTk::Subject *subj) {
if (m_win.clientList().empty())
return;
XWMHints *hints = XGetWMHints(FbTk::App::instance()->display(), m_win.winClient().window());
Display *display = FbTk::App::instance()->display();
XWMHints *hints = XGetWMHints(display, m_win.winClient().window());
if (hints == 0)
return;
int screen = m_win.screen().screenNumber();
if (m_use_pixmap && (hints->flags & IconPixmapHint) && hints->icon_pixmap != 0) {
// setup icon window
m_icon_window.show();
@ -237,7 +241,7 @@ void IconButton::update(FbTk::Subject *subj) {
int new_width = new_height;
m_icon_window.resize((new_width>0) ? new_width : 1, (new_height>0) ? new_height : 1);
m_icon_pixmap.copy(hints->icon_pixmap);
m_icon_pixmap.copy(hints->icon_pixmap, DefaultDepth(display, screen), screen);
m_icon_pixmap.scale(m_icon_window.width(), m_icon_window.height());
m_icon_window.setBackgroundPixmap(m_icon_pixmap.drawable());
@ -249,7 +253,7 @@ void IconButton::update(FbTk::Subject *subj) {
}
if(m_use_pixmap && (hints->flags & IconMaskHint)) {
m_icon_mask.copy(hints->icon_mask);
m_icon_mask.copy(hints->icon_mask, 0, 0);
m_icon_mask.scale(m_icon_pixmap.width(), m_icon_pixmap.height());
} else
m_icon_mask = 0;
@ -260,7 +264,7 @@ void IconButton::update(FbTk::Subject *subj) {
#ifdef SHAPE
if (m_icon_mask.drawable() != 0) {
XShapeCombineMask(FbTk::App::instance()->display(),
XShapeCombineMask(display,
m_icon_window.drawable(),
ShapeBounding,
0, 0,