Merge lp:~fboucault/unity-mir/dpr_rebase_qt_5.1 into lp:unity-mir

Proposed by Florian Boucault
Status: Work in progress
Proposed branch: lp:~fboucault/unity-mir/dpr_rebase_qt_5.1
Merge into: lp:unity-mir
Diff against target: 72 lines (+24/-4)
2 files modified
src/modules/Unity/Application/inputarea.cpp (+21/-4)
src/modules/Unity/Application/inputarea.h (+3/-0)
To merge this branch: bzr merge lp:~fboucault/unity-mir/dpr_rebase_qt_5.1
Reviewer Review Type Date Requested Status
Florian Boucault (community) Disapprove
PS Jenkins bot (community) continuous-integration Approve
Ricardo Mendoza Pending
Review via email: mp+209775@code.launchpad.net

Commit message

Rebase resolution independence on Qt's infrastructure:
- QPlatformScreen::devicePixelRatio
- QPlatformWindow::devicePixelRatio

Change is only enabled for Qt version >= 5.1

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
186. By Florian Boucault

Take into account that there might not be a window.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
187. By Florian Boucault

Round width and height so that the actual dimensions are computed from the virtual ones without missing any pixel.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Florian Boucault (fboucault) wrote :

This change should be landed for now as the DPR patches in QtUbuntu and the UI Toolkit are only enabled for the webbrowser and the webapps (not for Unity).

review: Disapprove

Unmerged revisions

187. By Florian Boucault

Round width and height so that the actual dimensions are computed from the virtual ones without missing any pixel.

186. By Florian Boucault

Take into account that there might not be a window.

185. By Florian Boucault

Rebase resolution independence on Qt's infrastructure:
- QPlatformScreen::devicePixelRatio
- QPlatformWindow::devicePixelRatio

Change is only enabled for Qt version >= 5.1

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/modules/Unity/Application/inputarea.cpp'
--- src/modules/Unity/Application/inputarea.cpp 2013-11-26 08:56:08 +0000
+++ src/modules/Unity/Application/inputarea.cpp 2014-03-06 22:02:00 +0000
@@ -16,6 +16,8 @@
1616
17//Qt17//Qt
18#include <QCoreApplication>18#include <QCoreApplication>
19#include <QtCore/qmath.h>
20#include <QQuickWindow>
1921
20// mir22// mir
21#include <mircommon/mir/geometry/rectangle.h>23#include <mircommon/mir/geometry/rectangle.h>
@@ -138,6 +140,15 @@
138 setMirInputArea(m_geometry);140 setMirInputArea(m_geometry);
139}141}
140142
143#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
144void InputArea::onWindowChanged()
145{
146 DLOG("InputArea::onWindowChanged (this=%p)", this);
147
148 setMirInputArea(m_geometry);
149}
150#endif
151
141void InputArea::listenToAscendantsChanges()152void InputArea::listenToAscendantsChanges()
142{153{
143 DLOG("InputArea::listenToAscendantsChanges (this=%p)", this);154 DLOG("InputArea::listenToAscendantsChanges (this=%p)", this);
@@ -157,6 +168,9 @@
157 m_connections.append(connect(parent, &QQuickItem::yChanged, this, &InputArea::onAscendantGeometryChanged));168 m_connections.append(connect(parent, &QQuickItem::yChanged, this, &InputArea::onAscendantGeometryChanged));
158 m_connections.append(connect(parent, &QQuickItem::widthChanged, this, &InputArea::onAscendantGeometryChanged));169 m_connections.append(connect(parent, &QQuickItem::widthChanged, this, &InputArea::onAscendantGeometryChanged));
159 m_connections.append(connect(parent, &QQuickItem::heightChanged, this, &InputArea::onAscendantGeometryChanged));170 m_connections.append(connect(parent, &QQuickItem::heightChanged, this, &InputArea::onAscendantGeometryChanged));
171#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
172 m_connections.append(connect(this, &QQuickItem::windowChanged, this, &InputArea::onWindowChanged));
173#endif
160 parent = parent->parentItem();174 parent = parent->parentItem();
161 }175 }
162}176}
@@ -178,12 +192,15 @@
178 using namespace mir::geometry;192 using namespace mir::geometry;
179 const QRect rect = parentItem()->mapRectToScene(relativeGeometry).toRect();193 const QRect rect = parentItem()->mapRectToScene(relativeGeometry).toRect();
180194
181 m_mirInputArea.top_left.x = X{rect.x()};195 const float kPixelRatio = (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)) && window() != NULL ? static_cast<float>(window()->devicePixelRatio()) : 1.0f;
182 m_mirInputArea.top_left.y = Y{rect.y()};196
183 m_mirInputArea.size.width = Width{rect.width()};197 m_mirInputArea.top_left.x = X{rect.x() * kPixelRatio};
184 m_mirInputArea.size.height = Height{rect.height()};198 m_mirInputArea.top_left.y = Y{rect.y() * kPixelRatio};
199 m_mirInputArea.size.width = Width{qCeil(rect.width() * kPixelRatio)};
200 m_mirInputArea.size.height = Height{qCeil(rect.height() * kPixelRatio)};
185201
186 if (m_surface) {202 if (m_surface) {
203 m_surface->removeInputArea(this);
187 m_surface->installInputArea(this);204 m_surface->installInputArea(this);
188 }205 }
189}206}
190207
=== modified file 'src/modules/Unity/Application/inputarea.h'
--- src/modules/Unity/Application/inputarea.h 2013-11-26 08:56:08 +0000
+++ src/modules/Unity/Application/inputarea.h 2014-03-06 22:02:00 +0000
@@ -54,6 +54,9 @@
54private Q_SLOTS:54private Q_SLOTS:
55 void onAscendantChanged();55 void onAscendantChanged();
56 void onAscendantGeometryChanged();56 void onAscendantGeometryChanged();
57#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
58 void onWindowChanged();
59#endif
57 void setNullSurface();60 void setNullSurface();
5861
59private:62private:

Subscribers

People subscribed via source and target branches