diff options
author | Arvid Nilsson <anilsson@blackberry.com> | 2013-11-28 15:29:40 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-04 14:23:33 +0100 |
commit | 5d66b66df1bc205a9ce3d25cfaaa84c961fa7a29 (patch) | |
tree | b99b54d09ba93dbe66a65313c50ac6d831e5a8d0 /src/core/web_event_factory.cpp | |
parent | 5d92938e5bb830b8ca5a711fd4c1999dd09fd0e3 (diff) |
Quick: Add experimental.viewport.devicePixelRatio
This specifies a devicePixelRatio to be used by web content instead of
the QScreen::devicePixelRatio(). This is necessary on non-iOS mobile
devices to remain compatible with the mobile web which assumes
devicePixelRatio is computed as the ratio of actual dpi to 160 dpi.
Non-iOS mobile platforms may use different criteria to determine the
QScreen::devicePixelRatio(), depending on the history of the platform,
or simply leave it at 1.0.
For QNX, this setting gets a reasonable default value so developers
don't have to regularly use this experimental API.
These changes were inspired by the Android Chromium port which uses a
GetDpiScale() to accomplish the same in
content/browser/android/content_view_core_impl.cc.
Change-Id: I1bc8878a47dabcdb6986c4fe5c8c4ac230ae2514
Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
Diffstat (limited to 'src/core/web_event_factory.cpp')
-rw-r--r-- | src/core/web_event_factory.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/core/web_event_factory.cpp b/src/core/web_event_factory.cpp index d750aa3e0..febad0a3a 100644 --- a/src/core/web_event_factory.cpp +++ b/src/core/web_event_factory.cpp @@ -527,15 +527,15 @@ static WebInputEvent::Type webEventTypeForEvent(const QEvent* event) } } -WebMouseEvent WebEventFactory::toWebMouseEvent(QMouseEvent *ev) +WebMouseEvent WebEventFactory::toWebMouseEvent(QMouseEvent *ev, double dpiScale) { WebMouseEvent webKitEvent; webKitEvent.timeStampSeconds = currentTimeForEvent(ev); webKitEvent.button = mouseButtonForEvent(ev); webKitEvent.modifiers = modifiersForEvent(ev); - webKitEvent.x = webKitEvent.windowX = ev->x(); - webKitEvent.y = webKitEvent.windowY = ev->y(); + webKitEvent.x = webKitEvent.windowX = ev->x() / dpiScale; + webKitEvent.y = webKitEvent.windowY = ev->y() / dpiScale; webKitEvent.globalX = ev->globalX(); webKitEvent.globalY = ev->globalY(); @@ -545,20 +545,20 @@ WebMouseEvent WebEventFactory::toWebMouseEvent(QMouseEvent *ev) return webKitEvent; } -WebMouseEvent WebEventFactory::toWebMouseEvent(QHoverEvent *ev) +WebMouseEvent WebEventFactory::toWebMouseEvent(QHoverEvent *ev, double dpiScale) { WebMouseEvent webKitEvent; webKitEvent.timeStampSeconds = currentTimeForEvent(ev); webKitEvent.modifiers = modifiersForEvent(ev); - webKitEvent.x = webKitEvent.windowX = ev->pos().x(); - webKitEvent.y = webKitEvent.windowY = ev->pos().y(); + webKitEvent.x = webKitEvent.windowX = ev->pos().x() / dpiScale; + webKitEvent.y = webKitEvent.windowY = ev->pos().y() / dpiScale; webKitEvent.type = webEventTypeForEvent(ev); return webKitEvent; } -WebKit::WebMouseWheelEvent WebEventFactory::toWebWheelEvent(QWheelEvent *ev) +WebKit::WebMouseWheelEvent WebEventFactory::toWebWheelEvent(QWheelEvent *ev, double dpiScale) { WebMouseWheelEvent webEvent; webEvent.type = webEventTypeForEvent(ev); @@ -582,8 +582,8 @@ WebKit::WebMouseWheelEvent WebEventFactory::toWebWheelEvent(QWheelEvent *ev) webEvent.deltaX = webEvent.wheelTicksX * wheelScrollLines * cDefaultQtScrollStep; webEvent.deltaY = webEvent.wheelTicksY * wheelScrollLines * cDefaultQtScrollStep; - webEvent.x = webEvent.windowX = ev->x(); - webEvent.y = webEvent.windowY = ev->y(); + webEvent.x = webEvent.windowX = ev->x() / dpiScale; + webEvent.y = webEvent.windowY = ev->y() / dpiScale; webEvent.globalX = ev->globalX(); webEvent.globalY = ev->globalY(); return webEvent; |