;;; -*- Mode: Common-Lisp; Package: User; Base: 10.; Patch-File: T -*-

;;; Reason: Refresh of suggestions-off-frame when (mmon-p) for cold-boot.
;;; See also suggestions patch 6.1 for warm-boot refresh.
;;; Also fixed other minor problems with tv:initial-lisp-listener.

;;;                           RESTRICTED RIGHTS LEGEND
;;;
;;; Use, duplication, or disclosure by the Government is subject to
;;; restrictions as set forth in subdivision (c)(1)(ii) of the Rights in
;;; Technical Data and Computer Software clause at 52.227-7013.
;;;
;;;   TEXAS INSTRUMENTS INCORPORATED      
;;;   P.O. BOX 2909, M/S 2151             
;;;   AUSTIN, TEXAS 78769                 
;;;
;;; Copyright (C) 1989 Texas Instruments Incorporated.
;;; All rights reserved.

;;; Patch file for TV version 6.16
;;; Written 10/20/89 09:59:59 by marky,
;;; while running on LIBRA from band LODA
;;; With SYSTEM 6.20, VIRTUAL-MEMORY 6.2, EH 6.5, MAKE-SYSTEM 6.2, MICRONET 6.0, LOCAL-FILE 6.1,
;;;  BASIC-PATHNAME 6.2, NETWORK-SUPPORT-COLD 6.2, BASIC-NAMESPACE 6.4, NETWORK-NAMESPACE 6.0,
;;;  DISK-IO 6.1, DISK-LABEL 6.0, BASIC-FILE 6.4, MAC-PATHNAME 6.0, NETWORK-PATHNAME 6.0,
;;;  COMPILER 6.12, TV 6.15, DATALINK 6.0, CHAOSNET 6.1, GC 6.3, MEMORY-AUX 6.0, NVRAM 6.2,
;;;  SYSLOG 6.2, STREAMER-TAPE 6.4, UCL 6.0, INPUT-EDITOR 6.0, METER 6.1, ZWEI 6.7,
;;;  DEBUG-TOOLS 6.3, NETWORK-SUPPORT 6.0, NETWORK-SERVICE 6.1, DATALINK-DISPLAYS 6.0,
;;;  FONT-EDITOR 6.1, SERIAL 6.0, PRINTER 6.3, MAC-PRINTER-TYPES 6.1, PRINTER-TYPES 6.2,
;;;  IMAGEN 6.1, SUGGESTIONS 6.1, MAIL-DAEMON 6.3, MAIL-READER 6.5, TELNET 6.0, VT100 6.0,
;;;  NAMESPACE-EDITOR 6.3, PROFILE 6.2, VISIDOC 6.5, TI-CLOS 6.25, CLEH 6.5, IP 3.54,
;;;  Experimental CLX 6.5, CLUE 6.25, X11M 6.15, Experimental BUG 11.15, Inconsistent MMON 6.1,
;;;   microcode 429, Band Name: clogged

;;; SPR 9802 - fix refresh of suggestions-off-frame when (mmon-p) for cold-boot.
;;; See also suggestions patch 6.1 for warm-boot
;;; Also fixed other minor problems with initial appearance of Lisp Listener :
;;; * forget mouse doc of disk-save function
;;; * correct tv:inhibit-who-line documentation
;;; * init the mouse ON initial-lisp-listener, if possible, to allow
;;;   lisp-help-mixin to work w/o moving mouse off suggestions-off-frame first,
;;;   and init the mouse to the :left side if user wants it there.

#!C
; From file INITIALIZATIONS.LISP#> WINDOW; Hotel:
#10R TV#:
(COMPILER-LET ((*PACKAGE* (FIND-PACKAGE "TV"))
                          (SI:*LISP-MODE* :COMMON-LISP)
                          (*READTABLE* COMMON-LISP-READTABLE)
                          (SI:*READER-SYMBOL-SUBSTITUTIONS* SYS::*COMMON-LISP-SYMBOL-SUBSTITUTIONS*))
  (COMPILER#:PATCH-SOURCE-FILE "SYS: WINDOW; INITIALIZATIONS.#"


(DEFUN COLD-WINDOW-INITIALIZATIONS ()			;jlm 2/28/89
  (unless (or (mac-system-p)
	      (si:cool-boot-p))
    (SEND WHO-LINE-SCREEN :REFRESH))
  (unless (si:cool-boot-p)
    (SEND INITIAL-LISP-LISTENER :REFRESH))

  ;; may 10/18/89 Refresh suggestions-off-frame if needed.
  ;; Fixes SPR 9802 for cold-boot only. See also decide-if-suggestions-visible in sugg pkg.
  (when (and (mmon-p)
	     (not (or (tv:mac-system-p)
	     	      (si:mp-system-p)))
	     (MEMBER suggestions-off-frame
		     (sheet-inferiors w:default-screen) :test #'eq))
    (send suggestions-off-frame :refresh))

  (W:PREALLOCATE-SEARCH-WINDOW-RESOURCES)
  ;; For the microExplorer, these get set to NIL since they are not MAC windows.
  ;; See (after-tv-initialized).
  ;; They must get re-created and will then be MAC windows.  03/18/88 KJF.
  ;; We'll do a check for mac-system since if these end up NIL for any other reason,
  ;; we'll assume someone knew what they were doing.  04/10/88 KJF.
  (WHEN (mac-system-p)
    (UNLESS w:cache-window
      (SETQ w:cache-window (MAKE-INSTANCE 'w:cache-window)))
    (UNLESS w:sprite-window
      (SETQ w:sprite-window (MAKE-INSTANCE 'w:sprite-window)))))

(defun clear-who-state ()
  "Called from si:before-cold-initialization-list to clear who-line doc, etc."
  (without-interrupts ;; may 10/23/89 Exclude mouse-process from calling :who-line-documentation-string
    (SEND initial-lisp-listener :eval-inside-yourself
	  '(SETF who-line-string nil
		function-doc nil
		who-line-refresh-flag nil	;; may 10/23/89 NIL was t
		;; may 10/23/89 Added ptr inits below to remove ctrl-c rememberance
		(rh-fill-pointer) 0
		(rh-scan-pointer) 0
		(rh-typein-pointer) 0))
    ;; may 10/19/89 Above does not quite do the job...
    ;; We also need to clear the actual who line string to prevent remembering si:disk-save arglist...
    ;; NOTE: (:method tv:who-line-file-sheet :update) uses si:who-line-just-cold-booted-p instead.
    (send who-line-documentation-window :eval-inside-yourself '(setf WHO-LINE-ITEM-STATE nil))
    ))
;; Below is almost the same as
;; (progn (delete-INITIALIZATION "Clear whostate" :before-cold)
;;        (ADD-INITIALIZATION "Clear whostate" '(tv:clear-who-state) :before-cold))
;; but preserves position in list.
(let ((init-position (member "Clear whostate" si:before-cold-initialization-list
			     :test #'(lambda (name-string init)
				       (and init
					    (stringp (si:init-name init))
					    (string-equal (si:init-name init) name-string))))))
  (when init-position
    (setf (car init-position)
	  (list "Clear whostate" '(tv:clear-who-state) t si:FDEFINE-FILE-PATHNAME))))


;; This doc string was ancient and never updated for MMON changes
(setf (documentation 'tv:inhibit-who-line 'variable)
      "When non-nil, who-line is disabled until next screen expose. Specifically, 
screen deexposure causes this to be set to :deexposed.")


))

#!C
; From file MOUSE.LISP#> WINDOW; Hotel:
#10R TV#:
(COMPILER-LET ((*PACKAGE* (FIND-PACKAGE "TV"))
                          (SI:*LISP-MODE* :COMMON-LISP)
                          (*READTABLE* COMMON-LISP-READTABLE)
                          (SI:*READER-SYMBOL-SUBSTITUTIONS* SYS::*COMMON-LISP-SYMBOL-SUBSTITUTIONS*))
  (COMPILER#:PATCH-SOURCE-FILE "SYS: WINDOW; MOUSE.#"

;;; 10/20/89 MAY	Changed Mouse-initialize to move mouse off suggestions pane into lisp listener
;;;                         so that lisp-help-mixin can provide arg documentation when first booted.
;;;                         Also start off on the side the user wants to use.
(DEFUN MOUSE-INITIALIZE (&OPTIONAL (SHEET DEFAULT-SCREEN))
  (when (or (not (si:mp-system-p))				;jlm 2/28/89
	    (funcall mp-sib-owner-p))				;jlm 3/07/89
    (OR (BOUNDP 'MOUSE-PROCESS)			;If first time loaded, initialize everything
	(SETQ MOUSE-PROCESS (MAKE-PROCESS "Mouse" :SPECIAL-PDL-SIZE 2000. :PRIORITY 30.
					  :WARM-BOOT-ACTION NIL)))
    ;; Above warm-boot-action prevents the process from starting up
    ;; until after these initializations have been completed.
    (SETQ MOUSE-WINDOW        NIL
	  WINDOW-OWNING-MOUSE NIL
	  MOUSE-X 0
	  MOUSE-Y 0
	  MOUSE-SHEET SHEET)
    (%SET-MOUSE-SCREEN SHEET)
    ;; Fill the mouse tracker's arrays with NIL instead of the garbage
    ;; that they contain initially.  At least interpreted ASET won't work otherwise.
    (LOOP FOR I FROM #o1640 BELOW #o1774
	  DO (%P-dpb nil %%q-all-but-cdr-code (+ A-MEMORY-VIRTUAL-ADDRESS I)))
    ;; Set scaling and speed dependence.
    (MOUSE-SPEED-HACK 0.6 80. 0.8 104. 1 128. 1.3 192. 1.5 256. 1.8 320. 2.2 448. 2.5)
    ;; Make sure at least one blinker of each type exists
    (MOUSE-GET-BLINKER :CHARACTER)
    (MOUSE-GET-BLINKER :RECTANGLE-CORNER-BLINKER)
    (MOUSE-GET-BLINKER :RECTANGLE-BLINKER)
    (AND MOUSE-BLINKER (BLINKER-SET-VISIBILITY MOUSE-BLINKER NIL))
    (MOUSE-STANDARD-BLINKER)
    ;; may 10/19/89 START PATCH ...
    ;; Move mouse off suggestions pane into lisp listener
    ;; so that lisp-help-mixin can provide arg documentation when first booted.
    ;; Also start off on the side the user wants to use.
    (LET ((sheet (IF (eq mouse-sheet (sheet-get-screen initial-lisp-listener))
		     initial-lisp-listener
		     mouse-sheet)))
      (multiple-value-bind (window-x-offset window-y-offset)
	  (sheet-calculate-offsets sheet mouse-sheet)
	(IF (EQ mouse-handedness :left) ;; mouse bottom left, else bottom right
	    (mouse-warp window-x-offset
			(+ window-y-offset (- (sheet-height sheet) 16.)))
	    (MOUSE-WARP (+ window-x-offset (- (SHEET-width sheet) 8.))
			(+ window-y-offset (- (SHEET-height sheet) 16.))))))
    ;; Call MOUSE-INPUT once to flush any pending motion and update variables, but don't wait.
    (SETQ MOUSE-BUTTONS-BUFFER-OUT-INDEX MOUSE-BUTTONS-BUFFER-IN-INDEX)
    (MOUSE-INPUT NIL)
    (SETQ MOUSE-X-SPEED 0
	  MOUSE-Y-SPEED 0)
    ;; Start up the mouse process
    (SEND MOUSE-PROCESS :PRESET 'MOUSE-OVERSEER)
    (SEND MOUSE-PROCESS :RUN-REASON)))
))
