Return to BSD News archive
Xref: sserve comp.windows.x.i386unix:8002 comp.os.386bsd.apps:1065 comp.os.linux.development:7060
Path: sserve!newshost.anu.edu.au!munnari.oz.au!metro!news.cs.su.oz.au!harbinger.cc.monash.edu.au!yeshua.marcam.com!MathWorks.Com!europa.eng.gtefsd.com!howland.reston.ans.net!agate!asami
From: asami@cs.berkeley.edu (Satoshi ASAMI)
Newsgroups: comp.windows.x.i386unix,comp.os.386bsd.apps,comp.os.linux.development
Subject: xterm for Xaw3d patch [XFree86 2.1]
Followup-To: comp.windows.x.i386unix
Date: 22 Mar 94 00:17:22
Organization: CS Div. - EECS, University of California, Berkeley, CA 94720
Lines: 244
Message-ID: <ASAMI.94Mar22001722@forgery.cs.berkeley.edu>
NNTP-Posting-Host: forgery.cs.berkeley.edu
(I'm not sure if this is the correct Linux group to post this, sorry
if it's not.)
I grabbed the xterm patch from ftp.x.org:/contrib/Xaw3d so that I can
use arrow scrollbars of xterm on my just-compiled XFree86 2.1
(FreeBSD-(almost-)current, Orchid F1280+ VLB). Unfortunately, quite a
bit of the source has changed and many hunks failed. The following is
the result of my hand-applying of the patches.
Disclaimer: I didn't bother with the version headers. I haven't
tested the Tek part. The VT window looks ok.
If anybody made a similar patch for kterm, please let me know. Kalib
(kaleb@x.org, the author of Xaw3d) will probably like to hear that
too.
Satoshi
P.S. Xaw3d is great! If you have Sun-style shared libraries (aka
*BSD-current), all you need to do is to compile Xaw3d and make a
symbolic link libXaw.so.2.0 --> libXaw3d.so.2.0 and boom!
everything is 3D!
---
diff -rub xterm.org/Tekproc.c xterm/Tekproc.c
--- xterm.org/Tekproc.c Sun Mar 20 02:25:24 1994
+++ xterm/Tekproc.c Sun Mar 20 13:46:55 1994
@@ -151,6 +151,8 @@
extern int Tpttable[];
extern int Tspttable[];
+extern XtAppContext app_con;
+
static int *curstate = Talptable;
static int *Tparsestate = Talptable;
@@ -606,7 +608,7 @@
TekGINoff();
TCursorDown();
if (!TekRefresh &&
- (QLength(screen->display) > 0 ||
+ (XtAppPending(app_con) ||
GetBytesAvailable (ConnectionNumber(screen->display)) > 0))
xevents();
break;
@@ -726,7 +728,7 @@
Ttoggled = FALSE;
}
#ifndef AMOEBA
- if(QLength(screen->display))
+ if(XtAppPending(app_con) & XtIMXEvent)
Tselect_mask = X_mask;
else {
XFlush(screen->display);
diff -rub xterm.org/charproc.c xterm/charproc.c
--- xterm.org/charproc.c Sun Mar 20 02:25:25 1994
+++ xterm/charproc.c Sun Mar 20 14:06:04 1994
@@ -68,6 +68,7 @@
extern jmp_buf VTend;
+extern XtAppContext app_con;
extern Widget toplevel;
extern void exit();
extern char *malloc();
@@ -620,7 +621,7 @@
Index(screen, 1);
if (term->flags & LINEFEED)
CarriageReturn(screen);
- if (QLength(screen->display) > 0 ||
+ if (XtAppPending(app_con) ||
GetBytesAvailable (ConnectionNumber(screen->display)) > 0)
xevents();
parsestate = groundtable;
@@ -996,7 +997,7 @@
case CASE_IND:
/* IND */
Index(screen, 1);
- if (QLength(screen->display) > 0 ||
+ if (XtAppPending(app_con) ||
GetBytesAvailable (ConnectionNumber(screen->display)) > 0)
xevents();
parsestate = groundtable;
@@ -1007,7 +1008,7 @@
Index(screen, 1);
CarriageReturn(screen);
- if (QLength(screen->display) > 0 ||
+ if (XtAppPending(app_con) ||
GetBytesAvailable (ConnectionNumber(screen->display)) > 0)
xevents();
parsestate = groundtable;
@@ -1431,15 +1432,26 @@
XFlush(screen->display); /* always flush writes before waiting */
#ifndef AMOEBA
- /* Update the masks and, unless X events are already in the queue,
- wait for I/O to be possible. */
+ /*
+ * Update the masks and, unless X events are already in the
+ * queue, wait for I/O to be possible.
+ */
select_mask = Select_mask;
write_mask = ptymask();
select_timeout.tv_sec = 0;
+ /*
+ * if there's either an XEvent or an XtTimeout pending, just take
+ * a quick peek, i.e. timeout from the select() immediately. If
+ * there's nothing pending, let select() block a little while, but
+ * for a shorter interval than the arrow-style scrollbar timeout.
+ */
+ if (XtAppPending(app_con))
select_timeout.tv_usec = 0;
- i = select(max_plus1, (fd_set *)&select_mask, (fd_set *)&write_mask,
- (fd_set *)NULL, QLength(screen->display) ? &select_timeout
- : (struct timeval *) NULL);
+ else
+ select_timeout.tv_usec = 50000;
+ i = select(max_plus1,
+ (fd_set *)&select_mask, (fd_set *)&write_mask,
+ (fd_set *)NULL, &select_timeout);
if (i < 0) {
if (errno != EINTR)
SysError(ERROR_SELECT);
@@ -1453,7 +1465,7 @@
/* if there are X events already in our queue, it
counts as being readable */
- if (QLength(screen->display) || (select_mask & X_mask)) {
+ if (XtAppPending(app_con) || (select_mask & X_mask)) {
xevents();
}
#else
@@ -2552,7 +2564,6 @@
/* make sure that the resize gravity acceptable */
if ( new->misc.resizeGravity != NorthWestGravity &&
new->misc.resizeGravity != SouthWestGravity) {
- extern XtAppContext app_con;
Cardinal nparams = 1;
XtAppWarningMsg(app_con, "rangeError", "resizeGravity", "XTermError",
@@ -2992,7 +3003,7 @@
* (screen->max_row + 1) + 2 * screen->border,
&junk, &junk);
XSync(screen->display, FALSE); /* synchronize */
- if(QLength(screen->display) > 0)
+ if(XtAppPending(app_con))
xevents();
}
CursorSet(screen, 0, 0, term->flags);
diff -rub xterm.org/main.c xterm/main.c
--- xterm.org/main.c Sun Mar 20 02:25:25 1994
+++ xterm/main.c Sun Mar 20 14:26:03 1994
@@ -223,6 +223,10 @@
#define ttyslot() 1
#endif /* apollo */
+#ifdef sun
+#include <sys/filio.h>
+#endif
+
#ifdef UTMP
#include <utmp.h>
#endif
@@ -3486,15 +3490,19 @@
{
#ifndef AMOEBA
#ifdef FIONREAD
- static long arg;
+ long arg;
ioctl (fd, FIONREAD, (char *) &arg);
return (int) arg;
#else
+#ifdef FIORDCK
+ return (ioctl (fd, FIORDCHK, NULL));
+#else
struct pollfd pollfds[1];
pollfds[0].fd = fd;
pollfds[0].events = POLLIN;
return poll (pollfds, 1, 0);
+#endif
#endif
#else
/*
diff -rub xterm.org/misc.c xterm/misc.c
--- xterm.org/misc.c Sun Mar 20 02:25:26 1994
+++ xterm/misc.c Sun Mar 20 13:44:05 1994
@@ -64,21 +64,33 @@
static void DoSpecialEnterNotify();
static void DoSpecialLeaveNotify();
+extern XtAppContext app_con;
+
xevents()
{
XEvent event;
+ XtInputMask input_mask;
register TScreen *screen = &term->screen;
- extern XtAppContext app_con;
if(screen->scroll_amt)
FlushScroll(screen);
- if (!XPending (screen->display))
- /* protect against events/errors being swallowed by us or Xlib */
+ /*
+ * process timeouts, relying on the fact that XtAppProcessEvent
+ * will process the timeout and return without blockng on the
+ * XEvent queue. Other sources i.e. the pty are handled elsewhere
+ * with select().
+ */
+ while ((input_mask = XtAppPending(app_con)) & XtIMTimer)
+ XtAppProcessEvent(app_con, XtIMTimer);
+ /*
+ * If there's no XEvents, don't wait around...
+ */
+ if ((input_mask & XtIMXEvent) != XtIMXEvent)
return;
do {
if (waitingForTrackInfo)
return;
- XNextEvent (screen->display, &event);
+ XtAppNextEvent (app_con, &event);
/*
* Hack to get around problems with the toolkit throwing away
* eventing during the exclusive grab of the menu popup. By
@@ -104,7 +116,7 @@
(event.xany.type != ButtonPress) &&
(event.xany.type != ButtonRelease)))
XtDispatchEvent(&event);
- } while (QLength(screen->display) > 0);
+ } while ((input_mask = XtAppPending(app_con)) & XtIMXEvent);
}
@@ -322,7 +334,7 @@
the bell again? */
if(screen->bellSuppressTime) {
if(screen->bellInProgress) {
- if (QLength(screen->display) > 0 ||
+ if (XtAppPending(app_con) ||
GetBytesAvailable (ConnectionNumber(screen->display)) > 0)
xevents();
if(screen->bellInProgress) { /* even after new events? */