home *** CD-ROM | disk | FTP | other *** search
- /*
- wintop.c 3/15/88
-
- % win_Top
-
- by Ted.
- Extracted from winsetp.c
-
- OWL 1.1
- Copyright (c) 1988, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 10/31/88 Ted: Removed linking.
- 12/08/88 ted: Added ddisp_Cache/Flush calls for mouse.
- 12/11/88 ted: Added dhard_Claim/Release calls for reentrancy.
- 12/11/88 ted: moved win_IsAbove here from winlist.c because only
- win_PutUnder calls it right now.
- 03/09/89 ted: fixed bug where PutUnder didn't repaint in goingdown case.
- 5/01/89 ted Added wmgr_SetNewCurrentFlag call to fix mouse support.
- 5/01/89 ted Merged in win_Employ, UnEmploy, got rid of winempl.c
- 7/07/89 gam Changed NULL to FNULL where necessary
- 8/08/89 jmd combined win_Top and win_PutUnder into win_ReallyPutUnder
- switched order of args to PutUnder
- 8/10/89 ted added allowances for shadows.
- 8/13/89 jmd removed GETEXPLODE message
- */
-
- #include "oakhead.h"
- #include "disppriv.h"
-
- /* -------------------------------------------------------------------------- */
-
- boolean win_ReallyPutUnder(win, destwin)
- win_type win;
- win_type destwin;
- /*
- Removes win from the list it is in and inserts it below destwin in
- destwin's list. Thus, if destwin is unemployed, the effect is to retire
- win if it is employed. Likewise, if destwin is employed the effect is to
- employ win if it is unemployed. The display is updated to reflect the new
- position of win.
-
- if destwin is NULL, put the window on top.
- */
- {
- boolean obscured, goingdown;
- win_type oldunder;
- opbox winbox, wshbox;
-
- if (win == NULL) {
- return(FALSE);
- }
-
- if (destwin == NULL) {
- /* put the window on top */
- if (win_IsEmployed(win)) {
- destwin = wmgr_botsyswin();
- }
- else { /* move window(s) to top of unemployed list (why not?) */
- destwin = wmgr_unemployedhead();
- }
- }
-
- hard_Claim(); /* Here for re-entrancy protection */
-
- if (win == destwin || win == win_GetBelow(destwin)) {
- hard_Release();
- return(TRUE); /* Quit if already there */
- }
-
- /* If target is in unemployed list, take care of it */
- if (!win_IsEmployed(destwin)) {
-
- if (win_IsEmployed(win)) {
- win_UnEmploy(win);
- }
- win_ListRemove(win);
- win_ListAdd(destwin, win);
-
- hard_Release();
- return(TRUE);
- }
-
- /* else: Target is in employed list */
- disp_Cache();
-
- /* Save portions that need to be saved and then remove window from list */
- if (win_IsEmployed(win)) {
- goingdown = win_IsAbove(win, destwin);
- }
- else { /* win is unemployed */
- /* Note: if win is not in the employed list, it will work like NULL */
- /* for IsObscuredPixBox and SavePixLayer. */
- goingdown = FALSE;
- }
-
- /* Find out whether window is obscured and save places it will soon obscure */
- win_getshadowbox(win, &wshbox);
- obscured = (wmgr_IsObscuredPixBox(destwin, win, &wshbox, TRUE) != NULL);
-
- if (!goingdown) {
- /* Save from wins that were obscuring and will be obscured where win's going */
- if (obscured) {
- wmgr_SavePixLayer(win_GetBelow(destwin), win, &wshbox);
- }
- }
- else { /* if going down */
- /* Save from window only if its insides will be obscured */
- win_getwinbox(win, &winbox);
- if (wmgr_IsObscuredPixBox(win, win_GetBelow(destwin), &winbox, TRUE) != NULL) {
- oldunder = win_GetBelow(win);
- wmgr_SavePixBox(win, &winbox);
- }
- }
-
- /* Update bot_employed pointer if neccesary */
- if (curr_wmgr->bot_employed_win == win) {
- curr_wmgr->bot_employed_win = win_GetAbove(win);
- }
- /* Link window into employed list below destwin */
- win_ListRemove(win);
- win_ListAdd(destwin, win);
-
- /* Update bot_employed pointer if neccesary */
- if (win_GetBelow(win) == NULL) {
- curr_wmgr->bot_employed_win = win;
- }
-
- /* Paint the explode visuals if win is becoming employed */
- if (!win_IsEmployed(win) ) {
- win_setemployed(win, TRUE); /* Just in case it wasn't already */
-
- if (win_GetExplodeFptr(win) != FNULL) {
- win_Expose(win, WINM_EXPLODE, NULL);
- }
- obscured = TRUE; /* Force paint for win becoming employed */
- }
-
- /* Paint portions that need to be painted */
- if (obscured) {
- if (!goingdown) {
- wmgr_PaintPixBox(win, &wshbox);
- }
- else { /* if going down */
- wmgr_PaintPixLayer(oldunder, win, &wshbox);
- }
- }
- /* Set flag for kb_Read/Check to wrap up mouse msgs for new mouse win */
- if (wmgr_SMMptr() != FNULL) {
- wmgr_SetNewCurrentFlag(TRUE);
- }
- disp_Flush();
- hard_Release();
- return(TRUE);
- }
- /* -------------------------------------------------------------------------- */
-
- boolean win_ReallyUnEmploy(win)
- win_type win;
- /*
- Called by win object in response to WINM_UNEMPLOY message.
- Unemploy a window.
- Remove it from the display.
- Refresh Display
- */
- {
- win_type newtop;
- opbox pbox;
-
- if (win == NULL) {
- return(FALSE);
- }
- hard_Claim(); /* Here for re-entrancy protection */
-
- if (!win_IsEmployed(win)) { /* window already retired */
- hard_Release();
- return(TRUE);
- }
- disp_Cache();
-
- /* Remember window's below-window, which will be where we repaint from */
- newtop = win_GetBelow(win);
-
- /* Save contents of win before it goes away */
- win_getwinbox(win, &pbox);
- wmgr_SavePixBox(win, &pbox);
-
- /* Remove window from employed list */
- if (curr_wmgr->bot_employed_win == win) {
- curr_wmgr->bot_employed_win = win_GetAbove(win);
- }
-
- /* Update bot_employed pointer if neccesary */
- if (win_GetBelow(win) == NULL) {
- curr_wmgr->bot_employed_win = win_GetAbove(win);
- }
- win_ListRemove(win);
-
- win_setemployed(win, FALSE);
-
- /* Link window into top of unemployed list */
- win_ListAdd(curr_wmgr->unemployedhead, win); /* win becomes new top */
-
- /* Restore in box from windows below where win was */
- win_getshadowbox(win, &pbox);
- wmgr_PaintPixBox(newtop, &pbox);
-
- /* Set flag for kb_Read/Check to wrap up mouse msgs for new mouse win */
- if (wmgr_SMMptr() != FNULL) {
- wmgr_SetNewCurrentFlag(TRUE);
- }
-
- disp_Flush();
- hard_Release();
- return(TRUE);
- }
- /* -------------------------------------------------------------------------- */
-
- boolean win_IsAbove(winabove, win)
- win_type winabove;
- win_type win;
- /*
- Returns TRUE if win is found below winabove in winabove's window list.
- */
- {
- if (winabove == NULL || win == NULL || win == winabove) {
- return(FALSE);
- }
-
- hard_Claim(); /* Here for re-entrancy protection */
-
- for (;;) {
- winabove = win_GetBelow(winabove);
- if (winabove == NULL) {
- hard_Release();
- return(FALSE);
- }
- if (winabove == win) {
- hard_Release();
- return(TRUE);
- }
- }
- }
- /* -------------------------------------------------------------------------- */
-
-