The Trunk: Morphic-tpr.1067.mcz

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

The Trunk: Morphic-tpr.1067.mcz

commits-2
tim Rowledge uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-tpr.1067.mcz

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

Name: Morphic-tpr.1067
Author: tpr
Time: 14 January 2016, 5:09:31.880065 pm
UUID: 9f5c0b23-31d9-4698-99ba-588068d5e268
Ancestors: Morphic-mt.1066

Use the new Time class>eventMillisecondClock method to get a fake timestamp for places where we have to fake up an event and want to compare its timestamp with a real event.

=============== Diff against Morphic-mt.1066 ===============

Item was changed:
  ----- Method: HandMorph>>generateDropFilesEvent: (in category 'private events') -----
  generateDropFilesEvent: evtBuf
  "Generate the appropriate mouse event for the given raw event buffer"
 
  "Note: This is still in an experimental phase and will need more work"
 
  | position buttons modifiers stamp numFiles dragType |
  stamp := evtBuf second.
+ stamp = 0 ifTrue: [stamp := Time eventMillisecondClock].
- stamp = 0 ifTrue: [stamp := Time millisecondClockValue].
  dragType := evtBuf third.
  position := evtBuf fourth @ evtBuf fifth.
  buttons := 0.
  modifiers := evtBuf sixth.
  buttons := buttons bitOr: (modifiers bitShift: 3).
  numFiles := evtBuf seventh.
  dragType = 4
  ifTrue:
  ["e.g., drop"
 
  owner borderWidth: 0.
  ^DropFilesEvent new
  setPosition: position
  contents: numFiles
  hand: self].
  "the others are currently not handled by morphs themselves"
  dragType = 1
  ifTrue:
  ["experimental drag enter"
 
  owner
  borderWidth: 4;
  borderColor: owner color asColor negated].
  dragType = 2
  ifTrue:
  ["experimental drag move"
 
  ].
  dragType = 3
  ifTrue:
  ["experimental drag leave"
 
  owner borderWidth: 0].
  ^nil!

Item was changed:
  ----- Method: HandMorph>>generateKeyboardEvent: (in category 'private events') -----
  generateKeyboardEvent: evtBuf
  "Generate the appropriate mouse event for the given raw event buffer"
 
  | buttons modifiers type pressType stamp keyValue |
  stamp := evtBuf second.
+ stamp = 0 ifTrue: [stamp := Time eventMillisecondClock].
- stamp = 0 ifTrue: [stamp := Time millisecondClockValue].
  pressType := evtBuf fourth.
  pressType = EventKeyDown ifTrue: [type := #keyDown].
  pressType = EventKeyUp ifTrue: [type := #keyUp].
  pressType = EventKeyChar ifTrue: [type := #keystroke].
  modifiers := evtBuf fifth.
  buttons := (modifiers bitShift: 3) bitOr: (lastMouseEvent buttons bitAnd: 7).
  type = #keystroke
  ifTrue: [keyValue := (self keyboardInterpreter nextCharFrom: Sensor firstEvt: evtBuf) asInteger]
  ifFalse: [keyValue := evtBuf third].
  ^ KeyboardEvent new
  setType: type
  buttons: buttons
  position: self position
  keyValue: keyValue
  hand: self
  stamp: stamp.
  !

Item was changed:
  ----- Method: HandMorph>>generateMouseEvent: (in category 'private events') -----
  generateMouseEvent: evtBuf
  "Generate the appropriate mouse event for the given raw event buffer"
 
  | position buttons modifiers type trail stamp oldButtons evtChanged |
  evtBuf first = lastEventBuffer first
  ifTrue:
  ["Workaround for Mac VM bug, *always* generating 3 events on clicks"
 
  evtChanged := false.
  3 to: evtBuf size
  do: [:i | (lastEventBuffer at: i) = (evtBuf at: i) ifFalse: [evtChanged := true]].
  evtChanged ifFalse: [^nil]].
  stamp := evtBuf second.
+ stamp = 0 ifTrue: [stamp := Time eventMillisecondClock].
- stamp = 0 ifTrue: [stamp := Time millisecondClockValue].
  position := evtBuf third @ evtBuf fourth.
  buttons := evtBuf fifth.
  modifiers := evtBuf sixth.
 
  type := buttons = 0
  ifTrue:[
  lastEventBuffer fifth = 0
  ifTrue: [#mouseMove] "this time no button and previously no button .. just mouse move"
  ifFalse: [#mouseUp] "this time no button but previously some button ... therefore button was released"
  ]
  ifFalse:[
  buttons = lastEventBuffer fifth
  ifTrue: [#mouseMove] "button states are the same .. now and past .. therfore a mouse movement"
  ifFalse: [ "button states are different .. button was pressed or released"
  buttons > lastEventBuffer fifth
  ifTrue: [#mouseDown]
  ifFalse:[#mouseUp].
  ].
  ].
  buttons := buttons bitOr: (modifiers bitShift: 3).
  oldButtons := lastEventBuffer fifth
  bitOr: (lastEventBuffer sixth bitShift: 3).
  lastEventBuffer := evtBuf.
  type == #mouseMove
  ifTrue:
  [trail := self mouseTrailFrom: evtBuf.
  ^MouseMoveEvent new
  setType: type
  startPoint: (self position)
  endPoint: trail last
  trail: trail
  buttons: buttons
  hand: self
  stamp: stamp].
  ^MouseButtonEvent new
  setType: type
  position: position
  which: (oldButtons bitXor: buttons)
  buttons: buttons
  hand: self
  stamp: stamp!

Item was changed:
  ----- Method: HandMorph>>generateWindowEvent: (in category 'private events') -----
  generateWindowEvent: evtBuf
  "Generate the appropriate window event for the given raw event buffer"
 
  | evt |
  evt := WindowEvent new.
  evt setTimeStamp: evtBuf second.
+ evt timeStamp = 0 ifTrue: [evt setTimeStamp: Time eventMillisecondClock].
- evt timeStamp = 0 ifTrue: [evt setTimeStamp: Time millisecondClockValue].
  evt action: evtBuf third.
  evt rectangle: (Rectangle origin: evtBuf fourth @ evtBuf fifth corner: evtBuf sixth @ evtBuf seventh ).
 
  ^evt!

Item was changed:
  ----- Method: MorphicEvent>>timeStamp (in category 'accessing') -----
  timeStamp
  "Return the millisecond clock value at which the event was generated"
+ ^timeStamp ifNil:[timeStamp := Time eventMillisecondClock]!
- ^timeStamp ifNil:[timeStamp := Time millisecondClockValue]!

Item was changed:
  ----- Method: MouseEvent>>asMouseMove (in category 'converting') -----
  asMouseMove
  "Convert the receiver into a mouse move"
+ ^MouseMoveEvent new setType: #mouseMove startPoint: position endPoint: position trail: {position. position} buttons: buttons hand: source stamp: Time eventMillisecondClock!
- ^MouseMoveEvent new setType: #mouseMove startPoint: position endPoint: position trail: {position. position} buttons: buttons hand: source stamp: Time millisecondClockValue.!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Morphic-tpr.1067.mcz

timrowledge

> On 14-01-2016, at 1:10 AM, [hidden email] wrote:
>
> tim Rowledge uploaded a new version of Morphic to project The Trunk:
> http://source.squeak.org/trunk/Morphic-tpr.1067.mcz
>
> ==================== Summary ====================
>
> Name: Morphic-tpr.1067
> Author: tpr
> Time: 14 January 2016, 5:09:31.880065 pm
> UUID: 9f5c0b23-31d9-4698-99ba-588068d5e268
> Ancestors: Morphic-mt.1066
>
> Use the new Time class>eventMillisecondClock method to get a fake timestamp for places where we have to fake up an event and want to compare its timestamp with a real event.

This seems to mostly solve the problem but I’m not really happy with seeing ‘clicktimeout’ notifications in the ClickExerciserMorph after a fast click-release.


tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Useful random insult:- Been playing with the pharmacy section again.



Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Morphic-tpr.1067.mcz

David T. Lewis
On Wed, Jan 13, 2016 at 05:34:07PM -0800, tim Rowledge wrote:

>
> > On 14-01-2016, at 1:10 AM, [hidden email] wrote:
> >
> > tim Rowledge uploaded a new version of Morphic to project The Trunk:
> > http://source.squeak.org/trunk/Morphic-tpr.1067.mcz
> >
> > ==================== Summary ====================
> >
> > Name: Morphic-tpr.1067
> > Author: tpr
> > Time: 14 January 2016, 5:09:31.880065 pm
> > UUID: 9f5c0b23-31d9-4698-99ba-588068d5e268
> > Ancestors: Morphic-mt.1066
> >
> > Use the new Time class>eventMillisecondClock method to get a fake timestamp for places where we have to fake up an event and want to compare its timestamp with a real event.
>
> This seems to mostly solve the problem but I???m not really happy with seeing ???clicktimeout??? notifications in the ClickExerciserMorph after a fast click-release.
>

I don't know if you have it perfect, but your approach makes sense for now.
The millisecond clock is/was by definition an arbitrary value that should
be expected to roll over periodically. There is no expectation that it be
tied to e.g. the Smalltalk or Posix epoch. If we can fix things up in the
VM such that it /does/ align with a sensible time scale, that's great, but
in the mean time it is probably better if the image does not depend on it.

There are enough dependencies on 32 bit event time stamps to preserve that
behavior. Assuming that event times are given with millisecond resolution,
there is no need to provide a large time scale range. So for events, a
32-bit time stamp is fine, millisecond resolution is reasonable, and existing
data structures for events are ok.

+1 for #eventMillisecondClock.

Dave


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Morphic-tpr.1067.mcz

marcel.taeumel
In reply to this post by commits-2
Why is it implemented in the Time class and not in HandMorph or MorphicEvent?

Best,
Marcel
Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Morphic-tpr.1067.mcz

Bert Freudenberg

> On 14.01.2016, at 09:58, marcel.taeumel <[hidden email]> wrote:
>
> Why is it implemented in the Time class and not in HandMorph or MorphicEvent?

Seems like a very reasonable place to me, because it’s answering a time value. The only other reasonable place would be in EventSensor, which Morphic uses to fetch events.

- Bert -






smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Morphic-tpr.1067.mcz

timrowledge
In reply to this post by marcel.taeumel

> On 14-01-2016, at 12:58 AM, marcel.taeumel <[hidden email]> wrote:
>
> Why is it implemented in the Time class and not in HandMorph or MorphicEvent?

A fair question. Probably the best answer is “simple-minded editing”. I don’t think it matters a great deal where it goes and if anyone thinks there is a better place they should feel free to change it. Can’t see how performance would be measurably affected by any of the choices.


tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Useful random insult:- Immune from any serious head injury.



Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Morphic-tpr.1067.mcz

marcel.taeumel
In reply to this post by Bert Freudenberg
I consider "event" being more specific than "time" and thus would prefer to have it, for example, in EventSensor. But maybe it is just me. :)

Best,
Marcel