From 9daf464b2812027c4a5a074f23896457471109f1 Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Mon, 24 Dec 2007 21:58:50 -0800 Subject: fix showing program icons with depth=1 in menus --- src/FbTk/MenuItem.cc | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/FbTk/MenuItem.cc b/src/FbTk/MenuItem.cc index 0e99192..7bfb8ef 100644 --- a/src/FbTk/MenuItem.cc +++ b/src/FbTk/MenuItem.cc @@ -114,14 +114,30 @@ void MenuItem::draw(FbDrawable &draw, int icon_x = x + theme.bevelWidth(); int icon_y = y + theme.bevelWidth(); // enable clip mask - XSetClipMask(disp, gc, None); //tmp_mask.drawable()); + XSetClipMask(disp, gc, tmp_mask.drawable()); XSetClipOrigin(disp, gc, icon_x, icon_y); - draw.copyArea(tmp_pixmap.drawable(), - gc, - 0, 0, - icon_x, icon_y, - tmp_pixmap.width(), tmp_pixmap.height()); + if (draw.depth() == tmp_pixmap.depth()) { + draw.copyArea(tmp_pixmap.drawable(), + gc, + 0, 0, + icon_x, icon_y, + tmp_pixmap.width(), tmp_pixmap.height()); + } else { // TODO: wrong in soon-to-be-common circumstances + XGCValues backup; + XGetGCValues(draw.display(), gc, GCForeground|GCBackground, + &backup); + XSetForeground(draw.display(), gc, + Color("black", theme.screenNum()).pixel()); + XSetBackground(draw.display(), gc, + Color("white", theme.screenNum()).pixel()); + XCopyPlane(draw.display(), tmp_pixmap.drawable(), + draw.drawable(), gc, + 0, 0, tmp_pixmap.width(), tmp_pixmap.height(), + icon_x, icon_y, 1); + XSetForeground(draw.display(), gc, backup.foreground); + XSetBackground(draw.display(), gc, backup.background); + } // restore clip mask XSetClipMask(disp, gc, None); -- cgit v0.11.2