Send adds an event to the end of the deque, replacing the last of the same type unless marked as Unique. They are returned by NextEvent in FIFO order.
(ev Event)
| 94 | // as Unique. |
| 95 | // They are returned by NextEvent in FIFO order. |
| 96 | func (q *Deque) Send(ev Event) { |
| 97 | q.LockAndInit() |
| 98 | defer q.Mu.Unlock() |
| 99 | |
| 100 | n := len(q.Back) |
| 101 | if !ev.IsUnique() && n > 0 { |
| 102 | lev := q.Back[n-1] |
| 103 | if ev.IsSame(lev) { |
| 104 | q.Back[n-1] = ev // replace |
| 105 | switch ev.Type() { |
| 106 | case MouseMove, MouseDrag: |
| 107 | me := ev.(*Mouse) |
| 108 | le := lev.(*Mouse) |
| 109 | me.Prev = le.Prev |
| 110 | me.PrvTime = le.PrvTime |
| 111 | case Scroll: |
| 112 | me := ev.(*MouseScroll) |
| 113 | le := lev.(*MouseScroll) |
| 114 | me.Delta = me.Delta.Add(le.Delta) |
| 115 | } |
| 116 | q.Cond.Signal() |
| 117 | if TraceEventCompression { |
| 118 | fmt.Println("compressed back:", ev) |
| 119 | } |
| 120 | return |
| 121 | } |
| 122 | } |
| 123 | q.Back = append(q.Back, ev) |
| 124 | q.Cond.Signal() |
| 125 | } |
| 126 | |
| 127 | // SendFirst adds an event to the start of the deque. |
| 128 | // They are returned by NextEvent in LIFO order, |
no test coverage detected