From 1b059b51b6d236ace4ec8c5203873caae250cf78 Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Fri, 12 Jun 2009 10:24:03 -0700 Subject: Scroll the dirty parts of the scroll area in scrollby for Cocoa. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ah! One less ###! The scroll functions in Carbon and Cocoa don't scroll the regions that have been marked dirty. In the past, we killed performance by updating the whole view. We got a workaround for Carbon in the form of an SPI, but I wasn't aware of a corresponding item in the NSView API, but it is there publically and available in 10.5. Fast scrolling in Cocoa now for people who like to use the keyboard. Reviewed by: Morten Sørvig --- src/gui/kernel/qwidget_mac.mm | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index ad80f15..a75c2a3 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -4347,20 +4347,9 @@ void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r) } } - // ### Scroll the dirty regions as well, the following is not correct. - QRegion displayRegion = r.isNull() ? dirtyOnWidget : (dirtyOnWidget & r); - const QVector &rects = dirtyOnWidget.rects(); - const QVector::const_iterator end = rects.end(); - QVector::const_iterator it = rects.begin(); - while (it != end) { - const QRect rect = *it; - const NSRect dirtyRect = NSMakeRect(rect.x() + dx, rect.y() + dy, - rect.width(), rect.height()); - [view setNeedsDisplayInRect:dirtyRect]; - ++it; - } - [view scrollRect:scrollRect by:NSMakeSize(dx, dy)]; - // Yes, we potentially send a duplicate area, but I think Cocoa can handle it. + NSSize deltaSize = NSMakeSize(dx, dy); + [view translateRectsNeedingDisplayInRect:scrollRect by:deltaSize]; + [view scrollRect:scrollRect by:deltaSize]; [view setNeedsDisplayInRect:deltaXRect]; [view setNeedsDisplayInRect:deltaYRect]; #endif // QT_MAC_USE_COCOA -- cgit v0.12