Subject: bug#21301: 25.0.50; Emacs Trunk: Fringe bitmaps confuse foreground/background colors.

From: Mustafa Kocaturk <[email-masked]>
Date: Thu, 8 Oct 2015 16:26:25 -0500

Hi,

The fringe bitmap is not only displayed in inverse video, but also as a mirror image of the original.

Both issues are fixed in initFromXBM as follows:

1. Flip the bit shift direction: Put most significant bit first. Fixes the mirrored image back to normal.
2. Swap background and foreground color.

The resulting display makes better sense and looks as original as I can tell.

————— Patch follows:

*** Temp/ediff7256bpj	Wed Oct  7 19:22:04 2015
--- src/nsimage.m	Wed Oct  7 18:50:41 2015
***************
*** 253,272 ****
            for (k = 0; i < w && k < 8; ++k, ++i)
              {
                *alpha++ = 0xff;
!               if (c & 1)
!                 {
!                   *rr++ = fgr;
!                   *gg++ = fgg;
!                   *bb++ = fgb;
!                 }
!               else
                  {
                    *rr++ = bgr;
                    *gg++ = bgg;
                    *bb++ = bgb;
                  }
                idx++;
!               c >>= 1;
              }
          }
    }
--- 253,272 ----
            for (k = 0; i < w && k < 8; ++k, ++i)
              {
                *alpha++ = 0xff;
!               if (c & 0x80)
                  {
                    *rr++ = bgr;
                    *gg++ = bgg;
                    *bb++ = bgb;
                  }
+               else
+                 {
+                   *rr++ = fgr;
+                   *gg++ = fgg;
+                   *bb++ = fgb;
+                 }
                idx++;
!               c <<= 1;
              }
          }
    }

> > Date:  Sat, 29 Aug 2015 12:51:11 -0700
> > From:  Keith David Bershatsky <address@hidden>
> > Cc:  address@hidden
> > 
> > I rolled back to the commit "SHA 67a878f78f879ce534232408c34dd11f42dd802b" 
> > [May 15, 2015 at 2:31 a.m.], then built Emacs, and bug#21301 WAS present.
> > 
> > I rolled back to the commit "SHA b1c23fb94072cca7f08ea5f50430916b9ea168e6" 
> > [May 15, 2015 at 2:17 a.m.], then built Emacs, and bug#21301 was NOT present 
> > -- i.e., everything was working as it should.
> > 
> Great, thanks.  So we now know for sure that 67a878f _was_ the
> culprit.
> 
> I hope someone knowledgeable about NS and OS X will be able to tell
> what's wrong with that change, and how to fix it.
Just the two reversals mentioned above, which were obvious from the way bitmaps appear on screen.
Not much else was needed in the way of OS X or NS knowledge, luckily for me :).

Another annoying display issue remains, though: 
Visible bell no longer displays solid black, but distorted pieces of bitmap from another part of the screen, and leaves a stubborn garbled rectangle behind, hiding the original text. 
I’m not sure if this has been reported as a bug, but suspecting it involves ns_ring_bell in nsterm.m and around the same time frame.

Best regards,
Mustafa