casey@gauss.llnl.gov (Casey Leedom) (10/09/90)
[[Also sent to xbugs@expo.lcs.mit.edu]]
VERSION:
R4/PL14
CLIENT MACHINE and OPERATING SYSTEM:
Sun3/SunOS 3.5
DISPLAY TYPE:
bwtwo0
WINDOW MANAGER:
twm, uwm
AREA:
mit/lib/Xaw/Label.c?
mit/lib/Xt/VarGet.c?
mit/lib/X/XCrPFBData.c?
mit/lib/X/XPutImage.c?
mit/server/...?
SYNOPSIS:
Who can suammarize randomness? In any case, XCreatePixmapFromBitmapData
doesn't seem to be using its foreground and background parameters on
monochrome displays exactly as one might suspect. In fact, I'm hard
put to see how its using them.
DESCRIPTION:
I first ran into this problem trying to figure out why xdbx 2.1's
stop sign and other signs kept on showing up black on white in the
middle of my otherwise white on black display (yes, I'm one of the
few people in the universe who set *ReverseVideo:on.) I eventually
traced the problem down to XCreatePixmapFromBitmapData but I've only
managed to confuse myself since then. I have figured out the
following:
1. It seems to be 0/1 related. Xsun maps white to Pixel 0 and black
to Pixel 1. You have to fight to get a white on black pixmap
displayed. The GraphOn server Xgo maps white to Pixel 1 and black
to Pixel 0. On that display I have to fight to get a black on
white pixmap displayed.
2. Someone is trying to make me crazy. Using the test program below
and specifying -fg black -bg white I get a black on white display.
Hardwiring the values of foreground to 1 (black) and background
to 0 (white), I get a white on black display! Both tests
performed with *ReverseVideo:on -- you can use -rv to the test
program.
I thought: ``Ah ha! XtVaGetValues is screwing up memory,'' but
hardwiring the values of foreground and background after calling
XtVaGetValues, printing various values every other line not only
disclosed no difference between the 0s and 1s returned by
XtVaGetValues, but continued to display a white on black
display.
By the way, adding +rv to the modified test program yielded
a black on white display which leads to the next observation.
3. Something is paying attention to ReverseVideo. But we're not
talking about XtNForeground defaulting to XtNDefaultForeground
which is supposed to pay attention to ReverseVideo, we're
talking about something after XCreatePixmapFromBitmapData
gets our hard Pixel values. I don't know who though. I'm
totally confused by now.
REPEAT BY:
The attached test program yields the following results when run on an
MIT Xsun server:
xtest arguements resulting bitmap label background
---------------- ---------------- ----------------
+rv -fg black -bg black black on black black
foreground = 1, background = 1
white = 0, black = 1
+rv -fg black -bg white black on white white
foreground = 1, background = 0
white = 0, black = 1
+rv -fg white -bg black black on white* black
foreground = 0, background = 1
white = 0, black = 1
+rv -fg white -bg white white on white white
foreground = 0, background = 0
white = 0, black = 1
-rv -fg black -bg black black on black black
foreground = 1, background = 1
white = 0, black = 1
-rv -fg black -bg white black on white white
foreground = 1, background = 0
white = 0, black = 1
-rv -fg white -bg black black on white* black
foreground = 0, background = 1
white = 0, black = 1
-rv -fg white -bg white white on white white
foreground = 0, background = 0
white = 0, black = 1
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
# xtest
# This archive created: Tue Oct 9 04:38:59 1990
export PATH; PATH=/bin:/usr/bin:$PATH
if test ! -d 'xtest'
then
mkdir 'xtest'
fi
cd 'xtest'
if test -f 'Imakefile'
then
echo shar: "will not over-write existing file 'Imakefile'"
else
sed 's/^X//' << \SHAR_EOF > 'Imakefile'
X DEPLIBS = XawClientDepLibs
XLOCAL_LIBRARIES = XawClientLibs
X SRCS = xtest.c
X OBJS = xtest.o
X
XComplexProgramTarget(xtest)
SHAR_EOF
fi
if test -f 'xtest.c'
then
echo shar: "will not over-write existing file 'xtest.c'"
else
sed 's/^X//' << \SHAR_EOF > 'xtest.c'
X#include <X11/Intrinsic.h>
X#include <X11/StringDefs.h>
X#include <X11/Xaw/Cardinals.h>
X#include <X11/Xaw/Label.h>
X
X#define x_width 16
X#define x_height 16
Xstatic char x_bits[] = {
X 0x03, 0xc0, 0x07, 0xe0, 0x0e, 0x70, 0x1c, 0x38, 0x38, 0x1c, 0x70, 0x0e,
X 0xe0, 0x07, 0xc0, 0x03, 0xc0, 0x03, 0xe0, 0x07, 0x70, 0x0e, 0x38, 0x1c,
X 0x1c, 0x38, 0x0e, 0x70, 0x07, 0xe0, 0x03, 0xc0};
X
Xvoid
Xmain (argc, argv)
X int argc;
X char **argv;
X{
X Widget toplevel, widget;
X Display *display;
X int screen;
X Pixel foreground, background;
X
X toplevel = XtInitialize("main", "XTest", NULL, ZERO, &argc, argv);
X display = XtDisplay(toplevel);
X screen = DefaultScreen(display);
X
X widget = XtVaCreateManagedWidget("x", labelWidgetClass, toplevel,
X NULL);
X XtVaGetValues(widget,
X XtNforeground, &foreground,
X XtNbackground, &background,
X NULL);
X printf("foreground = %#x, background = %#x\n", foreground, background);
X printf("white = %#x, black = %#x\n",
X WhitePixel(display, screen), BlackPixel(display, screen));
X XtVaSetValues(widget,
X XtNbitmap,
X XCreatePixmapFromBitmapData(display,
X DefaultRootWindow(display),
X x_bits, x_width, x_height,
X foreground, background,
X DefaultDepth(display, screen)),
X NULL);
X XtRealizeWidget(toplevel);
X XtMainLoop();
X}
SHAR_EOF
fi
cd ..
exit 0
# End of shell archive