Merge lp:~aacid/qtubuntu/dpr_rebase_qt_5.1_with_ifdefs into lp:qtubuntu

Proposed by Albert Astals Cid
Status: Rejected
Rejected by: Albert Astals Cid
Proposed branch: lp:~aacid/qtubuntu/dpr_rebase_qt_5.1_with_ifdefs
Merge into: lp:qtubuntu
Diff against target: 176 lines (+62/-2)
6 files modified
src/platforms/base/input.cc (+10/-0)
src/platforms/base/window.cc (+6/-0)
src/platforms/base/window.h (+3/-0)
src/platforms/ubuntu/ubuntucommon/screen.cc (+19/-0)
src/platforms/ubuntu/ubuntucommon/screen.h (+3/-0)
src/platforms/ubuntu/ubuntucommon/window.cc (+21/-2)
To merge this branch: bzr merge lp:~aacid/qtubuntu/dpr_rebase_qt_5.1_with_ifdefs
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Ubuntu Phablet Team Pending
Review via email: mp+196165@code.launchpad.net

Commit message

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

while still supporting Qt 5.0 way

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

Unmerged revisions

177. By Albert Astals Cid

Add ifdefs to support also the 5.0 code

176. By Albert Astals Cid

Merge

175. By Florian Boucault

Removed spamming log.

174. By Florian Boucault

Merged trunk

173. By Florian Boucault

Adapt to the Qt 5.2 way of creating the event dispatcher

172. By Florian Boucault

Merged from trunk

171. By Florian Boucault

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/platforms/base/input.cc'
2--- src/platforms/base/input.cc 2013-10-17 18:38:03 +0000
3+++ src/platforms/base/input.cc 2013-11-21 16:57:13 +0000
4@@ -369,6 +369,9 @@
5 // needs to be fixed as soon as the compat input lib adds query support.
6 const float kMaxPressure = 1.28;
7 const QRect kWindowGeometry = window->geometry();
8+#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
9+ qreal pixelRatio = window->devicePixelRatio();
10+#endif
11 QList<QWindowSystemInterface::TouchPoint> touchPoints;
12
13
14@@ -378,10 +381,17 @@
15 for (int i = 0; i < kPointerCount; ++i) {
16 QWindowSystemInterface::TouchPoint touchPoint;
17
18+#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
19+ const float kX = event->details.motion.pointer_coordinates[i].raw_x / pixelRatio;
20+ const float kY = event->details.motion.pointer_coordinates[i].raw_y / pixelRatio;
21+ const float kW = event->details.motion.pointer_coordinates[i].touch_major / pixelRatio;
22+ const float kH = event->details.motion.pointer_coordinates[i].touch_minor / pixelRatio;
23+#else
24 const float kX = event->details.motion.pointer_coordinates[i].raw_x;
25 const float kY = event->details.motion.pointer_coordinates[i].raw_y;
26 const float kW = event->details.motion.pointer_coordinates[i].touch_major;
27 const float kH = event->details.motion.pointer_coordinates[i].touch_minor;
28+#endif
29 const float kP = event->details.motion.pointer_coordinates[i].pressure;
30 touchPoint.id = event->details.motion.pointer_coordinates[i].id;
31 touchPoint.normalPosition = QPointF(kX / kWindowGeometry.width(), kY / kWindowGeometry.height());
32
33=== modified file 'src/platforms/base/window.cc'
34--- src/platforms/base/window.cc 2013-10-09 12:11:20 +0000
35+++ src/platforms/base/window.cc 2013-11-21 16:57:13 +0000
36@@ -45,3 +45,9 @@
37 eglSurface_ = EGL_NO_SURFACE;
38 }
39 }
40+
41+#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
42+qreal QUbuntuBaseWindow::devicePixelRatio() const {
43+ return screen_->devicePixelRatio();
44+}
45+#endif
46
47=== modified file 'src/platforms/base/window.h'
48--- src/platforms/base/window.h 2013-10-09 12:11:20 +0000
49+++ src/platforms/base/window.h 2013-11-21 16:57:13 +0000
50@@ -28,6 +28,9 @@
51
52 // QPlatformWindow methods.
53 WId winId() const { return id_; }
54+#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
55+ qreal devicePixelRatio() const;
56+#endif
57
58 // New methods.
59 void createEGLSurface(EGLNativeWindowType nativeWindow);
60
61=== modified file 'src/platforms/ubuntu/ubuntucommon/screen.cc'
62--- src/platforms/ubuntu/ubuntucommon/screen.cc 2013-08-02 16:34:13 +0000
63+++ src/platforms/ubuntu/ubuntucommon/screen.cc 2013-11-21 16:57:13 +0000
64@@ -76,8 +76,13 @@
65
66 // Get screen resolution.
67 UAUiDisplay* display = ua_ui_display_new_with_index(0);
68+#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
69+ const int kScreenWidth = ua_ui_display_query_horizontal_res(display) / densityPixelRatio_;
70+ const int kScreenHeight = ua_ui_display_query_vertical_res(display) / densityPixelRatio_;
71+#else
72 const int kScreenWidth = ua_ui_display_query_horizontal_res(display);
73 const int kScreenHeight = ua_ui_display_query_vertical_res(display);
74+#endif
75 ASSERT(kScreenWidth > 0 && kScreenHeight > 0);
76 DLOG("screen resolution: %dx%d", kScreenWidth, kScreenHeight);
77 ua_ui_display_destroy(display);
78@@ -118,6 +123,12 @@
79 delete orientationSensor_;
80 }
81
82+#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
83+qreal QUbuntuScreen::devicePixelRatio() const {
84+ return densityPixelRatio_;
85+}
86+#endif
87+
88 void QUbuntuScreen::toggleSensors(bool enable) const {
89 DLOG("QUbuntuScreen::toggleSensors (this=%p, enable=%d)", this, enable);
90 if (enable)
91@@ -128,17 +139,25 @@
92
93 int QUbuntuScreen::gridUnitToPixel(int value) const {
94 DLOG("QUbuntuScreen::gridUnitToPixel (this=%p, value=%d)", this, value);
95+#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
96+ return value * kDefaultGridUnit;
97+#else
98 return value * gridUnit_;
99+#endif
100 }
101
102 int QUbuntuScreen::densityPixelToPixel(int value) const {
103 DLOG("QUbuntuScreen::densityPixelToPixel (this=%p, value=%d)", this, value);
104+#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
105+ return value;
106+#else
107 if (value <= 2) {
108 // For values under 2dp, return only multiples of the value.
109 return static_cast<int>(value * qFloor(densityPixelRatio_));
110 } else {
111 return static_cast<int>(qRound(value * densityPixelRatio_));
112 }
113+#endif
114 }
115
116 void QUbuntuScreen::customEvent(QEvent* event) {
117
118=== modified file 'src/platforms/ubuntu/ubuntucommon/screen.h'
119--- src/platforms/ubuntu/ubuntucommon/screen.h 2013-08-02 16:34:13 +0000
120+++ src/platforms/ubuntu/ubuntucommon/screen.h 2013-11-21 16:57:13 +0000
121@@ -32,6 +32,9 @@
122 // QPlatformScreen methods.
123 QRect geometry() const { return geometry_; }
124 QRect availableGeometry() const { return availableGeometry_; }
125+#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
126+ qreal devicePixelRatio() const;
127+#endif
128
129 Qt::ScreenOrientation nativeOrientation() const { return nativeOrientation_; }
130 Qt::ScreenOrientation orientation() const { return currentOrientation_; }
131
132=== modified file 'src/platforms/ubuntu/ubuntucommon/window.cc'
133--- src/platforms/ubuntu/ubuntucommon/window.cc 2013-10-09 12:11:20 +0000
134+++ src/platforms/ubuntu/ubuntucommon/window.cc 2013-11-21 16:57:13 +0000
135@@ -109,11 +109,24 @@
136 // Create platform window
137 window_ = ua_ui_window_new_for_application_with_properties(uainstance_, wprops_);
138
139- if (geometry.width() != 0 || geometry.height() != 0)
140+#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
141+ qreal pixelRatio = devicePixelRatio();
142+#endif
143+ if (geometry.width() != 0 || geometry.height() != 0) {
144+#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
145+ ua_ui_window_resize(window_, geometry.width() * pixelRatio, geometry.height() * pixelRatio);
146+#else
147 ua_ui_window_resize(window_, geometry.width(), geometry.height());
148+#endif
149+ }
150
151- if (geometry.x() != 0 || geometry.y() != 0)
152+ if (geometry.x() != 0 || geometry.y() != 0) {
153+#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
154+ ua_ui_window_move(window_, geometry.x() * pixelRatio, geometry.y() * pixelRatio);
155+#else
156 ua_ui_window_move(window_, geometry.x(), geometry.y());
157+#endif
158+ }
159
160 ASSERT(window_ != NULL);
161 createEGLSurface(ua_ui_window_get_native_type(window_));
162@@ -129,8 +142,14 @@
163 void QUbuntuWindow::moveResize(const QRect& rect) {
164 fprintf(stderr, "\nQUbuntuWindow::moveResize (this=%p, x=%d, y=%d, w=%d, h=%d)\n", this, rect.x(), rect.y(),
165 rect.width(), rect.height());
166+#if QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)
167+ qreal pixelRatio = devicePixelRatio();
168+ ua_ui_window_move(window_, rect.x() * pixelRatio, rect.y() * pixelRatio);
169+ ua_ui_window_resize(window_, rect.width() * pixelRatio, rect.height() * pixelRatio);
170+#else
171 ua_ui_window_move(window_, rect.x(), rect.y());
172 ua_ui_window_resize(window_, rect.width(), rect.height());
173+#endif
174 QWindowSystemInterface::handleGeometryChange(window(), rect);
175 QPlatformWindow::setGeometry(rect);
176 }

Subscribers

People subscribed via source and target branches