From 5e5e16fd7107334e10939592170fc322cfa86da9 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Thu, 20 Jan 2011 12:35:20 +0100 Subject: Cocoa/Alien: let QWidget::scroll_sys handle overlapping widgets --- src/gui/kernel/qcocoaview_mac.mm | 5 +++-- src/gui/kernel/qwidget_mac.mm | 25 ++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index dbf9d56..575343f 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -129,6 +129,7 @@ extern "C" { extern NSString *NSTextInputReplacementRangeAttributeName; } +//#define ALIEN_DEBUG 1 #ifdef ALIEN_DEBUG static int qCocoaViewCount = 0; #endif @@ -146,7 +147,7 @@ static int qCocoaViewCount = 0; #ifdef ALIEN_DEBUG ++qCocoaViewCount; - qDebug() << "init: qCocoaViewCount is" << qCocoaViewCount; + qDebug() << "Alien: create native view for" << widget << ". qCocoaViewCount is:" << qCocoaViewCount; #endif composing = false; @@ -174,7 +175,7 @@ static int qCocoaViewCount = 0; #ifdef ALIEN_DEBUG --qCocoaViewCount; - qDebug() << "qCocoaViewCount is" << qCocoaViewCount; + qDebug() << "Alien: widget deallocated. qCocoaViewCount is:" << qCocoaViewCount; #endif [super dealloc]; diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index df8e61e..8d6c09c 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -4662,6 +4662,17 @@ void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &qscrollRect) return; } + static int accelEnv = -1; + if (accelEnv == -1) { + accelEnv = qgetenv("QT_NO_FAST_SCROLL").toInt() == 0; + } + + // Scroll the whole widget instead if qscrollRect is not valid: + QRect validScrollRect = qscrollRect.isValid() ? qscrollRect : q->rect(); + // If q is overlapped by other widgets, we cannot just blit pixels since + // this will move overlapping widgets as well. In case we just update: + const bool overlapped = isOverlapped(validScrollRect.translated(data.crect.topLeft())); + const bool accelerateScroll = accelEnv && isOpaque && !overlapped; const bool isAlien = (q->internalWinId() == 0); const QPoint scrollDelta(dx, dy); @@ -4677,10 +4688,21 @@ void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &qscrollRect) return; } + if (!accelerateScroll) { + if (overlapped) { + QRegion region(validScrollRect); + subtractOpaqueSiblings(region); + update_sys(region); + }else { + update_sys(qscrollRect); + } + return; + } #ifdef QT_MAC_USE_COCOA QMacCocoaAutoReleasePool pool; #else + Q_UNUSED(isAlien); // We're not sure what the following call is supposed to achive // but until we see what it breaks, we don't bring it into the // Cocoa port: @@ -4750,9 +4772,6 @@ void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &qscrollRect) if (!view) return; - // Scroll the whole widget instead if qscrollRect is not valid: - QRect validScrollRect = qscrollRect.isValid() ? qscrollRect : QRect(0, 0, q->width(), q->height()); - if (isAlien) { // Since q is alien, we need to translate the scroll rect: QPoint widgetTopLeftInsideNative = nativeWidget->mapFromGlobal(q->mapToGlobal(QPoint())); -- cgit v0.12