diff options
author | Neil Hodgson <nyamatongwe@gmail.com> | 2017-09-18 12:24:00 +1000 |
---|---|---|
committer | Neil Hodgson <nyamatongwe@gmail.com> | 2017-09-18 12:24:00 +1000 |
commit | 171c07ab4d63b2aee57762eb9ac65834102207b5 (patch) | |
tree | 1bbea0050f4ed2474bc4bbe3b741f4a55cefd74e /cocoa/ScintillaView.mm | |
parent | 0e997cdb65909c817b7147609590a079abedb3d2 (diff) | |
download | scintilla-mirror-171c07ab4d63b2aee57762eb9ac65834102207b5.tar.gz |
Bug [#1885]. Improve scrolling on macOS 10.12.
Diffstat (limited to 'cocoa/ScintillaView.mm')
-rw-r--r-- | cocoa/ScintillaView.mm | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/cocoa/ScintillaView.mm b/cocoa/ScintillaView.mm index 7891beed8..c19c976f7 100644 --- a/cocoa/ScintillaView.mm +++ b/cocoa/ScintillaView.mm @@ -696,20 +696,20 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) { //-------------------------------------------------------------------------------------------------- /** - * Mouse wheel with command key magnifies text. - * Enabling this code causes visual garbage to appear when scrolling - * horizontally on OS X 10.9 with a retina display. - * Pinch gestures and key commands can be used for magnification. + * Implementing scrollWheel makes scrolling work better even if just + * calling super. + * Mouse wheel with command key may magnify text if enabled. + * Pinch gestures and key commands can also be used for magnification. */ -#ifdef SCROLL_WHEEL_MAGNIFICATION - (void) scrollWheel: (NSEvent *) theEvent { +#ifdef SCROLL_WHEEL_MAGNIFICATION if (([theEvent modifierFlags] & NSCommandKeyMask) != 0) { mOwner.backend->MouseWheel(theEvent); - } else { - [super scrollWheel: theEvent]; + return; } -} #endif + [super scrollWheel: theEvent]; +} //-------------------------------------------------------------------------------------------------- @@ -728,6 +728,13 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) { long lineHeight = mOwner.backend->WndProc(SCI_TEXTHEIGHT, 0, 0); rc.origin.y = roundf(static_cast<XYPOSITION>(rc.origin.y) / lineHeight) * lineHeight; } + // Snap to whole points - on retina displays this avoids visual debris + // when scrolling horizontally. + if ((rc.origin.x > 0) && (NSMaxX(rc) < contentRect.size.width)) { + // Only snap for positions inside the document - allow outside + // for overshoot. + rc.origin.x = roundf(static_cast<XYPOSITION>(rc.origin.x)); + } return rc; } |