diff --git a/console_win.go b/console_win.go index 5f0063e2..fe5dfd53 100644 --- a/console_win.go +++ b/console_win.go @@ -779,7 +779,7 @@ func (s *cScreen) getConsoleInput() error { btns := mrec2btns(mrec.btns, mrec.flags) // we ignore double click, events are delivered normally s.PostEventWait(NewEventMouse(int(mrec.x), int(mrec.y), btns, - mod2mask(mrec.mod))) + mod2mask(mrec.mod), false)) case resizeEvent: var rrec resizeRecord diff --git a/mouse.go b/mouse.go index 008c2e26..4e7abaa6 100644 --- a/mouse.go +++ b/mouse.go @@ -40,6 +40,7 @@ type EventMouse struct { mod ModMask x int y int + mtn bool } // When returns the time when this EventMouse was created. @@ -64,10 +65,14 @@ func (ev *EventMouse) Position() (int, int) { return ev.x, ev.y } +func (ev *EventMouse) HasMotion() bool { + return ev.mtn +} + // NewEventMouse is used to create a new mouse event. Applications // shouldn't need to use this; its mostly for screen implementors. -func NewEventMouse(x, y int, btn ButtonMask, mod ModMask) *EventMouse { - return &EventMouse{t: time.Now(), x: x, y: y, btn: btn, mod: mod} +func NewEventMouse(x, y int, btn ButtonMask, mod ModMask, motion bool) *EventMouse { + return &EventMouse{t: time.Now(), x: x, y: y, btn: btn, mod: mod, mtn: motion} } // ButtonMask is a mask of mouse buttons and wheel events. Mouse button presses diff --git a/simulation.go b/simulation.go index 9ad6131e..ba209234 100644 --- a/simulation.go +++ b/simulation.go @@ -393,7 +393,7 @@ func (s *simscreen) PostEvent(ev Event) error { } func (s *simscreen) InjectMouse(x, y int, buttons ButtonMask, mod ModMask) { - ev := NewEventMouse(x, y, buttons, mod) + ev := NewEventMouse(x, y, buttons, mod, false) s.PostEvent(ev) } diff --git a/tscreen.go b/tscreen.go index e9c2dd4b..d651cc85 100644 --- a/tscreen.go +++ b/tscreen.go @@ -1215,7 +1215,7 @@ func (t *tScreen) clip(x, y int) (int, int) { // buildMouseEvent returns an event based on the supplied coordinates and button // state. Note that the screen's mouse button state is updated based on the // input to this function (i.e. it mutates the receiver). -func (t *tScreen) buildMouseEvent(x, y, btn int) *EventMouse { +func (t *tScreen) buildMouseEvent(x, y, btn int, motion bool) *EventMouse { // XTerm mouse events only report at most one button at a time, // which may include a wheel button. Wheel motion events are @@ -1259,7 +1259,7 @@ func (t *tScreen) buildMouseEvent(x, y, btn int) *EventMouse { // to the screen in that case. x, y = t.clip(x, y) - return NewEventMouse(x, y, button, mod) + return NewEventMouse(x, y, button, mod, motion) } // parseSgrMouse attempts to locate an SGR mouse record at the start of the @@ -1375,7 +1375,7 @@ func (t *tScreen) parseSgrMouse(buf *bytes.Buffer, evs *[]Event) (bool, bool) { _, _ = buf.ReadByte() i-- } - *evs = append(*evs, t.buildMouseEvent(x, y, btn)) + *evs = append(*evs, t.buildMouseEvent(x, y, btn, motion)) return true, true } } @@ -1428,7 +1428,7 @@ func (t *tScreen) parseXtermMouse(buf *bytes.Buffer, evs *[]Event) (bool, bool) _, _ = buf.ReadByte() i-- } - *evs = append(*evs, t.buildMouseEvent(x, y, btn)) + *evs = append(*evs, t.buildMouseEvent(x, y, btn, false)) return true, true } }