[comp.sys.att] Help with 3b1 track

elh@vu-vlsi.UUCP (Edward L. Hepler) (10/16/87)

I have been trying to figure out how track(3T) works all evening!

I assumed that one calls track and it returns when something happens
which it thinks you should know about.  I am getting very strange results.
I have written a small program to try to get the feel for what is going
on and have run out of ideas.  Can anyone help me?

I am running on a 3b1 release 3.5 of the OS, release 3.51 of the development
tools.  I compile using:
cc -o dr d.c -ltam -ltermcap

Many thanks,
Ed Hepler
elh@vu-vlsi

The source for d.c follows:


#include <stdio.h>
#include <tam.h>
#include <track.h>

track_t screen_map;

tkitem_t track_items[] = {
	{0,	0,	100,	100,	(struct icon *)0,	1},
	{0,	100,	100,	100,	(struct icon *)0,	2},
	{0,	200,	100,	100,	(struct icon *)0,	3},
	{100,	0,	300,	300,	(struct icon *)0,	4},
	{0,0,0,0,(struct icon *)0,0}
	};
	
main(argc,argv)
	int argc;
	char *argv[];
{
int pw;
pw = init_screen();
setup_screen(pw);
cycle_screen(pw);
}

int
init_screen()
{
int pw;

winit();
if((pw = wcreate((short)1,(short)0,(short)24,(short)80,
		(unsigned short)NBORDER)) < 0)
	{
	perror("Couldn't open window");
	exit(1);
	}
clear();
return(pw);
}

restore_screen(pw,exit_code)
	int pw;
	int exit_code;
{
struct wstat curstat;

clear();
curstat.begx = 0;
curstat.begy = 1;
curstat.height = 18;
curstat.width = 80;
curstat.uflags = BORDRESIZE | NOSETUFLAGS;
wsetstat(pw,&curstat);
wexit(exit_code);
}

setup_screen(pw)
	int pw;
{
int but,why;
int reason;

screen_map.t_flags = MSUP | MSDOWN;
screen_map.t_scalex = screen_map.t_scaley = 1;
screen_map.t_tkitems = track_items;

reason = track(pw,&screen_map,T_BEGIN,&but,&why);
wgoto(pw,2,0);
wprintf(pw,"Init to track returned %d",reason);
} 

cycle_screen(pw)
	int pw;
{
int but,why;
int reason;
int loop = 0;

while(1)
	{
wgoto(pw,3,0);
wprintf(pw,"Loop is %d",loop);
	reason = track(pw,&screen_map,T_INPUT,&but,&why);
	switch(reason)
		{
	case Mouse:
		switch(why)
			{
		case MSIN:
wgoto(pw,4,0);
wprintf(pw,"Mouse entered window - loop %d",loop);
			break;
		case MSOUT:
wgoto(pw,5,0);
wprintf(pw,"Mouse outside window - loop %d",loop);
			break;
		case MSUP:
wgoto(pw,6,0);
wprintf(pw,"Mouse button up - loop %d",loop);
			break;
		case MSDOWN:
wgoto(pw,7,0);
wprintf(pw,"Mouse button down - loop %d",loop);
			break;
		default:
wgoto(pw,8,0);
wprintf(pw,"Unknown why - loop %d",loop);
			restore_screen(pw,1);
			break;
			}
	default:
wgoto(pw,9,0);
wprintf(pw,"Keycode returned: %o",reason);
		break;
		}
	loop++;
	}
}

pjc@pbhyf.UUCP (Paul Condie) (10/19/87)

In article <1163@vu-vlsi.UUCP> elh@vu-vlsi.UUCP (Edward L. Hepler) writes:
>
>I have been trying to figure out how track(3T) works all evening!
>
>track_t screen_map;
>
>tkitem_t track_items[] = {
>	{0,	0,	100,	100,	(struct icon *)0,	1},
>	{0,	100,	100,	100,	(struct icon *)0,	2},
>	{0,	200,	100,	100,	(struct icon *)0,	3},
                ^^^^^
	The window you created 24x80 is only 288 pixels by 720 pixels.
	Your rectangle is going outside the bounds of the window.  Track
	does not work right if any of the retangles go outside the window.
>	{100,	0,	300,	300,	(struct icon *)0,	4},
                       ^^^^^^
	Same with this one.
>	{0,0,0,0,(struct icon *)0,0}
>	};
>