Skip to content

Commit

Permalink
Fix [1d8b7124b6]: X11: Photo images not drawn correctly for 32-bit vi…
Browse files Browse the repository at this point in the history
…suals. Patch from Christian Werner proposed in [https://www.androwish.org/home/info/7aeac931688d2525].
  • Loading branch information
fvogelnew1 committed Dec 2, 2023
1 parent ac572d6 commit d276dd2
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions generic/tkImgPhInstance.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ TkImgPhotoGet(
char buf[TCL_INTEGER_SPACE * 3];
XColor *white, *black;
XGCValues gcValues;
#if (!defined(_WIN32) && !defined(MAC_OSX_TK))
int gcmask;
#endif

/*
* Table of "best" choices for palette for PseudoColor displays with
Expand Down Expand Up @@ -254,7 +257,11 @@ TkImgPhotoGet(
for (instancePtr = modelPtr->instancePtr; instancePtr != NULL;
instancePtr = instancePtr->nextPtr) {
if ((colormap == instancePtr->colormap)
&& (Tk_Display(tkwin) == instancePtr->display)) {
&& (Tk_Display(tkwin) == instancePtr->display)
#if (!defined(_WIN32) && !defined(MAC_OSX_TK))
&& (Tk_Visual(tkwin) == instancePtr->visualInfo.visual)
#endif
) {
/*
* Re-use this instance.
*/
Expand Down Expand Up @@ -311,13 +318,25 @@ TkImgPhotoGet(
nGreen = nBlue = 0;
mono = 1;
instancePtr->visualInfo = *visInfoPtr;
#if (!defined(_WIN32) && !defined(MAC_OSX_TK))
gcmask = 0;
instancePtr->visualInfo.visual = Tk_Visual(tkwin);
#endif
switch (visInfoPtr->c_class) {
case DirectColor:
case TrueColor:
nRed = 1 << CountBits(visInfoPtr->red_mask);
nGreen = 1 << CountBits(visInfoPtr->green_mask);
nBlue = 1 << CountBits(visInfoPtr->blue_mask);
mono = 0;
#if (!defined(_WIN32) && !defined(MAC_OSX_TK))
if (visInfoPtr->depth > 24) {
gcValues.plane_mask = visInfoPtr->red_mask
| visInfoPtr->green_mask
| visInfoPtr->blue_mask;
gcmask = GCPlaneMask;
}
#endif
break;
case PseudoColor:
case StaticColor:
Expand Down Expand Up @@ -362,8 +381,13 @@ TkImgPhotoGet(
Tk_FreeColor(white);
Tk_FreeColor(black);
gcValues.graphics_exposures = False;
#if (!defined(_WIN32) && !defined(MAC_OSX_TK))
instancePtr->gc = Tk_GetGC(tkwin,
gcmask|GCForeground|GCBackground|GCGraphicsExposures, &gcValues);
#else
instancePtr->gc = Tk_GetGC(tkwin,
GCForeground|GCBackground|GCGraphicsExposures, &gcValues);
GCForeground|GCBackground|GCGraphicsExposures, &gcValues);
#endif

/*
* Set configuration options and finish the initialization of the
Expand Down

0 comments on commit d276dd2

Please sign in to comment.