home *** CD-ROM | disk | FTP | other *** search
- /*
- winobsc.c 10/14/88
-
- % Window routines for determining who is obscuring who.
- by Ted.
-
- OWL 1.1
- 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.
- */
-
- #include "oakhead.h"
- #include "disppriv.h"
-
- /* -------------------------------------------------------------------------- */
-
- win_type wmgr_IsObscuredPixBox(topwin, win, boxp, doshad)
- win_type topwin;
- win_type win;
- opbox *boxp; /* box within which to do the exposure */
- 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, boxp, doshad)
- 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(x, y)
- 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(curr_wmgr->employedhead, NULL, &cursbox, FALSE));
- }
- /* -------------------------------------------------------------------------- */
-
- win_type wmgr_FindBelow(win)
- 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);
- }
- /* -------------------------------------------------------------------------- */
-
-