(DEFINE-FILE-INFO PACKAGE "INTERLISP" READTABLE "INTERLISP")
(FILECREATED "25-May-88 21:51:25" {QV}<NOTECARDS>1.3LNEXT>RHTPATCH320.;1 12674  

      changes to%:  (VARS RHTPATCH320COMS))


(* "
Copyright (c) 1988 by Xerox Corporation.  All rights reserved.
")

(PRETTYCOMPRINT RHTPATCH320COMS)

(RPAQQ RHTPATCH320COMS ((DECLARE%: DONTCOPY (PROPS (RHTPATCH320 MAKEFILE-ENVIRONMENT)
                                                   (RHTPATCH320 FILETYPE)))
                        

(* ;;; 
"Fixes the bug whereby bringing up a card flashes its prompt window in lower left corner of screen.")

                        
          
          (* ;; "Change to NCINTERFACE")

                        (FNS NC.GETPROMPTWINDOW)))
(DECLARE%: DONTCOPY 

(PUTPROPS RHTPATCH320 MAKEFILE-ENVIRONMENT (:PACKAGE "INTERLISP" :READTABLE "INTERLISP"))

(PUTPROPS RHTPATCH320 FILETYPE :TCOMPL)
)



(* ;;; 
"Fixes the bug whereby bringing up a card flashes its prompt window in lower left corner of screen.")




(* ;; "Change to NCINTERFACE")

(DEFINEQ

(NC.GETPROMPTWINDOW
  [LAMBDA (MAINWINDOW %#LINES FONT DONTCREATE MINWIDTH)      (* ; "Edited 25-May-88 21:20 by Trigg")

(* ;;; "makes sure that MAINWINDOW has an attached promptwindow and returns it.  If one already exists, it is shaped to be at least #LINES high.  If FONT is NIL, the font of the main window is used for the promptwindow.")
          
          (* ;; "fgh 6/6/86 Adapted from system GETPROMPTWINDOW.  Added MINWIDTH arg.")
          
          (* ;; "rht 7/2/86: Now attaches prompt window on right if near right edge of screen.")
          
          (* ;; "rht 7/4/86: Yanked out PositionOnEdge localvar.  Put code in place.")
          
          (* ;; "rht 3/21/87: AttachWindowPositionOnEdge to attach prompt window is left if possible, then center, then right.  Also doesn't let prompt window be wider than screen.")
          
          (* ;; "rht 3/30/87: More ATTACHEDWINDOWS hacking.  This time to get the unstacking and restacking of attachedwindows right during reshaping of the prompt window.")
          
          (* ;; "rht&rg&pmi 4/22/87: Added stack of extra prompt windows and checks for whether they have processes equal to this one.")
          
          (* ;; "rht 5/25/88: The CREATEW call now uses off-screen position instead of 0,0.")

    (DECLARE (GLOBALVARS WBorder NC.OffScreenPosition))
    (AND MINWIDTH (SETQ MINWIDTH (MIN (DIFFERENCE SCREENWIDTH (TIMES WBorder 2))
                                      MINWIDTH)))
    (WITH.MONITOR
     NC.PromptWindowMonitorLock
     (PROG ((PWINDOWPROP (WINDOWPROP MAINWINDOW 'PROMPTWINDOW))
            (PWINDOWMINWIDTH (WINDOWPROP MAINWINDOW 'PROMPTWINDOWMINWIDTH))
            (MAINWINDOWREGION (WINDOWPROP MAINWINDOW 'REGION))
            (OtherPWindowProps (WINDOWPROP MAINWINDOW 'OtherPromptWindows))
            PWINDOW PWINDOWREGION WIDTH HEIGHT OBSCUREDHEIGHT PWINDOW.PWINDOW PWinWidth 
            AttachWindowPositionOnEdge ThisPWindowProp)
           (SETQ PWinWidth (WIDTHIFWINDOW (OR MINWIDTH PWINDOWMINWIDTH 1)))
           [SETQ AttachWindowPositionOnEdge (COND
                                               ((LEQ (PLUS (fetch (REGION LEFT) of MAINWINDOWREGION)
                                                           PWinWidth)
                                                     SCREENWIDTH)
                                                'LEFT)
                                               ((LEQ (PLUS (fetch (REGION LEFT) of MAINWINDOWREGION)
                                                           (LRSH (PLUS PWinWidth (fetch (REGION
                                                                                         WIDTH)
                                                                                    of 
                                                                                     MAINWINDOWREGION
                                                                                        ))
                                                                 1))
                                                     SCREENWIDTH)
                                                'CENTER)
                                               (T 'RIGHT]    (* ; "Find a free prompt window.")

           [for PWindowProp in (CONS PWINDOWPROP OtherPWindowProps)
              do (LET [(PWindowProcess (WINDOWPROP (CAR PWindowProp)
                                              'PromptWindowProcess]
                      (if (EQ (THIS.PROCESS)
                              PWindowProcess)
                          then (SETQ ThisPWindowProp PWindowProp)
                               (RETURN PWindowProp))
                      (if (AND (NULL ThisPWindowProp)
                               (NOT (PROCESSP PWindowProcess)))
                          then (SETQ ThisPWindowProp PWindowProp]
           [COND
              (DONTCREATE (RETURN (CAR ThisPWindowProp)))
              [ThisPWindowProp
               (SETQ PWINDOW (CAR ThisPWindowProp))
               (WINDOWPROP PWINDOW 'PromptWindowProcess (THIS.PROCESS))
               [COND
                  ((NOT (OPENWP PWINDOW))
                   (ATTACHWINDOW PWINDOW MAINWINDOW 'TOP AttachWindowPositionOnEdge 'LOCALCLOSE]
               (if (SETQ PWINDOW.PWINDOW (WINDOWPROP PWINDOW 'PROMPTWINDOW))
                   then                                      (* ; 
                           "This prompt window has a prompt window of its own.  Close and detach it.")

                        (REMOVEWINDOW (CAR PWINDOW.PWINDOW)))
               (WINDOWPROP PWINDOW 'MAXSIZE (CONS 64000 64000))
               (WINDOWPROP PWINDOW 'MINSIZE (CONS 1 1))
               [SETQ HEIGHT (HEIGHTIFWINDOW (TIMES (OR %#LINES (CDR ThisPWindowProp)
                                                       1)
                                                   (FONTPROP (DSPFONT NIL PWINDOW)
                                                          'HEIGHT]
               (SETQ WIDTH (MAX PWinWidth (fetch (REGION WIDTH) of MAINWINDOWREGION)))
               (SETQ PWINDOWREGION (WINDOWPROP PWINDOW 'REGION))
               (COND
                  ([OR (NOT (EQP HEIGHT (fetch (REGION HEIGHT) of PWINDOWREGION)))
                       (NOT (EQP WIDTH (fetch (REGION WIDTH) of PWINDOWREGION]
          
          (* ;; "Window exists, but not right size.  Keep windows detached during reshaping in case AttachWindowPositionOnEdge has changed.")

(* ;;; "Need to distinguish among the windows attached to MAINWINDOW between those attached before PWINDOW and those attached after.  The latter need to be reattached at AttachWindowPositionOnEdge after PWINDOW is reshaped.")

                   [LET [(DescriptionList (for Win in (ATTACHEDWINDOWS MAINWINDOW) bind WA
                                             when [EQ 'TOP (CAR (SETQ WA (WINDOWPROP Win '
                                                                                WHEREATTACHED]
                                             collect         (* ; 
 "Detach attached windows at the top of the main Win and retuirn a list describing their attachment.")

                                                   (PROG1 (LIST Win (CDR WA)
                                                                (WINDOWPROP Win 'PASSTOMAINCOMS))
                                                          (DETACHWINDOW Win]
                                                             (* ; 
                                                            "Have to smash these to let SHAPEW work.")

                        (WINDOWPROP PWINDOW 'MAXSIZE NIL)
                        (WINDOWPROP PWINDOW 'MINSIZE NIL)
                        (WINDOWPROP PWINDOW 'PASSTOMAINCOMS NIL)
                        (RESETLST [RESETSAVE NIL
                                         `(PROGN (WINDOWPROP ,PWINDOW 'OPENFN
                                                        ',(WINDOWPROP PWINDOW 'OPENFN NIL]
                               (SHAPEW PWINDOW (create REGION
                                                  using PWINDOWREGION HEIGHT ← HEIGHT WIDTH ← WIDTH))
                               )

(* ;;; "Now reattach all the windows in order to their old locations, except that PWINDOW and those after it should be attached at AttachWindowPositionOnEdge.")

                        (for WindowDescription in DescriptionList bind SeenPWINDOW
                           do (LET ((Win (CAR WindowDescription)))
                                   (if (EQ Win PWINDOW)
                                       then (SETQ SeenPWINDOW T))
                                   (ATTACHWINDOW Win MAINWINDOW 'TOP (if SeenPWINDOW
                                                                         then 
                                                                           AttachWindowPositionOnEdge
                                                                       else (CADR WindowDescription))
                                          )
                                   (WINDOWPROP Win 'PASSTOMAINCOMS (CADDR WindowDescription]
                   (RPLACD ThisPWindowProp %#LINES)          (* ; "Fall through to check visibility")

                   ]
              (T (SETQ PWINDOW (CREATEW [create REGION
                                               LEFT ← (fetch (POSITION XCOORD) of 
                                                                                 NC.OffScreenPosition
                                                             )
                                               BOTTOM ← (fetch (POSITION YCOORD) of 
                                                                                 NC.OffScreenPosition
                                                               )
                                               WIDTH ← (MAX PWinWidth (fetch (REGION WIDTH)
                                                                         of MAINWINDOWREGION))
                                               HEIGHT ←
                                               (SETQ HEIGHT
                                                (HEIGHTIFWINDOW (TIMES (OR %#LINES (SETQ %#LINES 1))
                                                                       (FONTPROP
                                                                        (OR FONT (SETQ FONT
                                                                                  (DSPFONT NIL 
                                                                                         MAINWINDOW))
                                                                            )
                                                                        'HEIGHT]
                                      NIL NIL T))
                 (DSPSCROLL T PWINDOW)
                 (DSPFONT FONT PWINDOW)
                 (WINDOWPROP PWINDOW 'PAGEFULLFN 'NILL)
                 (ATTACHWINDOW PWINDOW MAINWINDOW 'TOP AttachWindowPositionOnEdge 'LOCALCLOSE)
                 (if (NULL PWINDOWPROP)
                     then (WINDOWPROP MAINWINDOW 'PROMPTWINDOW (CONS PWINDOW %#LINES))
                   else (WINDOWADDPROP MAINWINDOW 'OtherPromptWindows (CONS PWINDOW %#LINES)))
                 (WINDOWPROP PWINDOW 'PromptWindowProcess (THIS.PROCESS))
                 (WINDOWPROP PWINDOW 'OPENFN (FUNCTION \PROMPTWINDOW.OPENFN]
           [COND
              ((ILESSP [SETQ OBSCUREDHEIGHT (IDIFFERENCE SCREENHEIGHT (fetch (REGION TOP)
                                                                         of (WINDOWPROP PWINDOW
                                                                                   'REGION]
                      0)                                     (* ; 
                       "Promptwindow off screen at top, so slip window group down to make it visible")

               (RELMOVEW MAINWINDOW (create POSITION
                                           XCOORD ← 0
                                           YCOORD ← OBSCUREDHEIGHT]
           (WINDOWPROP PWINDOW 'MINSIZE (CONS 1 HEIGHT))
           (WINDOWPROP PWINDOW 'MAXSIZE (CONS 64000 HEIGHT))
           (WINDOWPROP MAINWINDOW 'PROMPTWINDOWMINWIDTH (OR MINWIDTH 1))
           (OPENW PWINDOW)
           (RETURN PWINDOW])
)
(PUTPROPS RHTPATCH320 COPYRIGHT ("Xerox Corporation" 1988))
(DECLARE%: DONTCOPY
  (FILEMAP (NIL (1067 12591 (NC.GETPROMPTWINDOW 1077 . 12589)))))
STOP