home *** CD-ROM | disk | FTP | other *** search
- /*
- winobsc.c 10/14/88
-
- % Window routines for determining who is obscuring who.
- by Ted.
-
- OWL 1.2
- Copyright (c) 1988, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 12/09/88 ted: Added ddisp_Cache/Flush calls for mouse.
- 12/11/88 ted: Added dhard_Claim/Release calls for reentrancy.
- 3/31/89 ted: Added wmgr_PointWin.
- 4/25/89 ted Added wmgr_FindBelow. Added check for employed in IsObscured.
- 5/11/89 ted Added win parent clip check.
- 8/30/89 ted Added shadow support to IsObscured and ParentClip.
-
- 11/06/89 ted Added win_TopChild function used in fixing nested paint bug.
- 3/28/90 jmd ansi-fied
- */
-
- #include "oakhead.h"
- #include "disppriv.h"
-
- /* -------------------------------------------------------------------------- */
-
- win_type wmgr_IsObscuredPixBox(win_type topwin, win_type win, opbox *boxp, boolean doshad)
- /*
- Determines if the given box is covered by an employed window below topwin
- and above win. If win is NULL, all windows below topwin are checked.
- Returns uppermost obscuring window, or NULL if box is unobscured.
- If 'doshad' is TRUE, returns uppermost window whose self or shadow
- obscures the box.
- */
- {
- opbox tbox;
-
- if (topwin != NULL) {
- hard_Claim(); /* Here for re-entrancy protection */
-
- if (win_IsEmployed(topwin)) {
- for(;;) {
- topwin = win_GetBelow(topwin);
- if (topwin == NULL || topwin == win) {
- break;
- }
- if (win_IsEmployed(topwin)) {
- if (win_ParentClip(topwin, &tbox, doshad)) {
- if(opbox_clipbox(boxp, &tbox)) {
- /* windows overlap */
- hard_Release();
- return(topwin);
- }
- }
- }
- }
- }
- hard_Release();
- }
- return(NULL);
- }
- /* -------------------------------------------------------------------------- */
-
- unsigned OWLPRIV win_ParentClip(win_type win, opbox *boxp, boolean doshad)
- /*
- Fills the passed boxp with the coordinates of the given window's outer box
- (plus the window's shadow if 'doshad' is TRUE),
- clipped by the inner boxes of all the window's parent windows.
- Return Sutherland clip code for box clipped: 0 if box is completely
- clipped out; otherwise bits saying which side(s) it was clipped on:
- 1, 2, 4, 8 for right, top, left, bottom; 16 for coming through at all.
- */
- {
- unsigned scode, rcode;
- win_type parent;
- opbox winbox;
-
- opbox_copy(boxp, win_pixboxp(win));
- if (doshad) {
- boxp->xmax += win_GetShadowX(win);
- boxp->ymax += win_GetShadowY(win);
- }
- rcode = 16;
- for (;;) {
- parent = win_GetParent(win);
- if (parent == NULL || !win_IsParentClip(win)) {
- return(rcode);
- }
- win_getwinbox(parent, &winbox);
- if ((scode = opbox_clipbox(&winbox, boxp)) == 0) {
- return(0);
- }
- rcode |= scode;
- win = parent;
- }
- }
- /* -------------------------------------------------------------------------- */
-
- win_type wmgr_PointWin(opcoord x, opcoord y)
- /*
- Return the first employed window lying below the given point.
- */
- {
- opbox cursbox;
-
- /* Find which window the mouse point falls in */
- cursbox.xmin = x; cursbox.xmax = cursbox.xmin + 1;
- cursbox.ymin = y; cursbox.ymax = cursbox.ymin + 1;
-
- return(wmgr_IsObscuredPixBox(wmgr_employedhead(), NULL, &cursbox, FALSE));
- }
- /* -------------------------------------------------------------------------- */
-
- win_type wmgr_FindBelow(win_type win)
- /*
- Return the first employed window lying below the upper left corner of the
- given window.
- */
- {
- win_type bwin;
-
- if (win_IsEmployed(win)) {
- win_setemployed(win, FALSE);
- bwin = wmgr_PointWin(win_GetXmin(win), win_GetYmin(win));
- win_setemployed(win, TRUE);
- return(bwin);
- }
- else return(NULL);
- }
- /* -------------------------------------------------------------------------- */
-
- win_type OWLPRIV win_TopChild(win_type win)
- /*
- Returns the topmost employed child window of the given window.
- If no child is found above the window, the window itself is returned.
- If the window is not in the employed list itself, NULL is returned.
- */
- {
- win_type currwin, parent;
-
- /* For all windows from top down, */
- /* starting with the top eligible window */
- for (currwin = win_GetBelow(wmgr_botsyswin()); currwin != NULL;
- currwin = win_GetBelow(currwin)) {
-
- /* For all (grand)parents of the current win, check if they are the win */
- for (parent = currwin; parent != NULL;
- parent = win_GetParent(parent)) {
- if (parent == win) {
- return(currwin);
- }
- }
- }
- return(NULL);
- }
- /* -------------------------------------------------------------------------- */
-