WindowSensor.st
changeset 2439 358644786358
parent 2437 2058aceaed41
child 2441 6925d83b717e
equal deleted inserted replaced
2438:618503d1c7f6 2439:358644786358
   732 !WindowSensor methodsFor:'event processing'!
   732 !WindowSensor methodsFor:'event processing'!
   733 
   733 
   734 buttonMotion:state x:x y:y view:aView
   734 buttonMotion:state x:x y:y view:aView
   735     "mouse was moved - this is sent from the device (Display)"
   735     "mouse was moved - this is sent from the device (Display)"
   736 
   736 
   737     |args ev|
   737     |args ev ignoreIt|
   738 
   738 
   739     "/ update my idea of shift/alt/ctrl pressed information
   739     "/ update my idea of shift/alt/ctrl pressed information
   740     self updateModifierStateFrom:state device:(aView graphicsDevice).
   740     self updateModifierStateFrom:state device:(aView graphicsDevice).
   741 
   741 
   742     EventListener notNil ifTrue:[
   742     EventListener notNil ifTrue:[
   754     compressMotionEvents ifTrue:[
   754     compressMotionEvents ifTrue:[
   755         "
   755         "
   756          merge with last motion
   756          merge with last motion
   757         "
   757         "
   758         self criticalUserEventQueueAccess:[
   758         self criticalUserEventQueueAccess:[
   759             mouseAndKeyboard reverseDo:[:ev |
   759             |idx|
       
   760 
       
   761             idx := mouseAndKeyboard size.
       
   762             [idx > 0] whileTrue:[
       
   763                 ev := mouseAndKeyboard at:idx.
   760                 ev notNil ifTrue:[
   764                 ev notNil ifTrue:[
   761                     ((ev type == #buttonMotion:x:y:) 
   765                     ((ev type == #buttonMotion:x:y:) 
   762                     and:[(ev view == aView)
   766                     and:[(ev view == aView)
   763                     and:[(ev arguments at:1) == state]]) ifTrue:[
   767                     and:[(ev arguments at:1) == state]]) ifTrue:[
   764                         ev arguments:args.
   768                         ev arguments:args.
   765                         ^ self
   769                         idx := 0.
       
   770                         ignoreIt := true
   766                     ]
   771                     ]
   767                 ]
   772                 ].
   768             ]
   773                 idx := idx - 1.
       
   774             ].
       
   775         ].
       
   776         ignoreIt == true ifTrue:[
       
   777             ^ self
   769         ]
   778         ]
   770     ].
   779     ].
   771 
   780 
   772     ev := WindowEvent buttonEvent
   781     ev := WindowEvent buttonEvent
   773              for:aView
   782              for:aView
   775              arguments:args.
   784              arguments:args.
   776     ev hasShift:shiftDown ctrl:ctrlDown alt:altDown meta:metaDown
   785     ev hasShift:shiftDown ctrl:ctrlDown alt:altDown meta:metaDown
   777        button1:leftButtonDown button2:middleButtonDown button3:rightButtonDown.
   786        button1:leftButtonDown button2:middleButtonDown button3:rightButtonDown.
   778     self pushEvent:ev.
   787     self pushEvent:ev.
   779 
   788 
   780     "Modified: / 6.6.1998 / 21:09:14 / cg"
   789     "Modified: / 5.2.1999 / 21:23:31 / cg"
   781 !
   790 !
   782 
   791 
   783 buttonMultiPress:button x:x y:y view:aView
   792 buttonMultiPress:button x:x y:y view:aView
   784     "mouse button was pressed - this is sent from the device (Display)"
   793     "mouse button was pressed - this is sent from the device (Display)"
   785 
   794 
  1803                     idx := damageSize.
  1812                     idx := damageSize.
  1804                 ].
  1813                 ].
  1805             ].
  1814             ].
  1806             idx := idx + 1.
  1815             idx := idx + 1.
  1807         ].
  1816         ].
  1808         damageSize > 10 ifTrue:[
  1817         firstNonNilIndex isNil ifTrue:[
  1809             firstNonNilIndex isNil ifTrue:[
  1818             damage removeAll
  1810                 damage removeAll
  1819         ] ifFalse:[
  1811             ] ifFalse:[
  1820             firstNonNilIndex ~~ 1 ifTrue:[
  1812                 firstNonNilIndex ~~ 1 ifTrue:[
  1821                 damage removeFromIndex:1 toIndex:firstNonNilIndex
  1813                     damage removeFromIndex:1 toIndex:firstNonNilIndex
       
  1814                 ]
       
  1815             ]
  1822             ]
  1816         ]
  1823         ]
  1817     ].
  1824     ].
  1818 
  1825 
  1819     ^ theEvent
  1826     ^ theEvent
  1820 
  1827 
  1821     "Created: / 3.12.1998 / 13:41:49 / cg"
  1828     "Created: / 3.12.1998 / 13:41:49 / cg"
  1822     "Modified: / 3.2.1999 / 01:39:26 / cg"
  1829     "Modified: / 5.2.1999 / 20:58:20 / cg"
  1823 !
  1830 !
  1824 
  1831 
  1825 nextEvent
  1832 nextEvent
  1826     "retrieve the next event or nil, if there is none.
  1833     "retrieve the next event or nil, if there is none.
  1827      Remove it from the queue."
  1834      Remove it from the queue."
  1884                 ].
  1891                 ].
  1885             ].
  1892             ].
  1886             idx := idx + 1.
  1893             idx := idx + 1.
  1887         ].
  1894         ].
  1888 
  1895 
  1889         damageSize > 10 ifTrue:[
  1896         firstNonNilIndex isNil ifTrue:[
  1890             firstNonNilIndex isNil ifTrue:[
  1897             damage removeAll
  1891                 damage removeAll
  1898         ] ifFalse:[
  1892             ] ifFalse:[
  1899             firstNonNilIndex ~~ 1 ifTrue:[
  1893                 firstNonNilIndex ~~ 1 ifTrue:[
  1900                 damage removeFromIndex:1 toIndex:firstNonNilIndex-1
  1894                     damage removeFromIndex:1 toIndex:firstNonNilIndex-1
       
  1895                 ]
       
  1896             ]
  1901             ]
  1897         ].
  1902         ].
  1898     ].
  1903     ].
  1899 
  1904 
  1900     ^ theEvent
  1905     ^ theEvent
  1901 
  1906 
  1902     "Created: / 21.5.1996 / 17:20:54 / cg"
  1907     "Created: / 21.5.1996 / 17:20:54 / cg"
  1903     "Modified: / 3.2.1999 / 01:41:31 / cg"
  1908     "Modified: / 5.2.1999 / 20:58:28 / cg"
  1904 !
  1909 !
  1905 
  1910 
  1906 pendingEvent
  1911 pendingEvent
  1907     "retrieve the next pending user (i.e. non-damage) event.
  1912     "retrieve the next pending user (i.e. non-damage) event.
  1908      Return nil, if there is none pending.
  1913      Return nil, if there is none pending.
  2708 ! !
  2713 ! !
  2709 
  2714 
  2710 !WindowSensor class methodsFor:'documentation'!
  2715 !WindowSensor class methodsFor:'documentation'!
  2711 
  2716 
  2712 version
  2717 version
  2713     ^ '$Header: /cvs/stx/stx/libview/WindowSensor.st,v 1.140 1999-02-04 23:13:09 cg Exp $'
  2718     ^ '$Header: /cvs/stx/stx/libview/WindowSensor.st,v 1.141 1999-02-05 20:25:47 cg Exp $'
  2714 ! !
  2719 ! !
  2715 WindowSensor initialize!
  2720 WindowSensor initialize!