The Trunk: Kernel-mt.988.mcz

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

The Trunk: Kernel-mt.988.mcz

commits-2
Marcel Taeumel uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-mt.988.mcz

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

Name: Kernel-mt.988
Author: mt
Time: 16 February 2016, 10:03:44.570748 am
UUID: 33646804-d866-4db9-9a27-ac599c317383
Ancestors: Kernel-mt.987

Fix accessor for eventQueue in EventSensor and make use of that accessor throughout the EventSensor code.

=============== Diff against Kernel-mt.987 ===============

Item was changed:
  ----- Method: EventSensor>>eventQueue (in category 'accessing') -----
  eventQueue
+ ^ eventQueue!
- ^nil!

Item was changed:
  ----- Method: EventSensor>>eventQueue: (in category 'accessing') -----
  eventQueue: aSharedQueue
+ eventQueue := aSharedQueue.!
- !

Item was changed:
  ----- Method: EventSensor>>flushAllButDandDEvents (in category 'accessing') -----
  flushAllButDandDEvents
  | newQueue oldQueue  |
 
  newQueue := SharedQueue new.
+ self eventQueue ifNil: [
+ self eventQueue: newQueue.
+ ^ self].
- self eventQueue ifNil:
- [eventQueue := newQueue.
- ^self].
  oldQueue := self eventQueue.
  [oldQueue size > 0] whileTrue:
  [| item type |
  item := oldQueue next.
  type := item at: 1.
  type = EventTypeDragDropFiles ifTrue: [ newQueue nextPut: item]].
+ self eventQueue: newQueue.!
- eventQueue := newQueue.
- !

Item was changed:
  ----- Method: EventSensor>>flushEvents (in category 'accessing') -----
  flushEvents
+ self eventQueue ifNotNil:[:queue | queue flush].!
- eventQueue ifNotNil:[eventQueue flush].!

Item was changed:
  ----- Method: EventSensor>>flushNonKbdEvents (in category 'private') -----
  flushNonKbdEvents
+
+ self eventQueue ifNotNil: [:queue |
+ queue flushAllSuchThat: [:buf | (self isKbdEvent: buf) not]].!
- eventQueue ifNil: [^ self].
- eventQueue flushAllSuchThat:
- [:buf | (self isKbdEvent: buf) not]
- !

Item was changed:
  ----- Method: EventSensor>>nextEvent (in category 'accessing') -----
  nextEvent
  "Return the next event from the receiver."
+
+ ^ self eventQueue
+ ifNil: [self nextEventSynthesized]
+ ifNotNil: [self nextEventFromQueue]
- eventQueue == nil
- ifTrue:[^self nextEventSynthesized]
- ifFalse:[^self nextEventFromQueue]
  !

Item was changed:
  ----- Method: EventSensor>>nextEventFromQueue (in category 'private') -----
  nextEventFromQueue
+ "Return the next event from the receiver. If the queue is empty, try to fetch more events once."
+
+ self eventQueue isEmpty
+ ifTrue: [self fetchMoreEvents].
+
+ ^ self eventQueue isEmpty
+ ifTrue: [nil]
+ ifFalse: [self eventQueue next]!
- "Return the next event from the receiver."
- eventQueue isEmpty ifTrue:[self fetchMoreEvents].
- eventQueue isEmpty
- ifTrue:[^nil]
- ifFalse:[^eventQueue next]!

Item was changed:
  ----- Method: EventSensor>>peekEvent (in category 'accessing') -----
  peekEvent
+ "Look ahead at the next event. Try to fetch more events first."
+
+ ^ self eventQueue
+ ifNil: [nil]
+ ifNotNil: [:queue |
+ self fetchMoreEvents.
+ queue peek]!
- "Look ahead at the next event."
- eventQueue ifNil:[^nil].
- self fetchMoreEvents.
- ^eventQueue peek!

Item was changed:
  ----- Method: EventSensor>>peekKeyboardEvent (in category 'accessing') -----
  peekKeyboardEvent
  "Return the next keyboard char event from the receiver or nil if none available"
+
+ ^ self eventQueue
+ ifNil: [nil]
+ ifNotNil: [:queue |
+ self fetchMoreEvents.
+ queue nextOrNilSuchThat: [:buf |
+ buf first = EventTypeKeyboard and: [(buf fourth) = EventKeyChar]]]!
- ^eventQueue nextOrNilSuchThat:
- [:buf |
- buf first = EventTypeKeyboard and: [(buf fourth) = EventKeyChar]]!

Item was removed:
- ----- Method: EventSensor>>peekMousePt (in category 'accessing') -----
- peekMousePt
- ^mousePosition!

Item was changed:
  ----- Method: EventSensor>>primKbdNext (in category 'private') -----
  primKbdNext
  "Allows for use of old Sensor protocol to get at the keyboard,
  as when running kbdTest or the InterpreterSimulator in Morphic"
  | evtBuf |
  self fetchMoreEvents.
  keyboardBuffer isEmpty ifFalse:[^ keyboardBuffer next].
+ self eventQueue ifNotNil: [:queue |
+ evtBuf := queue nextOrNilSuchThat: [:buf | self isKbdEvent: buf].
- eventQueue ifNotNil:
- [evtBuf := eventQueue nextOrNilSuchThat: [:buf | self isKbdEvent: buf].
  self flushNonKbdEvents].
  ^ evtBuf ifNotNil: [evtBuf at: 3]
  !

Item was changed:
  ----- Method: EventSensor>>primKbdPeek (in category 'private') -----
  primKbdPeek
  "Allows for use of old Sensor protocol to get at the keyboard,
  as when running kbdTest or the InterpreterSimulator in Morphic"
  | char |
  self fetchMoreEvents.
  keyboardBuffer isEmpty ifFalse: [^ keyboardBuffer peek].
  char := nil.
+ self eventQueue ifNotNil: [:queue |
+ queue nextOrNilSuchThat:  "NOTE: must not return out of this block, so loop to end"
- eventQueue ifNotNil:
- [eventQueue nextOrNilSuchThat:  "NOTE: must not return out of this block, so loop to end"
  [:buf | (self isKbdEvent: buf) ifTrue: [char ifNil: [char := buf at: 3]].
  false  "NOTE: block value must be false so Queue won't advance"]].
  ^ char!

Item was changed:
  ----- Method: EventSensor>>processKeyboardEvent: (in category 'private-I/O') -----
  processKeyboardEvent: evt
  "process a keyboard event, updating EventSensor state"
  | charCode pressCode |
  "Never update keyboardBuffer if we have an eventQueue active"
  mouseButtons := (mouseButtons bitAnd: 7) bitOr: ((evt at: 5) bitShift: 3).
+ self eventQueue ifNotNil:[^self].
- eventQueue ifNotNil:[^self].
  charCode := evt at: 3.
  charCode = nil ifTrue:[^self]. "extra characters not handled in MVC"
  pressCode := evt at: 4.
  pressCode = EventKeyChar ifFalse:[^self]. "key down/up not handled in MVC"
  "mix in modifiers"
  charCode := charCode bitOr: ((evt at: 5) bitShift: 8).
  keyboardBuffer nextPut: charCode.!

Item was changed:
  ----- Method: EventSensor>>queueEvent: (in category 'private-I/O') -----
  queueEvent: evt
  "Queue the given event in the event queue (if any).
  Note that the event buffer must be copied since it
  will be reused later on."
+
+ self eventQueue ifNotNil: [:queue |
+ queue nextPut: evt clone].!
- eventQueue ifNil:[^self].
- eventQueue nextPut: evt clone.!