From e632e7f23e91810ae096fcd623f4c5f437875e01 Mon Sep 17 00:00:00 2001 From: rjb330 <122177540+rjb330@users.noreply.github.com> Date: Mon, 28 Oct 2024 13:49:16 -0700 Subject: Add some comments in drawTQPixmapToWindow() Signed-off-by: rjb330 <122177540+rjb330@users.noreply.github.com> (cherry picked from commit d055f3b3ad49e11f2b2666623de1f7a13e05f122) --- src/qt_qt_wrapper.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/qt_qt_wrapper.cpp b/src/qt_qt_wrapper.cpp index a909463..618e6f5 100644 --- a/src/qt_qt_wrapper.cpp +++ b/src/qt_qt_wrapper.cpp @@ -655,10 +655,13 @@ TQColor gdkColorToTQColor(GdkColor* c) return TQColor(c->red / 256, c->green / 256, c->blue / 256); } -void drawTQPixmapToWindow(GdkWindow* window, GdkGC* gc, TQPixmap* pixmap, int x, int y, int w, int h) { - static GdkGC* igc = gdk_gc_new(window); +void drawTQPixmapToWindow(GdkWindow* window, GdkGC* gc, TQPixmap* pixmap, int x, int y, int w, int h) +{ + static GdkGC* imggc = gdk_gc_new(window); GdkPixmap* pix; + // gdk_drawable_get_image crashes if requested region is outside of the window. + // Bitmap masks cause artifacts with Domino and Baghira. int width, height; gdk_drawable_get_size(window, &width, &height); if (!pixmap->hasAlpha() || isDomino || isBaghira || @@ -669,10 +672,12 @@ void drawTQPixmapToWindow(GdkWindow* window, GdkGC* gc, TQPixmap* pixmap, int x, return; } + // Gdk isn't aware of the TQPixmap mask, + // so instead we create a new pixmap from the window region and bitBlt over it. TQPixmap gpixmap(w, h); pix = gdk_pixmap_foreign_new(gpixmap.handle()); GdkImage* img = gdk_drawable_get_image(window, x, y, w, h); - gdk_draw_image(pix, igc, img, 0, 0, 0, 0, w, h); + gdk_draw_image(pix, imggc, img, 0, 0, 0, 0, w, h); bitBlt(&gpixmap, 0, 0, pixmap, 0, 0, w, h, TQt::CopyROP); gdk_draw_drawable(window, gc, pix, 0, 0, x, y, w, h); -- cgit v1.2.1