DeviceWorkstation.st
changeset 1578 01db7f44cbbd
parent 1562 9a061e6942b9
child 1580 9a28ea48ec73
equal deleted inserted replaced
1577:3d8eedcc0ad8 1578:01db7f44cbbd
     1 "
     1 "
     2 COPYRIGHT (c) 1993 by Claus Gittinger
     2 COPYRIGHT (c) 1993 by Claus Gittinger
     3               All Rights Reserved
     3 	      All Rights Reserved
     4 
     4 
     5  This software is furnished under a license and may be used
     5  This software is furnished under a license and may be used
     6  only in accordance with the terms of that license and with the
     6  only in accordance with the terms of that license and with the
     7  inclusion of the above copyright notice.   This software may not
     7  inclusion of the above copyright notice.   This software may not
     8  be provided or otherwise made available to, or used by, any
     8  be provided or otherwise made available to, or used by, any
    22 		altModifiers metaModifiers ctrlModifiers shiftModifiers
    22 		altModifiers metaModifiers ctrlModifiers shiftModifiers
    23 		supportsDeepIcons preferredIconSize ditherColors fixColors
    23 		supportsDeepIcons preferredIconSize ditherColors fixColors
    24 		numFixRed numFixGreen numFixBlue copyBuffer lastCopyBuffer
    24 		numFixRed numFixGreen numFixBlue copyBuffer lastCopyBuffer
    25 		blackColor whiteColor'
    25 		blackColor whiteColor'
    26 	classVariableNames:'ButtonTranslation MultiClickTimeDelta DeviceErrorSignal
    26 	classVariableNames:'ButtonTranslation MultiClickTimeDelta DeviceErrorSignal
    27 		ErrorPrinting DefaultScreen AllScreens ExitOnLastClose
    27 		DeviceIOErrorSignal ErrorPrinting DefaultScreen AllScreens ExitOnLastClose
    28 		CurrentScreenQuerySignal LastActiveScreen LastActiveProcess'
    28 		CurrentScreenQuerySignal LastActiveScreen LastActiveProcess'
    29 	poolDictionaries:''
    29 	poolDictionaries:''
    30 	category:'Interface-Graphics'
    30 	category:'Interface-Graphics'
    31 !
    31 !
    32 
    32 
    33 !DeviceWorkstation class methodsFor:'documentation'!
    33 !DeviceWorkstation class methodsFor:'documentation'!
    34 
    34 
    35 copyright
    35 copyright
    36 "
    36 "
    37 COPYRIGHT (c) 1993 by Claus Gittinger
    37 COPYRIGHT (c) 1993 by Claus Gittinger
    38               All Rights Reserved
    38 	      All Rights Reserved
    39 
    39 
    40  This software is furnished under a license and may be used
    40  This software is furnished under a license and may be used
    41  only in accordance with the terms of that license and with the
    41  only in accordance with the terms of that license and with the
    42  inclusion of the above copyright notice.   This software may not
    42  inclusion of the above copyright notice.   This software may not
    43  be provided or otherwise made available to, or used by, any
    43  be provided or otherwise made available to, or used by, any
    64       monitorType     <Symbol>          one of #monochrome, #color, #unknown
    64       monitorType     <Symbol>          one of #monochrome, #color, #unknown
    65 
    65 
    66       depth           <SmallInteger>    bits per color
    66       depth           <SmallInteger>    bits per color
    67       ncells          <SmallInteger>    number of colors (i.e. colormap size; not always == 2^depth)
    67       ncells          <SmallInteger>    number of colors (i.e. colormap size; not always == 2^depth)
    68       bitsPerRGB      <SmallInteger>    number of valid bits per rgb component
    68       bitsPerRGB      <SmallInteger>    number of valid bits per rgb component
    69                                         (actual number taken in A/D converter; not all devices report the true value)
    69 					(actual number taken in A/D converter; not all devices report the true value)
    70       bitsRed         <SmallInteger>    number of red bits (only valid for TrueColor displays)
    70       bitsRed         <SmallInteger>    number of red bits (only valid for TrueColor displays)
    71       bitsGreen       <SmallInteger>    number of green bits (only valid for TrueColor displays)
    71       bitsGreen       <SmallInteger>    number of green bits (only valid for TrueColor displays)
    72       bitsBlue        <SmallInteger>    number of blue bits (only valid for TrueColor displays)
    72       bitsBlue        <SmallInteger>    number of blue bits (only valid for TrueColor displays)
    73       redMask         <SmallInteger>    shifted red mask (only useful for TrueColor displays)
    73       redMask         <SmallInteger>    shifted red mask (only useful for TrueColor displays)
    74       greenMask       <SmallInteger>    shifted green mask (only useful for TrueColor displays)
    74       greenMask       <SmallInteger>    shifted green mask (only useful for TrueColor displays)
    98       shiftDown       <Boolean>         true, if shift key currently pressed
    98       shiftDown       <Boolean>         true, if shift key currently pressed
    99       metaDown        <Boolean>         true, if meta key (cmd-key) is currently pressed
    99       metaDown        <Boolean>         true, if meta key (cmd-key) is currently pressed
   100       altDown         <Boolean>         true, if alt key is currently pressed
   100       altDown         <Boolean>         true, if alt key is currently pressed
   101 
   101 
   102       motionEventCompression
   102       motionEventCompression
   103                       <Boolean>         if true motion events are compressed
   103 		      <Boolean>         if true motion events are compressed
   104                                         (obsolete: now done in sensor)
   104 					(obsolete: now done in sensor)
   105 
   105 
   106       lastId          <Number>          the id of the last events view (internal)
   106       lastId          <Number>          the id of the last events view (internal)
   107       lastView        <View>            the last events view (internal, for faster id->view mapping)
   107       lastView        <View>            the last events view (internal, for faster id->view mapping)
   108 
   108 
   109       keyboardMap     <KeyBdMap>        mapping for keys
   109       keyboardMap     <KeyBdMap>        mapping for keys
   110       rootView        <DisplayRootView> this displays root window
   110       rootView        <DisplayRootView> this displays root window
   111       isSlow          <Boolean>         set/cleared from startup - used to turn off
   111       isSlow          <Boolean>         set/cleared from startup - used to turn off
   112                                         things like popup-shadows etc.
   112 					things like popup-shadows etc.
   113 
   113 
   114     [class variables:]
   114     [class variables:]
   115 
   115 
   116       MultiClickTimeDelta               in ms; controls how long of a delay is
   116       MultiClickTimeDelta               in ms; controls how long of a delay is
   117                                         required between two clicks, to NOT take
   117 					required between two clicks, to NOT take
   118                                         it as a multi-click.
   118 					it as a multi-click.
   119 
   119 
   120       ErrorPrinting                     controls low-level (X-) error message printing
   120       ErrorPrinting                     controls low-level (X-) error message printing
   121 
   121 
   122       AllScreens                        a collectin of known screens
   122       AllScreens                        a collectin of known screens
   123 
   123 
   124       ExitOnLastClose                   if true, the dispatch process terminates when the
   124       ExitOnLastClose                   if true, the dispatch process terminates when the
   125                                         last view is closed. (for stand alone apps)
   125 					last view is closed. (for stand alone apps)
   126                                         Should be set to false, if a standAlone app
   126 					Should be set to false, if a standAlone app
   127                                         closes all views and still needs an event dispatcher
   127 					closes all views and still needs an event dispatcher
   128                                         later (i.e. is temporary view-less)
   128 					later (i.e. is temporary view-less)
   129 
   129 
   130     [see also:]
   130     [see also:]
   131         GraphicsContext DeviceDrawable
   131 	GraphicsContext DeviceDrawable
   132         WindowSensor WindowGroup WindowEvent
   132 	WindowSensor WindowGroup WindowEvent
   133         ProcessorScheduler
   133 	ProcessorScheduler
   134         PSMedium
   134 	PSMedium
   135 
   135 
   136     [author:]
   136     [author:]
   137         Claus Gittinger
   137 	Claus Gittinger
   138 "
   138 "
   139 !
   139 !
   140 
   140 
   141 events
   141 events
   142 "
   142 "
   155     and CTRL-C handling to be performed even while other processes are running.
   155     and CTRL-C handling to be performed even while other processes are running.
   156     The code executed by the event process is found in startDispatch.
   156     The code executed by the event process is found in startDispatch.
   157 
   157 
   158     Individual events can be enabled or disabled. The ones that are enabled
   158     Individual events can be enabled or disabled. The ones that are enabled
   159     by default are:
   159     by default are:
   160         keypress / keyRelease
   160 	keypress / keyRelease
   161         buttonPress / buttonRelease / buttonMotion (i.e. motion with button pressed)
   161 	buttonPress / buttonRelease / buttonMotion (i.e. motion with button pressed)
   162         pointerEnter / pointerLeave
   162 	pointerEnter / pointerLeave
   163 
   163 
   164     other events have to be enabled by sending a corresponding #enableXXXEvent
   164     other events have to be enabled by sending a corresponding #enableXXXEvent
   165     message to the view which shall receive those events.
   165     message to the view which shall receive those events.
   166     For example, pointerMotion events (i.e. motion without button being pressed)
   166     For example, pointerMotion events (i.e. motion without button being pressed)
   167     are enabled by: 'aView enableMotionEvent'
   167     are enabled by: 'aView enableMotionEvent'
   182     this is the default graphics display, on which new views are created
   182     this is the default graphics display, on which new views are created
   183     (however, provisions exist for multi-display operation)
   183     (however, provisions exist for multi-display operation)
   184 
   184 
   185     Currently, there is are only two concrete display classes (released to the public):
   185     Currently, there is are only two concrete display classes (released to the public):
   186 
   186 
   187         XWorkstation    - a plain X window interface
   187 	XWorkstation    - a plain X window interface
   188 
   188 
   189         GLXWorkstation  - an X window interface with a GL(tm) (3D graphic library) 
   189 	GLXWorkstation  - an X window interface with a GL(tm) (3D graphic library) 
   190                           extension; either simulated (VGL) or a real GL 
   190 			  extension; either simulated (VGL) or a real GL 
   191                           (real GL is only available on SGI machines)
   191 			  (real GL is only available on SGI machines)
   192 
   192 
   193     the following are coming soon:
   193     the following are coming soon:
   194 
   194 
   195         OpenGLWorkstation   
   195 	OpenGLWorkstation   
   196                         - an X window interface with a openGL(tm) (3D graphic library) 
   196 			- an X window interface with a openGL(tm) (3D graphic library) 
   197                           extension; either simulated (MESA) or a real openGL 
   197 			  extension; either simulated (MESA) or a real openGL 
   198                           (real openGL is only available on SGI/NT machines)
   198 			  (real openGL is only available on SGI/NT machines)
   199 
   199 
   200         WinWorkstation  - what will that be ?
   200 	WinWorkstation  - what will that be ?
   201 
   201 
   202     An experimental version for a NeXTStep interface exists, but is currently
   202     An experimental version for a NeXTStep interface exists, but is currently
   203     no longer maintained and not released.
   203     no longer maintained and not released.
   204     Also, interfaces for other graphic systems (i.e. OS/2) are
   204     Also, interfaces for other graphic systems (i.e. OS/2) are
   205     planned for and will be available (hopefully) in late 96.
   205     planned for and will be available (hopefully) in late 96.
   217     This does not work with other devices (i.e. Windows).
   217     This does not work with other devices (i.e. Windows).
   218 
   218 
   219     If you want to experiment with multi-display applications,
   219     If you want to experiment with multi-display applications,
   220     you have to:
   220     you have to:
   221 
   221 
   222         - create a new instance of XWorkstation:
   222 	- create a new instance of XWorkstation:
   223 
   223 
   224             Smalltalk at:#Display2 put:(XWorkstation new).
   224 	    Smalltalk at:#Display2 put:(XWorkstation new).
   225           or:
   225 	  or:
   226             Smalltalk at:#Display2 put:(GLXWorkstation new).
   226 	    Smalltalk at:#Display2 put:(GLXWorkstation new).
   227 
   227 
   228 
   228 
   229         - have it connect to the display (i.e. the xServer):
   229 	- have it connect to the display (i.e. the xServer):
   230           (replace 'localhost' below with the name of your display)
   230 	  (replace 'localhost' below with the name of your display)
   231 
   231 
   232             Display2 := Display2 initializeFor:'localhost:0.0'
   232 	    Display2 := Display2 initializeFor:'localhost:0.0'
   233 
   233 
   234           returns nil, if connection is refused 
   234 	  returns nil, if connection is refused 
   235           - leaving you with Display2==nil in this case.
   235 	  - leaving you with Display2==nil in this case.
   236 
   236 
   237 
   237 
   238         - start an event dispatcher process for it:
   238 	- start an event dispatcher process for it:
   239           (this is now no longer needed - the first opened view will do it for you)
   239 	  (this is now no longer needed - the first opened view will do it for you)
   240 
   240 
   241             Display2 startDispatch
   241 	    Display2 startDispatch
   242 
   242 
   243 
   243 
   244         - optionally set its keyboard map
   244 	- optionally set its keyboard map
   245           (since this is usually done for Display in the startup-file,
   245 	  (since this is usually done for Display in the startup-file,
   246            the new display does not have all your added key bindings)
   246 	   the new display does not have all your added key bindings)
   247 
   247 
   248             Display2 keyboardMap:(Display keyboardMap)
   248 	    Display2 keyboardMap:(Display keyboardMap)
   249 
   249 
   250 
   250 
   251         - create a view for it:
   251 	- create a view for it:
   252 
   252 
   253             (FileBrowser onDevice:Display2) open
   253 	    (FileBrowser onDevice:Display2) open
   254 
   254 
   255             (Workspace onDevice:Display2) open
   255 	    (Workspace onDevice:Display2) open
   256 
   256 
   257             (Launcher onDevice:Display2) open
   257 	    (Launcher onDevice:Display2) open
   258                 does not work with Launcher, since its an ApplicationModel (not a view)
   258 		does not work with Launcher, since its an ApplicationModel (not a view)
   259                 use:
   259 		use:
   260                     Launcher openOnDevice:Display2
   260 		    Launcher openOnDevice:Display2
   261                 instead.
   261 		instead.
   262 
   262 
   263     However, as mentioned above, there may be a few places, where the default
   263     However, as mentioned above, there may be a few places, where the default
   264     display 'Display' is still hard-coded - especially, in contributed and
   264     display 'Display' is still hard-coded - especially, in contributed and
   265     Public domain code, you may find those.
   265     Public domain code, you may find those.
   266 
   266 
   291 
   291 
   292 initialize
   292 initialize
   293     "create local error signals; enable errorPrinting"
   293     "create local error signals; enable errorPrinting"
   294 
   294 
   295     DeviceErrorSignal isNil ifTrue:[
   295     DeviceErrorSignal isNil ifTrue:[
   296         DeviceErrorSignal := (Signal new) mayProceed:true.
   296 	DeviceErrorSignal := (Signal new) mayProceed:true.
   297         DeviceErrorSignal notifierString:'device error'.
   297 	DeviceErrorSignal notifierString:'device error'.
   298 
   298 
   299         CurrentScreenQuerySignal := QuerySignal new.
   299 	DeviceIOErrorSignal := (Signal new) mayProceed:false.
   300         CurrentScreenQuerySignal nameClass:self message:#currentScreenQuerySignal.
   300 	DeviceIOErrorSignal notifierString:'device IO error'.
   301         CurrentScreenQuerySignal notifierString:'asking for current screen'.
   301 
       
   302 	CurrentScreenQuerySignal := QuerySignal new.
       
   303 	CurrentScreenQuerySignal nameClass:self message:#currentScreenQuerySignal.
       
   304 	CurrentScreenQuerySignal notifierString:'asking for current screen'.
   302     ].
   305     ].
   303     ErrorPrinting := true.
   306     ErrorPrinting := true.
   304     ExitOnLastClose := false.
   307     ExitOnLastClose := false.
   305 
   308 
   306     self initializeConstants.
   309     self initializeConstants.
   325 
   328 
   326     "Created: 15.2.1997 / 15:07:20 / cg"
   329     "Created: 15.2.1997 / 15:07:20 / cg"
   327 !
   330 !
   328 
   331 
   329 deviceErrorSignal
   332 deviceErrorSignal
   330     "return the signal used for device error reporting"
   333     "return the signal used for device error reporting.
       
   334      In multi-display configurations, this is the parent of
       
   335      all per-instance deviceErrorSignals."
   331 
   336 
   332     ^ DeviceErrorSignal
   337     ^ DeviceErrorSignal
       
   338 !
       
   339 
       
   340 deviceIOErrorSignal
       
   341     "return the signal used for device I/O error reporting.
       
   342      In multi-display configurations, this is the parent of
       
   343      all per-instance deviceIOErrorSignals."
       
   344 
       
   345     ^ DeviceIOErrorSignal
       
   346 ! !
       
   347 
       
   348 !DeviceWorkstation methodsFor:'Signal constants'!
       
   349 
       
   350 deviceErrorSignal
       
   351     "return the per-device signal, which is used for error reporting.
       
   352      The default here is the global DeviceErrorSignal (which is the
       
   353      parent of the per-instance signals)."
       
   354 
       
   355     ^ self class deviceErrorSignal
       
   356 !
       
   357 
       
   358 deviceIOErrorSignal
       
   359     "return the signal used for device I/O error reporting.
       
   360      The default here is the global DeviceIOErrorSignal (which is the
       
   361      parent of the per-instance signals)."
       
   362 
       
   363     ^ self class deviceIOErrorSignal
   333 ! !
   364 ! !
   334 
   365 
   335 !DeviceWorkstation class methodsFor:'accessing'!
   366 !DeviceWorkstation class methodsFor:'accessing'!
   336 
   367 
   337 buttonTranslation:anArray
   368 buttonTranslation:anArray
   338     "set the button translation, #(1 2 3) is no-translation,
   369     "set the button translation, #(1 2 3) is no-translation,
   339      #(3 2 1) is ok for left-handers"
   370      #(3 2 1) is ok for left-handers"
   340 
   371 
   341     ButtonTranslation := anArray.
   372     ButtonTranslation := anArray.
   342     Display notNil ifTrue:[
   373     Display notNil ifTrue:[
   343         Display buttonTranslation:anArray
   374 	Display buttonTranslation:anArray
   344     ].
   375     ].
   345 ! !
   376 ! !
   346 
   377 
   347 !DeviceWorkstation class methodsFor:'error handling'!
   378 !DeviceWorkstation class methodsFor:'error handling'!
   348 
   379 
   349 errorInterrupt:errID with:aParameter
   380 errorInterrupt:errID with:aParameter
   350     "{ Pragma: +optSpace }"
   381     "{ Pragma: +optSpace }"
   351 
   382 
   352     "an error in the devices low level code (typically Xlib or XtLib)
   383     "an error in the devices low level code (typically Xlib or XtLib)
   353      This is invoked via 
   384      This is invoked via 
   354         XError->errorInterrupt:#DisplayError->registeredErrorInterruptHandlers
   385 	XError->errorInterrupt:#DisplayError->registeredErrorInterruptHandlers
       
   386      or
       
   387 	XError->errorInterrupt:#DisplayIOError->registeredErrorInterruptHandlers
   355 
   388 
   356      looks if a signal handler for DeviceErrorSignal is present,
   389      looks if a signal handler for DeviceErrorSignal is present,
   357      and - if so raises the signal. If the signal not handled, simply output a
   390      and - if so raises the signal. 
   358      message and continue.
   391      If the signal not handled, simply output a message and continue.
   359      This allows for non disrupted error reporting OR to catch and
   392      This allows for non disrupted error reporting OR to catch and
   360      investigate errors as required."
   393      investigate errors as required.
   361 
   394      However, io-errors are always delivered as a signal raise."
   362     |badId badResource msg|
   395 
   363 
   396     |badId badResource msg theDevice theSignal p|
   364     badId := self resourceIdOfLastError.
   397 
   365     badId ~~ 0 ifTrue:[
   398     errID notNil ifTrue:[
   366         badResource := self resourceOfId:badId.
   399 	AllScreens do:[:aDisplayDevice |
   367     ].
   400 	    aDisplayDevice id = aParameter ifTrue:[
   368     msg := 'Display error: ' , (self lastErrorString).
   401 		theDevice := aDisplayDevice.
   369 
   402 	    ]
   370     DeviceErrorSignal isHandled ifFalse:[
   403 	]
   371         ErrorPrinting ifTrue:[
   404     ].
   372             ('DeviceWorkstation [error]: ' , msg) errorPrintCR
   405 
   373         ].
   406     "/ now, we have the bad guy at hand ...
   374         ^ self
   407     "/ get a per-instance signal.
   375     ].
   408 
   376 
   409     theDevice isNil ifTrue:[
   377     ^ DeviceErrorSignal
   410 	errID == #DisplayIOError ifTrue:[
   378             raiseRequestWith:badResource 
   411 	    theSignal := self deviceIOErrorSignal.
   379             errorString:msg
   412 	] ifFalse:[
   380 
   413 	    theSignal := self deviceErrorSignal
   381     "Modified: 10.1.1997 / 17:48:06 / cg"
   414 	]
       
   415     ] ifFalse:[
       
   416 	errID == #DisplayIOError ifTrue:[
       
   417 	    theSignal := theDevice deviceIOErrorSignal.
       
   418 	] ifFalse:[
       
   419 	    theSignal := theDevice deviceErrorSignal
       
   420 	]
       
   421     ].
       
   422 
       
   423     errID == #DisplayIOError ifTrue:[
       
   424 	"/ always raises an exception
       
   425 	msg := 'Display I/O Error'.
       
   426 	badResource := theDevice.
       
   427     ] ifFalse:[
       
   428 	"/ only raises an exception if handled
       
   429 
       
   430 	"/ that will become instance-specific information in
       
   431 	"/ the near future ...
       
   432 
       
   433 	badId := self resourceIdOfLastError.
       
   434 	badId ~~ 0 ifTrue:[
       
   435 	    badResource := self resourceOfId:badId.
       
   436 	].
       
   437 	msg := 'Display error: ' , (self lastErrorString).
       
   438 
       
   439 	theSignal isHandled ifFalse:[
       
   440 	    ErrorPrinting ifTrue:[
       
   441 		('DeviceWorkstation [error]: ' , msg) errorPrintCR
       
   442 	    ].
       
   443 	    ^ self
       
   444 	]
       
   445     ].
       
   446 
       
   447     "/ interrupt that dispatcher
       
   448     theDevice notNil ifTrue:[
       
   449 	p := theDevice dispatchProcess.
       
   450 	p ~~ Processor activeProcess ifTrue:[
       
   451 'interrupting: ' print. p displayString printCR.
       
   452 	    p interruptWith:[
       
   453 		theDevice brokenConnection.
       
   454 
       
   455 		theSignal 
       
   456 		    raiseRequestWith:badResource
       
   457 		    errorString:msg.
       
   458 		p terminateWithAllSubprocesses.
       
   459 		p terminateNoSignal.   "/ just in case
       
   460 	    ].
       
   461 	    Processor reschedule.
       
   462 	    AbortSignal raise.
       
   463 	].
       
   464     ].
       
   465 
       
   466     theDevice brokenConnection.
       
   467     theSignal
       
   468 	raiseRequestWith:badResource 
       
   469 	errorString:msg.
       
   470 
       
   471     AbortSignal raise.
       
   472 
       
   473     "Modified: 11.4.1997 / 11:28:27 / cg"
   382 !
   474 !
   383 
   475 
   384 errorPrinting
   476 errorPrinting
   385     "return the `errorPrinting-is-on' flag"
   477     "return the `errorPrinting-is-on' flag"
   386 
   478 
   415 
   507 
   416     "search thru all device stuff for a resource.
   508     "search thru all device stuff for a resource.
   417      Needed for error handling"
   509      Needed for error handling"
   418 
   510 
   419     Form allInstances do:[:f |
   511     Form allInstances do:[:f |
   420         f id == id ifTrue:[^ f]
   512 	f id == id ifTrue:[^ f]
   421     ].
   513     ].
   422 
   514 
   423     self allInstances do:[:aDisplay |
   515     self allInstances do:[:aDisplay |
   424         aDisplay allViewsDo:[:aView |
   516 	aDisplay allViewsDo:[:aView |
   425             aView id == id ifTrue:[^ aView].
   517 	    aView id == id ifTrue:[^ aView].
   426             aView gcId == id ifTrue:[^ aView]
   518 	    aView gcId == id ifTrue:[^ aView]
   427         ].
   519 	].
   428 
   520 
   429 "/        |views|
   521 "/        |views|
   430 "/        views := aDisplay knownViews.
   522 "/        views := aDisplay knownViews.
   431 "/        views notNil ifTrue:[
   523 "/        views notNil ifTrue:[
   432 "/            views do:[:v |
   524 "/            views do:[:v |
   435 "/            ].
   527 "/            ].
   436 "/        ].
   528 "/        ].
   437     ].
   529     ].
   438 
   530 
   439     Color allInstances do:[:c |
   531     Color allInstances do:[:c |
   440         c colorId == id ifTrue:[^ c]
   532 	c colorId == id ifTrue:[^ c]
   441     ].
   533     ].
   442 
   534 
   443     Font allInstances do:[:f |
   535     Font allInstances do:[:f |
   444         f fontId == id ifTrue:[^ f]
   536 	f fontId == id ifTrue:[^ f]
   445     ].
   537     ].
   446     ^ nil
   538     ^ nil
   447 
   539 
   448     "Modified: 24.4.1996 / 19:36:15 / cg"
   540     "Modified: 24.4.1996 / 19:36:15 / cg"
   449 ! !
   541 ! !
   477     "/
   569     "/
   478     "/ if there is only one screen,
   570     "/ if there is only one screen,
   479     "/ take that ... it ought to be display
   571     "/ take that ... it ought to be display
   480     "/
   572     "/
   481     AllScreens size <= 1 ifTrue:[
   573     AllScreens size <= 1 ifTrue:[
   482         ^ Display
   574 	^ Display
   483     ].
   575     ].
   484 
   576 
   485     "/
   577     "/
   486     "/ someone willing to tell me ?
   578     "/ someone willing to tell me ?
   487     "/
   579     "/
   488     (dev := CurrentScreenQuerySignal raise) notNil ifTrue:[
   580     (dev := CurrentScreenQuerySignal raise) notNil ifTrue:[
   489         ^ dev
   581 	^ dev
   490     ].
   582     ].
   491 
   583 
   492     thisProcess := Processor activeProcess.
   584     thisProcess := Processor activeProcess.
   493     LastActiveScreen notNil ifTrue:[
   585     LastActiveScreen notNil ifTrue:[
   494         LastActiveProcess == thisProcess ifTrue:[
   586 	LastActiveProcess == thisProcess ifTrue:[
   495             ^ LastActiveScreen
   587 	    ^ LastActiveScreen
   496         ]
   588 	]
   497     ].
   589     ].
   498 
   590 
   499     "/
   591     "/
   500     "/ mhmh - multiple screens are active;
   592     "/ mhmh - multiple screens are active;
   501     "/ look for the active windowGroups screen.
   593     "/ look for the active windowGroups screen.
   502     "/ Be careful, to not run into an error in case
   594     "/ Be careful, to not run into an error in case
   503     "/ the current windowGroup got corrupted somehow ...
   595     "/ the current windowGroup got corrupted somehow ...
   504 
   596 
   505     (wg := WindowGroup activeGroup) notNil ifTrue:[
   597     (wg := WindowGroup activeGroup) notNil ifTrue:[
   506         "/
   598 	"/
   507         "/ ok, not a background process or scheduler ...
   599 	"/ ok, not a background process or scheduler ...
   508         "/
   600 	"/
   509         (dev := wg graphicsDevice) notNil ifTrue:[
   601 	(dev := wg graphicsDevice) notNil ifTrue:[
   510             LastActiveScreen := dev.
   602 	    LastActiveScreen := dev.
   511             LastActiveProcess := thisProcess.
   603 	    LastActiveProcess := thisProcess.
   512             ^ dev
   604 	    ^ dev
   513         ].
   605 	].
   514     ].
   606     ].
   515 
   607 
   516     "/
   608     "/
   517     "/ in all other cases, return the default display
   609     "/ in all other cases, return the default display
   518     "/
   610     "/
   580 
   672 
   581 zoom:startRect to:endRect
   673 zoom:startRect to:endRect
   582     "animate a rubber-rectangle from startRect to endRect.
   674     "animate a rubber-rectangle from startRect to endRect.
   583      Can be used by buttons, which open some dialog for nicer user feedback.
   675      Can be used by buttons, which open some dialog for nicer user feedback.
   584      Notice: since the displays window manager typically allows a topWindow
   676      Notice: since the displays window manager typically allows a topWindow
   585              to be placed by the user, this should not be used for modeless
   677 	     to be placed by the user, this should not be used for modeless
   586              topViews.
   678 	     topViews.
   587     "
   679     "
   588 
   680 
   589     ^ self 
   681     ^ self 
   590         zoom:startRect to:endRect duration:0.3    
   682 	zoom:startRect to:endRect duration:0.3    
   591 
   683 
   592     "
   684     "
   593      Screen current zoom:(10@10 corner:20@20) to:(20@20 corner:1000@1000)
   685      Screen current zoom:(10@10 corner:20@20) to:(20@20 corner:1000@1000)
   594      Screen current zoom:(20@20 corner:1000@1000) to:(10@10 corner:20@20)
   686      Screen current zoom:(20@20 corner:1000@1000) to:(10@10 corner:20@20)
   595     "
   687     "
   599 
   691 
   600 zoom:startRect to:endRect duration:milliseconds
   692 zoom:startRect to:endRect duration:milliseconds
   601     "animate a rubber-rectangle from startRect to endRect.
   693     "animate a rubber-rectangle from startRect to endRect.
   602      Can be used by buttons, which open some dialog for nicer user feedback.
   694      Can be used by buttons, which open some dialog for nicer user feedback.
   603      Notice: since the displays window manager typically allows a topWindow
   695      Notice: since the displays window manager typically allows a topWindow
   604              to be placed by the user, this should not be used for modeless
   696 	     to be placed by the user, this should not be used for modeless
   605              topViews.
   697 	     topViews.
   606     "
   698     "
   607 
   699 
   608     |steps dExt dOrg org ext root|
   700     |steps dExt dOrg org ext root|
   609 
   701 
   610     root := self rootView.
   702     root := self rootView.
   611 
   703 
   612     steps := 10.
   704     steps := 10.
   613     dExt := (endRect extent - startRect extent) / steps.
   705     dExt := (endRect extent - startRect extent) / steps.
   614     dOrg := (endRect origin - startRect origin) / steps.
   706     dOrg := (endRect origin - startRect origin) / steps.
   615     0 to:steps do:[:step |
   707     0 to:steps do:[:step |
   616         org := (startRect origin + (dOrg * step)) rounded.
   708 	org := (startRect origin + (dOrg * step)) rounded.
   617         ext := (startRect extent + (dExt * step)) rounded.
   709 	ext := (startRect extent + (dExt * step)) rounded.
   618         rootView clippedByChildren:false.
   710 	rootView clippedByChildren:false.
   619         rootView xoring:[
   711 	rootView xoring:[
   620             rootView displayRectangleX:org x y:org y width:ext x height:ext y
   712 	    rootView displayRectangleX:org x y:org y width:ext x height:ext y
   621         ].
   713 	].
   622         Delay waitForMilliseconds:(milliseconds // steps).
   714 	Delay waitForMilliseconds:(milliseconds // steps).
   623         rootView xoring:[
   715 	rootView xoring:[
   624             rootView displayRectangleX:org x y:org y width:ext x height:ext y
   716 	    rootView displayRectangleX:org x y:org y width:ext x height:ext y
   625         ].
   717 	].
   626     ].
   718     ].
   627     rootView clippedByChildren:true.
   719     rootView clippedByChildren:true.
   628 
   720 
   629     "
   721     "
   630      Screen current zoom:(10@10 corner:20@20) to:(20@20 corner:1000@1000) duration:1000
   722      Screen current zoom:(10@10 corner:20@20) to:(20@20 corner:1000@1000) duration:1000
   637 zoom:startRect to:endRect speed:pixelsPerSecond
   729 zoom:startRect to:endRect speed:pixelsPerSecond
   638     "animate a rubber-rectangle from startRect to endRect.
   730     "animate a rubber-rectangle from startRect to endRect.
   639      Can be used by buttons, which open some dialog for nicer user feedback.
   731      Can be used by buttons, which open some dialog for nicer user feedback.
   640      The speed is computed for the longest edge to run at the given speed.
   732      The speed is computed for the longest edge to run at the given speed.
   641      Notice: since the displays window manager typically allows a topWindow
   733      Notice: since the displays window manager typically allows a topWindow
   642              to be placed by the user, this should not be used for modeless
   734 	     to be placed by the user, this should not be used for modeless
   643              topViews.
   735 	     topViews.
   644     "
   736     "
   645 
   737 
   646     |maxDistance|
   738     |maxDistance|
   647 
   739 
   648     maxDistance := (endRect origin - startRect origin).
   740     maxDistance := (endRect origin - startRect origin).
   650     maxDistance := maxDistance max:(endRect bottomLeft - startRect bottomLeft).
   742     maxDistance := maxDistance max:(endRect bottomLeft - startRect bottomLeft).
   651     maxDistance := maxDistance max:(endRect corner - startRect corner).
   743     maxDistance := maxDistance max:(endRect corner - startRect corner).
   652     maxDistance := maxDistance x max:(maxDistance y).
   744     maxDistance := maxDistance x max:(maxDistance y).
   653 
   745 
   654     ^ self
   746     ^ self
   655         zoom:startRect to:endRect duration:(maxDistance / pixelsPerSecond * 1000)       
   747 	zoom:startRect to:endRect duration:(maxDistance / pixelsPerSecond * 1000)       
   656 
   748 
   657     "
   749     "
   658      Screen current zoom:(10@10 corner:20@20) to:(20@20 corner:1000@1000) speed:1000
   750      Screen current zoom:(10@10 corner:20@20) to:(20@20 corner:1000@1000) speed:1000
   659      Screen current zoom:(20@20 corner:1000@1000) to:(10@10 corner:20@20) speed:2000
   751      Screen current zoom:(20@20 corner:1000@1000) to:(10@10 corner:20@20) speed:2000
   660     "
   752     "
   671 
   763 
   672     |buttonNr|
   764     |buttonNr|
   673 
   765 
   674     "reverse buttonTranslation"
   766     "reverse buttonTranslation"
   675     buttonTranslation notNil ifTrue:[
   767     buttonTranslation notNil ifTrue:[
   676         buttonNr := buttonTranslation indexOf:aButton ifAbsent:[1].
   768 	buttonNr := buttonTranslation indexOf:aButton ifAbsent:[1].
   677     ] ifFalse:[
   769     ] ifFalse:[
   678         buttonNr := aButton.
   770 	buttonNr := aButton.
   679     ].
   771     ].
   680     ^ (aMask bitTest:(self buttonMotionMask:buttonNr))
   772     ^ (aMask bitTest:(self buttonMotionMask:buttonNr))
   681 !
   773 !
   682 
   774 
   683 dispatchProcess
   775 dispatchProcess
   737 rootView
   829 rootView
   738     "return the rootView (i.e. the background window) on the receiver screen.
   830     "return the rootView (i.e. the background window) on the receiver screen.
   739      It is not guaranteed, that a particular display device supports this."
   831      It is not guaranteed, that a particular display device supports this."
   740 
   832 
   741     rootView isNil ifTrue:[
   833     rootView isNil ifTrue:[
   742         rootView := DisplayRootView onDevice:self
   834 	rootView := DisplayRootView onDevice:self
   743     ].
   835     ].
   744     ^ rootView
   836     ^ rootView
   745 
   837 
   746     "
   838     "
   747      |v|
   839      |v|
   815 
   907 
   816     |id searchId foundId|
   908     |id searchId foundId|
   817 
   909 
   818     searchId := self rootWindowId.
   910     searchId := self rootWindowId.
   819     [searchId notNil] whileTrue:[
   911     [searchId notNil] whileTrue:[
   820         id := self viewIdFromPoint:aPoint in:searchId.
   912 	id := self viewIdFromPoint:aPoint in:searchId.
   821         foundId := searchId.
   913 	foundId := searchId.
   822         searchId := id
   914 	searchId := id
   823     ].
   915     ].
   824     ^ foundId
   916     ^ foundId
   825 !
   917 !
   826 
   918 
   827 viewIdFromPoint:aPoint in:windowId
   919 viewIdFromPoint:aPoint in:windowId
   849 
   941 
   850 bitsBlue
   942 bitsBlue
   851     "return the number of valid bits in the red component."
   943     "return the number of valid bits in the red component."
   852 
   944 
   853     bitsBlue isNil ifTrue:[
   945     bitsBlue isNil ifTrue:[
   854         "/ not a truecolor display
   946 	"/ not a truecolor display
   855         ^ bitsPerRGB
   947 	^ bitsPerRGB
   856     ].
   948     ].
   857     ^ bitsBlue
   949     ^ bitsBlue
   858 
   950 
   859     "
   951     "
   860      Display bitsBlue   
   952      Display bitsBlue   
   865 
   957 
   866 bitsGreen
   958 bitsGreen
   867     "return the number of valid bits in the red component."
   959     "return the number of valid bits in the red component."
   868 
   960 
   869     bitsGreen isNil ifTrue:[
   961     bitsGreen isNil ifTrue:[
   870         "/ not a truecolor display
   962 	"/ not a truecolor display
   871         ^ bitsPerRGB
   963 	^ bitsPerRGB
   872     ].
   964     ].
   873     ^ bitsGreen
   965     ^ bitsGreen
   874 
   966 
   875     "
   967     "
   876      Display bitsGreen   
   968      Display bitsGreen   
   898 
   990 
   899 bitsRed
   991 bitsRed
   900     "return the number of valid bits in the red component."
   992     "return the number of valid bits in the red component."
   901 
   993 
   902     bitsRed isNil ifTrue:[
   994     bitsRed isNil ifTrue:[
   903         "/ not a truecolor display
   995 	"/ not a truecolor display
   904         ^ bitsPerRGB
   996 	^ bitsPerRGB
   905     ].
   997     ].
   906     ^ bitsRed
   998     ^ bitsRed
   907 
   999 
   908     "
  1000     "
   909      Display bitsRed
  1001      Display bitsRed
  1086      (of which the server knows nothing).
  1178      (of which the server knows nothing).
  1087      So, this should be used from a display-specific startup file only."
  1179      So, this should be used from a display-specific startup file only."
  1088 
  1180 
  1089     visualType := aSymbol.
  1181     visualType := aSymbol.
  1090     (visualType == #StaticGray or:[visualType == #GrayScale]) ifTrue:[
  1182     (visualType == #StaticGray or:[visualType == #GrayScale]) ifTrue:[
  1091         hasColors := false
  1183 	hasColors := false
  1092     ] ifFalse:[
  1184     ] ifFalse:[
  1093         hasColors := true
  1185 	hasColors := true
  1094     ]
  1186     ]
  1095 !
  1187 !
  1096 
  1188 
  1097 whiteColor
  1189 whiteColor
  1098     "return the white color on this device.
  1190     "return the white color on this device.
  1346      We return nil here (as if there are no special size preferences)."
  1438      We return nil here (as if there are no special size preferences)."
  1347 
  1439 
  1348     |sizes spec sz sz2|
  1440     |sizes spec sz sz2|
  1349 
  1441 
  1350     preferredIconSize isNil ifTrue:[
  1442     preferredIconSize isNil ifTrue:[
  1351         sizes := self iconSizes.
  1443 	sizes := self iconSizes.
  1352         sizes notNil ifTrue:[
  1444 	sizes notNil ifTrue:[
  1353             spec := sizes first.
  1445 	    spec := sizes first.
  1354 
  1446 
  1355             "/ we prefer square icons ...
  1447 	    "/ we prefer square icons ...
  1356 
  1448 
  1357             sz := (spec at:#maxWidth) min: (spec at:#maxHeight).
  1449 	    sz := (spec at:#maxWidth) min: (spec at:#maxHeight).
  1358             sz > 64 ifTrue:[
  1450 	    sz > 64 ifTrue:[
  1359                 sz2 := (spec at:#minWidth) max: (spec at:#minHeight).
  1451 		sz2 := (spec at:#minWidth) max: (spec at:#minHeight).
  1360                 sz2 <= 48 ifTrue:[
  1452 		sz2 <= 48 ifTrue:[
  1361                     sz := 48
  1453 		    sz := 48
  1362                 ]
  1454 		]
  1363             ].
  1455 	    ].
  1364             preferredIconSize := sz @ sz
  1456 	    preferredIconSize := sz @ sz
  1365         ].
  1457 	].
  1366         preferredIconSize isNil ifTrue:[
  1458 	preferredIconSize isNil ifTrue:[
  1367             preferredIconSize := 48@48
  1459 	    preferredIconSize := 48@48
  1368         ].
  1460 	].
  1369     ].
  1461     ].
  1370 
  1462 
  1371     ^ preferredIconSize
  1463     ^ preferredIconSize
  1372 
  1464 
  1373     "
  1465     "
  1572 heightInMillimeter:aNumber
  1664 heightInMillimeter:aNumber
  1573     "set the height in millimeter of the display 
  1665     "set the height in millimeter of the display 
  1574      - needed since some displays do not tell the truth or do not know it"
  1666      - needed since some displays do not tell the truth or do not know it"
  1575 
  1667 
  1576     aNumber > 0 ifTrue:[
  1668     aNumber > 0 ifTrue:[
  1577         heightMM := aNumber.
  1669 	heightMM := aNumber.
  1578         resolutionVer := nil.
  1670 	resolutionVer := nil.
  1579     ]
  1671     ]
  1580 
  1672 
  1581     "Modified: 10.9.1996 / 14:25:39 / cg"
  1673     "Modified: 10.9.1996 / 14:25:39 / cg"
  1582 !
  1674 !
  1583 
  1675 
  1589 
  1681 
  1590 horizontalPixelPerMillimeter
  1682 horizontalPixelPerMillimeter
  1591     "return the number of horizontal pixels per millimeter of the display"
  1683     "return the number of horizontal pixels per millimeter of the display"
  1592 
  1684 
  1593     resolutionHor notNil ifTrue:[
  1685     resolutionHor notNil ifTrue:[
  1594         ^ resolutionHor
  1686 	^ resolutionHor
  1595     ].
  1687     ].
  1596     resolutionHor := (width / widthMM) asFloat.
  1688     resolutionHor := (width / widthMM) asFloat.
  1597     ^ resolutionHor
  1689     ^ resolutionHor
  1598 !
  1690 !
  1599 
  1691 
  1628 
  1720 
  1629 verticalPixelPerMillimeter
  1721 verticalPixelPerMillimeter
  1630     "return the number of vertical pixels per millimeter of the display"
  1722     "return the number of vertical pixels per millimeter of the display"
  1631 
  1723 
  1632     resolutionVer notNil ifTrue:[
  1724     resolutionVer notNil ifTrue:[
  1633         ^ resolutionVer
  1725 	^ resolutionVer
  1634     ].
  1726     ].
  1635     resolutionVer := (height / heightMM) asFloat.
  1727     resolutionVer := (height / heightMM) asFloat.
  1636     ^ resolutionVer
  1728     ^ resolutionVer
  1637 !
  1729 !
  1638 
  1730 
  1686 widthInMillimeter:aNumber
  1778 widthInMillimeter:aNumber
  1687     "set the width in millimeter of the display 
  1779     "set the width in millimeter of the display 
  1688      - needed since some displays do not tell the truth or do not know it"
  1780      - needed since some displays do not tell the truth or do not know it"
  1689 
  1781 
  1690     aNumber > 0 ifTrue:[
  1782     aNumber > 0 ifTrue:[
  1691         widthMM := aNumber.
  1783 	widthMM := aNumber.
  1692         resolutionHor := nil.
  1784 	resolutionHor := nil.
  1693     ].
  1785     ].
  1694 
  1786 
  1695     "Modified: 10.9.1996 / 14:25:27 / cg"
  1787     "Modified: 10.9.1996 / 14:25:27 / cg"
  1696 ! !
  1788 ! !
  1697 
  1789 
  1810     "create a new faxImage in the workstation.
  1902     "create a new faxImage in the workstation.
  1811      This is a special interface to servers with the fax-image
  1903      This is a special interface to servers with the fax-image
  1812      extension (you won't find it in standard X-servers).
  1904      extension (you won't find it in standard X-servers).
  1813 
  1905 
  1814      type: 0 -> uncompressed
  1906      type: 0 -> uncompressed
  1815            1 -> group3 1D (k is void)
  1907 	   1 -> group3 1D (k is void)
  1816            2 -> group3 2D
  1908 	   2 -> group3 2D
  1817            3 -> group4 2D (k is void)
  1909 	   3 -> group4 2D (k is void)
  1818     "
  1910     "
  1819 
  1911 
  1820     ^ nil
  1912     ^ nil
  1821 !
  1913 !
  1822 
  1914 
  1827     ^ self subclassResponsibility
  1919     ^ self subclassResponsibility
  1828 !
  1920 !
  1829 
  1921 
  1830 createSubWindowFor:aView origin:org extent:ext borderWidth:bw subViewOf:sv inputOnly:inp cursor:cursor
  1922 createSubWindowFor:aView origin:org extent:ext borderWidth:bw subViewOf:sv inputOnly:inp cursor:cursor
  1831     ^ self
  1923     ^ self
  1832         createWindowFor:aView
  1924 	createWindowFor:aView
  1833 	type:nil
  1925 	type:nil
  1834         origin:org 
  1926 	origin:org 
  1835 	extent:ext
  1927 	extent:ext
  1836         minExtent:nil 
  1928 	minExtent:nil 
  1837 	maxExtent:nil
  1929 	maxExtent:nil
  1838         borderWidth:bw
  1930 	borderWidth:bw
  1839         subViewOf:sv
  1931 	subViewOf:sv
  1840         onTop:false
  1932 	onTop:false
  1841         inputOnly:inp
  1933 	inputOnly:inp
  1842         label:nil
  1934 	label:nil
  1843         cursor:cursor
  1935 	cursor:cursor
  1844         icon:nil iconMask:nil 
  1936 	icon:nil iconMask:nil 
  1845 	iconView:nil
  1937 	iconView:nil
  1846 !
  1938 !
  1847 
  1939 
  1848 createWindowFor:aView left:xpos top:ypos width:wwidth height:wheight
  1940 createWindowFor:aView left:xpos top:ypos width:wwidth height:wheight
  1849     "will vanish - for compatibility with previous versions"
  1941     "will vanish - for compatibility with previous versions"
  1850 
  1942 
  1851     ^ self 
  1943     ^ self 
  1852         createWindowFor:aView 
  1944 	createWindowFor:aView 
  1853 	type:nil
  1945 	type:nil
  1854         origin:(xpos @ ypos)
  1946 	origin:(xpos @ ypos)
  1855         extent:(wwidth @ wheight)
  1947 	extent:(wwidth @ wheight)
  1856         minExtent:(aView minExtent)
  1948 	minExtent:(aView minExtent)
  1857         maxExtent:(aView maxExtent)
  1949 	maxExtent:(aView maxExtent)
  1858         borderWidth:(aView borderWidth)
  1950 	borderWidth:(aView borderWidth)
  1859         subViewOf:(aView superView)
  1951 	subViewOf:(aView superView)
  1860         onTop:(aView isPopUpView)
  1952 	onTop:(aView isPopUpView)
  1861         inputOnly:(aView isInputOnly)
  1953 	inputOnly:(aView isInputOnly)
  1862         label:(aView label)
  1954 	label:(aView label)
  1863         cursor:(aView cursor)
  1955 	cursor:(aView cursor)
  1864         icon:(aView icon) iconMask:(aView iconMask)
  1956 	icon:(aView icon) iconMask:(aView iconMask)
  1865         iconView:(aView iconView)
  1957 	iconView:(aView iconView)
  1866 
  1958 
  1867     "Modified: 1.6.1996 / 13:22:48 / cg"
  1959     "Modified: 1.6.1996 / 13:22:48 / cg"
  1868 !
  1960 !
  1869 
  1961 
  1870 createWindowFor:aView type:typeSymbol origin:org extent:ext minExtent:minE maxExtent:maxE borderWidth:bw subViewOf:sv onTop:onTop inputOnly:inp label:label cursor:curs icon:icn iconMask:icnM iconView:icnV
  1962 createWindowFor:aView type:typeSymbol origin:org extent:ext minExtent:minE maxExtent:maxE borderWidth:bw subViewOf:sv onTop:onTop inputOnly:inp label:label cursor:curs icon:icn iconMask:icnM iconView:icnV
  1941      plus possibly available fixColors."
  2033      plus possibly available fixColors."
  1942 
  2034 
  1943     |s|
  2035     |s|
  1944 
  2036 
  1945     fixColors notNil ifTrue:[
  2037     fixColors notNil ifTrue:[
  1946         s := IdentitySet new.
  2038 	s := IdentitySet new.
  1947         s addAll:fixColors.
  2039 	s addAll:fixColors.
  1948         s addAll:ditherColors.
  2040 	s addAll:ditherColors.
  1949         ^ s asArray
  2041 	^ s asArray
  1950     ].
  2042     ].
  1951     ^ ditherColors
  2043     ^ ditherColors
  1952 
  2044 
  1953     "Created: 11.7.1996 / 18:13:30 / cg"
  2045     "Created: 11.7.1996 / 18:13:30 / cg"
  1954 !
  2046 !
  1972 
  2064 
  1973     |mapSize "{ Class: SmallInteger }"
  2065     |mapSize "{ Class: SmallInteger }"
  1974      depthUsed mapArray|
  2066      depthUsed mapArray|
  1975 
  2067 
  1976     visualType == #DirectColor ifTrue:[
  2068     visualType == #DirectColor ifTrue:[
  1977         'DeviceWorkstation [info]: directColor displays not fully supported.' infoPrintCR.
  2069 	'DeviceWorkstation [info]: directColor displays not fully supported.' infoPrintCR.
  1978         ^ nil
  2070 	^ nil
  1979     ].
  2071     ].
  1980         
  2072         
  1981     (visualType == #StaticGray or:[visualType == #TrueColor]) ifTrue:[
  2073     (visualType == #StaticGray or:[visualType == #TrueColor]) ifTrue:[
  1982         "
  2074 	"
  1983          those have no colorMap - we're done
  2075 	 those have no colorMap - we're done
  1984         "
  2076 	"
  1985         ^ nil
  2077 	^ nil
  1986     ].
  2078     ].
  1987 
  2079 
  1988     "
  2080     "
  1989      get some attributes of the display device
  2081      get some attributes of the display device
  1990     "
  2082     "
  1993     "/ kludge for 15bit XFree server
  2085     "/ kludge for 15bit XFree server
  1994     "/ (but: I have never encountered a PseudoColor display with more
  2086     "/ (but: I have never encountered a PseudoColor display with more
  1995     "/  than 8 bits ...)
  2087     "/  than 8 bits ...)
  1996 
  2088 
  1997     depthUsed == 15 ifTrue:[
  2089     depthUsed == 15 ifTrue:[
  1998         depthUsed := 16
  2090 	depthUsed := 16
  1999     ].
  2091     ].
  2000     depthUsed > 16 ifTrue:[
  2092     depthUsed > 16 ifTrue:[
  2001         "/ do not allocate zillions of colors ...
  2093 	"/ do not allocate zillions of colors ...
  2002         self error:'unreasonably large colorMap ...'.
  2094 	self error:'unreasonably large colorMap ...'.
  2003         ^ nil
  2095 	^ nil
  2004     ].
  2096     ].
  2005 
  2097 
  2006     mapSize := (1 bitShift:depthUsed).
  2098     mapSize := (1 bitShift:depthUsed).
  2007 
  2099 
  2008     "/ get the palette
  2100     "/ get the palette
  2009     mapArray := Array new:mapSize.
  2101     mapArray := Array new:mapSize.
  2010     1 to:mapSize do:[:i |
  2102     1 to:mapSize do:[:i |
  2011         self getRGBFrom:(i-1) into:[:r :g :b |
  2103 	self getRGBFrom:(i-1) into:[:r :g :b |
  2012             mapArray at:i put:(Color red:r green:g blue:b)
  2104 	    mapArray at:i put:(Color red:r green:g blue:b)
  2013         ]
  2105 	]
  2014     ].
  2106     ].
  2015     ^ mapArray.
  2107     ^ mapArray.
  2016 
  2108 
  2017     "
  2109     "
  2018      Display colorMap
  2110      Display colorMap
  2066      than those below are X specific."
  2158      than those below are X specific."
  2067 
  2159 
  2068     |idx names triple|
  2160     |idx names triple|
  2069 
  2161 
  2070     names := #(
  2162     names := #(
  2071                 'red' 
  2163 		'red' 
  2072                 'green' 
  2164 		'green' 
  2073                 'blue' 
  2165 		'blue' 
  2074                 'yellow' 
  2166 		'yellow' 
  2075                 'magenta' 
  2167 		'magenta' 
  2076                 'cyan' 
  2168 		'cyan' 
  2077                 'white' 
  2169 		'white' 
  2078                 'black'
  2170 		'black'
  2079 
  2171 
  2080                 'olive'
  2172 		'olive'
  2081                 'teal'
  2173 		'teal'
  2082                 'silver'
  2174 		'silver'
  2083                 'lime'
  2175 		'lime'
  2084                 'fuchsia'
  2176 		'fuchsia'
  2085                 'aqua'
  2177 		'aqua'
  2086               ).
  2178 	      ).
  2087     idx := names indexOf:colorName.
  2179     idx := names indexOf:colorName.
  2088     idx == 0 ifTrue:[
  2180     idx == 0 ifTrue:[
  2089         idx := names indexOf:colorName asLowercase.
  2181 	idx := names indexOf:colorName asLowercase.
  2090     ].
  2182     ].
  2091     idx == 0 ifFalse:[
  2183     idx == 0 ifFalse:[
  2092         triple := #(
  2184 	triple := #(
  2093                         (100   0   0)  "red"
  2185 			(100   0   0)  "red"
  2094                         (  0 100   0)  "green"
  2186 			(  0 100   0)  "green"
  2095                         (  0   0 100)  "blue"
  2187 			(  0   0 100)  "blue"
  2096                         (100 100   0)  "yellow"
  2188 			(100 100   0)  "yellow"
  2097                         (100   0 100)  "magenta"
  2189 			(100   0 100)  "magenta"
  2098                         (  0 100 100)  "cyan"
  2190 			(  0 100 100)  "cyan"
  2099                         (100 100 100)  "white"
  2191 			(100 100 100)  "white"
  2100                         (  0   0   0)  "black"
  2192 			(  0   0   0)  "black"
  2101 
  2193 
  2102                         ( 50  50   0)  "olive"
  2194 			( 50  50   0)  "olive"
  2103                         (  0  50  50)  "teal"
  2195 			(  0  50  50)  "teal"
  2104                         ( 40  40  40)  "silver"
  2196 			( 40  40  40)  "silver"
  2105                         ( 20 100   0)  "lime"
  2197 			( 20 100   0)  "lime"
  2106                         ( 60   3 100)  "fuchsia"
  2198 			( 60   3 100)  "fuchsia"
  2107                         ( 10 100 100)  "aqua"
  2199 			( 10 100 100)  "aqua"
  2108                    ) at:idx.
  2200 		   ) at:idx.
  2109                         
  2201                         
  2110         ^ aBlock value:(triple at:1)
  2202 	^ aBlock value:(triple at:1)
  2111                  value:(triple at:2)
  2203 		 value:(triple at:2)
  2112                  value:(triple at:3)
  2204 		 value:(triple at:3)
  2113     ].
  2205     ].
  2114     ^ nil
  2206     ^ nil
  2115 
  2207 
  2116     "Modified: 18.9.1996 / 12:27:11 / cg"
  2208     "Modified: 18.9.1996 / 12:27:11 / cg"
  2117 !
  2209 !
  2119 getScaledRGBFromName:colorName into:aBlock
  2211 getScaledRGBFromName:colorName into:aBlock
  2120     "get rgb components (0..16rFFFF) of color named colorName,
  2212     "get rgb components (0..16rFFFF) of color named colorName,
  2121      and evaluate the 3-arg block, aBlock with them"
  2213      and evaluate the 3-arg block, aBlock with them"
  2122 
  2214 
  2123     self getRGBFromName:colorName into:[:r :g :b |
  2215     self getRGBFromName:colorName into:[:r :g :b |
  2124         |sr sg sb|
  2216 	|sr sg sb|
  2125 
  2217 
  2126         sr := self percentToDeviceColorValue:r.
  2218 	sr := self percentToDeviceColorValue:r.
  2127         sg := self percentToDeviceColorValue:g.
  2219 	sg := self percentToDeviceColorValue:g.
  2128         sb := self percentToDeviceColorValue:b.
  2220 	sb := self percentToDeviceColorValue:b.
  2129         ^ aBlock value:sr value:sg value:sb
  2221 	^ aBlock value:sr value:sg value:sb
  2130     ]
  2222     ]
  2131 !
  2223 !
  2132 
  2224 
  2133 greenComponentOfColor:colorId
  2225 greenComponentOfColor:colorId
  2134     "get green component (0..100) of color in map at:index"
  2226     "get green component (0..100) of color in map at:index"
  2320 
  2412 
  2321     ^ self copyPlaneFromId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h
  2413     ^ self copyPlaneFromId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h
  2322 !
  2414 !
  2323 
  2415 
  2324 displayArcX:x y:y width:width height:height from:startAngle angle:angle
  2416 displayArcX:x y:y width:width height:height from:startAngle angle:angle
  2325              in:aDrawableId with:aGCId
  2417 	     in:aDrawableId with:aGCId
  2326     "draw an arc"
  2418     "draw an arc"
  2327 
  2419 
  2328     ^ self subclassResponsibility
  2420     ^ self subclassResponsibility
  2329 
  2421 
  2330     "Created: 8.5.1996 / 08:44:43 / cg"
  2422     "Created: 8.5.1996 / 08:44:43 / cg"
  2342 displayOpaqueString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId
  2434 displayOpaqueString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId
  2343     "draw a sub-string - draw foreground on background.
  2435     "draw a sub-string - draw foreground on background.
  2344      If the coordinates are not integers, retry with rounded." 
  2436      If the coordinates are not integers, retry with rounded." 
  2345 
  2437 
  2346     self displayString:aString 
  2438     self displayString:aString 
  2347          from:index1
  2439 	 from:index1
  2348          to:index2
  2440 	 to:index2
  2349          x:x 
  2441 	 x:x 
  2350          y:y 
  2442 	 y:y 
  2351          in:aDrawableId 
  2443 	 in:aDrawableId 
  2352          with:aGCId 
  2444 	 with:aGCId 
  2353          opaque:true
  2445 	 opaque:true
  2354 !
  2446 !
  2355 
  2447 
  2356 displayOpaqueString:aString x:x y:y in:aDrawableId with:aGCId
  2448 displayOpaqueString:aString x:x y:y in:aDrawableId with:aGCId
  2357     "draw a string - draw foreground on background.
  2449     "draw a string - draw foreground on background.
  2358      If the coordinates are not integers, retry with rounded." 
  2450      If the coordinates are not integers, retry with rounded." 
  2359 
  2451 
  2360     self displayString:aString 
  2452     self displayString:aString 
  2361          x:x 
  2453 	 x:x 
  2362          y:y 
  2454 	 y:y 
  2363          in:aDrawableId 
  2455 	 in:aDrawableId 
  2364          with:aGCId 
  2456 	 with:aGCId 
  2365          opaque:true
  2457 	 opaque:true
  2366 !
  2458 !
  2367 
  2459 
  2368 displayPointX:x y:y in:aDrawableId with:aGCId
  2460 displayPointX:x y:y in:aDrawableId with:aGCId
  2369     "draw a point"
  2461     "draw a point"
  2370 
  2462 
  2394 displayString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId
  2486 displayString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId
  2395     "draw a sub-string - draw foreground only.
  2487     "draw a sub-string - draw foreground only.
  2396      If the coordinates are not integers, retry with rounded." 
  2488      If the coordinates are not integers, retry with rounded." 
  2397 
  2489 
  2398     self 
  2490     self 
  2399         displayString:aString 
  2491 	displayString:aString 
  2400         from:index1
  2492 	from:index1
  2401         to:index2
  2493 	to:index2
  2402         x:x 
  2494 	x:x 
  2403         y:y 
  2495 	y:y 
  2404         in:aDrawableId 
  2496 	in:aDrawableId 
  2405         with:aGCId 
  2497 	with:aGCId 
  2406         opaque:false
  2498 	opaque:false
  2407 !
  2499 !
  2408 
  2500 
  2409 displayString:aString from:i1 to:i2 x:x y:y in:aDrawableId with:aGCId opaque:opaque
  2501 displayString:aString from:i1 to:i2 x:x y:y in:aDrawableId with:aGCId opaque:opaque
  2410     "draw part of a string"
  2502     "draw part of a string"
  2411 
  2503 
  2415 displayString:aString x:x y:y in:aDrawableId with:aGCId
  2507 displayString:aString x:x y:y in:aDrawableId with:aGCId
  2416     "draw a string - draw foreground only.
  2508     "draw a string - draw foreground only.
  2417      If the coordinates are not integers, retry with rounded." 
  2509      If the coordinates are not integers, retry with rounded." 
  2418 
  2510 
  2419     self 
  2511     self 
  2420         displayString:aString 
  2512 	displayString:aString 
  2421         x:x 
  2513 	x:x 
  2422         y:y 
  2514 	y:y 
  2423         in:aDrawableId 
  2515 	in:aDrawableId 
  2424         with:aGCId 
  2516 	with:aGCId 
  2425         opaque:false
  2517 	opaque:false
  2426 !
  2518 !
  2427 
  2519 
  2428 displayString:aString x:x y:y in:aDrawableId with:aGCId opaque:opaque
  2520 displayString:aString x:x y:y in:aDrawableId with:aGCId opaque:opaque
  2429     "draw a string"
  2521     "draw a string"
  2430 
  2522 
  2431     self displayString:aString
  2523     self displayString:aString
  2432                   from:1
  2524 		  from:1
  2433                     to:aString size
  2525 		    to:aString size
  2434                      x:x 
  2526 		     x:x 
  2435                      y:y 
  2527 		     y:y 
  2436                      in:aDrawableId 
  2528 		     in:aDrawableId 
  2437                      with:aGCId
  2529 		     with:aGCId
  2438                      opaque:opaque
  2530 		     opaque:opaque
  2439 !
  2531 !
  2440 
  2532 
  2441 drawBits:imageBits depth:imageDepth width:imageWidth height:imageHeight
  2533 drawBits:imageBits depth:imageDepth width:imageWidth height:imageHeight
  2442                        x:srcx y:srcy
  2534 		       x:srcx y:srcy
  2443                     into:aDrawableId x:dstx y:dsty width:w height:h with:aGCId
  2535 		    into:aDrawableId x:dstx y:dsty width:w height:h with:aGCId
  2444 
  2536 
  2445     "draw a bitimage which has depth id, width iw and height ih into
  2537     "draw a bitimage which has depth id, width iw and height ih into
  2446      the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty.
  2538      the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty.
  2447      It has to be checked elsewhere, that server can do it with the given
  2539      It has to be checked elsewhere, that server can do it with the given
  2448      depth; also it is assumed, that the colormap is setup correctly"
  2540      depth; also it is assumed, that the colormap is setup correctly"
  2449 
  2541 
  2450     ^ self subclassResponsibility
  2542     ^ self subclassResponsibility
  2451 !
  2543 !
  2452 
  2544 
  2453 fillArcX:x y:y width:width height:height from:startAngle angle:angle
  2545 fillArcX:x y:y width:width height:height from:startAngle angle:angle
  2454                in:aDrawableId with:aGCId
  2546 	       in:aDrawableId with:aGCId
  2455     "fill an arc"
  2547     "fill an arc"
  2456 
  2548 
  2457     ^ self subclassResponsibility
  2549     ^ self subclassResponsibility
  2458 
  2550 
  2459     "Created: 8.5.1996 / 08:45:11 / cg"
  2551     "Created: 8.5.1996 / 08:45:11 / cg"
  2477     "return a collection of all my known views"
  2569     "return a collection of all my known views"
  2478 
  2570 
  2479     |setOfViews|
  2571     |setOfViews|
  2480 
  2572 
  2481     knownViews notNil ifTrue:[
  2573     knownViews notNil ifTrue:[
  2482         setOfViews := IdentitySet new.
  2574 	setOfViews := IdentitySet new.
  2483 
  2575 
  2484         knownViews validElementsDo:[:v | setOfViews add:v].
  2576 	knownViews validElementsDo:[:v | setOfViews add:v].
  2485     ].
  2577     ].
  2486     ^ setOfViews
  2578     ^ setOfViews
  2487 
  2579 
  2488     "Created: 14.2.1997 / 14:29:43 / cg"
  2580     "Created: 14.2.1997 / 14:29:43 / cg"
  2489     "Modified: 23.1.1997 / 21:27:03 / cg"
  2581     "Modified: 23.1.1997 / 21:27:03 / cg"
  2498 "/                aBlock value:aView
  2590 "/                aBlock value:aView
  2499 "/            ]
  2591 "/            ]
  2500 "/      ]
  2592 "/      ]
  2501         
  2593         
  2502     knownViews notNil ifTrue:[
  2594     knownViews notNil ifTrue:[
  2503         knownViews validElementsDo:[:v |
  2595 	knownViews validElementsDo:[:v |
  2504             aBlock value:v
  2596 	    aBlock value:v
  2505         ]
  2597 	]
  2506     ]
  2598     ]
  2507 
  2599 
  2508     "
  2600     "
  2509      View defaultStyle:#iris.
  2601      View defaultStyle:#iris.
  2510      Display allViewsDo:[:v | v initStyle. v redraw]
  2602      Display allViewsDo:[:v | v initStyle. v redraw]
  2527     "forward a button-motion for some view"
  2619     "forward a button-motion for some view"
  2528 
  2620 
  2529     |sensor|
  2621     |sensor|
  2530 
  2622 
  2531     (sensor := aView sensor) notNil ifTrue:[
  2623     (sensor := aView sensor) notNil ifTrue:[
  2532         sensor buttonMotion:button x:x y:y view:aView
  2624 	sensor buttonMotion:button x:x y:y view:aView
  2533     ] ifFalse:[
  2625     ] ifFalse:[
  2534         aView shown ifTrue:[ "/ could be a late event arrival
  2626 	aView shown ifTrue:[ "/ could be a late event arrival
  2535             "
  2627 	    "
  2536              if there is no sensor ...
  2628 	     if there is no sensor ...
  2537             "
  2629 	    "
  2538             WindowEvent
  2630 	    WindowEvent
  2539                 sendEvent:#buttonMotion:x:y:
  2631 		sendEvent:#buttonMotion:x:y:
  2540                 arguments:(Array with:button with:x with:y)
  2632 		arguments:(Array with:button with:x with:y)
  2541                 view:aView
  2633 		view:aView
  2542         ]
  2634 	]
  2543     ]
  2635     ]
  2544 
  2636 
  2545     "Modified: 26.2.1997 / 15:02:18 / cg"
  2637     "Modified: 26.2.1997 / 15:02:18 / cg"
  2546 !
  2638 !
  2547 
  2639 
  2549     "forward a button-multi-press event for some view"
  2641     "forward a button-multi-press event for some view"
  2550 
  2642 
  2551     |sensor|
  2643     |sensor|
  2552 
  2644 
  2553     (sensor := aView sensor) notNil ifTrue:[
  2645     (sensor := aView sensor) notNil ifTrue:[
  2554         sensor buttonMultiPress:button x:x y:y view:aView
  2646 	sensor buttonMultiPress:button x:x y:y view:aView
  2555     ] ifFalse:[
  2647     ] ifFalse:[
  2556         aView shown ifTrue:[ "/ could be a late event arrival
  2648 	aView shown ifTrue:[ "/ could be a late event arrival
  2557             "
  2649 	    "
  2558              if there is no sensor ...
  2650 	     if there is no sensor ...
  2559             "
  2651 	    "
  2560             WindowEvent
  2652 	    WindowEvent
  2561                 sendEvent:#buttonMultiPress:x:y:
  2653 		sendEvent:#buttonMultiPress:x:y:
  2562                 arguments:(Array with:button with:x with:y)
  2654 		arguments:(Array with:button with:x with:y)
  2563                 view:aView
  2655 		view:aView
  2564         ]
  2656 	]
  2565     ]
  2657     ]
  2566 
  2658 
  2567     "Modified: 26.2.1997 / 15:02:29 / cg"
  2659     "Modified: 26.2.1997 / 15:02:29 / cg"
  2568 !
  2660 !
  2569 
  2661 
  2571     "forward a button-press event for some view"
  2663     "forward a button-press event for some view"
  2572 
  2664 
  2573     |sensor|
  2665     |sensor|
  2574 
  2666 
  2575     (sensor := aView sensor) notNil ifTrue:[
  2667     (sensor := aView sensor) notNil ifTrue:[
  2576         sensor buttonPress:button x:x y:y view:aView
  2668 	sensor buttonPress:button x:x y:y view:aView
  2577     ] ifFalse:[
  2669     ] ifFalse:[
  2578         aView shown ifTrue:[ "/ could be a late event arrival
  2670 	aView shown ifTrue:[ "/ could be a late event arrival
  2579             "
  2671 	    "
  2580              if there is no sensor ...
  2672 	     if there is no sensor ...
  2581             "
  2673 	    "
  2582             WindowEvent
  2674 	    WindowEvent
  2583                 sendEvent:#buttonPress:x:y:
  2675 		sendEvent:#buttonPress:x:y:
  2584                 arguments:(Array with:button with:x with:y)
  2676 		arguments:(Array with:button with:x with:y)
  2585                 view:aView
  2677 		view:aView
  2586         ]
  2678 	]
  2587     ]
  2679     ]
  2588 
  2680 
  2589     "Modified: 26.2.1997 / 15:02:42 / cg"
  2681     "Modified: 26.2.1997 / 15:02:42 / cg"
  2590 !
  2682 !
  2591 
  2683 
  2593     "forward a button-release event for some view"
  2685     "forward a button-release event for some view"
  2594 
  2686 
  2595     |sensor|
  2687     |sensor|
  2596 
  2688 
  2597     (sensor := aView sensor) notNil ifTrue:[
  2689     (sensor := aView sensor) notNil ifTrue:[
  2598         sensor buttonRelease:button x:x y:y view:aView
  2690 	sensor buttonRelease:button x:x y:y view:aView
  2599     ] ifFalse:[
  2691     ] ifFalse:[
  2600         aView shown ifTrue:[ "/ could be a late event arrival
  2692 	aView shown ifTrue:[ "/ could be a late event arrival
  2601             "
  2693 	    "
  2602              if there is no sensor ...
  2694 	     if there is no sensor ...
  2603             "
  2695 	    "
  2604             WindowEvent
  2696 	    WindowEvent
  2605                 sendEvent:#buttonRelease:x:y:
  2697 		sendEvent:#buttonRelease:x:y:
  2606                 arguments:(Array with:button with:x with:y)
  2698 		arguments:(Array with:button with:x with:y)
  2607                 view:aView
  2699 		view:aView
  2608         ]
  2700 	]
  2609     ]
  2701     ]
  2610 
  2702 
  2611     "Modified: 26.2.1997 / 15:02:52 / cg"
  2703     "Modified: 26.2.1997 / 15:02:52 / cg"
  2612 !
  2704 !
  2613 
  2705 
  2615     "forward a configure for some view"
  2707     "forward a configure for some view"
  2616 
  2708 
  2617     |sensor|
  2709     |sensor|
  2618 
  2710 
  2619     (sensor := aView sensor) notNil ifTrue:[
  2711     (sensor := aView sensor) notNil ifTrue:[
  2620         sensor configureX:x y:y width:w height:h view:aView
  2712 	sensor configureX:x y:y width:w height:h view:aView
  2621     ] ifFalse:[
  2713     ] ifFalse:[
  2622         "
  2714 	"
  2623          if there is no sensor ...
  2715 	 if there is no sensor ...
  2624         "
  2716 	"
  2625         aView configureX:x y:y width:w height:h 
  2717 	aView configureX:x y:y width:w height:h 
  2626     ]
  2718     ]
  2627 !
  2719 !
  2628 
  2720 
  2629 coveredBy:otherView view:aView
  2721 coveredBy:otherView view:aView
  2630     "forward a covered for some view"
  2722     "forward a covered for some view"
  2631 
  2723 
  2632     |sensor|
  2724     |sensor|
  2633 
  2725 
  2634     (sensor := aView sensor) notNil ifTrue:[
  2726     (sensor := aView sensor) notNil ifTrue:[
  2635         sensor coveredBy:otherView view:aView
  2727 	sensor coveredBy:otherView view:aView
  2636     ] ifFalse:[
  2728     ] ifFalse:[
  2637         "
  2729 	"
  2638          if there is no sensor ...
  2730 	 if there is no sensor ...
  2639         "
  2731 	"
  2640         aView coveredBy:otherView 
  2732 	aView coveredBy:otherView 
  2641     ]
  2733     ]
  2642 !
  2734 !
  2643 
  2735 
  2644 destroyedView:aView
  2736 destroyedView:aView
  2645     "forward a destroyed event for some view"
  2737     "forward a destroyed event for some view"
  2646 
  2738 
  2647     |sensor|
  2739     |sensor|
  2648 
  2740 
  2649     (sensor := aView sensor) notNil ifTrue:[
  2741     (sensor := aView sensor) notNil ifTrue:[
  2650         sensor destroyedView:aView
  2742 	sensor destroyedView:aView
  2651     ] ifFalse:[
  2743     ] ifFalse:[
  2652         "
  2744 	"
  2653          if there is no sensor ...
  2745 	 if there is no sensor ...
  2654         "
  2746 	"
  2655         aView destroyed
  2747 	aView destroyed
  2656     ]
  2748     ]
  2657 !
  2749 !
  2658 
  2750 
  2659 exposeX:x y:y width:w height:h view:aView
  2751 exposeX:x y:y width:w height:h view:aView
  2660     "forward an expose for some view"
  2752     "forward an expose for some view"
  2661 
  2753 
  2662     |sensor|
  2754     |sensor|
  2663 
  2755 
  2664     (sensor := aView sensor) notNil ifTrue:[
  2756     (sensor := aView sensor) notNil ifTrue:[
  2665         sensor exposeX:x y:y width:w height:h view:aView
  2757 	sensor exposeX:x y:y width:w height:h view:aView
  2666     ] ifFalse:[
  2758     ] ifFalse:[
  2667         "
  2759 	"
  2668          if there is no sensor ...
  2760 	 if there is no sensor ...
  2669         "
  2761 	"
  2670         WindowEvent
  2762 	WindowEvent
  2671             sendEvent:#exposeX:y:width:height:
  2763 	    sendEvent:#exposeX:y:width:height:
  2672             arguments:(Array with:x with:y with:w with:h)
  2764 	    arguments:(Array with:x with:y with:w with:h)
  2673             view:aView
  2765 	    view:aView
  2674     ]
  2766     ]
  2675 !
  2767 !
  2676 
  2768 
  2677 focusInView:aView
  2769 focusInView:aView
  2678     "forward a focusIn event for some view"
  2770     "forward a focusIn event for some view"
  2679 
  2771 
  2680     |sensor|
  2772     |sensor|
  2681 
  2773 
  2682     (sensor := aView sensor) notNil ifTrue:[
  2774     (sensor := aView sensor) notNil ifTrue:[
  2683         sensor focusInView:aView
  2775 	sensor focusInView:aView
  2684     ] ifFalse:[
  2776     ] ifFalse:[
  2685         "
  2777 	"
  2686          if there is no sensor ...
  2778 	 if there is no sensor ...
  2687         "
  2779 	"
  2688         WindowEvent
  2780 	WindowEvent
  2689             sendEvent:#focusIn
  2781 	    sendEvent:#focusIn
  2690             arguments:nil
  2782 	    arguments:nil
  2691             view:aView
  2783 	    view:aView
  2692     ]
  2784     ]
  2693 !
  2785 !
  2694 
  2786 
  2695 focusOutView:aView 
  2787 focusOutView:aView 
  2696     "forward a focusOut event for some view"
  2788     "forward a focusOut event for some view"
  2697 
  2789 
  2698     |sensor|
  2790     |sensor|
  2699 
  2791 
  2700     (sensor := aView sensor) notNil ifTrue:[
  2792     (sensor := aView sensor) notNil ifTrue:[
  2701         sensor focusOutView:aView
  2793 	sensor focusOutView:aView
  2702     ] ifFalse:[
  2794     ] ifFalse:[
  2703         "
  2795 	"
  2704          if there is no sensor ...
  2796 	 if there is no sensor ...
  2705         "
  2797 	"
  2706         WindowEvent
  2798 	WindowEvent
  2707             sendEvent:#focusOut
  2799 	    sendEvent:#focusOut
  2708             arguments:nil
  2800 	    arguments:nil
  2709             view:aView
  2801 	    view:aView
  2710     ]
  2802     ]
  2711 !
  2803 !
  2712 
  2804 
  2713 graphicsExposeX:x y:y width:w height:h final:final view:aView
  2805 graphicsExposeX:x y:y width:w height:h final:final view:aView
  2714     "forward a graphic expose for some view"
  2806     "forward a graphic expose for some view"
  2715 
  2807 
  2716     |sensor|
  2808     |sensor|
  2717 
  2809 
  2718     (sensor := aView sensor) notNil ifTrue:[
  2810     (sensor := aView sensor) notNil ifTrue:[
  2719         sensor graphicsExposeX:x y:y width:w height:h final:final view:aView
  2811 	sensor graphicsExposeX:x y:y width:w height:h final:final view:aView
  2720     ] ifFalse:[
  2812     ] ifFalse:[
  2721         "
  2813 	"
  2722          if there is no sensor ...
  2814 	 if there is no sensor ...
  2723         "
  2815 	"
  2724         WindowEvent
  2816 	WindowEvent
  2725             sendEvent:#graphicsExposeX:y:width:height:final:
  2817 	    sendEvent:#graphicsExposeX:y:width:height:final:
  2726             arguments:(Array with:x with:y with:w with:h with:final)
  2818 	    arguments:(Array with:x with:y with:w with:h with:final)
  2727             view:aView
  2819 	    view:aView
  2728     ]
  2820     ]
  2729 !
  2821 !
  2730 
  2822 
  2731 keyPress:untranslatedKey x:x y:y view:aView
  2823 keyPress:untranslatedKey x:x y:y view:aView
  2732     "forward a key-press event for some view"
  2824     "forward a key-press event for some view"
  2737 
  2829 
  2738     "/
  2830     "/
  2739     "/ ctrl-Esc gives up focus
  2831     "/ ctrl-Esc gives up focus
  2740     "/
  2832     "/
  2741     untranslatedKey == #Escape ifTrue:[
  2833     untranslatedKey == #Escape ifTrue:[
  2742         ctrlDown ifTrue:[
  2834 	ctrlDown ifTrue:[
  2743             self ungrabPointer.
  2835 	    self ungrabPointer.
  2744             self setInputFocusTo:nil 
  2836 	    self setInputFocusTo:nil 
  2745         ]
  2837 	]
  2746     ].
  2838     ].
  2747 
  2839 
  2748     self modifierKeyProcessing:untranslatedKey down:true.
  2840     self modifierKeyProcessing:untranslatedKey down:true.
  2749 
  2841 
  2750     (sensor := aView sensor) notNil ifTrue:[
  2842     (sensor := aView sensor) notNil ifTrue:[
  2751         sensor keyPress:untranslatedKey x:x y:y view:aView
  2843 	sensor keyPress:untranslatedKey x:x y:y view:aView
  2752     ] ifFalse:[
  2844     ] ifFalse:[
  2753         aView shown ifTrue:[ "/ could be a late event arrival
  2845 	aView shown ifTrue:[ "/ could be a late event arrival
  2754             "
  2846 	    "
  2755              if there is no sensor ...
  2847 	     if there is no sensor ...
  2756             "
  2848 	    "
  2757             xlatedKey := self translateKey:untranslatedKey.
  2849 	    xlatedKey := self translateKey:untranslatedKey.
  2758             xlatedKey notNil ifTrue:[
  2850 	    xlatedKey notNil ifTrue:[
  2759                 WindowEvent
  2851 		WindowEvent
  2760                   sendEvent:#keyPress:x:y:
  2852 		  sendEvent:#keyPress:x:y:
  2761                   arguments:(Array with:xlatedKey with:x with:y)
  2853 		  arguments:(Array with:xlatedKey with:x with:y)
  2762                   view:aView
  2854 		  view:aView
  2763             ]
  2855 	    ]
  2764         ]
  2856 	]
  2765     ]
  2857     ]
  2766 
  2858 
  2767     "Modified: 26.2.1997 / 15:03:28 / cg"
  2859     "Modified: 26.2.1997 / 15:03:28 / cg"
  2768 !
  2860 !
  2769 
  2861 
  2773     |xlatedKey sensor|
  2865     |xlatedKey sensor|
  2774 
  2866 
  2775     self modifierKeyProcessing:untranslatedKey down:false.
  2867     self modifierKeyProcessing:untranslatedKey down:false.
  2776 
  2868 
  2777     (sensor := aView sensor) notNil ifTrue:[
  2869     (sensor := aView sensor) notNil ifTrue:[
  2778         sensor keyRelease:untranslatedKey x:x y:y view:aView
  2870 	sensor keyRelease:untranslatedKey x:x y:y view:aView
  2779     ] ifFalse:[
  2871     ] ifFalse:[
  2780         aView shown ifTrue:[ "/ could be a late event arrival
  2872 	aView shown ifTrue:[ "/ could be a late event arrival
  2781             "
  2873 	    "
  2782              if there is no sensor ...
  2874 	     if there is no sensor ...
  2783             "
  2875 	    "
  2784             xlatedKey := self translateKey:untranslatedKey.
  2876 	    xlatedKey := self translateKey:untranslatedKey.
  2785             xlatedKey notNil ifTrue:[
  2877 	    xlatedKey notNil ifTrue:[
  2786                 WindowEvent
  2878 		WindowEvent
  2787                     sendEvent:#keyRelease:x:y:
  2879 		    sendEvent:#keyRelease:x:y:
  2788                     arguments:(Array with:xlatedKey with:x with:y)
  2880 		    arguments:(Array with:xlatedKey with:x with:y)
  2789                     view:aView
  2881 		    view:aView
  2790             ]
  2882 	    ]
  2791         ]
  2883 	]
  2792     ]
  2884     ]
  2793 
  2885 
  2794     "Modified: 26.2.1997 / 15:03:40 / cg"
  2886     "Modified: 26.2.1997 / 15:03:40 / cg"
  2795 !
  2887 !
  2796 
  2888 
  2798     "forward a mapped event for some view"
  2890     "forward a mapped event for some view"
  2799 
  2891 
  2800     |sensor|
  2892     |sensor|
  2801 
  2893 
  2802     (sensor := aView sensor) notNil ifTrue:[
  2894     (sensor := aView sensor) notNil ifTrue:[
  2803         sensor mappedView:aView
  2895 	sensor mappedView:aView
  2804     ] ifFalse:[
  2896     ] ifFalse:[
  2805         "
  2897 	"
  2806          if there is no sensor ...
  2898 	 if there is no sensor ...
  2807         "
  2899 	"
  2808         aView mapped
  2900 	aView mapped
  2809     ]
  2901     ]
  2810 !
  2902 !
  2811 
  2903 
  2812 noExposeView:aView
  2904 noExposeView:aView
  2813     "forward a noExpose event for some view"
  2905     "forward a noExpose event for some view"
  2814 
  2906 
  2815     |sensor|
  2907     |sensor|
  2816 
  2908 
  2817     (sensor := aView sensor) notNil ifTrue:[
  2909     (sensor := aView sensor) notNil ifTrue:[
  2818         sensor noExposeView:aView
  2910 	sensor noExposeView:aView
  2819     ] ifFalse:[
  2911     ] ifFalse:[
  2820         "
  2912 	"
  2821          if there is no sensor ...
  2913 	 if there is no sensor ...
  2822         "
  2914 	"
  2823         aView noExpose 
  2915 	aView noExpose 
  2824     ]
  2916     ]
  2825 !
  2917 !
  2826 
  2918 
  2827 pointerEnter:buttonState x:x y:y view:aView
  2919 pointerEnter:buttonState x:x y:y view:aView
  2828     "forward a pointer enter for some view"
  2920     "forward a pointer enter for some view"
  2829 
  2921 
  2830     |sensor|
  2922     |sensor|
  2831 
  2923 
  2832     (sensor := aView sensor) notNil ifTrue:[
  2924     (sensor := aView sensor) notNil ifTrue:[
  2833         sensor pointerEnter:buttonState x:x y:y view:aView
  2925 	sensor pointerEnter:buttonState x:x y:y view:aView
  2834     ] ifFalse:[
  2926     ] ifFalse:[
  2835         "
  2927 	"
  2836          if there is no sensor ...
  2928 	 if there is no sensor ...
  2837         "
  2929 	"
  2838         WindowEvent
  2930 	WindowEvent
  2839             sendEvent:#pointerEnter:x:y:
  2931 	    sendEvent:#pointerEnter:x:y:
  2840             arguments:(Array with:buttonState with:x with:y)
  2932 	    arguments:(Array with:buttonState with:x with:y)
  2841             view:aView
  2933 	    view:aView
  2842     ]
  2934     ]
  2843 !
  2935 !
  2844 
  2936 
  2845 pointerLeave:buttonState view:aView
  2937 pointerLeave:buttonState view:aView
  2846     "forward a pointer leave for some view"
  2938     "forward a pointer leave for some view"
  2847 
  2939 
  2848     |sensor|
  2940     |sensor|
  2849 
  2941 
  2850     (sensor := aView sensor) notNil ifTrue:[
  2942     (sensor := aView sensor) notNil ifTrue:[
  2851         sensor pointerLeave:buttonState view:aView
  2943 	sensor pointerLeave:buttonState view:aView
  2852     ] ifFalse:[
  2944     ] ifFalse:[
  2853         "
  2945 	"
  2854          if there is no sensor ...
  2946 	 if there is no sensor ...
  2855         "
  2947 	"
  2856         WindowEvent
  2948 	WindowEvent
  2857             sendEvent:#pointerLeave:
  2949 	    sendEvent:#pointerLeave:
  2858             arguments:(Array with:buttonState)
  2950 	    arguments:(Array with:buttonState)
  2859             view:aView
  2951 	    view:aView
  2860     ]
  2952     ]
  2861 !
  2953 !
  2862 
  2954 
  2863 saveAndTerminateView:aView
  2955 saveAndTerminateView:aView
  2864     "forward a saveAndTerminate event for some view"
  2956     "forward a saveAndTerminate event for some view"
  2865 
  2957 
  2866     |sensor|
  2958     |sensor|
  2867 
  2959 
  2868     (sensor := aView sensor) notNil ifTrue:[
  2960     (sensor := aView sensor) notNil ifTrue:[
  2869         sensor saveAndTerminateView:aView
  2961 	sensor saveAndTerminateView:aView
  2870     ] ifFalse:[
  2962     ] ifFalse:[
  2871         "
  2963 	"
  2872          if there is no sensor ...
  2964 	 if there is no sensor ...
  2873         "
  2965 	"
  2874         aView saveAndTerminate
  2966 	aView saveAndTerminate
  2875     ]
  2967     ]
  2876 !
  2968 !
  2877 
  2969 
  2878 terminateView:aView
  2970 terminateView:aView
  2879     "forward a terminate event for some view"
  2971     "forward a terminate event for some view"
  2880 
  2972 
  2881     |sensor|
  2973     |sensor|
  2882 
  2974 
  2883     (sensor := aView sensor) notNil ifTrue:[
  2975     (sensor := aView sensor) notNil ifTrue:[
  2884         sensor terminateView:aView
  2976 	sensor terminateView:aView
  2885     ] ifFalse:[
  2977     ] ifFalse:[
  2886         "
  2978 	"
  2887          if there is no sensor ...
  2979 	 if there is no sensor ...
  2888         "
  2980 	"
  2889         aView terminate
  2981 	aView terminate
  2890     ]
  2982     ]
  2891 !
  2983 !
  2892 
  2984 
  2893 unmappedView:aView
  2985 unmappedView:aView
  2894     "forward an unmapped event for some view"
  2986     "forward an unmapped event for some view"
  2895 
  2987 
  2896     |sensor|
  2988     |sensor|
  2897 
  2989 
  2898     (sensor := aView sensor) notNil ifTrue:[
  2990     (sensor := aView sensor) notNil ifTrue:[
  2899         sensor unmappedView:aView
  2991 	sensor unmappedView:aView
  2900     ] ifFalse:[
  2992     ] ifFalse:[
  2901         "
  2993 	"
  2902          if there is no sensor ...
  2994 	 if there is no sensor ...
  2903         "
  2995 	"
  2904         aView unmapped
  2996 	aView unmapped
  2905     ]
  2997     ]
  2906 ! !
  2998 ! !
  2907 
  2999 
  2908 !DeviceWorkstation methodsFor:'event handling'!
  3000 !DeviceWorkstation methodsFor:'event handling'!
  2909 
  3001 
  2914      We only do this for displays other that the default Display."
  3006      We only do this for displays other that the default Display."
  2915 
  3007 
  2916     dispatching ifFalse:[^ self].
  3008     dispatching ifFalse:[^ self].
  2917 
  3009 
  2918     self == Display ifTrue:[
  3010     self == Display ifTrue:[
  2919         ExitOnLastClose ifFalse:[^ self].
  3011 	ExitOnLastClose ifFalse:[^ self].
  2920     ].
  3012     ].
  2921 
  3013 
  2922     knownViews notNil ifTrue:[
  3014     knownViews notNil ifTrue:[
  2923         (knownViews findFirst:[:slot | 
  3015 	(knownViews findFirst:[:slot | 
  2924                 slot notNil 
  3016 		slot notNil 
  2925                 and:[slot ~~ 0
  3017 		and:[slot ~~ 0
  2926                 and:[slot isRootView not 
  3018 		and:[slot isRootView not 
  2927                 and:[slot superView isNil
  3019 		and:[slot superView isNil
  2928                 and:[slot realized]]]]]) == 0 ifTrue:[
  3020 		and:[slot realized]]]]]) == 0 ifTrue:[
  2929             "/ my last view was closed
  3021 	    "/ my last view was closed
  2930             dispatching := false.
  3022 	    dispatching := false.
  2931             'DeviceWorkstation [info]: finished dispatch (last view closed)' infoPrintCR.
  3023 	    'DeviceWorkstation [info]: finished dispatch (last view closed)' infoPrintCR.
  2932         ]
  3024 	]
  2933     ].
  3025     ].
  2934 
  3026 
  2935     "Modified: 19.9.1995 / 11:31:54 / claus"
  3027     "Modified: 19.9.1995 / 11:31:54 / claus"
  2936     "Modified: 18.3.1997 / 10:42:11 / cg"
  3028     "Modified: 18.3.1997 / 10:42:11 / cg"
  2937 !
  3029 !
  2970      it is used; otherwise we poll (with a delay to not lock up
  3062      it is used; otherwise we poll (with a delay to not lock up
  2971      the workstation)
  3063      the workstation)
  2972     "
  3064     "
  2973     myFd := self displayFileDescriptor.
  3065     myFd := self displayFileDescriptor.
  2974     [aBlock value] whileTrue:[
  3066     [aBlock value] whileTrue:[
  2975         self eventPending ifFalse:[
  3067 	self eventPending ifFalse:[
  2976             myFd isNil ifTrue:[
  3068 	    myFd isNil ifTrue:[
  2977                 OperatingSystem millisecondDelay:50
  3069 		OperatingSystem millisecondDelay:50
  2978             ] ifFalse:[
  3070 	    ] ifFalse:[
  2979                 OperatingSystem selectOn:myFd withTimeOut:50.
  3071 		OperatingSystem selectOn:myFd withTimeOut:50.
  2980             ].
  3072 	    ].
  2981             Processor evaluateTimeouts.
  3073 	    Processor evaluateTimeouts.
  2982         ].
  3074 	].
  2983         self eventPending ifTrue:[
  3075 	self eventPending ifTrue:[
  2984             self dispatchEvent
  3076 	    self dispatchEvent
  2985         ].
  3077 	].
  2986     ]
  3078     ]
  2987 !
  3079 !
  2988 
  3080 
  2989 dispatchPendingEvents
  3081 dispatchPendingEvents
  2990     "go dispatch events as long as there is one.
  3082     "go dispatch events as long as there is one.
  2991      This is only used with modal operation.
  3083      This is only used with modal operation.
  2992      (i.e. when in the modal debugger)"
  3084      (i.e. when in the modal debugger)"
  2993 
  3085 
  2994     [self eventPending] whileTrue:[
  3086     [self eventPending] whileTrue:[
  2995         self dispatchEventFor:nil withMask:nil
  3087 	self dispatchEventFor:nil withMask:nil
  2996     ]
  3088     ]
  2997 !
  3089 !
  2998 
  3090 
  2999 disposeButtonEventsFor:aViewIdOrNil
  3091 disposeButtonEventsFor:aViewIdOrNil
  3000     "dispose (i.e. forget) all pending button events on this display"
  3092     "dispose (i.e. forget) all pending button events on this display"
  3009 
  3101 
  3010 disposeEvents
  3102 disposeEvents
  3011     "dispose (i.e. forget) all events pending on this display"
  3103     "dispose (i.e. forget) all events pending on this display"
  3012 
  3104 
  3013     [self eventPending] whileTrue:[
  3105     [self eventPending] whileTrue:[
  3014         self getEventFor:nil withMask:nil
  3106 	self getEventFor:nil withMask:nil
  3015     ].
  3107     ].
  3016 !
  3108 !
  3017 
  3109 
  3018 disposeEventsWithMask:aMask for:aWindowId
  3110 disposeEventsWithMask:aMask for:aWindowId
  3019     "dispose (throw away) specific events"
  3111     "dispose (throw away) specific events"
  3078     "/
  3170     "/
  3079     dispatching ifTrue:[^ self].
  3171     dispatching ifTrue:[^ self].
  3080     dispatching := true.
  3172     dispatching := true.
  3081 
  3173 
  3082     AllScreens isNil ifTrue:[
  3174     AllScreens isNil ifTrue:[
  3083         AllScreens := IdentitySet new:1
  3175 	AllScreens := IdentitySet new:1
  3084     ].
  3176     ].
  3085     AllScreens add:self.
  3177     AllScreens add:self.
  3086 
  3178 
  3087     fd := self displayFileDescriptor.
  3179     fd := self displayFileDescriptor.
  3088 
  3180 
  3091     "/ on my filedescriptor. Since a select alone is not enough to
  3183     "/ on my filedescriptor. Since a select alone is not enough to
  3092     "/ know if events are pending (Xlib reads out event-queue while
  3184     "/ know if events are pending (Xlib reads out event-queue while
  3093     "/ doing output), we also have to install a poll-check block.        
  3185     "/ doing output), we also have to install a poll-check block.        
  3094 
  3186 
  3095     OperatingSystem supportsSelect ifTrue:[
  3187     OperatingSystem supportsSelect ifTrue:[
  3096         inputSema := Semaphore new name:'display inputSema'.
  3188 	inputSema := Semaphore new name:'display inputSema'.
  3097     ].
  3189     ].
  3098 
  3190 
  3099     p := [
  3191     p := [
  3100         self initializeDeviceResources.
  3192 	self initializeDeviceResources.
  3101 
  3193 
  3102         [dispatching] whileTrue:[
  3194 	[dispatching] whileTrue:[
  3103             AbortSignal handle:[:ex |
  3195 	    AbortSignal handle:[:ex |
  3104                 ex return
  3196 		ex return
  3105             ] do:[
  3197 	    ] do:[
  3106                 self eventPending ifFalse:[
  3198 		self eventPending ifFalse:[
  3107                     Processor activeProcess setStateTo:#ioWait if:#active.
  3199 		    Processor activeProcess setStateTo:#ioWait if:#active.
  3108                     inputSema notNil ifTrue:[
  3200 		    inputSema notNil ifTrue:[
  3109                         inputSema wait.
  3201 			inputSema wait.
  3110                     ] ifFalse:[
  3202 		    ] ifFalse:[
  3111                         Delay waitForMilliseconds:50
  3203 			Delay waitForMilliseconds:50
  3112                     ]
  3204 		    ]
  3113                 ].
  3205 		].
  3114 
  3206 
  3115                 self dispatchPendingEvents.
  3207 		self dispatchPendingEvents.
  3116             ]
  3208 	    ]
  3117         ].
  3209 	].
  3118         inputSema notNil ifTrue:[
  3210 	inputSema notNil ifTrue:[
  3119             Processor disableSemaphore:inputSema.
  3211 	    Processor disableSemaphore:inputSema.
  3120             inputSema := nil.
  3212 	    inputSema := nil.
  3121         ].
  3213 	].
  3122         AllScreens remove:self.
  3214 	AllScreens remove:self.
  3123         dispatchProcess := nil.
  3215 	dispatchProcess := nil.
  3124         self close.
  3216 	self close.
  3125     ] newProcess.
  3217     ] newProcess.
  3126 
  3218 
  3127     "/
  3219     "/
  3128     "/ give the process a nice name (for the processMonitor)
  3220     "/ give the process a nice name (for the processMonitor)
  3129     "/
  3221     "/
  3130     (nm := self displayName) notNil ifTrue:[
  3222     (nm := self displayName) notNil ifTrue:[
  3131         nm := 'event dispatcher (' ,  nm , ')'.
  3223 	nm := 'event dispatcher (' ,  nm , ')'.
  3132     ] ifFalse:[
  3224     ] ifFalse:[
  3133         nm := 'event dispatcher'.
  3225 	nm := 'event dispatcher'.
  3134     ].
  3226     ].
  3135     p name:nm.
  3227     p name:nm.
  3136     p priority:(Processor userInterruptPriority).
  3228     p priority:(Processor userInterruptPriority).
  3137     dispatchProcess := p.
  3229     dispatchProcess := p.
  3138     p resume.
  3230     p resume.
  3139 
  3231 
  3140     "/ finally, arrange for the processor to signal that semaphore on input
  3232     "/ finally, arrange for the processor to signal that semaphore on input
  3141 
  3233 
  3142     inputSema notNil ifTrue:[
  3234     inputSema notNil ifTrue:[
  3143         Processor signal:inputSema onInput:fd orCheck:[self eventPending].
  3235 	Processor signal:inputSema onInput:fd orCheck:[self eventPending].
  3144     ]
  3236     ]
  3145 
  3237 
  3146     "Modified: 12.12.1995 / 20:52:57 / stefan"
  3238     "Modified: 12.12.1995 / 20:52:57 / stefan"
  3147     "Modified: 1.2.1997 / 12:17:26 / cg"
  3239     "Modified: 1.2.1997 / 12:17:26 / cg"
  3148 ! !
  3240 ! !
  3223 
  3315 
  3224     ^ (fonts collect:[:descr | descr face]) asSortedCollection
  3316     ^ (fonts collect:[:descr | descr face]) asSortedCollection
  3225 
  3317 
  3226     "
  3318     "
  3227      Display facesInFamily:'fixed' filtering:[:f |
  3319      Display facesInFamily:'fixed' filtering:[:f |
  3228         f encoding notNil and:[f encoding startsWith:'jis']]
  3320 	f encoding notNil and:[f encoding startsWith:'jis']]
  3229     "
  3321     "
  3230 
  3322 
  3231     "Created: 27.2.1996 / 01:33:25 / cg"
  3323     "Created: 27.2.1996 / 01:33:25 / cg"
  3232     "Modified: 29.2.1996 / 04:29:01 / cg"
  3324     "Modified: 29.2.1996 / 04:29:01 / cg"
  3233 !
  3325 !
  3255 
  3347 
  3256     ^ (fonts collect:[:descr | descr family]) asSortedCollection
  3348     ^ (fonts collect:[:descr | descr family]) asSortedCollection
  3257 
  3349 
  3258     "
  3350     "
  3259      Display fontFamiliesFiltering:[:f | 
  3351      Display fontFamiliesFiltering:[:f | 
  3260         f encoding notNil and:[f encoding startsWith:'jis']]
  3352 	f encoding notNil and:[f encoding startsWith:'jis']]
  3261     "
  3353     "
  3262 
  3354 
  3263     "Modified: 29.2.1996 / 04:31:51 / cg"
  3355     "Modified: 29.2.1996 / 04:31:51 / cg"
  3264 !
  3356 !
  3265 
  3357 
  3276     maxDescent := self maxDescentOf:fontId.
  3368     maxDescent := self maxDescentOf:fontId.
  3277     minWidth := self minWidthOfFont:fontId.
  3369     minWidth := self minWidthOfFont:fontId.
  3278     maxWidth := self maxWidthOfFont:fontId.
  3370     maxWidth := self maxWidthOfFont:fontId.
  3279     avgWidth := self widthOf:' ' inFont:fontId.
  3371     avgWidth := self widthOf:' ' inFont:fontId.
  3280     aBlock value:encoding 
  3372     aBlock value:encoding 
  3281            value:avgAscent
  3373 	   value:avgAscent
  3282            value:avgDescent
  3374 	   value:avgDescent
  3283            value:maxAscent
  3375 	   value:maxAscent
  3284            value:maxDescent
  3376 	   value:maxDescent
  3285            value:minWidth
  3377 	   value:minWidth
  3286            value:maxWidth
  3378 	   value:maxWidth
  3287            value:avgWidth
  3379 	   value:avgWidth
  3288 !
  3380 !
  3289 
  3381 
  3290 fontResolutionOf:fontId
  3382 fontResolutionOf:fontId
  3291     "return the resolution (as dpiX @ dpiY) of the font - this is usually the displays resolution,
  3383     "return the resolution (as dpiX @ dpiY) of the font - this is usually the displays resolution,
  3292      but due to errors in some XServer installations, some use 75dpi fonts on higher
  3384      but due to errors in some XServer installations, some use 75dpi fonts on higher
  3304     allFonts := self listOfAvailableFonts.
  3396     allFonts := self listOfAvailableFonts.
  3305     allFonts isNil ifTrue:[^ nil].
  3397     allFonts isNil ifTrue:[^ nil].
  3306 
  3398 
  3307     fonts := Set new.
  3399     fonts := Set new.
  3308     allFonts do:[:fntDescr |
  3400     allFonts do:[:fntDescr |
  3309         (aFilterBlock isNil or:[aFilterBlock value:fntDescr]) ifTrue:[
  3401 	(aFilterBlock isNil or:[aFilterBlock value:fntDescr]) ifTrue:[
  3310             fntDescr family notNil ifTrue:[
  3402 	    fntDescr family notNil ifTrue:[
  3311                 fonts add:fntDescr
  3403 		fonts add:fntDescr
  3312             ]
  3404 	    ]
  3313         ]
  3405 	]
  3314     ].
  3406     ].
  3315     ^ fonts
  3407     ^ fonts
  3316 
  3408 
  3317     "
  3409     "
  3318      Display fontsFiltering:[:f | 
  3410      Display fontsFiltering:[:f | 
  3319         f encoding notNil and:[f encoding startsWith:'jis']]
  3411 	f encoding notNil and:[f encoding startsWith:'jis']]
  3320     "
  3412     "
  3321 
  3413 
  3322     "Modified: 29.2.1996 / 04:30:35 / cg"
  3414     "Modified: 29.2.1996 / 04:30:35 / cg"
  3323 !
  3415 !
  3324 
  3416 
  3331     allFonts := self listOfAvailableFonts.
  3423     allFonts := self listOfAvailableFonts.
  3332     allFonts isNil ifTrue:[^ nil].
  3424     allFonts isNil ifTrue:[^ nil].
  3333 
  3425 
  3334     fonts := Set new.
  3426     fonts := Set new.
  3335     allFonts do:[:fntDescr |
  3427     allFonts do:[:fntDescr |
  3336         (aFamilyName = fntDescr family) ifTrue:[
  3428 	(aFamilyName = fntDescr family) ifTrue:[
  3337             (aFaceName = fntDescr face) ifTrue:[
  3429 	    (aFaceName = fntDescr face) ifTrue:[
  3338                 (filter isNil or:[filter value:fntDescr]) ifTrue:[
  3430 		(filter isNil or:[filter value:fntDescr]) ifTrue:[
  3339                     fonts add:fntDescr
  3431 		    fonts add:fntDescr
  3340                 ]
  3432 		]
  3341             ]
  3433 	    ]
  3342         ]
  3434 	]
  3343     ].
  3435     ].
  3344     ^ fonts
  3436     ^ fonts
  3345 
  3437 
  3346     "
  3438     "
  3347      Display fontsInFamily:'fixed' face:'medium' filtering:[:f |
  3439      Display fontsInFamily:'fixed' face:'medium' filtering:[:f |
  3348         f encoding notNil and:[f encoding startsWith:'jis']]
  3440 	f encoding notNil and:[f encoding startsWith:'jis']]
  3349     "
  3441     "
  3350 
  3442 
  3351     "Created: 29.2.1996 / 04:32:56 / cg"
  3443     "Created: 29.2.1996 / 04:32:56 / cg"
  3352 !
  3444 !
  3353 
  3445 
  3361     allFonts := self listOfAvailableFonts.
  3453     allFonts := self listOfAvailableFonts.
  3362     allFonts isNil ifTrue:[^ nil].
  3454     allFonts isNil ifTrue:[^ nil].
  3363 
  3455 
  3364     fonts := Set new.
  3456     fonts := Set new.
  3365     allFonts do:[:fntDescr |
  3457     allFonts do:[:fntDescr |
  3366         (aFamilyName = fntDescr family) ifTrue:[
  3458 	(aFamilyName = fntDescr family) ifTrue:[
  3367             (aFaceName = fntDescr face) ifTrue:[
  3459 	    (aFaceName = fntDescr face) ifTrue:[
  3368                 (aStyleName = fntDescr style) ifTrue:[
  3460 		(aStyleName = fntDescr style) ifTrue:[
  3369                     (filter isNil or:[filter value:fntDescr]) ifTrue:[
  3461 		    (filter isNil or:[filter value:fntDescr]) ifTrue:[
  3370                         fonts add:fntDescr
  3462 			fonts add:fntDescr
  3371                     ]    
  3463 		    ]    
  3372                 ]
  3464 		]
  3373             ]
  3465 	    ]
  3374         ]
  3466 	]
  3375     ].
  3467     ].
  3376     ^ fonts
  3468     ^ fonts
  3377 
  3469 
  3378     "
  3470     "
  3379      Display fontsInFamily:'fixed' face:'medium' style:'roman' filtering:[:f |
  3471      Display fontsInFamily:'fixed' face:'medium' style:'roman' filtering:[:f |
  3380         f encoding notNil and:[f encoding startsWith:'jis']]
  3472 	f encoding notNil and:[f encoding startsWith:'jis']]
  3381     "
  3473     "
  3382 
  3474 
  3383     "Created: 29.2.1996 / 04:25:30 / cg"
  3475     "Created: 29.2.1996 / 04:25:30 / cg"
  3384 !
  3476 !
  3385 
  3477 
  3392     allFonts := self listOfAvailableFonts.
  3484     allFonts := self listOfAvailableFonts.
  3393     allFonts isNil ifTrue:[^ nil].
  3485     allFonts isNil ifTrue:[^ nil].
  3394 
  3486 
  3395     fonts := Set new.
  3487     fonts := Set new.
  3396     allFonts do:[:fntDescr |
  3488     allFonts do:[:fntDescr |
  3397         aFamilyName = fntDescr family ifTrue:[
  3489 	aFamilyName = fntDescr family ifTrue:[
  3398             (filterBlock isNil or:[filterBlock value:fntDescr]) ifTrue:[
  3490 	    (filterBlock isNil or:[filterBlock value:fntDescr]) ifTrue:[
  3399                 fonts add:fntDescr
  3491 		fonts add:fntDescr
  3400             ]
  3492 	    ]
  3401         ]
  3493 	]
  3402     ].
  3494     ].
  3403     ^ fonts
  3495     ^ fonts
  3404 
  3496 
  3405     "
  3497     "
  3406      Display fontsInFamily:'fixed' filtering:[:f |
  3498      Display fontsInFamily:'fixed' filtering:[:f |
  3407         f encoding notNil and:[f encoding startsWith:'jis']]
  3499 	f encoding notNil and:[f encoding startsWith:'jis']]
  3408     "
  3500     "
  3409 
  3501 
  3410     "Modified: 27.2.1996 / 01:34:11 / cg"
  3502     "Modified: 27.2.1996 / 01:34:11 / cg"
  3411     "Created: 29.2.1996 / 04:27:49 / cg"
  3503     "Created: 29.2.1996 / 04:27:49 / cg"
  3412 !
  3504 !
  3426 
  3518 
  3427     ^ self subclassResponsibility
  3519     ^ self subclassResponsibility
  3428 !
  3520 !
  3429 
  3521 
  3430 getFontWithFamily:familyString
  3522 getFontWithFamily:familyString
  3431              face:faceString
  3523 	     face:faceString
  3432             style:styleString
  3524 	    style:styleString
  3433              size:sizeArg
  3525 	     size:sizeArg
  3434          encoding:encodingSym
  3526 	 encoding:encodingSym
  3435 
  3527 
  3436     "try to get the specified font, return id.
  3528     "try to get the specified font, return id.
  3437      If not available, try next smaller font. 
  3529      If not available, try next smaller font. 
  3438      If no font fits, return nil"
  3530      If no font fits, return nil"
  3439 
  3531 
  3479 
  3571 
  3480     ^ fonts collect:[:descr | descr size].
  3572     ^ fonts collect:[:descr | descr size].
  3481 
  3573 
  3482     "
  3574     "
  3483      Display sizesInFamily:'fixed' face:'medium' style:'roman' filtering:[:f |
  3575      Display sizesInFamily:'fixed' face:'medium' style:'roman' filtering:[:f |
  3484         f encoding notNil and:[f encoding startsWith:'jis']]
  3576 	f encoding notNil and:[f encoding startsWith:'jis']]
  3485     "
  3577     "
  3486 
  3578 
  3487     "Created: 27.2.1996 / 01:37:56 / cg"
  3579     "Created: 27.2.1996 / 01:37:56 / cg"
  3488     "Modified: 29.2.1996 / 04:26:52 / cg"
  3580     "Modified: 29.2.1996 / 04:26:52 / cg"
  3489 !
  3581 !
  3512 
  3604 
  3513     ^ (fonts collect:[:descr | descr style]) asSortedCollection
  3605     ^ (fonts collect:[:descr | descr style]) asSortedCollection
  3514 
  3606 
  3515     "
  3607     "
  3516      Display stylesInFamily:'fixed' face:'medium' filtering:[:f |
  3608      Display stylesInFamily:'fixed' face:'medium' filtering:[:f |
  3517         f encoding notNil and:[f encoding startsWith:'jis']]
  3609 	f encoding notNil and:[f encoding startsWith:'jis']]
  3518     "
  3610     "
  3519 
  3611 
  3520     "Created: 27.2.1996 / 01:35:22 / cg"
  3612     "Created: 27.2.1996 / 01:35:22 / cg"
  3521     "Modified: 29.2.1996 / 04:33:59 / cg"
  3613     "Modified: 29.2.1996 / 04:33:59 / cg"
  3522 !
  3614 !
  3559 grabKeyboardInView:aView
  3651 grabKeyboardInView:aView
  3560     "grab the keyboard - all keyboard input will be sent to aView.
  3652     "grab the keyboard - all keyboard input will be sent to aView.
  3561      Return true if ok, false if it failed for some reason."
  3653      Return true if ok, false if it failed for some reason."
  3562 
  3654 
  3563     activeKeyboardGrab notNil ifTrue:[
  3655     activeKeyboardGrab notNil ifTrue:[
  3564         self ungrabKeyboard.
  3656 	self ungrabKeyboard.
  3565         activeKeyboardGrab := nil
  3657 	activeKeyboardGrab := nil
  3566     ].
  3658     ].
  3567     (self grabKeyboardIn:(aView id)) ifTrue:[
  3659     (self grabKeyboardIn:(aView id)) ifTrue:[
  3568         activeKeyboardGrab := aView.
  3660 	activeKeyboardGrab := aView.
  3569         ^ true
  3661 	^ true
  3570     ].
  3662     ].
  3571     ^ false
  3663     ^ false
  3572 !
  3664 !
  3573 
  3665 
  3574 grabPointerIn:aWindowId
  3666 grabPointerIn:aWindowId
  3589 grabPointerInView:aView
  3681 grabPointerInView:aView
  3590     "grap the pointer; all pointer events will be reported to
  3682     "grap the pointer; all pointer events will be reported to
  3591      aView. Return true if ok, false if it failed for some reason."
  3683      aView. Return true if ok, false if it failed for some reason."
  3592 
  3684 
  3593     activePointerGrab notNil ifTrue:[
  3685     activePointerGrab notNil ifTrue:[
  3594         self ungrabPointer.
  3686 	self ungrabPointer.
  3595         activePointerGrab := nil
  3687 	activePointerGrab := nil
  3596     ].
  3688     ].
  3597     (self grabPointerIn:(aView id)) ifTrue:[
  3689     (self grabPointerIn:(aView id)) ifTrue:[
  3598         activePointerGrab := aView.
  3690 	activePointerGrab := aView.
  3599         ^ true
  3691 	^ true
  3600     ].
  3692     ].
  3601     ^ false
  3693     ^ false
  3602 !
  3694 !
  3603 
  3695 
  3604 setActivePointerGrab:aView
  3696 setActivePointerGrab:aView
  3764      (which are the keySyms as symbol). The mapping table which is
  3856      (which are the keySyms as symbol). The mapping table which is
  3765      setup here, is used in sendKeyPress:... later.
  3857      setup here, is used in sendKeyPress:... later.
  3766     "
  3858     "
  3767 
  3859 
  3768     keyboardMap isNil ifTrue:[
  3860     keyboardMap isNil ifTrue:[
  3769         keyboardMap := KeyboardMap new.
  3861 	keyboardMap := KeyboardMap new.
  3770     ].
  3862     ].
  3771 
  3863 
  3772     "
  3864     "
  3773      no more setup here - moved everything out into 'display.rc' file
  3865      no more setup here - moved everything out into 'display.rc' file
  3774     "
  3866     "
  3776 
  3868 
  3777 initializeScreenProperties
  3869 initializeScreenProperties
  3778     "setup screen specific properties."
  3870     "setup screen specific properties."
  3779 
  3871 
  3780     supportsDeepIcons isNil ifTrue:[
  3872     supportsDeepIcons isNil ifTrue:[
  3781         supportsDeepIcons := false.
  3873 	supportsDeepIcons := false.
  3782     ].
  3874     ].
  3783 
  3875 
  3784     fixColors := ditherColors := nil.
  3876     fixColors := ditherColors := nil.
  3785     numFixRed := numFixGreen := numFixBlue := 0.
  3877     numFixRed := numFixGreen := numFixBlue := 0.
  3786 
  3878 
  3819     lastId := nil.
  3911     lastId := nil.
  3820     lastView := nil.
  3912     lastView := nil.
  3821 
  3913 
  3822     self initializeFor:nil.
  3914     self initializeFor:nil.
  3823     displayId isNil ifTrue:[
  3915     displayId isNil ifTrue:[
  3824         Smalltalk exit.
  3916 	Smalltalk exit.
  3825         ^ self
  3917 	^ self
  3826     ].
  3918     ].
  3827 
  3919 
  3828     "
  3920     "
  3829      first, all Forms must be recreated
  3921      first, all Forms must be recreated
  3830      (since they may be needed for view recreation as
  3922      (since they may be needed for view recreation as
  3832     "
  3924     "
  3833     Form reinitializeAllOn:self.
  3925     Form reinitializeAllOn:self.
  3834 
  3926 
  3835 "/    prevMapping notNil ifTrue:[
  3927 "/    prevMapping notNil ifTrue:[
  3836     prevKnownViews notNil ifTrue:[
  3928     prevKnownViews notNil ifTrue:[
  3837         "
  3929 	"
  3838          first round: flush all device specific stuff
  3930 	 first round: flush all device specific stuff
  3839         "
  3931 	"
  3840 "/      prevMapping keysAndValuesDo:[:anId :aView |
  3932 "/      prevMapping keysAndValuesDo:[:anId :aView |
  3841         prevKnownViews do:[:aView |
  3933 	prevKnownViews do:[:aView |
  3842             (aView notNil and:[aView ~~ 0]) ifTrue:[
  3934 	    (aView notNil and:[aView ~~ 0]) ifTrue:[
  3843                 aView prepareForReinit
  3935 		aView prepareForReinit
  3844             ]
  3936 	    ]
  3845         ].
  3937 	].
  3846 
  3938 
  3847         "
  3939 	"
  3848          2nd round: all views should reinstall themself
  3940 	 2nd round: all views should reinstall themself
  3849                     on the new display
  3941 		    on the new display
  3850         "
  3942 	"
  3851 "/      prevMapping keysAndValuesDo:[:anId :aView |
  3943 "/      prevMapping keysAndValuesDo:[:anId :aView |
  3852 
  3944 
  3853         prevKnownViews do:[:aView |
  3945 	prevKnownViews do:[:aView |
  3854             (aView notNil and:[aView ~~ 0]) ifTrue:[
  3946 	    (aView notNil and:[aView ~~ 0]) ifTrue:[
  3855                 "have to re-create the view"
  3947 		"have to re-create the view"
  3856                 AbortSignal catch:[
  3948 		AbortSignal catch:[
  3857                     aView reinitialize
  3949 		    aView reinitialize
  3858                 ]
  3950 		]
  3859             ]
  3951 	    ]
  3860         ].
  3952 	].
  3861 
  3953 
  3862         (prevWidth ~~ width
  3954 	(prevWidth ~~ width
  3863         or:[prevHeight ~~ height]) ifTrue:[
  3955 	or:[prevHeight ~~ height]) ifTrue:[
  3864             "
  3956 	    "
  3865              3rd round: all views get a chance to handle
  3957 	     3rd round: all views get a chance to handle
  3866                         changed environment (colors, font sizes etc)
  3958 			changed environment (colors, font sizes etc)
  3867             "
  3959 	    "
  3868 "/          prevMapping keysAndValuesDo:[:anId :aView |
  3960 "/          prevMapping keysAndValuesDo:[:anId :aView |
  3869             prevKnownViews do:[:aView |
  3961 	    prevKnownViews do:[:aView |
  3870                 (aView notNil and:[aView ~~ 0]) ifTrue:[
  3962 		(aView notNil and:[aView ~~ 0]) ifTrue:[
  3871                     aView reAdjustGeometry
  3963 		    aView reAdjustGeometry
  3872                 ]
  3964 		]
  3873             ]
  3965 	    ]
  3874         ]
  3966 	]
  3875     ].
  3967     ].
  3876     dispatching := false.
  3968     dispatching := false.
  3877 
  3969 
  3878     "Modified: 23.1.1997 / 21:32:10 / cg"
  3970     "Modified: 23.1.1997 / 21:32:10 / cg"
  3879 !
  3971 !
  3880 
  3972 
  3881 releaseDeviceResources
  3973 releaseDeviceResources
  3882     "release any cached device resources"
  3974     "release any cached device resources"
  3883 
  3975 
  3884     blackColor on:nil.  "/ release those colors
  3976     blackColor notNil ifTrue:[
  3885     blackColor := nil.
  3977 	blackColor on:nil. 
  3886     whiteColor on:nil.
  3978 	blackColor := nil.
  3887     whiteColor := nil.
  3979     ].
       
  3980     whiteColor notNil ifTrue:[
       
  3981 	whiteColor on:nil.
       
  3982 	whiteColor := nil.
       
  3983     ].
  3888 
  3984 
  3889     Image releaseResourcesOnDevice:self.
  3985     Image releaseResourcesOnDevice:self.
  3890     Color releaseResourcesOnDevice:self.
  3986     Color releaseResourcesOnDevice:self.
  3891     Cursor releaseResourcesOnDevice:self.
  3987     Cursor releaseResourcesOnDevice:self.
  3892     Font releaseResourcesOnDevice:self.
  3988     Font releaseResourcesOnDevice:self.
  3922 
  4018 
  3923     root noClipByChildren.
  4019     root noClipByChildren.
  3924     root foreground:blackColor background:whiteColor.
  4020     root foreground:blackColor background:whiteColor.
  3925 
  4021 
  3926     root xoring:[
  4022     root xoring:[
  3927         |left right top bottom newOrigin newCorner p|
  4023 	|left right top bottom newOrigin newCorner p|
  3928 
  4024 
  3929         rect := origin extent:extent.
  4025 	rect := origin extent:extent.
  3930         root displayRectangle:rect.
  4026 	root displayRectangle:rect.
  3931 
  4027 
  3932         self 
  4028 	self 
  3933             grabPointerIn:root id 
  4029 	    grabPointerIn:root id 
  3934             withCursor:curs id
  4030 	    withCursor:curs id
  3935             pointerMode:#async 
  4031 	    pointerMode:#async 
  3936             keyboardMode:#sync 
  4032 	    keyboardMode:#sync 
  3937             confineTo:nil.
  4033 	    confineTo:nil.
  3938 
  4034 
  3939         [self leftButtonPressed] whileTrue:[
  4035 	[self leftButtonPressed] whileTrue:[
  3940             newOrigin := self pointerPosition.
  4036 	    newOrigin := self pointerPosition.
  3941 
  4037 
  3942             (newOrigin ~= origin) ifTrue:[
  4038 	    (newOrigin ~= origin) ifTrue:[
  3943                 root displayRectangle:rect.
  4039 		root displayRectangle:rect.
  3944 
  4040 
  3945                 self 
  4041 		self 
  3946                     grabPointerIn:root id 
  4042 		    grabPointerIn:root id 
  3947                     withCursor:curs id
  4043 		    withCursor:curs id
  3948                     pointerMode:#async 
  4044 		    pointerMode:#async 
  3949                     keyboardMode:#sync 
  4045 		    keyboardMode:#sync 
  3950                     confineTo:nil.
  4046 		    confineTo:nil.
  3951 
  4047 
  3952                 rect := newOrigin extent:extent.
  4048 		rect := newOrigin extent:extent.
  3953                 root displayRectangle:rect.
  4049 		root displayRectangle:rect.
  3954                 self disposeButtonEventsFor:nil.
  4050 		self disposeButtonEventsFor:nil.
  3955                 self flush.
  4051 		self flush.
  3956                 origin := newOrigin.
  4052 		origin := newOrigin.
  3957             ] ifFalse:[
  4053 	    ] ifFalse:[
  3958                 Processor yield
  4054 		Processor yield
  3959             ]
  4055 	    ]
  3960         ].
  4056 	].
  3961         root displayRectangle:rect.
  4057 	root displayRectangle:rect.
  3962         self ungrabPointer.
  4058 	self ungrabPointer.
  3963     ].
  4059     ].
  3964 
  4060 
  3965     self ungrabPointer.
  4061     self ungrabPointer.
  3966 
  4062 
  3967     "flush all events pending on my display"
  4063     "flush all events pending on my display"
  4002 
  4098 
  4003     |p|
  4099     |p|
  4004 
  4100 
  4005     self ungrabPointer.
  4101     self ungrabPointer.
  4006     self grabPointerIn:(self rootWindowId) withCursor:((aCursor onDevice:self) id)
  4102     self grabPointerIn:(self rootWindowId) withCursor:((aCursor onDevice:self) id)
  4007          pointerMode:#async keyboardMode:#sync confineTo:nil.
  4103 	 pointerMode:#async keyboardMode:#sync confineTo:nil.
  4008     activePointerGrab := rootView.
  4104     activePointerGrab := rootView.
  4009 
  4105 
  4010     "
  4106     "
  4011      wait for leftButton ...
  4107      wait for leftButton ...
  4012     "
  4108     "
  4074 
  4170 
  4075     root noClipByChildren.
  4171     root noClipByChildren.
  4076     root foreground:blackColor background:whiteColor.
  4172     root foreground:blackColor background:whiteColor.
  4077 
  4173 
  4078     root xoring:[
  4174     root xoring:[
  4079         |left right top bottom newOrigin newCorner p curs|
  4175 	|left right top bottom newOrigin newCorner p curs|
  4080 
  4176 
  4081         corner := origin.
  4177 	corner := origin.
  4082         rect := origin corner:corner.
  4178 	rect := origin corner:corner.
  4083         root displayRectangle:rect.
  4179 	root displayRectangle:rect.
  4084 
  4180 
  4085         self 
  4181 	self 
  4086             grabPointerIn:root id 
  4182 	    grabPointerIn:root id 
  4087             withCursor:curs1 id
  4183 	    withCursor:curs1 id
  4088             pointerMode:#async 
  4184 	    pointerMode:#async 
  4089             keyboardMode:#sync 
  4185 	    keyboardMode:#sync 
  4090             confineTo:nil.
  4186 	    confineTo:nil.
  4091 
  4187 
  4092         "
  4188 	"
  4093          just in case; wait for button to be down ...
  4189 	 just in case; wait for button to be down ...
  4094         "
  4190 	"
  4095         [self leftButtonPressed] whileFalse:[Processor yield].
  4191 	[self leftButtonPressed] whileFalse:[Processor yield].
  4096 
  4192 
  4097         [self leftButtonPressed] whileTrue:[
  4193 	[self leftButtonPressed] whileTrue:[
  4098             left := initialRectangle origin x.
  4194 	    left := initialRectangle origin x.
  4099             top := initialRectangle origin y.
  4195 	    top := initialRectangle origin y.
  4100             right := initialRectangle corner x.
  4196 	    right := initialRectangle corner x.
  4101             bottom := initialRectangle corner y.
  4197 	    bottom := initialRectangle corner y.
  4102 
  4198 
  4103             p := self pointerPosition.
  4199 	    p := self pointerPosition.
  4104             p x < initialRectangle left ifTrue:[
  4200 	    p x < initialRectangle left ifTrue:[
  4105                 p y < initialRectangle top ifTrue:[
  4201 		p y < initialRectangle top ifTrue:[
  4106                     curs := Cursor topLeft.
  4202 		    curs := Cursor topLeft.
  4107                     left := p x.
  4203 		    left := p x.
  4108                     top := p y.
  4204 		    top := p y.
  4109                 ] ifFalse:[
  4205 		] ifFalse:[
  4110                     curs := Cursor bottomLeft.
  4206 		    curs := Cursor bottomLeft.
  4111                     left := p x.
  4207 		    left := p x.
  4112                     bottom := p y
  4208 		    bottom := p y
  4113                 ]
  4209 		]
  4114             ] ifFalse:[
  4210 	    ] ifFalse:[
  4115                 p y < initialRectangle top ifTrue:[
  4211 		p y < initialRectangle top ifTrue:[
  4116                     curs := Cursor topRight.
  4212 		    curs := Cursor topRight.
  4117                     right := p x.
  4213 		    right := p x.
  4118                     top := p y
  4214 		    top := p y
  4119                 ] ifFalse:[
  4215 		] ifFalse:[
  4120                     curs := Cursor bottomRight.
  4216 		    curs := Cursor bottomRight.
  4121                     right := p x.
  4217 		    right := p x.
  4122                     bottom := p y
  4218 		    bottom := p y
  4123                 ]
  4219 		]
  4124             ].
  4220 	    ].
  4125 
  4221 
  4126             newOrigin := left @ top.
  4222 	    newOrigin := left @ top.
  4127             newCorner := right @ bottom.
  4223 	    newCorner := right @ bottom.
  4128 
  4224 
  4129             ((newOrigin ~= origin) or:[newCorner ~= corner]) ifTrue:[
  4225 	    ((newOrigin ~= origin) or:[newCorner ~= corner]) ifTrue:[
  4130                 root displayRectangle:rect.
  4226 		root displayRectangle:rect.
  4131 
  4227 
  4132                 self grabPointerIn:root id withCursor:curs id
  4228 		self grabPointerIn:root id withCursor:curs id
  4133                          pointerMode:#async keyboardMode:#sync confineTo:nil.
  4229 			 pointerMode:#async keyboardMode:#sync confineTo:nil.
  4134 
  4230 
  4135                 origin :=  newOrigin.
  4231 		origin :=  newOrigin.
  4136                 corner :=  newCorner.
  4232 		corner :=  newCorner.
  4137                 rect := origin corner:corner.
  4233 		rect := origin corner:corner.
  4138                 root displayRectangle:rect.
  4234 		root displayRectangle:rect.
  4139                 self disposeButtonEventsFor:nil.
  4235 		self disposeButtonEventsFor:nil.
  4140                 self flush.
  4236 		self flush.
  4141             ] ifFalse:[
  4237 	    ] ifFalse:[
  4142                 Processor yield
  4238 		Processor yield
  4143             ]
  4239 	    ]
  4144         ].
  4240 	].
  4145         root displayRectangle:rect.
  4241 	root displayRectangle:rect.
  4146         self ungrabPointer.
  4242 	self ungrabPointer.
  4147     ].
  4243     ].
  4148 
  4244 
  4149     self ungrabPointer.
  4245     self ungrabPointer.
  4150 
  4246 
  4151     "flush all events pending on my display"
  4247     "flush all events pending on my display"
  4173 
  4269 
  4174     |v|
  4270     |v|
  4175 
  4271 
  4176     v := self viewFromUser.
  4272     v := self viewFromUser.
  4177     v notNil ifTrue:[
  4273     v notNil ifTrue:[
  4178         v := v topView
  4274 	v := v topView
  4179     ].
  4275     ].
  4180     ^ v 
  4276     ^ v 
  4181 
  4277 
  4182     "
  4278     "
  4183      Display topviewFromUser
  4279      Display topviewFromUser
  4278 modifierKeyProcessing:key down:pressed
  4374 modifierKeyProcessing:key down:pressed
  4279     "internal, private method.
  4375     "internal, private method.
  4280      Called with every keyPress/keyRelease to update the xxxDown flags."
  4376      Called with every keyPress/keyRelease to update the xxxDown flags."
  4281 
  4377 
  4282     (altModifiers notNil and:[altModifiers includes:key]) ifTrue:[
  4378     (altModifiers notNil and:[altModifiers includes:key]) ifTrue:[
  4283         altDown := pressed
  4379 	altDown := pressed
  4284     ] ifFalse:[
  4380     ] ifFalse:[
  4285         (metaModifiers notNil and:[metaModifiers includes:key]) ifTrue:[
  4381 	(metaModifiers notNil and:[metaModifiers includes:key]) ifTrue:[
  4286             metaDown := pressed
  4382 	    metaDown := pressed
  4287         ] ifFalse:[
  4383 	] ifFalse:[
  4288             (shiftModifiers notNil and:[shiftModifiers includes:key]) ifTrue:[
  4384 	    (shiftModifiers notNil and:[shiftModifiers includes:key]) ifTrue:[
  4289                 shiftDown := pressed
  4385 		shiftDown := pressed
  4290             ] ifFalse:[
  4386 	    ] ifFalse:[
  4291                 (ctrlModifiers notNil and:[ctrlModifiers includes:key]) ifTrue:[
  4387 		(ctrlModifiers notNil and:[ctrlModifiers includes:key]) ifTrue:[
  4292                     ctrlDown := pressed
  4388 		    ctrlDown := pressed
  4293                 ]
  4389 		]
  4294             ]
  4390 	    ]
  4295         ]
  4391 	]
  4296     ]
  4392     ]
  4297 
  4393 
  4298     "Modified: 2.1.1996 / 15:00:25 / cg"
  4394     "Modified: 2.1.1996 / 15:00:25 / cg"
  4299 !
  4395 !
  4300 
  4396 
  4303      (i.e. to get the keyTop from a modifier)"
  4399      (i.e. to get the keyTop from a modifier)"
  4304 
  4400 
  4305     |t modifiers|
  4401     |t modifiers|
  4306 
  4402 
  4307     key == #Alt ifTrue:[
  4403     key == #Alt ifTrue:[
  4308         modifiers := altModifiers
  4404 	modifiers := altModifiers
  4309     ] ifFalse:[
  4405     ] ifFalse:[
  4310         key == #Cmd ifTrue:[
  4406 	key == #Cmd ifTrue:[
  4311             modifiers := metaModifiers
  4407 	    modifiers := metaModifiers
  4312         ]
  4408 	]
  4313     ].
  4409     ].
  4314     (modifiers size > 0) ifTrue:[
  4410     (modifiers size > 0) ifTrue:[
  4315         t := modifiers first.
  4411 	t := modifiers first.
  4316         (t includes:$_) ifTrue:[
  4412 	(t includes:$_) ifTrue:[
  4317             t := t copyTo:(t indexOf:$_)-1
  4413 	    t := t copyTo:(t indexOf:$_)-1
  4318         ].
  4414 	].
  4319         ^ t
  4415 	^ t
  4320     ].
  4416     ].
  4321     ^ key
  4417     ^ key
  4322 
  4418 
  4323     "Created: 28.2.1996 / 17:07:08 / cg"
  4419     "Created: 28.2.1996 / 17:07:08 / cg"
  4324     "Modified: 20.3.1996 / 17:03:39 / cg"
  4420     "Modified: 20.3.1996 / 17:03:39 / cg"
  4332 
  4428 
  4333     "/ the next statement will vanish ....
  4429     "/ the next statement will vanish ....
  4334     (untranslatedKey == #Control
  4430     (untranslatedKey == #Control
  4335     or:[untranslatedKey == #'Control_L'   
  4431     or:[untranslatedKey == #'Control_L'   
  4336     or:[untranslatedKey == #'Control_R']]) ifTrue:[
  4432     or:[untranslatedKey == #'Control_R']]) ifTrue:[
  4337         ^ #Ctrl
  4433 	^ #Ctrl
  4338     ].
  4434     ].
  4339 
  4435 
  4340     (untranslatedKey == #Ctrl
  4436     (untranslatedKey == #Ctrl
  4341     or:[untranslatedKey == #'Ctrl_L' 
  4437     or:[untranslatedKey == #'Ctrl_L' 
  4342     or:[untranslatedKey == #'Ctrl_R']]) ifTrue:[
  4438     or:[untranslatedKey == #'Ctrl_R']]) ifTrue:[
  4343         ^ #Ctrl
  4439 	^ #Ctrl
  4344     ].
  4440     ].
  4345     (untranslatedKey == #'Shift'   
  4441     (untranslatedKey == #'Shift'   
  4346     or:[untranslatedKey == #'Shift_L'   
  4442     or:[untranslatedKey == #'Shift_L'   
  4347     or:[untranslatedKey == #'Shift_R']]) ifTrue:[
  4443     or:[untranslatedKey == #'Shift_R']]) ifTrue:[
  4348         ^ #Shift
  4444 	^ #Shift
  4349     ].
  4445     ].
  4350     (untranslatedKey == #'Alt'   
  4446     (untranslatedKey == #'Alt'   
  4351     or:[untranslatedKey == #'Alt_L'   
  4447     or:[untranslatedKey == #'Alt_L'   
  4352     or:[untranslatedKey == #'Alt_R']]) ifTrue:[
  4448     or:[untranslatedKey == #'Alt_R']]) ifTrue:[
  4353         ^ #Alt
  4449 	^ #Alt
  4354     ].
  4450     ].
  4355     (untranslatedKey == #'Meta'   
  4451     (untranslatedKey == #'Meta'   
  4356     or:[untranslatedKey == #'Meta_L'   
  4452     or:[untranslatedKey == #'Meta_L'   
  4357     or:[untranslatedKey == #'Meta_R']]) ifTrue:[
  4453     or:[untranslatedKey == #'Meta_R']]) ifTrue:[
  4358         ^ #Meta
  4454 	^ #Meta
  4359     ].
  4455     ].
  4360     (untranslatedKey == #'Cmd'   
  4456     (untranslatedKey == #'Cmd'   
  4361     or:[untranslatedKey == #'Cmd_L'   
  4457     or:[untranslatedKey == #'Cmd_L'   
  4362     or:[untranslatedKey == #'Cmd_R']]) ifTrue:[
  4458     or:[untranslatedKey == #'Cmd_R']]) ifTrue:[
  4363         ^ #Cmd
  4459 	^ #Cmd
  4364     ].
  4460     ].
  4365     ^ nil
  4461     ^ nil
  4366 
  4462 
  4367     "Created: 28.2.1996 / 16:40:46 / cg"
  4463     "Created: 28.2.1996 / 16:40:46 / cg"
  4368     "Modified: 28.2.1996 / 17:11:34 / cg"
  4464     "Modified: 28.2.1996 / 17:11:34 / cg"
  4395     modifier := self modifierKeyTranslationFor:untranslatedKey.
  4491     modifier := self modifierKeyTranslationFor:untranslatedKey.
  4396     "/
  4492     "/
  4397     "/ only prepend, if this is not a modifier
  4493     "/ only prepend, if this is not a modifier
  4398     "/
  4494     "/
  4399     modifier isNil ifTrue:[
  4495     modifier isNil ifTrue:[
  4400         s := xlatedKey asString.
  4496 	s := xlatedKey asString.
  4401         ctrlDown ifTrue:[
  4497 	ctrlDown ifTrue:[
  4402             xlatedKey := 'Ctrl' , s
  4498 	    xlatedKey := 'Ctrl' , s
  4403         ].
  4499 	].
  4404         metaDown ifTrue:[
  4500 	metaDown ifTrue:[
  4405             xlatedKey := 'Cmd' , s
  4501 	    xlatedKey := 'Cmd' , s
  4406         ].
  4502 	].
  4407         altDown ifTrue:[
  4503 	altDown ifTrue:[
  4408             xlatedKey := 'Alt' , s
  4504 	    xlatedKey := 'Alt' , s
  4409         ].
  4505 	].
  4410         xlatedKey isCharacter ifFalse:[
  4506 	xlatedKey isCharacter ifFalse:[
  4411             xlatedKey := xlatedKey asSymbol
  4507 	    xlatedKey := xlatedKey asSymbol
  4412         ].
  4508 	].
  4413     ].
  4509     ].
  4414 
  4510 
  4415     xlatedKey := keyboardMap valueFor:xlatedKey.
  4511     xlatedKey := keyboardMap valueFor:xlatedKey.
  4416     xlatedKey isCharacter ifFalse:[
  4512     xlatedKey isCharacter ifFalse:[
  4417         xlatedKey := xlatedKey asSymbol
  4513 	xlatedKey := xlatedKey asSymbol
  4418     ].
  4514     ].
  4419     ^ xlatedKey
  4515     ^ xlatedKey
  4420 
  4516 
  4421     "Modified: 28.2.1996 / 17:12:16 / cg"
  4517     "Modified: 28.2.1996 / 17:12:16 / cg"
  4422 ! !
  4518 ! !
  4625 
  4721 
  4626     super printOn:aStream.
  4722     super printOn:aStream.
  4627 
  4723 
  4628     aStream nextPut:$(.
  4724     aStream nextPut:$(.
  4629     (name := self displayName) isNil ifTrue:[
  4725     (name := self displayName) isNil ifTrue:[
  4630         name := 'defaultDisplay'
  4726 	name := 'defaultDisplay'
  4631     ].
  4727     ].
  4632     aStream nextPutAll:name.
  4728     aStream nextPutAll:name.
  4633     aStream nextPut:$)
  4729     aStream nextPut:$)
  4634 ! !
  4730 ! !
  4635 
  4731 
  4653      info and the bits in imageBits. The info contains the depth, bitOrder and
  4749      info and the bits in imageBits. The info contains the depth, bitOrder and
  4654      number of bytes per scanline. The number of bytes per scanline is not known
  4750      number of bytes per scanline. The number of bytes per scanline is not known
  4655      in advance, since the X-server is free to return whatever it thinks is a good padding."
  4751      in advance, since the X-server is free to return whatever it thinks is a good padding."
  4656 
  4752 
  4657     ^ self
  4753     ^ self
  4658         getBitsFromId:aDrawableId 
  4754 	getBitsFromId:aDrawableId 
  4659         x:srcx 
  4755 	x:srcx 
  4660         y:srcy 
  4756 	y:srcy 
  4661         width:w 
  4757 	width:w 
  4662         height:h 
  4758 	height:h 
  4663         into:imageBits
  4759 	into:imageBits
  4664 
  4760 
  4665     "Created: 19.3.1997 / 13:43:04 / cg"
  4761     "Created: 19.3.1997 / 13:43:04 / cg"
  4666     "Modified: 19.3.1997 / 13:43:38 / cg"
  4762     "Modified: 19.3.1997 / 13:43:38 / cg"
  4667 !
  4763 !
  4668 
  4764 
  4672      info and the bits in imageBits. The info contains the depth, bitOrder and
  4768      info and the bits in imageBits. The info contains the depth, bitOrder and
  4673      number of bytes per scanline. The number of bytes per scanline is not known
  4769      number of bytes per scanline. The number of bytes per scanline is not known
  4674      in advance, since the X-server is free to return whatever it thinks is a good padding."
  4770      in advance, since the X-server is free to return whatever it thinks is a good padding."
  4675 
  4771 
  4676     ^ self
  4772     ^ self
  4677         getBitsFromId:aDrawableId 
  4773 	getBitsFromId:aDrawableId 
  4678         x:srcx 
  4774 	x:srcx 
  4679         y:srcy 
  4775 	y:srcy 
  4680         width:w 
  4776 	width:w 
  4681         height:h 
  4777 	height:h 
  4682         into:imageBits
  4778 	into:imageBits
  4683 
  4779 
  4684     "Created: 19.3.1997 / 13:43:04 / cg"
  4780     "Created: 19.3.1997 / 13:43:04 / cg"
  4685     "Modified: 19.3.1997 / 13:43:42 / cg"
  4781     "Modified: 19.3.1997 / 13:43:42 / cg"
  4686 !
  4782 !
  4687 
  4783 
  4729     |o s|
  4825     |o s|
  4730 
  4826 
  4731     o := self getCopyBuffer.
  4827     o := self getCopyBuffer.
  4732     s := o.
  4828     s := o.
  4733     o isString ifFalse:[
  4829     o isString ifFalse:[
  4734         o isNil ifTrue:[
  4830 	o isNil ifTrue:[
  4735             s := ''
  4831 	    s := ''
  4736         ] ifFalse:[
  4832 	] ifFalse:[
  4737             (o isKindOf:StringCollection) ifTrue:[
  4833 	    (o isKindOf:StringCollection) ifTrue:[
  4738                 s := o asStringWithCRsFrom:1 to:(o size) compressTabs:false withCR:false.
  4834 		s := o asStringWithCRsFrom:1 to:(o size) compressTabs:false withCR:false.
  4739                 s := s string.
  4835 		s := s string.
  4740             ] ifFalse:[
  4836 	    ] ifFalse:[
  4741                 o isString ifTrue:[
  4837 		o isString ifTrue:[
  4742                     s := o string
  4838 		    s := o string
  4743                 ] ifFalse:[
  4839 		] ifFalse:[
  4744                     s := o storeString
  4840 		    s := o storeString
  4745                 ]
  4841 		]
  4746             ]
  4842 	    ]
  4747         ]
  4843 	]
  4748     ].
  4844     ].
  4749     ^ s
  4845     ^ s
  4750 
  4846 
  4751     "Created: 13.2.1997 / 13:10:30 / cg"
  4847     "Created: 13.2.1997 / 13:10:30 / cg"
  4752 !
  4848 !
  4791     |freeIdx newArr sz newSize wasBlocked|
  4887     |freeIdx newArr sz newSize wasBlocked|
  4792 
  4888 
  4793     wasBlocked := OperatingSystem blockInterrupts.
  4889     wasBlocked := OperatingSystem blockInterrupts.
  4794 
  4890 
  4795     knownViews isNil ifTrue:[
  4891     knownViews isNil ifTrue:[
  4796         knownViews := WeakArray new:50.
  4892 	knownViews := WeakArray new:50.
  4797         knownIds := Array new:50.
  4893 	knownIds := Array new:50.
  4798         freeIdx := 1.
  4894 	freeIdx := 1.
  4799     ] ifFalse:[
  4895     ] ifFalse:[
  4800         freeIdx := knownViews identityIndexOf:nil.
  4896 	freeIdx := knownViews identityIndexOf:nil.
  4801         freeIdx == 0 ifTrue:[
  4897 	freeIdx == 0 ifTrue:[
  4802             freeIdx := knownViews identityIndexOf:0.
  4898 	    freeIdx := knownViews identityIndexOf:0.
  4803             [freeIdx ~~ 0 
  4899 	    [freeIdx ~~ 0 
  4804              and:[(knownIds at:freeIdx) notNil]] whileTrue:[
  4900 	     and:[(knownIds at:freeIdx) notNil]] whileTrue:[
  4805                 'XXX ' print. (knownIds at:freeIdx) displayString printCR.
  4901 		'XXX ' print. (knownIds at:freeIdx) displayString printCR.
  4806                 freeIdx := knownViews identityIndexOf:0 startingAt:(freeIdx + 1).
  4902 		freeIdx := knownViews identityIndexOf:0 startingAt:(freeIdx + 1).
  4807             ].
  4903 	    ].
  4808         ].
  4904 	].
  4809     ].
  4905     ].
  4810 
  4906 
  4811     freeIdx == 0 ifTrue:[
  4907     freeIdx == 0 ifTrue:[
  4812         sz := knownViews size.
  4908 	sz := knownViews size.
  4813         newSize := sz * 2.
  4909 	newSize := sz * 2.
  4814         newArr := WeakArray new:newSize.
  4910 	newArr := WeakArray new:newSize.
  4815         newArr replaceFrom:1 to:sz with:knownViews.
  4911 	newArr replaceFrom:1 to:sz with:knownViews.
  4816         knownViews := newArr.
  4912 	knownViews := newArr.
  4817 
  4913 
  4818         newArr := Array new:newSize.
  4914 	newArr := Array new:newSize.
  4819         newArr replaceFrom:1 to:sz with:knownIds.
  4915 	newArr replaceFrom:1 to:sz with:knownIds.
  4820         knownIds := newArr.
  4916 	knownIds := newArr.
  4821         freeIdx := sz + 1.
  4917 	freeIdx := sz + 1.
  4822     ].
  4918     ].
  4823     knownViews at:freeIdx put:aView.
  4919     knownViews at:freeIdx put:aView.
  4824     knownIds at:freeIdx put:aWindowID.
  4920     knownIds at:freeIdx put:aWindowID.
  4825     wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
  4921     wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
  4826 
  4922 
  4827     idToTableIndexMapping notNil ifTrue:[
  4923     idToTableIndexMapping notNil ifTrue:[
  4828         idToTableIndexMapping at:aWindowID put:freeIdx.
  4924 	idToTableIndexMapping at:aWindowID put:freeIdx.
  4829     ].
  4925     ].
  4830 
  4926 
  4831 "/    dispatching ifFalse:[
  4927 "/    dispatching ifFalse:[
  4832 "/        self startDispatch
  4928 "/        self startDispatch
  4833 "/    ].
  4929 "/    ].
  4842 
  4938 
  4843     lastId := nil.
  4939     lastId := nil.
  4844     lastView := nil.
  4940     lastView := nil.
  4845 
  4941 
  4846     knownViews notNil ifTrue:[
  4942     knownViews notNil ifTrue:[
  4847         wasBlocked := OperatingSystem blockInterrupts.
  4943 	wasBlocked := OperatingSystem blockInterrupts.
  4848 
  4944 
  4849         index := 0.
  4945 	index := 0.
  4850         aViewId notNil ifTrue:[
  4946 	aViewId notNil ifTrue:[
  4851             idToTableIndexMapping notNil ifTrue:[
  4947 	    idToTableIndexMapping notNil ifTrue:[
  4852                 index := idToTableIndexMapping at:aViewId ifAbsent:0.
  4948 		index := idToTableIndexMapping at:aViewId ifAbsent:0.
  4853             ]
  4949 	    ]
  4854         ].
  4950 	].
  4855         index == 0 ifTrue:[
  4951 	index == 0 ifTrue:[
  4856             aView notNil ifTrue:[
  4952 	    aView notNil ifTrue:[
  4857                 index := knownViews identityIndexOf:aView.
  4953 		index := knownViews identityIndexOf:aView.
  4858             ].
  4954 	    ].
  4859         ].
  4955 	].
  4860 
  4956 
  4861         index ~~ 0 ifTrue:[
  4957 	index ~~ 0 ifTrue:[
  4862             idToTableIndexMapping notNil ifTrue:[
  4958 	    idToTableIndexMapping notNil ifTrue:[
  4863                 aViewId notNil ifTrue:[
  4959 		aViewId notNil ifTrue:[
  4864                     idToTableIndexMapping removeKey:aViewId ifAbsent:nil
  4960 		    idToTableIndexMapping removeKey:aViewId ifAbsent:nil
  4865                 ] ifFalse:[
  4961 		] ifFalse:[
  4866                     id := knownIds at:index.
  4962 		    id := knownIds at:index.
  4867                     id notNil ifTrue:[
  4963 		    id notNil ifTrue:[
  4868                         idToTableIndexMapping removeKey:id ifAbsent:nil.
  4964 			idToTableIndexMapping removeKey:id ifAbsent:nil.
  4869                     ]
  4965 		    ]
  4870                 ]
  4966 		]
  4871             ].
  4967 	    ].
  4872             knownViews at:index put:nil.
  4968 	    knownViews at:index put:nil.
  4873             knownIds at:index put:nil.
  4969 	    knownIds at:index put:nil.
  4874             lastId := nil.
  4970 	    lastId := nil.
  4875             lastView := nil.
  4971 	    lastView := nil.
  4876         ].
  4972 	].
  4877 
  4973 
  4878         wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
  4974 	wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
  4879 
  4975 
  4880         aView notNil ifTrue:[
  4976 	aView notNil ifTrue:[
  4881             aView isTopView ifTrue:[
  4977 	    aView isTopView ifTrue:[
  4882                 "/ check for sparsely filled knownViews - array
  4978 		"/ check for sparsely filled knownViews - array
  4883                 wasBlocked := OperatingSystem blockInterrupts.
  4979 		wasBlocked := OperatingSystem blockInterrupts.
  4884                 n := 0.
  4980 		n := 0.
  4885                 knownViews do:[:v |
  4981 		knownViews do:[:v |
  4886                     (v notNil and:[v ~~ 0]) ifTrue:[
  4982 		    (v notNil and:[v ~~ 0]) ifTrue:[
  4887                         n := n + 1
  4983 			n := n + 1
  4888                     ].
  4984 		    ].
  4889                 ].
  4985 		].
  4890                 n < (knownViews size * 2 // 3) ifTrue:[
  4986 		n < (knownViews size * 2 // 3) ifTrue:[
  4891                     newSize := n * 3 // 2.
  4987 		    newSize := n * 3 // 2.
  4892                     newSize > 50 ifTrue:[
  4988 		    newSize > 50 ifTrue:[
  4893                         nV := WeakArray new:newSize.
  4989 			nV := WeakArray new:newSize.
  4894                         nI := Array new:newSize.
  4990 			nI := Array new:newSize.
  4895                         dstIdx := 1.
  4991 			dstIdx := 1.
  4896                         1 to:knownViews size do:[:srcIdx |
  4992 			1 to:knownViews size do:[:srcIdx |
  4897                             v := knownViews at:srcIdx.
  4993 			    v := knownViews at:srcIdx.
  4898                             (v notNil and:[v ~~ 0]) ifTrue:[
  4994 			    (v notNil and:[v ~~ 0]) ifTrue:[
  4899                                 nV at:dstIdx put:v.
  4995 				nV at:dstIdx put:v.
  4900                                 nI at:dstIdx put:(knownIds at:srcIdx).
  4996 				nI at:dstIdx put:(knownIds at:srcIdx).
  4901                                 dstIdx := dstIdx + 1.
  4997 				dstIdx := dstIdx + 1.
  4902                             ].
  4998 			    ].
  4903                         ].
  4999 			].
  4904                         knownViews := nV.
  5000 			knownViews := nV.
  4905                         knownIds := nI.
  5001 			knownIds := nI.
  4906                         idToTableIndexMapping := Dictionary new.
  5002 			idToTableIndexMapping := Dictionary new.
  4907                         knownIds keysAndValuesDo:[:idx :id |
  5003 			knownIds keysAndValuesDo:[:idx :id |
  4908                             id notNil ifTrue:[
  5004 			    id notNil ifTrue:[
  4909                                 idToTableIndexMapping at:id put:idx
  5005 				idToTableIndexMapping at:id put:idx
  4910                             ]
  5006 			    ]
  4911                         ].
  5007 			].
  4912                     ].
  5008 		    ].
  4913                 ].
  5009 		].
  4914                 wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
  5010 		wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
  4915             ].
  5011 	    ].
  4916         ].
  5012 	].
  4917         self checkForEndOfDispatch.
  5013 	self checkForEndOfDispatch.
  4918     ]
  5014     ]
  4919 
  5015 
  4920     "Created: 22.3.1997 / 14:56:20 / cg"
  5016     "Created: 22.3.1997 / 14:56:20 / cg"
  4921     "Modified: 27.3.1997 / 17:13:28 / cg"
  5017     "Modified: 27.3.1997 / 17:13:28 / cg"
  4922 !
  5018 !
  4925     "given an Id, return the corresponding view."
  5021     "given an Id, return the corresponding view."
  4926 
  5022 
  4927     |index v idx|
  5023     |index v idx|
  4928 
  5024 
  4929     aWindowID = lastId ifTrue:[
  5025     aWindowID = lastId ifTrue:[
  4930         lastView notNil ifTrue:[
  5026 	lastView notNil ifTrue:[
  4931             ^ lastView
  5027 	    ^ lastView
  4932         ]
  5028 	]
  4933     ].
  5029     ].
  4934 
  5030 
  4935     idToTableIndexMapping notNil ifTrue:[
  5031     idToTableIndexMapping notNil ifTrue:[
  4936         idx := idToTableIndexMapping at:aWindowID ifAbsent:nil.
  5032 	idx := idToTableIndexMapping at:aWindowID ifAbsent:nil.
  4937         idx notNil ifTrue:[
  5033 	idx notNil ifTrue:[
  4938             v := knownViews at:idx.
  5034 	    v := knownViews at:idx.
  4939             (v notNil and:[v ~~ 0]) ifTrue:[
  5035 	    (v notNil and:[v ~~ 0]) ifTrue:[
  4940                 lastView := v.
  5036 		lastView := v.
  4941                 lastId := aWindowID.
  5037 		lastId := aWindowID.
  4942                 ^ v
  5038 		^ v
  4943             ].
  5039 	    ].
  4944         ]
  5040 	]
  4945     ].
  5041     ].
  4946 
  5042 
  4947     index := knownIds indexOf:aWindowID.
  5043     index := knownIds indexOf:aWindowID.
  4948     index == 0 ifTrue:[
  5044     index == 0 ifTrue:[
  4949         ^ nil
  5045 	^ nil
  4950     ].
  5046     ].
  4951 
  5047 
  4952     v := knownViews at:index.
  5048     v := knownViews at:index.
  4953     v == 0 ifTrue:[
  5049     v == 0 ifTrue:[
  4954         knownViews at:index put:nil.
  5050 	knownViews at:index put:nil.
  4955         knownIds at:index put:nil.
  5051 	knownIds at:index put:nil.
  4956         ^ nil
  5052 	^ nil
  4957     ].
  5053     ].
  4958 
  5054 
  4959     lastId := aWindowID.
  5055     lastId := aWindowID.
  4960     lastView := v.
  5056     lastView := v.
  4961 
  5057 
  4968     "return true, if I still consider a windowId as being valid"
  5064     "return true, if I still consider a windowId as being valid"
  4969 
  5065 
  4970     |index v|
  5066     |index v|
  4971 
  5067 
  4972     aWindowID = lastId ifTrue:[
  5068     aWindowID = lastId ifTrue:[
  4973         lastView notNil ifTrue:[
  5069 	lastView notNil ifTrue:[
  4974             ^ true
  5070 	    ^ true
  4975         ]
  5071 	]
  4976     ].
  5072     ].
  4977 
  5073 
  4978     idToTableIndexMapping notNil ifTrue:[
  5074     idToTableIndexMapping notNil ifTrue:[
  4979         index := idToTableIndexMapping at:aWindowID ifAbsent:nil.
  5075 	index := idToTableIndexMapping at:aWindowID ifAbsent:nil.
  4980     ].
  5076     ].
  4981     index isNil ifTrue:[
  5077     index isNil ifTrue:[
  4982         index := knownIds indexOf:aWindowID.
  5078 	index := knownIds indexOf:aWindowID.
  4983     ].
  5079     ].
  4984     index ~~ 0 ifTrue:[
  5080     index ~~ 0 ifTrue:[
  4985         v := knownViews at:index.
  5081 	v := knownViews at:index.
  4986         ^ (v notNil and:[v ~~ 0])
  5082 	^ (v notNil and:[v ~~ 0])
  4987     ].
  5083     ].
  4988     ^ false.
  5084     ^ false.
  4989 
  5085 
  4990     "Created: 4.4.1997 / 11:01:07 / cg"
  5086     "Created: 4.4.1997 / 11:01:07 / cg"
  4991     "Modified: 4.4.1997 / 19:07:55 / cg"
  5087     "Modified: 4.4.1997 / 19:07:55 / cg"
  5065 restoreCursors
  5161 restoreCursors
  5066     "restore the cursors of all views to their current cursor.
  5162     "restore the cursors of all views to their current cursor.
  5067      This undoes the effect of #setCursors:"
  5163      This undoes the effect of #setCursors:"
  5068 
  5164 
  5069     knownViews notNil ifTrue:[
  5165     knownViews notNil ifTrue:[
  5070         knownViews validElementsDo:[:aView |
  5166 	knownViews validElementsDo:[:aView |
  5071             |c vid cid|
  5167 	    |c vid cid|
  5072 
  5168 
  5073             (vid := aView id) notNil ifTrue:[
  5169 	    (vid := aView id) notNil ifTrue:[
  5074                 c := aView cursor.
  5170 		c := aView cursor.
  5075                 (c notNil and:[(cid := c id) notNil]) ifTrue:[
  5171 		(c notNil and:[(cid := c id) notNil]) ifTrue:[
  5076                     self setCursor:cid in:vid
  5172 		    self setCursor:cid in:vid
  5077                 ]
  5173 		]
  5078             ]
  5174 	    ]
  5079         ].
  5175 	].
  5080         self flush
  5176 	self flush
  5081     ]
  5177     ]
  5082 
  5178 
  5083     "
  5179     "
  5084      Display setCursors:(Cursor wait).
  5180      Display setCursors:(Cursor wait).
  5085      Delay waitForSeconds:5.
  5181      Delay waitForSeconds:5.
  5121 
  5217 
  5122     | id |
  5218     | id |
  5123 
  5219 
  5124     id := (aCursor onDevice:self) id.
  5220     id := (aCursor onDevice:self) id.
  5125     id notNil ifTrue:[
  5221     id notNil ifTrue:[
  5126         knownViews validElementsDo:[:aView |
  5222 	knownViews validElementsDo:[:aView |
  5127             |vid|
  5223 	    |vid|
  5128 
  5224 
  5129             (vid := aView id) notNil ifTrue:[
  5225 	    (vid := aView id) notNil ifTrue:[
  5130                 self setCursor:id in:vid
  5226 		self setCursor:id in:vid
  5131             ]
  5227 	    ]
  5132         ].
  5228 	].
  5133         self flush
  5229 	self flush
  5134     ]
  5230     ]
  5135 
  5231 
  5136     "
  5232     "
  5137      Display setCursors:(Cursor wait).
  5233      Display setCursors:(Cursor wait).
  5138      Delay waitForSeconds:5.
  5234      Delay waitForSeconds:5.
  5266 ! !
  5362 ! !
  5267 
  5363 
  5268 !DeviceWorkstation class methodsFor:'documentation'!
  5364 !DeviceWorkstation class methodsFor:'documentation'!
  5269 
  5365 
  5270 version
  5366 version
  5271     ^ '$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.203 1997-04-08 08:33:08 cg Exp $'
  5367     ^ '$Header: /cvs/stx/stx/libview/DeviceWorkstation.st,v 1.204 1997-04-11 09:35:21 cg Exp $'
  5272 ! !
  5368 ! !
  5273 DeviceWorkstation initialize!
  5369 DeviceWorkstation initialize!