xref: /csrg-svn/lib/libcurses/toucholap.c (revision 57472)
122684Sdist /*
234677Sbostic  * Copyright (c) 1981 Regents of the University of California.
334677Sbostic  * All rights reserved.
434677Sbostic  *
542657Sbostic  * %sccs.include.redist.c%
622684Sdist  */
722684Sdist 
822684Sdist #ifndef lint
9*57472Sbostic static char sccsid[] = "@(#)toucholap.c	5.10 (Berkeley) 01/11/93";
1034677Sbostic #endif /* not lint */
1122684Sdist 
1255980Sbostic #include <curses.h>
1319897Sbloom 
1419897Sbloom /*
1555980Sbostic  * touchoverlap --
1619897Sbloom  *	Touch, on win2, the part that overlaps with win1.
1719897Sbloom  */
1855980Sbostic int
1919897Sbloom touchoverlap(win1, win2)
2055980Sbostic 	register WINDOW *win1, *win2;
2155980Sbostic {
2255983Sbostic 	register int y, endy, endx, starty, startx;
2319897Sbloom 
2455980Sbostic #ifdef DEBUG
2555980Sbostic 	__TRACE("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
3255980Sbostic 	__TRACE("touchoverlap: from (%d,%d) to (%d,%d)\n",
3355980Sbostic 	    starty, startx, endy, endx);
3455980Sbostic 	__TRACE("touchoverlap: win1 (%d,%d) to (%d,%d)\n",
3556238Selan 	    win1->begy, win1->begx, win1->begy + win1->maxy,
3656238Selan 	    win1->begx + win1->maxx);
3755980Sbostic 	__TRACE("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)
42*57472Sbostic 		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);
49*57472Sbostic 	return (OK);
5019897Sbloom }
5156650Selan 
52