mark@sunquest.UUCP (Mark McCourt) (01/16/90)
I am having problems with drawing dashed lines with line
widths of 0 and 1. Here is the environment i am running
under:
I am running an Xlib program (see below).
Client: on Sun4, SunOS 4.0.3
Server: X11/R3, on Sun 3/60, SunOS 4.0.2
Window mgr: mwm (motif release 1.0.1)
These are the simptoms i am having:
My server hangs when i try to draw dashed lines to the color
screen with width of 0 or 1. On the B&W screen the same
thing happens with a width of 1.
All possibilities work fine with solid lines. Only
dashed lines are a problem.
Color Screen Monochrome Screen
+--------------------------------------------------------------+
| Line width 0 Line width 1 | Line width 0 Line width 1 |
|-------------------------------+------------------------------|
Solid | OK OK | OK OK |
|-------------------------------+------------------------------|
Dashed | hang hang | OK hang |
+-------------------------------+------------------------------+
Am i doing something fundamentally wrong here?
Also, this doesn't happen on a DECStation 3100 running the X11
server nor does it happen on a Sun 3/60 running the X11/NeWS
server.
Any help is greatly appreciated.
Mark McCourt
#include <X11/Xlib.h>
#include <X11/Xutil.h>
main(argc, argv)
int argc;
char *argv[];
{
Display *mydisplay;
Window mywindow;
GC mygc;
XEvent myevent;
KeySym mykey;
int myscreen;
unsigned long myforeground, mybackground;
int i;
char text[2];
int done;
XSegment segments[2];
int nsegs = 2;
segments[0].x1 = 100; segments[0].y1 = 5;
segments[0].x2 = 100; segments[0].y2 = 245;
segments[1].x1 = 5; segments[1].y1 = 100;
segments[1].x2 = 345; segments[1].y2 = 100;
mydisplay = XOpenDisplay("");
myscreen = DefaultScreen (mydisplay);
mybackground = WhitePixel (mydisplay, myscreen);
myforeground = BlackPixel (mydisplay, myscreen);
mywindow = XCreateSimpleWindow (mydisplay,
DefaultRootWindow (mydisplay),
200, 300, 350, 250,
5, myforeground, mybackground);
mygc = XCreateGC (mydisplay, mywindow, 0,0);
XSetBackground (mydisplay, mygc, mybackground);
XSetForeground (mydisplay, mygc, myforeground);
XSelectInput (mydisplay, mywindow,
KeyPressMask | ExposureMask);
XMapRaised (mydisplay, mywindow);
/* set line style */
XSetLineAttributes (mydisplay, mygc, 0, LineOnOffDash, CapRound,
JoinRound);
done = 0;
while (done == 0) {
XNextEvent (mydisplay, &myevent); /* read next event */
switch (myevent.type) {
case Expose : /* repaint on expose events */
XDrawSegments (mydisplay, mywindow, mygc, segments, nsegs);
break;
case KeyPress : /* process keyboard input */
i = XLookupString ( &myevent, text, 10, &mykey, 0);
if (i == 1 && text[0] == 'q')
done = 1;
}
}
XFreeGC (mydisplay, mygc);
XDestroyWindow (mydisplay, mywindow);
XCloseDisplay (mydisplay);
exit(0);
}