DeviceWorkstation.st
changeset 2855 f1fca530bab1
parent 2854 50a01bc5e535
child 2858 1b9d41fbd239
equal deleted inserted replaced
2854:50a01bc5e535 2855:f1fca530bab1
    21 		isSlow activeKeyboardGrab activePointerGrab buttonTranslation
    21 		isSlow activeKeyboardGrab activePointerGrab buttonTranslation
    22 		multiClickTimeDelta altModifiers metaModifiers ctrlModifiers
    22 		multiClickTimeDelta altModifiers metaModifiers ctrlModifiers
    23 		shiftModifiers supportsDeepIcons preferredIconSize ditherColors
    23 		shiftModifiers supportsDeepIcons preferredIconSize ditherColors
    24 		fixColors numFixRed numFixGreen numFixBlue fixGrayColors
    24 		fixColors numFixRed numFixGreen numFixBlue fixGrayColors
    25 		copyBuffer lastCopyBuffer blackColor whiteColor focusMode
    25 		copyBuffer lastCopyBuffer blackColor whiteColor focusMode
    26 		activeView clipBoardEncoding focusView'
    26 		activeView clipBoardEncoding focusView deviceErrorSignal deviceIOErrorSignal'
    27 	classVariableNames:'ButtonTranslation MultiClickTimeDelta DeviceErrorSignal
    27 	classVariableNames:'ButtonTranslation MultiClickTimeDelta DeviceErrorSignal
    28 		DeviceIOErrorSignal DeviceIOTimeoutErrorSignal ErrorPrinting
    28 		DeviceIOErrorSignal DeviceIOTimeoutErrorSignal ErrorPrinting
    29 		DefaultScreen AllScreens CurrentScreenQuerySignal
    29 		DefaultScreen AllScreens CurrentScreenQuerySignal
    30 		LastActiveScreen LastActiveProcess NoBeep
    30 		LastActiveScreen LastActiveProcess NoBeep
    31 		WindowsRightButtonBehavior ExitOnLastClose'
    31 		WindowsRightButtonBehavior ExitOnLastClose'
   859 deviceErrorSignal
   859 deviceErrorSignal
   860     "return the per-device signal, which is used for error reporting.
   860     "return the per-device signal, which is used for error reporting.
   861      The default here is the global DeviceErrorSignal 
   861      The default here is the global DeviceErrorSignal 
   862      (which is the parent of any per-instance error signals)."
   862      (which is the parent of any per-instance error signals)."
   863 
   863 
       
   864     deviceErrorSignal notNil ifTrue:[^ deviceErrorSignal].
   864     ^ self class deviceErrorSignal
   865     ^ self class deviceErrorSignal
   865 !
   866 !
   866 
   867 
   867 deviceIOErrorSignal
   868 deviceIOErrorSignal
   868     "return the signal used for device I/O error reporting.
   869     "return the signal used for device I/O error reporting.
   869      The default here is the global DeviceIOErrorSignal 
   870      The default here is the global DeviceIOErrorSignal 
   870      (which is the parent of any per-instance I/O error signals)."
   871      (which is the parent of any per-instance I/O error signals)."
   871 
   872 
       
   873     deviceIOErrorSignal notNil ifTrue:[^ deviceIOErrorSignal].
   872     ^ self class deviceIOErrorSignal
   874     ^ self class deviceIOErrorSignal
   873 !
   875 !
   874 
   876 
   875 deviceIOTimeoutErrorSignal
   877 deviceIOTimeoutErrorSignal
   876     "return the signal used for device I/O timeout error reporting.
   878     "return the signal used for device I/O timeout error reporting.
  2458     ^ self subclassResponsibility
  2460     ^ self subclassResponsibility
  2459 !
  2461 !
  2460 
  2462 
  2461 colorScaledRed:red scaledGreen:green scaledBlue:blue
  2463 colorScaledRed:red scaledGreen:green scaledBlue:blue
  2462     visualType == #TrueColor ifTrue:[
  2464     visualType == #TrueColor ifTrue:[
  2463         ^ (((red bitShift:-8) bitShift:redShift)
  2465 	^ (((red bitShift:-8) bitShift:redShift)
  2464           bitOr:((green bitShift:-8) bitShift:greenShift))
  2466 	  bitOr:((green bitShift:-8) bitShift:greenShift))
  2465           bitOr:((blue bitShift:-8) bitShift:blueShift)
  2467 	  bitOr:((blue bitShift:-8) bitShift:blueShift)
  2466     ].
  2468     ].
  2467     self subclassResponsibility
  2469     self subclassResponsibility
  2468 !
  2470 !
  2469 
  2471 
  2470 ditherColors
  2472 ditherColors
  3607      We only do this for displays other that the default Display."
  3609      We only do this for displays other that the default Display."
  3608 
  3610 
  3609     dispatching ifFalse:[^ self].
  3611     dispatching ifFalse:[^ self].
  3610 
  3612 
  3611     self == Display ifTrue:[
  3613     self == Display ifTrue:[
  3612         ExitOnLastClose == true ifFalse:[^ self].
  3614 	ExitOnLastClose == true ifFalse:[^ self].
  3613     ].
  3615     ].
  3614     exitOnLastClose == true ifFalse:[^ self].
  3616     exitOnLastClose == true ifFalse:[^ self].
  3615 
  3617 
  3616     knownViews notNil ifTrue:[
  3618     knownViews notNil ifTrue:[
  3617         (knownViews findFirst:[:slot | 
  3619 	(knownViews findFirst:[:slot | 
  3618                 slot notNil 
  3620 		slot notNil 
  3619                 and:[slot ~~ 0
  3621 		and:[slot ~~ 0
  3620                 and:[slot isRootView not 
  3622 		and:[slot isRootView not 
  3621                 and:[slot superView isNil
  3623 		and:[slot superView isNil
  3622                 and:[slot realized]]]]]) == 0 ifTrue:[
  3624 		and:[slot realized]]]]]) == 0 ifTrue:[
  3623             "/ my last view was closed
  3625 	    "/ my last view was closed
  3624             dispatching := false.
  3626 	    dispatching := false.
  3625             'DeviceWorkstation [info]: finished dispatch (last view closed)' infoPrintCR.
  3627 	    'DeviceWorkstation [info]: finished dispatch (last view closed)' infoPrintCR.
  3626         ]
  3628 	]
  3627     ].
  3629     ].
  3628 
  3630 
  3629     "Modified: 19.9.1995 / 11:31:54 / claus"
  3631     "Modified: 19.9.1995 / 11:31:54 / claus"
  3630     "Modified: 18.3.1997 / 10:42:11 / cg"
  3632     "Modified: 18.3.1997 / 10:42:11 / cg"
  3631 !
  3633 !
  4583 
  4585 
  4584 initializeDeviceResources
  4586 initializeDeviceResources
  4585     "initialize heavily used device resources - to avoid looking them up later"
  4587     "initialize heavily used device resources - to avoid looking them up later"
  4586 
  4588 
  4587     blackColor isNil ifTrue:[
  4589     blackColor isNil ifTrue:[
  4588         blackColor := Color black onDevice:self.
  4590 	blackColor := Color black onDevice:self.
  4589         whiteColor := Color white onDevice:self.
  4591 	whiteColor := Color white onDevice:self.
  4590         Color getPrimaryColorsOn:self.
  4592 	Color getPrimaryColorsOn:self.
  4591     ]
  4593     ]
  4592 
  4594 
  4593     "Modified: 24.2.1997 / 22:07:50 / cg"
  4595     "Modified: 24.2.1997 / 22:07:50 / cg"
       
  4596 !
       
  4597 
       
  4598 initializeDeviceSignals
       
  4599     deviceErrorSignal := DeviceErrorSignal newSignalMayProceed:false.
       
  4600     deviceErrorSignal nameClass:self message:#deviceErrorSignal.
       
  4601     deviceIOErrorSignal := DeviceIOErrorSignal newSignalMayProceed:false.
       
  4602     deviceIOErrorSignal nameClass:self message:#deviceIOErrorSignal.
  4594 !
  4603 !
  4595 
  4604 
  4596 initializeFor:aDisplayOrNilForAny
  4605 initializeFor:aDisplayOrNilForAny
  4597     "initialize the receiver for a connection to a display. If the
  4606     "initialize the receiver for a connection to a display. If the
  4598      argument is non-nil, it should specify which workstation should be
  4607      argument is non-nil, it should specify which workstation should be
  4669     lastId := nil.
  4678     lastId := nil.
  4670     lastView := nil.
  4679     lastView := nil.
  4671 
  4680 
  4672     self initializeFor:nil.
  4681     self initializeFor:nil.
  4673     displayId isNil ifTrue:[
  4682     displayId isNil ifTrue:[
  4674         'DevWorkstation [error]: could not connect to display' errorPrintCR.
  4683 	'DevWorkstation [error]: could not connect to display' errorPrintCR.
  4675         Smalltalk exit.
  4684 	Smalltalk exit.
  4676         ^ self
  4685 	^ self
  4677     ].
  4686     ].
  4678 
  4687 
  4679     "
  4688     "
  4680      first, all Forms must be recreated
  4689      first, all Forms must be recreated
  4681      (since they may be needed for view recreation as
  4690      (since they may be needed for view recreation as
  4683     "
  4692     "
  4684     Form reinitializeAllOn:self.
  4693     Form reinitializeAllOn:self.
  4685 
  4694 
  4686 "/    prevMapping notNil ifTrue:[
  4695 "/    prevMapping notNil ifTrue:[
  4687     prevKnownViews notNil ifTrue:[
  4696     prevKnownViews notNil ifTrue:[
  4688         "
  4697 	"
  4689          first round: flush all device specific stuff
  4698 	 first round: flush all device specific stuff
  4690         "
  4699 	"
  4691 "/      prevMapping keysAndValuesDo:[:anId :aView |
  4700 "/      prevMapping keysAndValuesDo:[:anId :aView |
  4692         prevKnownViews do:[:aView |
  4701 	prevKnownViews do:[:aView |
  4693             (aView notNil and:[aView ~~ 0]) ifTrue:[
  4702 	    (aView notNil and:[aView ~~ 0]) ifTrue:[
  4694                 aView prepareForReinit
  4703 		aView prepareForReinit
  4695             ]
  4704 	    ]
  4696         ].
  4705 	].
  4697 
  4706 
  4698         "
  4707 	"
  4699          2nd round: all views should reinstall themself
  4708 	 2nd round: all views should reinstall themself
  4700                     on the new display
  4709 		    on the new display
  4701         "
  4710 	"
  4702 "/      prevMapping keysAndValuesDo:[:anId :aView |
  4711 "/      prevMapping keysAndValuesDo:[:anId :aView |
  4703 
  4712 
  4704         prevKnownViews do:[:aView |
  4713 	prevKnownViews do:[:aView |
  4705             (aView notNil and:[aView ~~ 0]) ifTrue:[
  4714 	    (aView notNil and:[aView ~~ 0]) ifTrue:[
  4706                 "have to re-create the view"
  4715 		"have to re-create the view"
  4707                 UserInterruptSignal catch:[
  4716 		UserInterruptSignal catch:[
  4708                     AbortSignal catch:[
  4717 		    AbortSignal catch:[
  4709                         GraphicsContext drawingOnClosedDrawableSignal handle:[:ex |
  4718 			GraphicsContext drawingOnClosedDrawableSignal handle:[:ex |
  4710                             'DeviceWorkstation [warning]: drawing attempt on closed drawable during reinit' errorPrintCR.
  4719 			    'DeviceWorkstation [warning]: drawing attempt on closed drawable during reinit' errorPrintCR.
  4711                             ex return
  4720 			    ex return
  4712                         ] do:[
  4721 			] do:[
  4713                             aView reinitialize
  4722 			    aView reinitialize
  4714                         ]
  4723 			]
  4715                     ]
  4724 		    ]
  4716                 ]
  4725 		]
  4717             ]
  4726 	    ]
  4718         ].
  4727 	].
  4719 
  4728 
  4720         (prevWidth ~~ width
  4729 	(prevWidth ~~ width
  4721         or:[prevHeight ~~ height]) ifTrue:[
  4730 	or:[prevHeight ~~ height]) ifTrue:[
  4722             "
  4731 	    "
  4723              3rd round: all views get a chance to handle
  4732 	     3rd round: all views get a chance to handle
  4724                         changed environment (colors, font sizes etc)
  4733 			changed environment (colors, font sizes etc)
  4725             "
  4734 	    "
  4726 "/          prevMapping keysAndValuesDo:[:anId :aView |
  4735 "/          prevMapping keysAndValuesDo:[:anId :aView |
  4727             prevKnownViews do:[:aView |
  4736 	    prevKnownViews do:[:aView |
  4728                 (aView notNil and:[aView ~~ 0]) ifTrue:[
  4737 		(aView notNil and:[aView ~~ 0]) ifTrue:[
  4729                     aView reAdjustGeometry
  4738 		    aView reAdjustGeometry
  4730                 ]
  4739 		]
  4731             ].
  4740 	    ].
  4732         ]
  4741 	]
  4733     ].
  4742     ].
  4734     dispatching := false.
  4743     dispatching := false.
  4735 
  4744 
  4736     "Modified: / 7.6.1998 / 02:45:13 / cg"
  4745     "Modified: / 7.6.1998 / 02:45:13 / cg"
  4737 !
  4746 !
  5983     |index wasBlocked nV nI n dstIdx v id newSize|
  5992     |index wasBlocked nV nI n dstIdx v id newSize|
  5984 
  5993 
  5985     lastId := nil.
  5994     lastId := nil.
  5986     lastView := nil.
  5995     lastView := nil.
  5987     focusView == aView ifTrue:[
  5996     focusView == aView ifTrue:[
  5988         focusView := nil
  5997 	focusView := nil
  5989     ].
  5998     ].
  5990 
  5999 
  5991     knownViews notNil ifTrue:[
  6000     knownViews notNil ifTrue:[
  5992         wasBlocked := OperatingSystem blockInterrupts.
  6001 	wasBlocked := OperatingSystem blockInterrupts.
  5993 
  6002 
  5994         index := 0.
  6003 	index := 0.
  5995         aViewId notNil ifTrue:[
  6004 	aViewId notNil ifTrue:[
  5996             idToTableIndexMapping notNil ifTrue:[
  6005 	    idToTableIndexMapping notNil ifTrue:[
  5997                 index := idToTableIndexMapping at:aViewId ifAbsent:0.
  6006 		index := idToTableIndexMapping at:aViewId ifAbsent:0.
  5998             ]
  6007 	    ]
  5999         ].
  6008 	].
  6000         index == 0 ifTrue:[
  6009 	index == 0 ifTrue:[
  6001             aView notNil ifTrue:[
  6010 	    aView notNil ifTrue:[
  6002                 index := knownViews identityIndexOf:aView.
  6011 		index := knownViews identityIndexOf:aView.
  6003             ].
  6012 	    ].
  6004         ].
  6013 	].
  6005 
  6014 
  6006         index ~~ 0 ifTrue:[
  6015 	index ~~ 0 ifTrue:[
  6007             idToTableIndexMapping notNil ifTrue:[
  6016 	    idToTableIndexMapping notNil ifTrue:[
  6008                 aViewId notNil ifTrue:[
  6017 		aViewId notNil ifTrue:[
  6009                     idToTableIndexMapping removeKey:aViewId ifAbsent:nil
  6018 		    idToTableIndexMapping removeKey:aViewId ifAbsent:nil
  6010                 ] ifFalse:[
  6019 		] ifFalse:[
  6011                     id := knownIds at:index.
  6020 		    id := knownIds at:index.
  6012                     id notNil ifTrue:[
  6021 		    id notNil ifTrue:[
  6013                         idToTableIndexMapping removeKey:id ifAbsent:nil.
  6022 			idToTableIndexMapping removeKey:id ifAbsent:nil.
  6014                     ]
  6023 		    ]
  6015                 ]
  6024 		]
  6016             ].
  6025 	    ].
  6017             knownViews at:index put:nil.
  6026 	    knownViews at:index put:nil.
  6018             knownIds at:index put:nil.
  6027 	    knownIds at:index put:nil.
  6019             lastId := nil.
  6028 	    lastId := nil.
  6020             lastView := nil.
  6029 	    lastView := nil.
  6021         ].
  6030 	].
  6022 
  6031 
  6023         wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
  6032 	wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
  6024 
  6033 
  6025         aView notNil ifTrue:[
  6034 	aView notNil ifTrue:[
  6026             aView isTopView ifTrue:[
  6035 	    aView isTopView ifTrue:[
  6027                 "/ check for sparsely filled knownViews - array
  6036 		"/ check for sparsely filled knownViews - array
  6028                 wasBlocked := OperatingSystem blockInterrupts.
  6037 		wasBlocked := OperatingSystem blockInterrupts.
  6029                 n := 0.
  6038 		n := 0.
  6030                 knownViews do:[:v |
  6039 		knownViews do:[:v |
  6031                     (v notNil and:[v ~~ 0]) ifTrue:[
  6040 		    (v notNil and:[v ~~ 0]) ifTrue:[
  6032                         n := n + 1
  6041 			n := n + 1
  6033                     ].
  6042 		    ].
  6034                 ].
  6043 		].
  6035                 n < (knownViews size * 2 // 3) ifTrue:[
  6044 		n < (knownViews size * 2 // 3) ifTrue:[
  6036                     newSize := n * 3 // 2.
  6045 		    newSize := n * 3 // 2.
  6037                     newSize > 50 ifTrue:[
  6046 		    newSize > 50 ifTrue:[
  6038                         nV := WeakArray new:newSize.
  6047 			nV := WeakArray new:newSize.
  6039                         nI := Array new:newSize.
  6048 			nI := Array new:newSize.
  6040                         dstIdx := 1.
  6049 			dstIdx := 1.
  6041                         1 to:knownViews size do:[:srcIdx |
  6050 			1 to:knownViews size do:[:srcIdx |
  6042                             v := knownViews at:srcIdx.
  6051 			    v := knownViews at:srcIdx.
  6043                             (v notNil and:[v ~~ 0]) ifTrue:[
  6052 			    (v notNil and:[v ~~ 0]) ifTrue:[
  6044                                 nV at:dstIdx put:v.
  6053 				nV at:dstIdx put:v.
  6045                                 nI at:dstIdx put:(knownIds at:srcIdx).
  6054 				nI at:dstIdx put:(knownIds at:srcIdx).
  6046                                 dstIdx := dstIdx + 1.
  6055 				dstIdx := dstIdx + 1.
  6047                             ].
  6056 			    ].
  6048                         ].
  6057 			].
  6049                         idToTableIndexMapping := nil.
  6058 			idToTableIndexMapping := nil.
  6050                         knownViews := nV.
  6059 			knownViews := nV.
  6051                         knownIds := nI.
  6060 			knownIds := nI.
  6052                         idToTableIndexMapping := Dictionary new.
  6061 			idToTableIndexMapping := Dictionary new.
  6053                         knownIds keysAndValuesDo:[:idx :id |
  6062 			knownIds keysAndValuesDo:[:idx :id |
  6054                             id notNil ifTrue:[
  6063 			    id notNil ifTrue:[
  6055                                 idToTableIndexMapping at:id put:idx
  6064 				idToTableIndexMapping at:id put:idx
  6056                             ]
  6065 			    ]
  6057                         ].
  6066 			].
  6058                     ].
  6067 		    ].
  6059                 ].
  6068 		].
  6060                 wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
  6069 		wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
  6061             ].
  6070 	    ].
  6062         ].
  6071 	].
  6063         self checkForEndOfDispatch.
  6072 	self checkForEndOfDispatch.
  6064     ]
  6073     ]
  6065 
  6074 
  6066     "Created: 22.3.1997 / 14:56:20 / cg"
  6075     "Created: 22.3.1997 / 14:56:20 / cg"
  6067     "Modified: 27.3.1997 / 17:13:28 / cg"
  6076     "Modified: 27.3.1997 / 17:13:28 / cg"
  6068 !
  6077 !
  6470 ! !
  6479 ! !
  6471 
  6480 
  6472 !DeviceWorkstation class methodsFor:'documentation'!
  6481 !DeviceWorkstation class methodsFor:'documentation'!
  6473 
  6482 
  6474 version
  6483 version
  6475     ^ '$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.316 1999-08-21 18:05:39 cg Exp $'
  6484     ^ '$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.317 1999-08-23 12:00:58 cg Exp $'
  6476 ! !
  6485 ! !
  6477 DeviceWorkstation initialize!
  6486 DeviceWorkstation initialize!