Eliot Miranda uploaded a new version of VMMaker to project VM Maker: http://source.squeak.org/VMMaker/VMMaker.oscog-eem.1419.mcz
==================== Summary ====================
Name: VMMaker.oscog-eem.1419 Author: eem Time: 15 July 2015, 12:03:32.999 am UUID: 40db9abe-8bac-4b73-8cfa-a8773c2f1db0 Ancestors: VMMaker.oscog-eem.1418
Reduce the simulator's event handling to just keyboard and mouse events. Filter-out mouse moves unless buttons are pressed so that the simulator doesn't get endless window leave events as one interacts with the simulator's window.
=============== Diff against VMMaker.oscog-eem.1418 ===============
Item was added: + ----- Method: CogVMSimulator>>handleListenEvent: (in category 'I/O primitives support') ----- + handleListenEvent: aMorphicEvent + "openAsMorph regsitered me for listen events via HandMorph>>addEventListener. + Transform the listen event and add it to my event queue." + (aMorphicEvent isMouse or: [aMorphicEvent isKeyboard]) ifFalse: + [^self]. + (SimulatorEventTransformer default degenerateEvent: aMorphicEvent) ifNotNil: + [:evtBuf| + (evtBuf first = SimulatorEventTransformer eventTypeMouse + and: [displayView bounds containsPoint: aMorphicEvent position]) ifTrue: + [| xtranslated ytranslated | + xtranslated := (evtBuf at:3) - displayView bounds left - 2. "<--heh" + ytranslated := (evtBuf at:4) - displayView bounds top. + evtBuf at: 3 put: xtranslated. + evtBuf at: 4 put: ytranslated]. + evtBuf at: 8 put: 1. "windowIndex" + self queueForwardedEvent: evtBuf]!
Item was added: + ----- Method: CogVMSimulator>>queueForwardedEvent: (in category 'I/O primitives support') ----- + queueForwardedEvent: event + eventQueue ifNil: + [eventQueue := SharedQueue new]. + eventQueue nextPut: event!
Item was changed: Object subclass: #SimulatorEventTransformer + instanceVariableNames: 'buttons' - instanceVariableNames: '' classVariableNames: 'Default' poolDictionaries: 'EventSensorConstants' category: 'VMMaker-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>>degenerateEvent: (in category 'event transformation') ----- degenerateEvent: aMorphicEvent "tty. Bert had mentioned a distinction between events and polling events and that Morphic could handle both. + I don't know what he is talking about." + aMorphicEvent isMouse ifTrue: + [^self degenerateMouseEvent: aMorphicEvent]. + aMorphicEvent isKeyboard ifTrue: + [^self degenerateKeyboardEvent: aMorphicEvent]. - I don't know what he is talking about." - | evt type | - self flag:'tty'. - - evt := nil. - type := aMorphicEvent type. - " Transcript show:type;cr." - (('mouse' charactersExactlyMatching: type asString) > 4) "mous" - ifTrue: [^self degenerateMouseEvent: aMorphicEvent]. - (('key' charactersExactlyMatching: type asString) > 2) "key" - ifTrue: [^self degenerateKeyboardEvent: aMorphicEvent]. " type = EventTypeDragDropFiles ifTrue: [evt := self generateDropFilesEvent: evtBuf]. type = EventTypeWindow ifTrue:[evt := self generateWindowEvent: evtBuf]."
+ ^nil! - ^ #(0 0 0 0 0 0 0 0).!
Item was changed: ----- Method: SimulatorEventTransformer>>degenerateKeyboardEvent: (in category 'event transformation') ----- degenerateKeyboardEvent: aMorphicEvent - | evt | "see HandMorph>>generateKeyboardEvent and EventSensor class comment" + ^{ 2. + aMorphicEvent timeStamp. + aMorphicEvent keyValue. "<--this is wrong. See Sensor FirstEvt: for what needs to happen. hooo boy" + aMorphicEvent type caseOf: { + [#keyDown] -> [EventKeyDown]. + [#keyUp] -> [EventKeyUp]. + [#keystroke] -> [EventKeyChar] }. + aMorphicEvent buttons bitAnd: 7. + aMorphicEvent keyValue. + 0. + 0 }! - evt := {2 . 0 . 0 . 0 . 0. 0 . 0 . 0}. - - evt at:2 put: aMorphicEvent timeStamp. - evt at:3 put: aMorphicEvent keyValue. "<--this is wrong. See Sensor FirstEvt: for what needs to happen. hooo boy" - evt at:4 put: aMorphicEvent position y. - evt at:5 put: (aMorphicEvent buttons bitAnd: 7). "thanks Ron T." - evt at:6 put: (aMorphicEvent buttons >> 3). "Thanks dtl" - ^evt - - - !
Item was removed: - ----- Method: SimulatorEventTransformer>>degenerateMouseButtonEvent: (in category 'event transformation') ----- - degenerateMouseButtonEvent: aMorphicEvent - | evt | - "see HandMorph>>generateMouseEvent" - evt := {1 . 0 . 0 . 0 . 0. 0 . 0 . 0}. - - evt at:2 put: aMorphicEvent timeStamp. - evt at:3 put: aMorphicEvent position x. - evt at:4 put: aMorphicEvent position y. - evt at:5 put: (aMorphicEvent buttons bitAnd: 7). "thanks Ron T." - evt at:6 put: (aMorphicEvent buttons >> 3). "Thanks dtl" - ^evt - - - !
Item was changed: ----- Method: SimulatorEventTransformer>>degenerateMouseEvent: (in category 'event transformation') ----- degenerateMouseEvent: aMorphicEvent "see HandMorph>>generateMouseEvent"
+ 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. + buttons bitAnd: 7. "thanks Ron T." + buttons >> 3. "Thanks dtl" + 0. + 0 }! - (aMorphicEvent type) = #mouseMove - ifTrue:[^self degenerateMouseMoveEvent: aMorphicEvent]. - - ((aMorphicEvent type) = #mouseUp) | ((aMorphicEvent type) = #mouseDown) - ifTrue:[^self degenerateMouseButtonEvent: aMorphicEvent]. - " (aMorphicEvent type) = #mouseDrag - ifTrue:[evt := self degenerateMouseDragEvent: aMorphicEvent]. - " - ^{0 . 0. 0. 0. 0. 0. 0. 0}.!
Item was removed: - ----- Method: SimulatorEventTransformer>>degenerateMouseMoveEvent: (in category 'event transformation') ----- - degenerateMouseMoveEvent: aMorphicEvent - | evt | - "see HandMorph>>generateMouseEvent" - evt := {1 . 0 . 0 . 0 . 0. 0 . 0 . 0}. - - evt at:2 put: aMorphicEvent timeStamp. - evt at:3 put: aMorphicEvent position x. - evt at:4 put: aMorphicEvent position y. - evt at:5 put: (aMorphicEvent buttons bitAnd: 7). "thanks Ron T." - evt at:6 put: (aMorphicEvent buttons >> 3). "Thanks dtl" - ^evt - - - !
Item was added: + ----- Method: SimulatorEventTransformer>>initialize (in category 'initialize-release') ----- + initialize + buttons := 0!
Item was changed: ----- Method: SimulatorMorphicModel>>handleListenEvent: (in category 'event-forwarding') ----- handleListenEvent: aMorphicEvent "The SimulatorImageMorph regsitered me (a SimulatorMorphicModel ) with HandMorph>>addEventListener HandMorph then broadcasts events to all registered listeners at this method. See HandMorph>>sendListenPrimitiveEvent " - | evtBuf xtranslated ytranslated | morph ifNotNil: + [(SimulatorEventTransformer default degenerateEvent: aMorphicEvent) ifNotNil: + [:evtBuf| + ((evtBuf at: 1) = EventTypeMouse and: [morph bounds containsPoint: aMorphicEvent position]) ifTrue: + [| xtranslated ytranslated | + xtranslated := (evtBuf at:3) - (morph bounds left) - 2 . "<--heh" + ytranslated := (evtBuf at:4) - (morph bounds top). + evtBuf at: 3 put: xtranslated. + evtBuf at: 4 put: ytranslated]. - [evtBuf := SimulatorEventTransformer default degenerateEvent: aMorphicEvent. - ((evtBuf at: 1) = EventTypeMouse and: [morph bounds containsPoint: aMorphicEvent position]) ifTrue: - [xtranslated := (evtBuf at:3) - (morph bounds left) - 2 . "<--heh" - ytranslated := (evtBuf at:4) - (morph bounds top). - evtBuf at: 3 put: xtranslated. - evtBuf at: 4 put: ytranslated. vm queueForwardedEvent: evtBuf]]!
Item was changed: ----- Method: StackInterpreterSimulator>>handleListenEvent: (in category 'I/O primitives support') ----- handleListenEvent: aMorphicEvent "openAsMorph regsitered me for listen events via HandMorph>>addEventListener. Transform the listen event and add it to my event queue." + (aMorphicEvent isMouse or: [aMorphicEvent isKeyboard]) ifFalse: + [^self]. + (SimulatorEventTransformer default degenerateEvent: aMorphicEvent) ifNotNil: + [:evtBuf| + (evtBuf first = SimulatorEventTransformer eventTypeMouse + and: [displayView bounds containsPoint: aMorphicEvent position]) ifTrue: + [| xtranslated ytranslated | + xtranslated := (evtBuf at:3) - displayView bounds left - 2. "<--heh" + ytranslated := (evtBuf at:4) - displayView bounds top. + evtBuf at: 3 put: xtranslated. + evtBuf at: 4 put: ytranslated]. + evtBuf at: 8 put: 1. "windowIndex" + self queueForwardedEvent: evtBuf]! - | evtBuf xtranslated ytranslated | - evtBuf := SimulatorEventTransformer default degenerateEvent: aMorphicEvent. - (evtBuf first = SimulatorEventTransformer eventTypeMouse - and: [displayView bounds containsPoint: aMorphicEvent position]) ifTrue: - [xtranslated := (evtBuf at:3) - displayView bounds left - 2. "<--heh" - ytranslated := (evtBuf at:4) - displayView bounds top. - evtBuf at: 3 put: xtranslated. - evtBuf at: 4 put: ytranslated]. - self queueForwardedEvent: evtBuf!
vm-dev@lists.squeakfoundation.org