;;; -*- Mode: Common-Lisp; Package: User; Base: 10.; Patch-File: T -*-
;;; Written 06/08/90 15:58:15 by marky,
;;; Reason: Fixed the checker function for defwindow resources when the keyboard
;;; and mouse pointed to different screens.
;;; while running on KES2 from band LOD2
;;; With SYSTEM 6.38, VIRTUAL-MEMORY 6.3, EH 6.6, MAKE-SYSTEM 6.2, MICRONET 6.0, LOCAL-FILE 6.2,
;;;  BASIC-PATHNAME 6.4, NETWORK-SUPPORT-COLD 6.2, BASIC-NAMESPACE 6.7, NETWORK-NAMESPACE 6.1,
;;;  DISK-IO 6.2, DISK-LABEL 6.0, BASIC-FILE 6.10, MAC-PATHNAME 6.0, NETWORK-PATHNAME 6.1,
;;;  COMPILER 6.14, TV 6.24, DATALINK 6.0, CHAOSNET 6.6, GC 6.3, MEMORY-AUX 6.0, NVRAM 6.2,
;;;  SYSLOG 6.2, STREAMER-TAPE 6.5, UCL 6.0, INPUT-EDITOR 6.0, METER 6.1, ZWEI 6.13,
;;;  DEBUG-TOOLS 6.4, NETWORK-SUPPORT 6.1, NETWORK-SERVICE 6.2, DATALINK-DISPLAYS 6.0,
;;;  FONT-EDITOR 6.1, SERIAL 6.0, PRINTER 6.7, MAC-PRINTER-TYPES 6.2, PRINTER-TYPES 6.2,
;;;  IMAGEN 6.1, SUGGESTIONS 6.1, MAIL-DAEMON 6.6, MAIL-READER 6.7, TELNET 6.1, VT100 6.0,
;;;  NAMESPACE-EDITOR 6.4, PROFILE 6.2, VISIDOC 6.7, TI-CLOS 6.43, CLEH 6.5, Experimental GRAPHICS-WINDOW 6.1,
;;;  TREE 6.0, MMON 6.2, IP 3.60, Experimental SNRL 16.0, Experimental SNRL-ADD-ONS 3.0,
;;;  Experimental QUERY 1.0, Experimental SST-WINDOWS 1.0, Experimental SCENARIO-MANAGER 1.0,
;;;  Experimental SNED 4.0, Experimental GRAPHICAL-SORT 3.0, Experimental STRATEGY-MANAGER 5.0,
;;;  Experimental RAMP 560.0,  microcode 2, Band Name: ramp eas 6/11/90

;;; The checkers below relied on the fact that w:default screen is where a window whould be exposed.
;;; IN fact, tv:mouse-sheet is probably more accurate since for a tv:confirmation-window tv:mouse sheet
;;; is pointing to where the mouse (and the ultimate window allocated) will come up and the w:default-screen 
;;; can be pointing the where the keyboard (i.e., w:default-screen) is. Before multiple screens the var
;;; w:default-screen used to be tv:main-screen and there was NEVER more than one. Now we must use the same
;;; screen that the window was created with as the screen which will become the resource's ultimate superior
;;; so as to prevent disparities between pixel size, plane mask, etc. Since the superior of the defresource
;;; *IS* passed in to #'using-resource & #'allocate-resource, then if THAT code is correct there will be no
;;; problem. The problem found was that when the w:default-screen and tv:mouse-sheet are pointing to different
;;; screens, CHECK-DEEXPOSED-WINDOW-RESOURCE would return nil and *EVERY* confirm would result in a *NEW*
;;; window being created unecessarily.

#!C
; From file TVDEFS.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; TVDEFS.#"


(DEFUN CHECK-DEEXPOSED-WINDOW-RESOURCE   (IGNORE WINDOW IN-USE-P superior &REST IGNORE) ;; may 06/11/90 added superior
  (AND (NOT IN-USE-P)
       ;;(or (not (mac-system-p))	;; may 07/10/89 
       ;; Prevent using a resource if the superior is pointing to a DIFFERENT screen
       (EQ superior (tv:sheet-get-screen window)) ;; may 06/11/90 superior was w:default-screen
       (NOT (SHEET-EXPOSED-P WINDOW))
       (SHEET-CAN-GET-LOCK   WINDOW)))

(DEFUN CHECK-DEACTIVATED-WINDOW-RESOURCE (IGNORE WINDOW IN-USE-P superior &REST IGNORE) ;; may 06/11/90 added superior 
  ;;;check the resource to insure it has the right attributes for the screen
  ;;;it is going to be displayed on. 
  (AND (NOT IN-USE-P)
       (EQ superior (tv:sheet-get-screen window)) ;; may 06/11/90 superior was w:default-screen
       (NOT (MEMBER WINDOW (SHEET-INFERIORS (SHEET-SUPERIOR WINDOW)) :TEST #'EQ))
       (SHEET-CAN-GET-LOCK WINDOW))) 
))
