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
1=== modified file 'src/modules/Unity/Application/inputarea.cpp'
2--- src/modules/Unity/Application/inputarea.cpp 2013-11-26 08:56:08 +0000
3+++ src/modules/Unity/Application/inputarea.cpp 2014-03-06 22:02:00 +0000
4@@ -16,6 +16,8 @@
5
6 //Qt
7 #include <QCoreApplication>
8+#include <QtCore/qmath.h>
9+#include <QQuickWindow>
10
11 // mir
12 #include <mircommon/mir/geometry/rectangle.h>
13@@ -138,6 +140,15 @@
14 setMirInputArea(m_geometry);
15 }
16
17+#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
18+void InputArea::onWindowChanged()
19+{
20+ DLOG("InputArea::onWindowChanged (this=%p)", this);
21+
22+ setMirInputArea(m_geometry);
23+}
24+#endif
25+
26 void InputArea::listenToAscendantsChanges()
27 {
28 DLOG("InputArea::listenToAscendantsChanges (this=%p)", this);
29@@ -157,6 +168,9 @@
30 m_connections.append(connect(parent, &QQuickItem::yChanged, this, &InputArea::onAscendantGeometryChanged));
31 m_connections.append(connect(parent, &QQuickItem::widthChanged, this, &InputArea::onAscendantGeometryChanged));
32 m_connections.append(connect(parent, &QQuickItem::heightChanged, this, &InputArea::onAscendantGeometryChanged));
33+#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
34+ m_connections.append(connect(this, &QQuickItem::windowChanged, this, &InputArea::onWindowChanged));
35+#endif
36 parent = parent->parentItem();
37 }
38 }
39@@ -178,12 +192,15 @@
40 using namespace mir::geometry;
41 const QRect rect = parentItem()->mapRectToScene(relativeGeometry).toRect();
42
43- m_mirInputArea.top_left.x = X{rect.x()};
44- m_mirInputArea.top_left.y = Y{rect.y()};
45- m_mirInputArea.size.width = Width{rect.width()};
46- m_mirInputArea.size.height = Height{rect.height()};
47+ const float kPixelRatio = (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)) && window() != NULL ? static_cast<float>(window()->devicePixelRatio()) : 1.0f;
48+
49+ m_mirInputArea.top_left.x = X{rect.x() * kPixelRatio};
50+ m_mirInputArea.top_left.y = Y{rect.y() * kPixelRatio};
51+ m_mirInputArea.size.width = Width{qCeil(rect.width() * kPixelRatio)};
52+ m_mirInputArea.size.height = Height{qCeil(rect.height() * kPixelRatio)};
53
54 if (m_surface) {
55+ m_surface->removeInputArea(this);
56 m_surface->installInputArea(this);
57 }
58 }
59
60=== modified file 'src/modules/Unity/Application/inputarea.h'
61--- src/modules/Unity/Application/inputarea.h 2013-11-26 08:56:08 +0000
62+++ src/modules/Unity/Application/inputarea.h 2014-03-06 22:02:00 +0000
63@@ -54,6 +54,9 @@
64 private Q_SLOTS:
65 void onAscendantChanged();
66 void onAscendantGeometryChanged();
67+#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
68+ void onWindowChanged();
69+#endif
70 void setNullSurface();
71
72 private:

Subscribers

People subscribed via source and target branches