VM Maker: VMMakerUI-eem.29.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

VM Maker: VMMakerUI-eem.29.mcz

commits-2
 
Eliot Miranda uploaded a new version of VMMakerUI to project VM Maker:
http://source.squeak.org/VMMaker/VMMakerUI-eem.29.mcz

==================== Summary ====================

Name: VMMakerUI-eem.29
Author: eem
Time: 23 October 2020, 2:09:59.699357 pm
UUID: 140f3784-da7f-452a-8259-f3b8a34616c4
Ancestors: VMMakerUI-eem.28

Provide a much simpler much more ratuional mechanism for squashing duplicate mouse move events in the simulator.  Simply peek last and update the last event's position if it's a duplicate of the next event.

=============== Diff against VMMakerUI-eem.28 ===============

Item was added:
+ ----- Method: CogVMSimulator>>eventQueue (in category '*VMMakerUI-InterpreterSimulation-Morphic') -----
+ eventQueue
+ ^eventQueue ifNil:
+ [eventQueue := SharedQueue2 new]!

Item was added:
+ ----- Method: SharedQueue>>withinPeekLastDo: (in category '*VMMakerUI-accessing') -----
+ withinPeekLastDo: aBlock
+ "Evaluate aBlock with the last (most recently added) item in the queue within the critical section"
+
+ ^readSynch
+ critical:
+ [accessProtect critical:
+ [writePosition > 1 ifTrue:
+ [aBlock value: (contentsArray at: writePosition - 1)]]]
+ ifLocked: [nil]!

Item was added:
+ ----- Method: SharedQueue2>>withinPeekLastDo: (in category '*VMMakerUI-accessing') -----
+ withinPeekLastDo: aBlock
+ "Evaluate aBlock with the last (most recently added) item in the queue within the critical section."
+ ^monitor critical:
+ [items isEmpty ifFalse:
+ [aBlock value: items last]]!

Item was changed:
  Object subclass: #SimulatorEventTransformer
+ instanceVariableNames: 'modifiers'
- instanceVariableNames: 'buttons modifiers lastMouseMoveEvent'
  classVariableNames: 'Default'
  poolDictionaries: 'EventSensorConstants'
  category: 'VMMakerUI-InterpreterSimulation-Morphic'!
 
  !SimulatorEventTransformer commentStamp: 'eem 7/14/2015 17:05' prior: 0!
  A SimulatorEventTransformer takes events as wrapped by HandMorph and converts them to a form a StackInterpreterSimulator can deal with.
 
  See HandMorph >> handleEvent to see what the wrapping entails.
  See HandMorph >> ProcessEvents  or EventSensor >> fetchMoreEvents for examples of what an unwrapped event looks like when given to the system for pre-wrapping.
 
  Instance Variables
  !

Item was changed:
  ----- Method: SimulatorEventTransformer>>degenerateMouseEvent: (in category 'event transformation') -----
  degenerateMouseEvent: aMorphicEvent
  "see HandMorph>>generateMouseEvent"
 
  modifiers := aMorphicEvent buttons >> 3. "Sad, but modifiers come in on mouse move events..."
+ ^{ EventTypeMouse.
- aMorphicEvent type == #mouseMove
- ifTrue: [buttons = 0 ifTrue: [^nil]] "filter-out mouse moves unless buttons are pressed, so simulation doersn't get window leave events when we leave its window"
- ifFalse: [buttons := aMorphicEvent buttons].
- ^{ 1.
  aMorphicEvent timeStamp.
  aMorphicEvent position x.
  aMorphicEvent position y.
+ aMorphicEvent button bitAnd: 7.  "thanks Ron T."
+ modifiers.     "Thanks dtl"
- buttons bitAnd: 7.  "thanks Ron T."
- buttons >> 3.     "Thanks dtl"
  aMorphicEvent class == MouseButtonEvent ifTrue: [aMorphicEvent nClicks] ifFalse: [0].
+ self windowIndex }!
- 0 "this is windowIndex" }!

Item was changed:
  ----- Method: SimulatorEventTransformer>>degenerateMouseEvent:for: (in category 'event transformation') -----
  degenerateMouseEvent: aMorphicEvent for: aClient
  "Convert the mouse event into low-level events for the VM simulator (aClient).  Filter-out mouse moves,
  and generate a fake mouse move before each button press.
  See HandMorph>>generateMouseEvent"
+ | translated newMouseEvent |
- | translated |
  modifiers := aMorphicEvent buttons >> 3. "Sad, but modifiers come in on mouse move events..."
 
  "filter-out mouse moves unless buttons are pressed, so simulation doesn't get window leave events when we leave its window"
  aMorphicEvent type == #mouseMove ifTrue:
  [(aClient displayView bounds containsPoint: aMorphicEvent position) ifFalse:
+ [^self]].
+
- [^self].
- "If buttons (which includes modifiers) change, or are pressed, communicate the event, otherwise (at least potentially) filter it out."
- aMorphicEvent buttons = 0 ifTrue:
- [lastMouseMoveEvent := aMorphicEvent copy.
- lastMouseMoveEvent timeStamp: (aClient ioUTCMicroseconds // 1000).
- lastMouseMoveEvent position: lastMouseMoveEvent position - aClient displayView bounds origin.
- ^self]].
- "Now output the last move event, and synthesize an event near to the current position"
- lastMouseMoveEvent ifNotNil:
- [:lastMouseMove|
- aClient
- queueForwardedEvent:
- { EventTypeMouse.
- lastMouseMove timeStamp.
- lastMouseMove position x.
- lastMouseMove position y.
- lastMouseMove buttons bitAnd: 7.
- lastMouseMove buttons >> 3.
- 0.
- self windowIndex };
- queueForwardedEvent:
- { EventTypeMouse.
- aClient ioUTCMicroseconds // 1000 + lastMouseMove timeStamp // 2.
- aMorphicEvent position x * 9 + lastMouseMove position x // 10.
- aMorphicEvent position y * 9 + lastMouseMove position y // 10.
- lastMouseMove buttons bitAnd: 7.
- lastMouseMove buttons >> 3.
- 0.
- self windowIndex }.
- lastMouseMoveEvent := nil].
- buttons := aMorphicEvent buttons.
  translated := aMorphicEvent position - aClient displayView bounds origin.
+ newMouseEvent := { EventTypeMouse.
+ aClient ioUTCMicroseconds // 1000.
+ translated x.
+ translated y.
+ aMorphicEvent buttons bitAnd: 7. "thanks Ron T."
+ modifiers. "Thanks dtl"
+ aMorphicEvent class == MouseButtonEvent ifTrue: [aMorphicEvent nClicks] ifFalse: [0].
+ self windowIndex }.
+ aClient eventQueue withinPeekLastDo:
+ [:event|
+ "Squash mouse move events..."
+ (#[1 5 6 7 8] allSatisfy: [:index| (event at: index) = (newMouseEvent at: index)]) ifTrue:
+ [^event replaceFrom: 2 to: 4 with: newMouseEvent startingAt: 2]].
+ aClient queueForwardedEvent: newMouseEvent!
- aClient queueForwardedEvent:
- { EventTypeMouse.
- aClient ioUTCMicroseconds // 1000.
- translated x.
- translated y.
- buttons bitAnd: 7. "thanks Ron T."
- buttons >> 3. "Thanks dtl"
- aMorphicEvent class == MouseButtonEvent ifTrue: [aMorphicEvent nClicks] ifFalse: [0].
- self windowIndex }!

Item was changed:
  ----- Method: SimulatorEventTransformer>>initialize (in category 'initialize-release') -----
  initialize
+ modifiers := 0!
- buttons := modifiers := 0!

Item was added:
+ ----- Method: StackInterpreterSimulator>>eventQueue (in category '*VMMakerUI-InterpreterSimulation-Morphic') -----
+ eventQueue
+ ^eventQueue ifNil:
+ [eventQueue := SharedQueue2 new]!