[winGRASS] Re: [GRASS5] Windows native Xdriver
Glynn Clements
glynn.clements at virgin.net
Thu May 2 17:11:39 EDT 2002
Mike Thomas wrote:
> > > As /dev doesn't exist on my computer, this wonn't work for me (and I suspect
> > > many Cygwin users).
> >
> > Cygwin implements device files such as /dev/tty, /dev/null and
> > /dev/windows internally. Try "ls -l /dev/windows"; it works, even
> > though there isn't a /dev/directory.
>
> Spot on, thanks. I appreciate your patient technical explanations - my
> personal programming preferences lie far away from the world of sockets and
> Unix emulation on Windows!
>
> Getting back to your earlier request for feedback on Windows NT, using:
>
> fd = open ("/dev/windows", O_NONBLOCK, 0);
>
> on my Windows XP computer is an improvement as it allows 3 Xdriver window
> refreshes (generated by covering and then uncovering the window with the
> Grass console window) before the XDriver degenerates into the buffered event
> behaviour described earlier.
> .
> This is probably being caused by the repeated opening using up some internal
> fd buffer - caching the fd by making it static cures the problem:
>
> -------------------------------------------------------------------
> int
> XConnectionNumber(Display* display)
> {
> static int fd = 0;
> NT_debug ("XConnectionNumber\n");
> if ( 0 == fd ) {
> fd = open ("/dev/windows", O_NONBLOCK, 0);
> if ( -1 == fd ) {
> NT_log ("XConnectionNumber unable to open /dev/windows, errno = %d\n",
> errno);
> }
> }
> return ( fd );
> }
> -------------------------------------------------------------------
Aha!
Technically, a better solution would be to do the above in
XOpenDisplay, and store the descriptor in "display->fd". Then,
XConnectionNumber() would become:
int XConnectionNumber(Display* display)
{
return display->fd;
}
which is basically the definition used by X proper. Actually, in X,
its the other way around:
lib/X11/Macros.c:
int XConnectionNumber(dpy) Display *dpy; { return (ConnectionNumber(dpy)); }
lib/X11/Xlib.h:
#define ConnectionNumber(dpy) (((_XPrivDisplay)dpy)->fd)
> This, of course assumes that nobody will close the fd. Is that likely?
Yes. Under X, closing the descriptor which is returned from
XConnectionNumber() would close the connection to the X server, which
would usually be fatal for the client.
--
Glynn Clements <glynn.clements at virgin.net>
More information about the grass-windows
mailing list