Merge lp:~fboucault/qtubuntu/dpr_rebase_qt_5.1 into lp:qtubuntu

Proposed by Florian Boucault
Status: Work in progress
Proposed branch: lp:~fboucault/qtubuntu/dpr_rebase_qt_5.1
Merge into: lp:qtubuntu
Diff against target: 261 lines (+74/-17)
8 files modified
src/modules/application/input_filter_area.cc (+16/-1)
src/modules/application/input_filter_area.h (+3/-0)
src/platforms/base/input.cc (+5/-4)
src/platforms/base/window.cc (+6/-0)
src/platforms/base/window.h (+3/-0)
src/platforms/ubuntu/ubuntucommon/screen.cc (+29/-7)
src/platforms/ubuntu/ubuntucommon/screen.h (+4/-0)
src/platforms/ubuntu/ubuntucommon/window.cc (+8/-5)
To merge this branch: bzr merge lp:~fboucault/qtubuntu/dpr_rebase_qt_5.1
Reviewer Review Type Date Requested Status
Unity8 CI Bot continuous-integration Needs Fixing
Daniel d'Andrada (community) Needs Information
Gerry Boland (community) Needs Fixing
PS Jenkins bot continuous-integration Approve
Loïc Molinari (community) Approve
Review via email: mp+183500@code.launchpad.net

Commit message

Change is only enabled for the webbrowser app.

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)
172. By Florian Boucault

Merged from trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

I wonder if this should/could be #ifdef:d so that it would work correctly regardless of if built against Qt 5.0.2 or Qt 5.1/5.2? See eg. https://code.launchpad.net/~aacid/qtubuntu/event_dispatcher_52/+merge/194128

Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

Ok, I may be wrong in asking for the #ifdef:s, so please ignore me if needed. I'm just interested that if a new qtubuntu is released before Qt 5.2, nothing breaks in the current images where Qt 5.0.2 is used.

< tsdgeos> Mirv: we'd need some input from Kaleo here but it seems to me the devicePixelRatio virutals are also in 5.0 so it may just work in both

173. By Florian Boucault

Adapt to the Qt 5.2 way of creating the event dispatcher

174. By Florian Boucault

Merged trunk

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

Removed spamming log.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :
176. By Florian Boucault

Merged trunk

177. By Florian Boucault

Merged conditional code from lp:~aacid/qtubuntu/dpr_rebase_qt_5.1_with_ifdefs

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

Merged with trunk

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

Merged from trunk.

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

More concise pixel ratio management.

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

ua_ui_window_properties_set_dimensions needs the geometry in actual pixels too.

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

Fix InputFilterArea by adding missing coordinates conversion.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
183. 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: Needs Fixing (continuous-integration)
184. 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: Needs Fixing (continuous-integration)
185. By Florian Boucault

Added forgotten ifdef.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Loïc Molinari (loic.molinari) wrote :

Good.

review: Approve
186. By Florian Boucault

Only activate devicePixelRatio based scaling for webbrowser-app.

187. By Florian Boucault

Also activate devicePixelRatio based scaling for webapps.

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

Missing semicolon.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

Hey Florian,
the surface flinger specific part of this MR can be deleted, i.e. all changes in src/modules/application

I could then take on a review.

review: Needs Fixing
Revision history for this message
Florian Boucault (fboucault) wrote :

> Hey Florian,
> the surface flinger specific part of this MR can be deleted, i.e. all changes
> in src/modules/application
>
> I could then take on a review.

Thanks but it was already reviewed and "good to go" but it depends on other non ready things.

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

Time has passed and we are now way beyond Qt 5.1. So all those version checks can go away.
Is this patch still relevant today?

review: Needs Information
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

FAILED: Continuous integration, rev:188
https://unity8-jenkins.ubuntu.com/job/lp-qtubuntu-1-ci/3/
Executed test runs:

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-qtubuntu-1-ci/3/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :
review: Needs Fixing (continuous-integration)

Unmerged revisions

188. By Florian Boucault

Missing semicolon.

187. By Florian Boucault

Also activate devicePixelRatio based scaling for webapps.

186. By Florian Boucault

Only activate devicePixelRatio based scaling for webbrowser-app.

185. By Florian Boucault

Added forgotten ifdef.

184. By Florian Boucault

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

183. By Florian Boucault

Take into account that there might not be a window.

182. By Florian Boucault

Fix InputFilterArea by adding missing coordinates conversion.

181. By Florian Boucault

ua_ui_window_properties_set_dimensions needs the geometry in actual pixels too.

180. By Florian Boucault

More concise pixel ratio management.

179. By Florian Boucault

Merged from trunk.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/modules/application/input_filter_area.cc'
2--- src/modules/application/input_filter_area.cc 2013-11-06 12:21:46 +0000
3+++ src/modules/application/input_filter_area.cc 2014-03-11 12:54:54 +0000
4@@ -16,6 +16,8 @@
5 #include "input_filter_area.h"
6 #include "logging.h"
7 #include <ubuntu/ui/ubuntu_ui_session_service.h>
8+#include <QtQuick/QQuickWindow>
9+#include <QtCore/qmath.h>
10
11 InputFilterArea::InputFilterArea(QQuickItem* parent)
12 : QQuickItem(parent)
13@@ -69,6 +71,14 @@
14 setInputTrap(relativeToAbsoluteGeometry(geometry_));
15 }
16
17+#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
18+void InputFilterArea::onWindowChanged() {
19+ DLOG("InputFilterArea::onWindowChanged (this=%p)", this);
20+
21+ setInputTrap(relativeToAbsoluteGeometry(geometry_));
22+}
23+#endif
24+
25 void InputFilterArea::listenToAscendantsChanges() {
26 DLOG("InputFilterArea::listenToAscendantsChanges (this=%p)", this);
27
28@@ -88,6 +98,9 @@
29 connections_.append(connect(parent, &QQuickItem::yChanged, this, &InputFilterArea::onAscendantGeometryChanged));
30 connections_.append(connect(parent, &QQuickItem::widthChanged, this, &InputFilterArea::onAscendantGeometryChanged));
31 connections_.append(connect(parent, &QQuickItem::heightChanged, this, &InputFilterArea::onAscendantGeometryChanged));
32+#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
33+ connections_.append(connect(this, &QQuickItem::windowChanged, this, &InputFilterArea::onWindowChanged));
34+#endif
35 parent = parent->parentItem();
36 }
37 }
38@@ -112,7 +125,9 @@
39 trapHandle_ = 0;
40 }
41 if (geometry.isValid()) {
42- trapHandle_ = ubuntu_ui_set_surface_trap(geometry.x(), geometry.y(), geometry.width(), geometry.height());
43+ const float kPixelRatio = (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)) && window() != NULL ? static_cast<float>(window()->devicePixelRatio()) : 1.0f;
44+ trapHandle_ = ubuntu_ui_set_surface_trap(geometry.x() * kPixelRatio, qCeil(geometry.y() * kPixelRatio),
45+ geometry.width() * kPixelRatio, qCeil(geometry.height() * kPixelRatio));
46 }
47 }
48 }
49
50=== modified file 'src/modules/application/input_filter_area.h'
51--- src/modules/application/input_filter_area.h 2013-11-06 12:21:46 +0000
52+++ src/modules/application/input_filter_area.h 2014-03-11 12:54:54 +0000
53@@ -40,6 +40,9 @@
54 private Q_SLOTS:
55 void onAscendantChanged();
56 void onAscendantGeometryChanged();
57+#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
58+ void onWindowChanged();
59+#endif
60
61 private:
62 void listenToAscendantsChanges();
63
64=== modified file 'src/platforms/base/input.cc'
65--- src/platforms/base/input.cc 2013-10-17 18:38:03 +0000
66+++ src/platforms/base/input.cc 2014-03-11 12:54:54 +0000
67@@ -369,6 +369,7 @@
68 // needs to be fixed as soon as the compat input lib adds query support.
69 const float kMaxPressure = 1.28;
70 const QRect kWindowGeometry = window->geometry();
71+ const float kPixelRatio = (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)) ? 1.0f / static_cast<float>(window->devicePixelRatio()) : 1.0f;
72 QList<QWindowSystemInterface::TouchPoint> touchPoints;
73
74
75@@ -378,10 +379,10 @@
76 for (int i = 0; i < kPointerCount; ++i) {
77 QWindowSystemInterface::TouchPoint touchPoint;
78
79- const float kX = event->details.motion.pointer_coordinates[i].raw_x;
80- const float kY = event->details.motion.pointer_coordinates[i].raw_y;
81- const float kW = event->details.motion.pointer_coordinates[i].touch_major;
82- const float kH = event->details.motion.pointer_coordinates[i].touch_minor;
83+ const float kX = event->details.motion.pointer_coordinates[i].raw_x * kPixelRatio;
84+ const float kY = event->details.motion.pointer_coordinates[i].raw_y * kPixelRatio;
85+ const float kW = event->details.motion.pointer_coordinates[i].touch_major * kPixelRatio;
86+ const float kH = event->details.motion.pointer_coordinates[i].touch_minor * kPixelRatio;
87 const float kP = event->details.motion.pointer_coordinates[i].pressure;
88 touchPoint.id = event->details.motion.pointer_coordinates[i].id;
89 touchPoint.normalPosition = QPointF(kX / kWindowGeometry.width(), kY / kWindowGeometry.height());
90
91=== modified file 'src/platforms/base/window.cc'
92--- src/platforms/base/window.cc 2013-10-09 12:11:20 +0000
93+++ src/platforms/base/window.cc 2014-03-11 12:54:54 +0000
94@@ -45,3 +45,9 @@
95 eglSurface_ = EGL_NO_SURFACE;
96 }
97 }
98+
99+#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
100+qreal QUbuntuBaseWindow::devicePixelRatio() const {
101+ return screen_->devicePixelRatio();
102+}
103+#endif
104
105=== modified file 'src/platforms/base/window.h'
106--- src/platforms/base/window.h 2013-10-09 12:11:20 +0000
107+++ src/platforms/base/window.h 2014-03-11 12:54:54 +0000
108@@ -28,6 +28,9 @@
109
110 // QPlatformWindow methods.
111 WId winId() const { return id_; }
112+#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
113+ qreal devicePixelRatio() const;
114+#endif
115
116 // New methods.
117 void createEGLSurface(EGLNativeWindowType nativeWindow);
118
119=== modified file 'src/platforms/ubuntu/ubuntucommon/screen.cc'
120--- src/platforms/ubuntu/ubuntucommon/screen.cc 2014-02-20 23:03:54 +0000
121+++ src/platforms/ubuntu/ubuntucommon/screen.cc 2014-03-11 12:54:54 +0000
122@@ -55,6 +55,9 @@
123 const int kTabletMinSize = 100;
124
125 QUbuntuScreen::QUbuntuScreen(UApplicationOptions *options) {
126+ useDevicePixelRatio_ = (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)) &&
127+ (QCoreApplication::applicationName() == "webbrowser-app" ||
128+ QCoreApplication::applicationName() == "webapp-container");
129 // Retrieve units from the environment.
130 int gridUnit = kDefaultGridUnit;
131 QByteArray gridUnitString = qgetenv("GRID_UNIT_PX");
132@@ -79,8 +82,9 @@
133
134 // Get screen resolution.
135 UAUiDisplay* display = ua_ui_display_new_with_index(0);
136- const int kScreenWidth = ua_ui_display_query_horizontal_res(display);
137- const int kScreenHeight = ua_ui_display_query_vertical_res(display);
138+ const float kPixelRatio = useDevicePixelRatio_ ? 1.0f / densityPixelRatio_ : 1.0f;
139+ const int kScreenWidth = ua_ui_display_query_horizontal_res(display) * kPixelRatio;
140+ const int kScreenHeight = ua_ui_display_query_vertical_res(display) * kPixelRatio;
141 ASSERT(kScreenWidth > 0 && kScreenHeight > 0);
142 DLOG("screen resolution: %dx%d", kScreenWidth, kScreenHeight);
143 ua_ui_display_destroy(display);
144@@ -124,6 +128,16 @@
145 delete orientationSensor_;
146 }
147
148+#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
149+qreal QUbuntuScreen::devicePixelRatio() const {
150+ if (useDevicePixelRatio_) {
151+ return densityPixelRatio_;
152+ } else {
153+ return 1.0;
154+ }
155+}
156+#endif
157+
158 void QUbuntuScreen::toggleSensors(bool enable) const {
159 DLOG("QUbuntuScreen::toggleSensors (this=%p, enable=%d)", this, enable);
160 if (enable)
161@@ -134,16 +148,24 @@
162
163 int QUbuntuScreen::gridUnitToPixel(int value) const {
164 DLOG("QUbuntuScreen::gridUnitToPixel (this=%p, value=%d)", this, value);
165- return value * gridUnit_;
166+ if (useDevicePixelRatio_) {
167+ return value * kDefaultGridUnit;
168+ } else {
169+ return value * gridUnit_;
170+ }
171 }
172
173 int QUbuntuScreen::densityPixelToPixel(int value) const {
174 DLOG("QUbuntuScreen::densityPixelToPixel (this=%p, value=%d)", this, value);
175- if (value <= 2) {
176- // For values under 2dp, return only multiples of the value.
177- return static_cast<int>(value * qFloor(densityPixelRatio_));
178+ if (useDevicePixelRatio_) {
179+ return value;
180 } else {
181- return static_cast<int>(qRound(value * densityPixelRatio_));
182+ if (value <= 2) {
183+ // For values under 2dp, return only multiples of the value.
184+ return static_cast<int>(value * qFloor(densityPixelRatio_));
185+ } else {
186+ return static_cast<int>(qRound(value * densityPixelRatio_));
187+ }
188 }
189 }
190
191
192=== modified file 'src/platforms/ubuntu/ubuntucommon/screen.h'
193--- src/platforms/ubuntu/ubuntucommon/screen.h 2013-08-02 16:34:13 +0000
194+++ src/platforms/ubuntu/ubuntucommon/screen.h 2014-03-11 12:54:54 +0000
195@@ -32,6 +32,9 @@
196 // QPlatformScreen methods.
197 QRect geometry() const { return geometry_; }
198 QRect availableGeometry() const { return availableGeometry_; }
199+#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
200+ qreal devicePixelRatio() const;
201+#endif
202
203 Qt::ScreenOrientation nativeOrientation() const { return nativeOrientation_; }
204 Qt::ScreenOrientation orientation() const { return currentOrientation_; }
205@@ -54,6 +57,7 @@
206 Qt::ScreenOrientation nativeOrientation_;
207 Qt::ScreenOrientation currentOrientation_;
208 QOrientationSensor* orientationSensor_;
209+ bool useDevicePixelRatio_;
210 };
211
212 #endif // QUBUNTUSCREEN_H
213
214=== modified file 'src/platforms/ubuntu/ubuntucommon/window.cc'
215--- src/platforms/ubuntu/ubuntucommon/window.cc 2013-12-11 04:32:09 +0000
216+++ src/platforms/ubuntu/ubuntucommon/window.cc 2014-03-11 12:54:54 +0000
217@@ -24,6 +24,7 @@
218 #include "base/logging.h"
219 #include <qpa/qwindowsysteminterface.h>
220 #include <ubuntu/application/ui/window.h>
221+#include <QtCore/qmath.h>
222
223 static void eventCallback(void* context, const Event* event) {
224 DLOG("eventCallback (context=%p, event=%p)", context, event);
225@@ -101,20 +102,21 @@
226 geometry.width(), geometry.height(), title.data());
227
228 // Setup platform window creation properties
229+ const float kPixelRatio = (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)) ? devicePixelRatio() : 1.0f;
230 wprops_ = ua_ui_window_properties_new_for_normal_window();
231 ua_ui_window_properties_set_titlen(wprops_, title.data(), title.size());
232 ua_ui_window_properties_set_role(wprops_, static_cast<UAUiWindowRole>(role));
233 ua_ui_window_properties_set_input_cb_and_ctx(wprops_, &eventCallback, this);
234- ua_ui_window_properties_set_dimensions(wprops_, geometry.width(), geometry.height());
235+ ua_ui_window_properties_set_dimensions(wprops_, qCeil(geometry.width() * kPixelRatio), qCeil(geometry.height() * kPixelRatio));
236
237 // Create platform window
238 window_ = ua_ui_window_new_for_application_with_properties(uainstance_, wprops_);
239
240 if (geometry.width() != 0 || geometry.height() != 0)
241- ua_ui_window_resize(window_, geometry.width(), geometry.height());
242+ ua_ui_window_resize(window_, qCeil(geometry.width() * kPixelRatio), qCeil(geometry.height() * kPixelRatio));
243
244 if (geometry.x() != 0 || geometry.y() != 0)
245- ua_ui_window_move(window_, geometry.x(), geometry.y());
246+ ua_ui_window_move(window_, geometry.x() * kPixelRatio, geometry.y() * kPixelRatio);
247
248 ASSERT(window_ != NULL);
249 createEGLSurface(ua_ui_window_get_native_type(window_));
250@@ -130,8 +132,9 @@
251 void QUbuntuWindow::moveResize(const QRect& rect) {
252 fprintf(stderr, "\nQUbuntuWindow::moveResize (this=%p, x=%d, y=%d, w=%d, h=%d)\n", this, rect.x(), rect.y(),
253 rect.width(), rect.height());
254- ua_ui_window_move(window_, rect.x(), rect.y());
255- ua_ui_window_resize(window_, rect.width(), rect.height());
256+ const float kPixelRatio = (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)) ? devicePixelRatio() : 1.0f;
257+ ua_ui_window_move(window_, rect.x() * kPixelRatio, rect.y() * kPixelRatio);
258+ ua_ui_window_resize(window_, qCeil(rect.width() * kPixelRatio), qCeil(rect.height() * kPixelRatio));
259 QWindowSystemInterface::handleGeometryChange(window(), rect);
260 QPlatformWindow::setGeometry(rect);
261 }

Subscribers

People subscribed via source and target branches