diff options
Diffstat (limited to 'scroller/qkineticscroller.cpp')
-rw-r--r-- | scroller/qkineticscroller.cpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/scroller/qkineticscroller.cpp b/scroller/qkineticscroller.cpp index b9c31a8..63ba4fc 100644 --- a/scroller/qkineticscroller.cpp +++ b/scroller/qkineticscroller.cpp @@ -480,22 +480,26 @@ void QKineticScroller::setDpi(qreal dpi) d->pixelPerMeter = dpi * qreal(39.3700787); } - void QKineticScroller::setDpiFromWidget(QWidget *widget) { -#ifdef Q_WS_MAEMO_5 - // The DPI value is hardcoded to 96 on Maemo5: - // https://projects.maemo.org/bugzilla/show_bug.cgi?id=152525 - // This value (260) is only correct for the N900 though, but - // there's no way to get the real DPI at run time. - setDpi(qreal(260)); -#else - if (!widget) - widget = QApplication::desktop(); - setDpi(qreal(widget->physicalDpiX() + widget->physicalDpiY()) / qreal(2)); -#endif + Q_D(QKineticScroller); + + QDesktopWidget *dw = QApplication::desktop(); + QPointF dpi = d->realDpi(widget ? dw->screenNumber(widget) : dw->primaryScreen()); + setDpi((dpi.x() + dpi.y()) / qreal(2)); } +#if !defined(Q_WS_MAEMO_5) && !defined(Q_WS_MAC) + +QPointF QKineticScrollerPrivate::realDpi(int screen) +{ + QWidget *w = QApplication::desktop()->screen(screen); + return QPointF(w->physicalDpiX(), w->physicalDpiY()); +} + +#endif + + void QKineticScrollerPrivate::updateVelocity(const QPointF &deltaPixelRaw, qint64 deltaTime) { qKSDebug() << "QKS::updateVelocity(" << deltaPixelRaw << " [delta pix], " << deltaTime << " [delta ms])"; |