Article View: comp.windows.x
Article #23910Problem with Sparc X11R4
From: David Campbell
Date: Fri, 21 Jun 1991 00:42
Date: Fri, 21 Jun 1991 00:42
141 lines
3647 bytes
3647 bytes
/* This code demonstrates a problem I am experiencing with line drawing
under X11R4 on a standard Color Sparcstation IPC running MIT X11R4.
I draw a two lines, a horizontal one and a vertical one, in the shape of
an upside-down capital T. The problem is that the vertical line
crosses over the horizontal line by 1 pixel.
Can somebody please criticize my code or tell me this is some problem
with X?
The system I am using is a standard Color Sparcstation IPC running MIT
X11R4, but the problem occurs on every color system here (that I tried)
running X11R4.
The problem does not occur when:
-Displaying on a machine running OpenWindows.
-Compiled and running on a machine displaying on a decstation.
-Compiled and running on a decstation displaying on a decstation.
-Displaying on an Sparc SLC (monochrome).
This is what happens:
|
|
|
|
---------------------+---------------------
| <-bonus pixel
This program lets you turn the horizontal line on and off with the first
two mouse buttons, making it easy to see the extra pixel that gets drawn.
The third mouse button exits.
Compile with cc -o problem problem.c -lX11
*/
#define XVAL 100
#define YVAL 95
#define DIST 40
#include <X11/Xlib.h>
#include <X11/Xutil.h>
char why[]= "WHY WHY WHY?";
Display *display;
Window window;
GC gc;
drawhoriz()
{
/* horizontal line */
XDrawLine(display, window, gc,
XVAL - DIST, YVAL,
XVAL + DIST, YVAL);
}
drawboth()
{
drawhoriz();
/* vertical line - THE PROBLEM */
XDrawLine(display, window, gc,
XVAL, YVAL,
XVAL, YVAL - DIST);
}
main(argc,argv)
int argc;
char **argv;
{
XEvent event;
KeySym key;
XSizeHints hint;
int screen;
unsigned long foreground, background;
int i;
char text[10];
int done;
display = XOpenDisplay("");
screen = DefaultScreen(display);
background = WhitePixel(display,screen);
foreground = BlackPixel(display,screen);
hint.x = 200;
hint.y = 300;
hint.width = 350;
hint.height = 250;
hint.flags = PPosition | PSize;
window = XCreateSimpleWindow(display, DefaultRootWindow(display),
hint.x, hint.y, hint.width, hint.height,
5, foreground, background);
XSetStandardProperties(display, window, why, why, None,
argv, argc, &hint);
gc = XCreateGC(display, window, 0, 0);
XSetBackground(display, gc, background);
XSetForeground(display, gc, foreground);
XSelectInput(display, window, ButtonPressMask | ExposureMask);
XMapRaised(display, window);
for(;;) {
XNextEvent(display, &event);
switch(event.type) {
case Expose:
drawboth();
break;
case ButtonPress:
switch(event.xbutton.button) {
case Button1:
/* draw both lines */
XSetForeground(display, gc, foreground);
drawboth();
break;
case Button2:
/* blank out the horizontal */
XSetForeground(display, gc, background);
drawhoriz();
break;
case Button3:
goto bye;
}
}
}
bye:
XFreeGC(display, gc);
XDestroyWindow(display, window);
XCloseDisplay(display);
exit(0);
}
/*
Regards,
-- Dave Campbell
-- dave@csis.dit.csiro.au
*/
--
dave campbell
Technical Details
Message-ID:
<1991Jun21.004216.2961@csis.dit.csiro.au>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!wuarchive!uunet!munnari.oz.au!manuel!csis!daveShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!wuarchive!uunet!munnari.oz.au!manuel!csis!dave From: dave@csis.dit.csiro.au (David Campbell) Newsgroups: comp.windows.x Subject: Problem with Sparc X11R4 Message-ID: <1991Jun21.004216.2961@csis.dit.csiro.au> Date: 21 Jun 91 00:42:16 GMT Organization: CSIRO Division of Information Technology Lines: 141