nanogui: Thread: X11 works well


[<<] [<] Page 1 of 1 [>] [>>]
Subject: X11 works well
From: Dave Creelman ####@####.####
Date: 3 Dec 1999 12:56:08 -0000
Message-Id: <3847BDBE.477E4417@geko.net.au>

Hi All,

I just got the X11 version of uwin to compile and it works quite nicely.
Well done. This will be so cool when people start to get it onto
palmtops.

I haven't been able to get the mterm demo to work properly, is that
being worked on or is there a problem with it ?

I'll see if I can work out the API and get some bits and pieces going.

It's mentioned somewhere that the API is windows compatible... Could I
just clarify that,  I remember reading somewhere that it was WinCE API
compatible. If you could let me know that would be great.

Cheers
DC

Subject: Re: X11 works well
From: Daniel R Risacher ####@####.####
Date: 3 Dec 1999 13:30:57 -0000
Message-Id: <m2u2m0qhuc.fsf@alum.mit.edu>

>>>>> "Dave" == Dave Creelman ####@####.#### writes:

    Dave> I haven't been able to get the mterm demo to work properly,
    Dave> is that being worked on or is there a problem with it ?

You may have the same problem I had, which is that the pseudo terminal
isn't opened properly.  I'm not sure of the most portable way to do
this, but if you have glibc, then the following patch may work.

Question: does whatever passes for libc on ELKS (and/or other OS's
that we're currently targeting) support the getpt(), grantpt(),
unlockpt(), and ptsname_r() calls?

--- demos/microwin/mterm.c.old  Fri Dec  3 07:03:39 1999
+++ demos/microwin/mterm.c      Fri Dec  3 07:16:23 1999
@@ -248,15 +248,16 @@
        char *  argv[2];
 
 again:
-       sprintf(pty_name, "/dev/ptyp%d", n);
-       if ((tfd = open(pty_name, O_RDWR | O_NONBLOCK)) < 0) {
-               if ((errno == EBUSY) && (n < 3)) {
-                       ++n;
-                       goto again;
-               }
-               fprintf(stderr, "Can't create pty %s\n", pty_name);
+        if ((tfd = getpt())<0) {
+               fprintf(stderr, "Can't create master pty\n");
                return -1;
        }
+
+        if (grantpt(tfd)) 
+                perror("failure");
+        if (unlockpt(tfd)) 
+                perror("failure");
+
        signal(SIGCHLD, ptysignaled);
        signal(SIGINT, ptysignaled);
        if ((pid = fork()) == -1) {
@@ -264,13 +265,13 @@
                return -1;
        }
        if (!pid) {
+                ptsname_r(tfd, pty_name, 12);
                close(STDIN_FILENO);
                close(STDOUT_FILENO);
                close(STDERR_FILENO);
                close(tfd);
 
                setsid();
-               pty_name[5] = 't';
                if ((tfd = open(pty_name, O_RDWR)) < 0) {
                        fprintf(stderr, "Child: Can't open pty %s\n", pty_name);
                        exit(1);
--- demos/nanox/nterm.c.old     Fri Dec  3 07:03:39 1999
+++ demos/nanox/nterm.c Fri Dec  3 07:16:20 1999
@@ -162,15 +162,16 @@
        pid_t pid;
 
 again:
-       sprintf(pty_name, "/dev/ptyp%d", n);
-       if ((tfd = open(pty_name, O_RDWR | O_NONBLOCK)) < 0) {
-               if ((errno == EBUSY || errno == EIO) && n < 10) {
-                       n++;
-                       goto again;
-               }
-               fprintf(stderr, "Can't create pty %s\n", pty_name);
+        if ((tfd = getpt())<0) {
+               fprintf(stderr, "Can't create master pty\n");
                return -1;
        }
+
+        if (grantpt(tfd)) 
+                perror("failure");
+        if (unlockpt(tfd)) 
+                perror("failure");
+
        signal(SIGCHLD, sigchild);
        signal(SIGINT, sigchild);
        if ((pid = fork()) == -1) {
@@ -178,13 +179,13 @@
                return -1;
        }
        if (!pid) {
+                ptsname_r(tfd, pty_name, 12);
                close(STDIN_FILENO);
                close(STDOUT_FILENO);
                close(STDERR_FILENO);
                close(tfd);
 
                setsid();
-               pty_name[5] = 't';
                if ((tfd = open(pty_name, O_RDWR)) < 0) {
                        fprintf(stderr, "Child: Can't open pty %s\n", pty_name);
                        exit(1);


-- 
               "So, shall we go act innocent now?"

Daniel Risacher                                   ####@####.####
Subject: RE: X11 works well
From: Greg Haerr ####@####.####
Date: 3 Dec 1999 18:33:53 -0000
Message-Id: <796896539E6CD311B0E70060083DFEFB076F98@NBA-SLAM.CenSoft.COM>

: I just got the X11 version of uwin to compile and it works quite nicely.
: Well done. 

Thanks.  And thank Tony Rogvall for writing the driver.

: 
: I haven't been able to get the mterm demo to work properly, is that
: being worked on or is there a problem with it ?

I didn't test mterm with the latest 0.87 cut.  It depends on pseudo
tty0 to be available, and IIRC, there was a bug in the nano-X version
when I tried it under X11, which uses pseudo tty0.  So, you probably
need to change the line in mterm.c, function CreatePtyShell():

	if((errno == EBUSY) && (n < 3))

to

	if((errno == EBUSY || errno == EIO) && (n < 10))

This allows microwindows to try up to 10 pty's, and also fixes an
undocumented
return value for pty's open fails, EIO.


: 
: I'll see if I can work out the API and get some bits and pieces going.

I think the above will fix your problem.


: 
: It's mentioned somewhere that the API is windows compatible... Could I
: just clarify that,  I remember reading somewhere that it was WinCE API
: compatible. If you could let me know that would be great.

The Microwindows API is almost 100% Win32 compatible, for what's
implemented.  I use some tricks in the <windows.h> structures, in 
that Microwindows system data is carried around at the end of 
the standard structures, so that separate internal structures aren't
necessary.  This still will compile any user code with no changes, though.
Any non-Win32 compatible function that's been added starts with WndXXX,
for namespace issues.  For instance, WndSetDesktopWallpaper().

Since Microwindows only currently attempts to implement graphics
api's, Microwindows is also WinCE compatible, since almost every
WinCE graphics entry point is a subset of Win32.  The only exception
now is LineToEx in Win32 is PolyLine in WinCE.  I've been planning
on handling that, but haven't got around to it yet.

Greg
Subject: RE: X11 works well
From: Greg Haerr ####@####.####
Date: 3 Dec 1999 18:42:17 -0000
Message-Id: <796896539E6CD311B0E70060083DFEFB076F9E@NBA-SLAM.CenSoft.COM>

On Friday, December 03, 1999 6:23 AM, Daniel R Risacher  wrote:
: >>>>> "Dave" == Dave Creelman ####@####.#### writes:
: 
:     Dave> I haven't been able to get the mterm demo to work properly,
:     Dave> is that being worked on or is there a problem with it ?
: 
: You may have the same problem I had, which is that the pseudo terminal
: isn't opened properly.  I'm not sure of the most portable way to do
: this, but if you have glibc, then the following patch may work.
: 
: Question: does whatever passes for libc on ELKS (and/or other OS's
: that we're currently targeting) support the getpt(), grantpt(),
: unlockpt(), and ptsname_r() calls?

Dan - 
	Thanks for the mods.  The current code for opening a pty is,
in fact, source code compatible with Linux and ELKS.  I'll add the grantpt
stuff you've submitted under an #ifdef LINUX option.

	I hadn't read this message before replying to this problem myself,
you may need this patch and my patch to get it to work.

Greg
Subject: Re: X11 works well
From: Daniel R Risacher ####@####.####
Date: 4 Dec 1999 06:29:34 -0000
Message-Id: <m2wvqvp6pa.fsf@alum.mit.edu>

My sincere apologies for my previous message, which contained a patch
that wouldn't apply correctly.  Somehow, in preparing the message, the
whitespace in the patch got garbled up.  Mea culpa.

Here it is again.  Hopefully more correct this time.

(Alert readers are warned that Greg's message may include a simpler
solution that I haven't tried yet..) 

--- demos/microwin/mterm.c.old	Fri Dec  3 07:03:39 1999
+++ demos/microwin/mterm.c	Fri Dec  3 07:16:23 1999
@@ -248,15 +248,16 @@
 	char *	argv[2];
 
 again:
-	sprintf(pty_name, "/dev/ptyp%d", n);
-	if ((tfd = open(pty_name, O_RDWR | O_NONBLOCK)) < 0) {
-		if ((errno == EBUSY) && (n < 3)) {
-			++n;
-			goto again;
-		}
-		fprintf(stderr, "Can't create pty %s\n", pty_name);
+        if ((tfd = getpt())<0) {
+		fprintf(stderr, "Can't create master pty\n");
 		return -1;
 	}
+
+        if (grantpt(tfd)) 
+                perror("failure");
+        if (unlockpt(tfd)) 
+                perror("failure");
+
 	signal(SIGCHLD, ptysignaled);
 	signal(SIGINT, ptysignaled);
 	if ((pid = fork()) == -1) {
@@ -264,13 +265,13 @@
 		return -1;
 	}
 	if (!pid) {
+                ptsname_r(tfd, pty_name, 12);
 		close(STDIN_FILENO);
 		close(STDOUT_FILENO);
 		close(STDERR_FILENO);
 		close(tfd);
 		
 		setsid();
-		pty_name[5] = 't';
 		if ((tfd = open(pty_name, O_RDWR)) < 0) {
 			fprintf(stderr, "Child: Can't open pty %s\n", pty_name);
 			exit(1);
--- demos/nanox/nterm.c.old	Fri Dec  3 07:03:39 1999
+++ demos/nanox/nterm.c	Fri Dec  3 07:16:20 1999
@@ -162,15 +162,16 @@
 	pid_t pid;
 
 again:
-	sprintf(pty_name, "/dev/ptyp%d", n);
-	if ((tfd = open(pty_name, O_RDWR | O_NONBLOCK)) < 0) {
-		if ((errno == EBUSY || errno == EIO) && n < 10) {
-			n++;
-			goto again;
-		}
-		fprintf(stderr, "Can't create pty %s\n", pty_name);
+        if ((tfd = getpt())<0) {
+		fprintf(stderr, "Can't create master pty\n");
 		return -1;
 	}
+
+        if (grantpt(tfd)) 
+                perror("failure");
+        if (unlockpt(tfd)) 
+                perror("failure");
+
 	signal(SIGCHLD, sigchild);
 	signal(SIGINT, sigchild);
 	if ((pid = fork()) == -1) {
@@ -178,13 +179,13 @@
 		return -1;
 	}
 	if (!pid) {
+                ptsname_r(tfd, pty_name, 12);
 		close(STDIN_FILENO);
 		close(STDOUT_FILENO);
 		close(STDERR_FILENO);
 		close(tfd);
 		
 		setsid();
-		pty_name[5] = 't';
 		if ((tfd = open(pty_name, O_RDWR)) < 0) {
 			fprintf(stderr, "Child: Can't open pty %s\n", pty_name);
 			exit(1);


-- 
               "So, shall we go act innocent now?"

Daniel Risacher                                   ####@####.####
[<<] [<] Page 1 of 1 [>] [>>]


Powered by ezmlm-browse 0.20.