From 690030444b984e6b348284ae3c88671ee65a530b Mon Sep 17 00:00:00 2001 From: simonb Date: Wed, 27 Apr 2005 17:45:56 +0000 Subject: add rough support for non-default depth pixmaps. Saves us having ghost holes in windows --- ChangeLog | 4 ++++ src/FbTk/FbPixmap.cc | 28 +++++++++++++++++++++------- src/FbTk/FbPixmap.hh | 2 +- src/FbTk/ImageImlib2.cc | 4 ++-- src/IconButton.cc | 12 ++++++++---- 5 files changed, 36 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2f5c26d..6422771 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/src/FbTk/FbPixmap.cc b/src/FbTk/FbPixmap.cc index e573945..b2937c3 100644 --- a/src/FbTk/FbPixmap.cc +++ b/src/FbTk/FbPixmap.cc @@ -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); diff --git a/src/FbTk/FbPixmap.hh b/src/FbTk/FbPixmap.hh index a1c17a5..c8640a2 100644 --- a/src/FbTk/FbPixmap.hh +++ b/src/FbTk/FbPixmap.hh @@ -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 diff --git a/src/FbTk/ImageImlib2.cc b/src/FbTk/ImageImlib2.cc index ca47209..62ed182 100644 --- a/src/FbTk/ImageImlib2.cc +++ b/src/FbTk/ImageImlib2.cc @@ -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(); diff --git a/src/IconButton.cc b/src/IconButton.cc index 4258f13..7918be9 100644 --- a/src/IconButton.cc +++ b/src/IconButton.cc @@ -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, -- cgit v0.11.2