Fix mouse-scrollbar offset on GNUstep and old macOS (bug#29053)

* src/nsterm.m (EmacsScroller::mouseDown,
EmacsScroller::mouseDragged): Take scroller buttons into account when
calculating scroller knob position.
This commit is contained in:
Alan Third 2017-11-02 21:41:11 +00:00
parent 04bc1410c2
commit 36400c7dc9

View file

@ -8912,10 +8912,20 @@ - (void)mouseDown: (NSEvent *)e
} }
last_mouse_offset = kloc; last_mouse_offset = kloc;
if (part != NSScrollerKnob) /* if knob, tell emacs a location offset by knob pos
/* this is a slot click on GNUstep: go straight there */ (to indicate top of handle) */
if (part == NSScrollerKnob)
pos = (loc - last_mouse_offset);
else
/* else this is a slot click on GNUstep: go straight there */
pos = loc; pos = loc;
/* If there are buttons in the scroller area, we need to
recalculate pos as emacs expects the scroller slot to take up
the entire available length. */
if (length != pixel_length)
pos = pos * pixel_length / length;
/* send a fake mouse-up to super to preempt modal -trackKnob: mode */ /* send a fake mouse-up to super to preempt modal -trackKnob: mode */
fake_event = [NSEvent mouseEventWithType: NSEventTypeLeftMouseUp fake_event = [NSEvent mouseEventWithType: NSEventTypeLeftMouseUp
location: [e locationInWindow] location: [e locationInWindow]
@ -8980,6 +8990,13 @@ - (void)mouseDragged: (NSEvent *)e
} }
pos = (loc - last_mouse_offset); pos = (loc - last_mouse_offset);
/* If there are buttons in the scroller area, we need to
recalculate pos as emacs expects the scroller slot to take up
the entire available length. */
if (length != pixel_length)
pos = pos * pixel_length / length;
[self sendScrollEventAtLoc: pos fromEvent: e]; [self sendScrollEventAtLoc: pos fromEvent: e];
} }