xref: /csrg-svn/lib/libcurses/toucholap.c (revision 67082)
122684Sdist /*
2*67082Sbostic  * Copyright (c) 1981, 1993, 1994
361272Sbostic  *	The Regents of the University of California.  All rights reserved.
434677Sbostic  *
542657Sbostic  * %sccs.include.redist.c%
622684Sdist  */
722684Sdist 
822684Sdist #ifndef lint
9*67082Sbostic static char sccsid[] = "@(#)toucholap.c	8.2 (Berkeley) 05/04/94";
1034677Sbostic #endif /* not lint */
1122684Sdist 
12*67082Sbostic #include "curses.h"
1319897Sbloom 
1419897Sbloom /*
1555980Sbostic  * touchoverlap --
1619897Sbloom  *	Touch, on win2, the part that overlaps with win1.
1719897Sbloom  */
1855980Sbostic int
touchoverlap(win1,win2)1919897Sbloom touchoverlap(win1, win2)
2055980Sbostic 	register WINDOW *win1, *win2;
2155980Sbostic {
2255983Sbostic 	register int y, endy, endx, starty, startx;
2319897Sbloom 
2455980Sbostic #ifdef DEBUG
2560058Sbostic 	__CTRACE("touchoverlap: (%0.2o, %0.2o);\n", win1, win2);
2655980Sbostic #endif
2756238Selan 	starty = max(win1->begy, win2->begy);
2856238Selan 	startx = max(win1->begx, win2->begx);
2956238Selan 	endy = min(win1->maxy + win1->begy, win2->maxy + win2->begx);
3056238Selan 	endx = min(win1->maxx + win1->begx, win2->maxx + win2->begx);
3155980Sbostic #ifdef DEBUG
3260058Sbostic 	__CTRACE("touchoverlap: from (%d,%d) to (%d,%d)\n",
3355980Sbostic 	    starty, startx, endy, endx);
3460058Sbostic 	__CTRACE("touchoverlap: win1 (%d,%d) to (%d,%d)\n",
3556238Selan 	    win1->begy, win1->begx, win1->begy + win1->maxy,
3656238Selan 	    win1->begx + win1->maxx);
3760058Sbostic 	__CTRACE("touchoverlap: win2 (%d,%d) to (%d,%d)\n",
3856238Selan 	    win2->begy, win2->begx, win2->begy + win2->maxy,
3956238Selan 	    win2->begx + win2->maxx);
4055980Sbostic #endif
4119897Sbloom 	if (starty >= endy || startx >= endx)
4257472Sbostic 		return (OK);
4356238Selan 	starty -= win2->begy;
4456238Selan 	startx -= win2->begx;
4556238Selan 	endy -= win2->begy;
4656238Selan 	endx -= win2->begx;
4755980Sbostic 	for (--endx, y = starty; y < endy; y++)
4856650Selan 		__touchline(win2, y, startx, endx, 0);
4957472Sbostic 	return (OK);
5019897Sbloom }
5156650Selan 
52