Merge lp:~gerboland/oxide/1.12-dynamic-grid-units into lp:oxide/1.12
- 1.12-dynamic-grid-units
- Merge into 1.12
Proposed by
Michał Sawicz
Status: | Work in progress |
---|---|
Proposed branch: | lp:~gerboland/oxide/1.12-dynamic-grid-units |
Merge into: | lp:oxide/1.12 |
Diff against target: |
839 lines (+322/-127) 14 files modified
qt/core/browser/oxide_qt_browser_platform_integration.cc (+5/-39) qt/core/browser/oxide_qt_browser_platform_integration.h (+4/-7) qt/core/browser/oxide_qt_screen_client.cc (+115/-0) qt/core/browser/oxide_qt_screen_client.h (+61/-0) qt/core/browser/oxide_qt_screen_utils.cc (+23/-33) qt/core/core.gyp (+8/-0) shared/browser/media/oxide_video_capture_device_hybris.cc (+8/-3) shared/browser/oxide_browser_main_parts.cc (+14/-24) shared/browser/oxide_browser_platform_integration.h (+5/-3) shared/browser/oxide_render_widget_host_view.cc (+1/-2) shared/browser/oxide_render_widget_host_view_container.h (+1/-0) shared/browser/oxide_screen_client.h (+37/-0) shared/port/content/browser/render_widget_host_view_oxide.cc (+31/-10) shared/port/content/browser/render_widget_host_view_oxide.h (+9/-6) |
To merge this branch: | bzr merge lp:~gerboland/oxide/1.12-dynamic-grid-units |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Chris Coulson | Needs Fixing | ||
Review via email: mp+286586@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
- 1314. By Gerry Boland
-
Fix signal name typo
Unmerged revisions
- 1314. By Gerry Boland
-
Fix signal name typo
- 1313. By Gerry Boland
-
Fix build fail, gfx::Screen has no GetScreen method, trying GetNativeScreen
- 1312. By Gerry Boland
-
Adding forgotton file
- 1311. By Loïc Molinari
-
Added support for scale factor retrieved from the Ubuntu QPA plugin.
- 1310. By Chris Coulson
-
Backport ScreenInfo patch from oxide trunk
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'qt/core/browser/oxide_qt_browser_platform_integration.cc' |
2 | --- qt/core/browser/oxide_qt_browser_platform_integration.cc 2016-01-12 16:42:49 +0000 |
3 | +++ qt/core/browser/oxide_qt_browser_platform_integration.cc 2016-02-19 12:04:49 +0000 |
4 | @@ -22,7 +22,6 @@ |
5 | #include <QEvent> |
6 | #include <QGuiApplication> |
7 | #include <QPointer> |
8 | -#include <QScreen> |
9 | #include <QString> |
10 | #include <QThread> |
11 | #include <QTouchDevice> |
12 | @@ -43,7 +42,7 @@ |
13 | #include "oxide_qt_clipboard.h" |
14 | #include "oxide_qt_location_provider.h" |
15 | #include "oxide_qt_message_pump.h" |
16 | -#include "oxide_qt_screen_utils.h" |
17 | +#include "oxide_qt_screen_client.h" |
18 | |
19 | namespace oxide { |
20 | namespace qt { |
21 | @@ -85,16 +84,6 @@ |
22 | NotifyClipboardDataChanged(); |
23 | } |
24 | |
25 | -void BrowserPlatformIntegration::OnScreenGeometryChanged( |
26 | - const QRect& geometry) { |
27 | - UpdateDefaultScreenInfo(); |
28 | -} |
29 | - |
30 | -void BrowserPlatformIntegration::OnScreenOrientationChanged( |
31 | - Qt::ScreenOrientation orientation) { |
32 | - UpdateDefaultScreenInfo(); |
33 | -} |
34 | - |
35 | void BrowserPlatformIntegration::UpdateApplicationState() { |
36 | ApplicationState state = CalculateApplicationState(suspended_); |
37 | if (state == state_) { |
38 | @@ -106,12 +95,6 @@ |
39 | NotifyApplicationStateChanged(); |
40 | } |
41 | |
42 | -void BrowserPlatformIntegration::UpdateDefaultScreenInfo() { |
43 | - base::AutoLock lock(default_screen_info_lock_); |
44 | - default_screen_info_ = |
45 | - GetWebScreenInfoFromQScreen(QGuiApplication::primaryScreen()); |
46 | -} |
47 | - |
48 | bool BrowserPlatformIntegration::LaunchURLExternally(const GURL& url) { |
49 | if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { |
50 | content::BrowserThread::PostTask( |
51 | @@ -144,9 +127,8 @@ |
52 | QGuiApplication::primaryScreen())); |
53 | } |
54 | |
55 | -blink::WebScreenInfo BrowserPlatformIntegration::GetDefaultScreenInfo() { |
56 | - base::AutoLock lock(default_screen_info_lock_); |
57 | - return default_screen_info_; |
58 | +oxide::ScreenClient* BrowserPlatformIntegration::GetScreenClient() { |
59 | + return screen_client_.get(); |
60 | } |
61 | |
62 | oxide::GLContextDependent* BrowserPlatformIntegration::GetGLShareContext() { |
63 | @@ -211,24 +193,8 @@ |
64 | BrowserPlatformIntegration::BrowserPlatformIntegration() |
65 | : application_name_(qApp->applicationName().toStdString()), |
66 | suspended_(false), |
67 | - state_(CalculateApplicationState(false)) { |
68 | - QScreen* primary_screen = QGuiApplication::primaryScreen(); |
69 | - primary_screen->setOrientationUpdateMask(Qt::LandscapeOrientation | |
70 | - Qt::PortraitOrientation | |
71 | - Qt::InvertedLandscapeOrientation | |
72 | - Qt::InvertedPortraitOrientation); |
73 | - connect(primary_screen, SIGNAL(virtualGeometryChanged(const QRect&)), |
74 | - SLOT(OnScreenGeometryChanged(const QRect&))); |
75 | - connect(primary_screen, SIGNAL(geometryChanged(const QRect&)), |
76 | - SLOT(OnScreenGeometryChanged(const QRect&))); |
77 | - connect(primary_screen, SIGNAL(orientationChanged(Qt::ScreenOrientation)), |
78 | - SLOT(OnScreenOrientationChanged(Qt::ScreenOrientation))); |
79 | - connect(primary_screen, |
80 | - SIGNAL(primaryOrientationChanged(Qt::ScreenOrientation)), |
81 | - SLOT(OnScreenOrientationChanged(Qt::ScreenOrientation))); |
82 | - |
83 | - UpdateDefaultScreenInfo(); |
84 | - |
85 | + state_(CalculateApplicationState(false)), |
86 | + screen_client_(new ScreenClient()) { |
87 | connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), |
88 | SLOT(OnApplicationStateChanged())); |
89 | connect(QGuiApplication::clipboard(), SIGNAL(dataChanged()), |
90 | |
91 | === modified file 'qt/core/browser/oxide_qt_browser_platform_integration.h' |
92 | --- qt/core/browser/oxide_qt_browser_platform_integration.h 2016-01-12 16:42:49 +0000 |
93 | +++ qt/core/browser/oxide_qt_browser_platform_integration.h 2016-02-19 12:04:49 +0000 |
94 | @@ -23,7 +23,6 @@ |
95 | |
96 | #include "base/macros.h" |
97 | #include "base/memory/ref_counted.h" |
98 | -#include "base/synchronization/lock.h" |
99 | |
100 | #include "shared/browser/oxide_browser_platform_integration.h" |
101 | |
102 | @@ -34,6 +33,8 @@ |
103 | namespace oxide { |
104 | namespace qt { |
105 | |
106 | +class ScreenClient; |
107 | + |
108 | class BrowserPlatformIntegration : public QObject, |
109 | public oxide::BrowserPlatformIntegration { |
110 | Q_OBJECT |
111 | @@ -45,18 +46,15 @@ |
112 | private Q_SLOTS: |
113 | void OnApplicationStateChanged(); |
114 | void OnClipboardDataChanged(); |
115 | - void OnScreenGeometryChanged(const QRect& geometry); |
116 | - void OnScreenOrientationChanged(Qt::ScreenOrientation orientation); |
117 | |
118 | private: |
119 | void UpdateApplicationState(); |
120 | - void UpdateDefaultScreenInfo(); |
121 | |
122 | // oxide::BrowserPlatformIntegration implementation |
123 | bool LaunchURLExternally(const GURL& url) override; |
124 | bool IsTouchSupported() override; |
125 | intptr_t GetNativeDisplay() override; |
126 | - blink::WebScreenInfo GetDefaultScreenInfo() override; |
127 | + oxide::ScreenClient* GetScreenClient() override; |
128 | oxide::GLContextDependent* GetGLShareContext() override; |
129 | scoped_ptr<oxide::MessagePump> CreateUIMessagePump() override; |
130 | ui::Clipboard* CreateClipboard() override; |
131 | @@ -89,8 +87,7 @@ |
132 | // when the state really does change |
133 | ApplicationState state_; |
134 | |
135 | - base::Lock default_screen_info_lock_; |
136 | - blink::WebScreenInfo default_screen_info_; |
137 | + scoped_ptr<ScreenClient> screen_client_; |
138 | |
139 | DISALLOW_COPY_AND_ASSIGN(BrowserPlatformIntegration); |
140 | }; |
141 | |
142 | === added file 'qt/core/browser/oxide_qt_screen_client.cc' |
143 | --- qt/core/browser/oxide_qt_screen_client.cc 1970-01-01 00:00:00 +0000 |
144 | +++ qt/core/browser/oxide_qt_screen_client.cc 2016-02-19 12:04:49 +0000 |
145 | @@ -0,0 +1,115 @@ |
146 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
147 | +// Copyright (C) 2016 Canonical Ltd. |
148 | + |
149 | +// This library is free software; you can redistribute it and/or |
150 | +// modify it under the terms of the GNU Lesser General Public |
151 | +// License as published by the Free Software Foundation; either |
152 | +// version 2.1 of the License, or (at your option) any later version. |
153 | + |
154 | +// This library is distributed in the hope that it will be useful, |
155 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
156 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
157 | +// Lesser General Public License for more details. |
158 | + |
159 | +// You should have received a copy of the GNU Lesser General Public |
160 | +// License along with this library; if not, write to the Free Software |
161 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
162 | + |
163 | +#include "oxide_qt_screen_client.h" |
164 | + |
165 | +#include <QGuiApplication> |
166 | +#include <QRect> |
167 | +#include <QScreen> |
168 | + |
169 | +#include "base/logging.h" |
170 | +#include "ui/gfx/display.h" |
171 | +#include "ui/gfx/geometry/rect.h" |
172 | + |
173 | +#include "oxide_qt_screen_utils.h" |
174 | + |
175 | +namespace oxide { |
176 | +namespace qt { |
177 | + |
178 | +void ScreenClient::OnScreenGeometryChanged(const QRect& geometry) { |
179 | + UpdatePrimaryDisplay(); |
180 | +} |
181 | + |
182 | +void ScreenClient::OnScreenOrientationChanged( |
183 | + Qt::ScreenOrientation orientation) { |
184 | + UpdatePrimaryDisplay(); |
185 | +} |
186 | + |
187 | +void ScreenClient::OnScreenPropertyChanged( |
188 | + QPlatformScreen *screen, const QString &propertyName) { |
189 | + if (propertyName == QStringLiteral("scale") && |
190 | + screen == QGuiApplication::primaryScreen()->handle()) { |
191 | + UpdatePrimaryDisplay(); |
192 | + } |
193 | +} |
194 | + |
195 | +void ScreenClient::UpdatePrimaryDisplay() { |
196 | + base::AutoLock lock(primary_display_lock_); |
197 | + |
198 | + QScreen* screen = QGuiApplication::primaryScreen(); |
199 | + |
200 | + primary_display_.set_id(0); |
201 | + primary_display_.set_touch_support(gfx::Display::TOUCH_SUPPORT_UNKNOWN); |
202 | + primary_display_.set_device_scale_factor( |
203 | + GetDeviceScaleFactorFromQScreen(screen)); |
204 | + |
205 | + QRect rect = screen->geometry(); |
206 | + primary_display_.set_bounds(gfx::Rect(rect.x(), |
207 | + rect.y(), |
208 | + rect.width(), |
209 | + rect.height())); |
210 | + |
211 | + QRect work_area = screen->availableGeometry(); |
212 | + primary_display_.set_work_area(gfx::Rect(work_area.x(), |
213 | + work_area.y(), |
214 | + work_area.width(), |
215 | + work_area.height())); |
216 | + |
217 | + primary_display_.SetRotationAsDegree( |
218 | + screen->angleBetween(screen->nativeOrientation(), |
219 | + screen->orientation())); |
220 | +} |
221 | + |
222 | +gfx::Display ScreenClient::GetPrimaryDisplay() { |
223 | + base::AutoLock lock(primary_display_lock_); |
224 | + return primary_display_; |
225 | +} |
226 | + |
227 | +gfx::Point ScreenClient::GetCursorScreenPoint() { |
228 | + NOTIMPLEMENTED(); |
229 | +} |
230 | + |
231 | +ScreenClient::ScreenClient() { |
232 | + QScreen* primary_screen = QGuiApplication::primaryScreen(); |
233 | + primary_screen->setOrientationUpdateMask(Qt::LandscapeOrientation | |
234 | + Qt::PortraitOrientation | |
235 | + Qt::InvertedLandscapeOrientation | |
236 | + Qt::InvertedPortraitOrientation); |
237 | + connect(primary_screen, SIGNAL(virtualGeometryChanged(const QRect&)), |
238 | + SLOT(OnScreenGeometryChanged(const QRect&))); |
239 | + connect(primary_screen, SIGNAL(geometryChanged(const QRect&)), |
240 | + SLOT(OnScreenGeometryChanged(const QRect&))); |
241 | + connect(primary_screen, SIGNAL(orientationChanged(Qt::ScreenOrientation)), |
242 | + SLOT(OnScreenOrientationChanged(Qt::ScreenOrientation))); |
243 | + connect(primary_screen, |
244 | + SIGNAL(primaryOrientationChanged(Qt::ScreenOrientation)), |
245 | + SLOT(OnScreenOrientationChanged(Qt::ScreenOrientation))); |
246 | + |
247 | + QString platform = QGuiApplication::platformName(); |
248 | + if (platform.startsWith("ubuntu") || platform == "mirserver") { |
249 | + connect(QGuiApplication::platformNativeInterface(), |
250 | + SIGNAL(screenPropertyChanged(QPlatformScreen*, const QString&)), |
251 | + SLOT(OnScreenPropertyChanged(QPlatformScreen*, const QString&))); |
252 | + } |
253 | + |
254 | + UpdatePrimaryDisplay(); |
255 | +} |
256 | + |
257 | +ScreenClient::~ScreenClient() {} |
258 | + |
259 | +} // namespace qt |
260 | +} // namespace oxide |
261 | |
262 | === added file 'qt/core/browser/oxide_qt_screen_client.h' |
263 | --- qt/core/browser/oxide_qt_screen_client.h 1970-01-01 00:00:00 +0000 |
264 | +++ qt/core/browser/oxide_qt_screen_client.h 2016-02-19 12:04:49 +0000 |
265 | @@ -0,0 +1,61 @@ |
266 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
267 | +// Copyright (C) 2016 Canonical Ltd. |
268 | + |
269 | +// This library is free software; you can redistribute it and/or |
270 | +// modify it under the terms of the GNU Lesser General Public |
271 | +// License as published by the Free Software Foundation; either |
272 | +// version 2.1 of the License, or (at your option) any later version. |
273 | + |
274 | +// This library is distributed in the hope that it will be useful, |
275 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
276 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
277 | +// Lesser General Public License for more details. |
278 | + |
279 | +// You should have received a copy of the GNU Lesser General Public |
280 | +// License along with this library; if not, write to the Free Software |
281 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
282 | + |
283 | +#ifndef _OXIDE_QT_CORE_BROWSER_SCREEN_CLIENT_H_ |
284 | +#define _OXIDE_QT_CORE_BROWSER_SCREEN_CLIENT_H_ |
285 | + |
286 | +#include <QObject> |
287 | +#include <QtGlobal> |
288 | +#include <QtGui/qpa/qplatformnativeinterface.h> |
289 | +#include <QtGui/qpa/qplatformscreen.h> |
290 | + |
291 | +#include "base/macros.h" |
292 | +#include "base/synchronization/lock.h" |
293 | + |
294 | +#include "shared/browser/oxide_screen_client.h" |
295 | + |
296 | +namespace oxide { |
297 | +namespace qt { |
298 | + |
299 | +class ScreenClient : public QObject, |
300 | + public oxide::ScreenClient { |
301 | + Q_OBJECT |
302 | + |
303 | + public: |
304 | + ScreenClient(); |
305 | + ~ScreenClient() override; |
306 | + |
307 | + private Q_SLOTS: |
308 | + void OnScreenGeometryChanged(const QRect& geometry); |
309 | + void OnScreenOrientationChanged(Qt::ScreenOrientation orientation); |
310 | + void OnScreenPropertyChanged(QPlatformScreen* screen, const QString& propertyName); |
311 | + |
312 | + private: |
313 | + void UpdatePrimaryDisplay(); |
314 | + |
315 | + // oxide::ScreenClient implementation |
316 | + gfx::Display GetPrimaryDisplay() override; |
317 | + gfx::Point GetCursorScreenPoint() override; |
318 | + |
319 | + base::Lock primary_display_lock_; |
320 | + gfx::Display primary_display_; |
321 | +}; |
322 | + |
323 | +} // namespace qt |
324 | +} // namespace oxide |
325 | + |
326 | +#endif // _OXIDE_QT_CORE_BROWSER_SCREEN_CLIENT_H_ |
327 | |
328 | === modified file 'qt/core/browser/oxide_qt_screen_utils.cc' |
329 | --- qt/core/browser/oxide_qt_screen_utils.cc 2015-11-27 21:35:14 +0000 |
330 | +++ qt/core/browser/oxide_qt_screen_utils.cc 2016-02-19 12:04:49 +0000 |
331 | @@ -22,12 +22,11 @@ |
332 | #include <QRect> |
333 | #include <QScreen> |
334 | #include <QString> |
335 | +#include <QtGui/qpa/qplatformnativeinterface.h> |
336 | |
337 | #include "third_party/WebKit/public/platform/modules/screen_orientation/WebScreenOrientationType.h" |
338 | #include "third_party/WebKit/public/platform/WebRect.h" |
339 | |
340 | -#include "shared/common/oxide_form_factor.h" |
341 | - |
342 | namespace oxide { |
343 | namespace qt { |
344 | |
345 | @@ -53,14 +52,15 @@ |
346 | } |
347 | |
348 | float GetDeviceScaleFactorFromQScreen(QScreen* screen) { |
349 | - // For some reason, the Ubuntu QPA plugin doesn't override |
350 | - // QScreen::devicePixelRatio. However, applications using the Ubuntu |
351 | - // SDK use something called "grid units". The relationship between |
352 | - // grid units and device pixels is set by the "GRID_UNIT_PX" environment |
353 | - // variable. On a screen with a DPR of 1.0f, GRID_UNIT_PX is set to 8, and |
354 | - // 1 grid unit == 8 device pixels. |
355 | - // If we are using the Ubuntu backend, we use GRID_UNIT_PX to derive the |
356 | - // device pixel ratio, else we get it from QScreen::devicePixelRatio. |
357 | + // Because it only supports integer scale factors, the Ubuntu QPA plugin |
358 | + // doesn't use the default Qt devicePixelRatio but a custom scaling system |
359 | + // based on grid units. The relationship between grid units and device pixels |
360 | + // is set by the "GRID_UNIT_PX" environment variable. On a screen with a scale |
361 | + // factor of 1, GRID_UNIT_PX is set to 8, and 1 grid unit == 8 device pixels. |
362 | + // If the Ubuntu backend is used, we retrieve scale factors from the QPA |
363 | + // plugin. For old versions that don't expose these factors, we deduce the |
364 | + // scale factor by reading the "GRID_UNIT_PX" environment variable. |
365 | + // |
366 | // XXX: There are 2 scenarios where this is completely broken: |
367 | // 1) Any apps not using the Ubuntu SDK but running with the Ubuntu |
368 | // QPA plugin. In this case, we derive a DPR from GRID_UNIT_PX if |
369 | @@ -87,6 +87,15 @@ |
370 | |
371 | QString platform = QGuiApplication::platformName(); |
372 | if (platform.startsWith("ubuntu") || platform == "mirserver") { |
373 | + |
374 | + QPlatformNativeInterface* interface = |
375 | + QGuiApplication::platformNativeInterface(); |
376 | + void* data = |
377 | + interface->nativeResourceForScreen(QByteArray("scale"), screen); |
378 | + if (data) { |
379 | + return *reinterpret_cast<float*>(data); |
380 | + } |
381 | + |
382 | QByteArray grid_unit_px(qgetenv("GRID_UNIT_PX")); |
383 | bool ok; |
384 | float scale = grid_unit_px.toFloat(&ok); |
385 | @@ -101,24 +110,18 @@ |
386 | blink::WebScreenInfo GetWebScreenInfoFromQScreen(QScreen* screen) { |
387 | blink::WebScreenInfo result; |
388 | |
389 | - result.depth = screen->depth(); |
390 | + result.depth = 24; |
391 | result.depthPerComponent = 8; // XXX: Copied the GTK impl here |
392 | result.isMonochrome = result.depth == 1; |
393 | result.deviceScaleFactor = GetDeviceScaleFactorFromQScreen(screen); |
394 | |
395 | - QRect rect = |
396 | - screen->mapBetween(Qt::PrimaryOrientation, |
397 | - screen->orientation(), |
398 | - screen->geometry()); |
399 | + QRect rect = screen->geometry(); |
400 | result.rect = blink::WebRect(rect.x(), |
401 | rect.y(), |
402 | rect.width(), |
403 | rect.height()); |
404 | |
405 | - QRect availableRect = |
406 | - screen->mapBetween(Qt::PrimaryOrientation, |
407 | - screen->orientation(), |
408 | - screen->availableGeometry()); |
409 | + QRect availableRect = screen->availableGeometry(); |
410 | result.availableRect = blink::WebRect(availableRect.x(), |
411 | availableRect.y(), |
412 | availableRect.width(), |
413 | @@ -127,22 +130,9 @@ |
414 | result.orientationType = |
415 | GetOrientationTypeFromScreenOrientation(screen->orientation()); |
416 | |
417 | - // We calculate orientationAngle, which is the clockwise rotation of the |
418 | - // content. However, QScreen::primaryOrientation doesn't work properly in |
419 | - // qtubuntu, so we assume it's portrait on phones and landscape elsewhere |
420 | - // See https://launchpad.net/bugs/1520670 |
421 | - Qt::ScreenOrientation primary_orientation = Qt::PrimaryOrientation; |
422 | - if (QGuiApplication::platformName().startsWith("ubuntu")) { |
423 | - if (oxide::GetFormFactorHint() == oxide::FORM_FACTOR_PHONE) { |
424 | - primary_orientation = Qt::PortraitOrientation; |
425 | - } else { |
426 | - primary_orientation = Qt::LandscapeOrientation; |
427 | - } |
428 | - } |
429 | - |
430 | result.orientationAngle = |
431 | screen->angleBetween(screen->orientation(), |
432 | - primary_orientation); |
433 | + screen->nativeOrientation()); |
434 | |
435 | return result; |
436 | } |
437 | |
438 | === modified file 'qt/core/core.gyp' |
439 | --- qt/core/core.gyp 2016-01-12 16:42:49 +0000 |
440 | +++ qt/core/core.gyp 2016-02-19 12:04:49 +0000 |
441 | @@ -60,6 +60,7 @@ |
442 | 'sources': [ |
443 | '<(INTERMEDIATE_DIR)/moc_oxide_qt_browser_platform_integration.cc', |
444 | '<(INTERMEDIATE_DIR)/moc_oxide_qt_input_method_context.cc', |
445 | + '<(INTERMEDIATE_DIR)/moc_oxide_qt_screen_client.cc', |
446 | 'api/internal/oxideqmediacapturedevices_p.cc', |
447 | 'api/internal/oxideqwebpreferences_p.cc', |
448 | 'app/oxide_qt_main.cc', |
449 | @@ -89,6 +90,8 @@ |
450 | 'browser/oxide_qt_location_provider.h', |
451 | 'browser/oxide_qt_message_pump.cc', |
452 | 'browser/oxide_qt_message_pump.h', |
453 | + 'browser/oxide_qt_screen_client.cc', |
454 | + 'browser/oxide_qt_screen_client.h', |
455 | 'browser/oxide_qt_screen_utils.cc', |
456 | 'browser/oxide_qt_screen_utils.h', |
457 | 'browser/oxide_qt_script_message.cc', |
458 | @@ -154,6 +157,11 @@ |
459 | ], |
460 | 'actions': [ |
461 | { |
462 | + 'action_name': 'moc_oxide_qt_screen_client.cc', |
463 | + 'moc_input': 'browser/oxide_qt_screen_client.h', |
464 | + 'includes': [ 'moc.gypi' ] |
465 | + }, |
466 | + { |
467 | 'action_name': 'oxide_qt_clipboard.moc', |
468 | 'moc_input': 'browser/oxide_qt_clipboard.cc', |
469 | 'includes': [ 'moc.gypi' ] |
470 | |
471 | === modified file 'shared/browser/media/oxide_video_capture_device_hybris.cc' |
472 | --- shared/browser/media/oxide_video_capture_device_hybris.cc 2015-12-09 20:33:45 +0000 |
473 | +++ shared/browser/media/oxide_video_capture_device_hybris.cc 2016-02-19 12:04:49 +0000 |
474 | @@ -25,6 +25,7 @@ |
475 | #include "base/strings/stringprintf.h" |
476 | #include "base/thread_task_runner_handle.h" |
477 | #include "media/base/video_types.h" |
478 | +#include "ui/gfx/display.h" |
479 | #include "ui/gl/gl_bindings.h" |
480 | #include "ui/gl/gl_context.h" |
481 | #include "ui/gl/gl_implementation.h" |
482 | @@ -32,6 +33,7 @@ |
483 | |
484 | #include "shared/browser/oxide_android_properties.h" |
485 | #include "shared/browser/oxide_browser_platform_integration.h" |
486 | +#include "shared/browser/oxide_screen_client.h" |
487 | |
488 | namespace oxide { |
489 | |
490 | @@ -52,9 +54,12 @@ |
491 | } |
492 | |
493 | int GetRotation(int orientation) { |
494 | - blink::WebScreenInfo info = |
495 | - BrowserPlatformIntegration::GetInstance()->GetDefaultScreenInfo(); |
496 | - return (orientation - info.orientationAngle) % 360; |
497 | + gfx::Display display = |
498 | + BrowserPlatformIntegration::GetInstance() |
499 | + ->GetScreenClient() |
500 | + ->GetPrimaryDisplay(); |
501 | + // XXX(chrisccoulson): Make sure this is the correct way around |
502 | + return (orientation - display.RotationAsDegree()) % 360; |
503 | } |
504 | |
505 | } |
506 | |
507 | === modified file 'shared/browser/oxide_browser_main_parts.cc' |
508 | --- shared/browser/oxide_browser_main_parts.cc 2015-10-29 16:48:48 +0000 |
509 | +++ shared/browser/oxide_browser_main_parts.cc 2016-02-19 12:04:49 +0000 |
510 | @@ -57,16 +57,13 @@ |
511 | #include "oxide_message_pump.h" |
512 | #include "oxide_power_save_blocker.h" |
513 | #include "oxide_render_process_initializer.h" |
514 | +#include "oxide_screen_client.h" |
515 | #include "oxide_web_contents_view.h" |
516 | |
517 | namespace oxide { |
518 | |
519 | namespace { |
520 | |
521 | -blink::WebScreenInfo DefaultScreenInfoGetter() { |
522 | - return BrowserPlatformIntegration::GetInstance()->GetDefaultScreenInfo(); |
523 | -} |
524 | - |
525 | scoped_ptr<media::VideoCaptureDeviceFactory> CreateVideoCaptureDeviceFactory( |
526 | scoped_ptr<media::VideoCaptureDeviceFactory> delegate) { |
527 | return make_scoped_ptr(new VideoCaptureDeviceFactoryLinux(delegate.Pass())); |
528 | @@ -141,27 +138,27 @@ |
529 | Screen() {} |
530 | |
531 | gfx::Point GetCursorScreenPoint() final { |
532 | - NOTIMPLEMENTED(); |
533 | + NOTREACHED(); |
534 | return gfx::Point(); |
535 | } |
536 | |
537 | gfx::NativeWindow GetWindowUnderCursor() final { |
538 | - NOTIMPLEMENTED(); |
539 | + NOTREACHED(); |
540 | return nullptr; |
541 | } |
542 | |
543 | gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) final { |
544 | - NOTIMPLEMENTED(); |
545 | + NOTREACHED(); |
546 | return nullptr; |
547 | } |
548 | |
549 | int GetNumDisplays() const final { |
550 | - NOTIMPLEMENTED(); |
551 | + NOTREACHED(); |
552 | return 1; |
553 | } |
554 | |
555 | std::vector<gfx::Display> GetAllDisplays() const final { |
556 | - NOTIMPLEMENTED(); |
557 | + NOTREACHED(); |
558 | return std::vector<gfx::Display>(); |
559 | } |
560 | |
561 | @@ -170,43 +167,36 @@ |
562 | // is the NativeView for the corresponding RenderWidgetHostView. It would |
563 | // be nice to find a way to cleverly map this to the associated RWHV and |
564 | // get the correct display |
565 | - return GetPrimaryDisplay(); |
566 | + return gfx::Display(); |
567 | } |
568 | |
569 | gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const final { |
570 | - NOTIMPLEMENTED(); |
571 | + NOTREACHED(); |
572 | return gfx::Display(); |
573 | } |
574 | |
575 | gfx::Display GetDisplayMatching(const gfx::Rect& match_rect) const final { |
576 | - NOTIMPLEMENTED(); |
577 | + NOTREACHED(); |
578 | return gfx::Display(); |
579 | } |
580 | |
581 | gfx::Display GetPrimaryDisplay() const final { |
582 | - blink::WebScreenInfo info( |
583 | - BrowserPlatformIntegration::GetInstance()->GetDefaultScreenInfo()); |
584 | - |
585 | - gfx::Display display; |
586 | - display.set_bounds(info.rect); |
587 | - display.set_work_area(info.availableRect); |
588 | - display.set_device_scale_factor(info.deviceScaleFactor); |
589 | - |
590 | - return display; |
591 | + return BrowserPlatformIntegration::GetInstance() |
592 | + ->GetScreenClient() |
593 | + ->GetPrimaryDisplay(); |
594 | } |
595 | |
596 | void AddObserver(gfx::DisplayObserver* observer) final { |
597 | - NOTIMPLEMENTED(); |
598 | + NOTREACHED(); |
599 | } |
600 | void RemoveObserver(gfx::DisplayObserver* observer) final { |
601 | - NOTIMPLEMENTED(); |
602 | + NOTREACHED(); |
603 | } |
604 | }; |
605 | |
606 | } // namespace |
607 | |
608 | void BrowserMainParts::PreEarlyInitialization() { |
609 | - content::SetDefaultScreenInfoGetterOxide(DefaultScreenInfoGetter); |
610 | content::SetWebContentsViewOxideFactory(WebContentsView::Create); |
611 | content::SetPowerSaveBlockerOxideDelegateFactory(CreatePowerSaveBlocker); |
612 | media::SetVideoCaptureDeviceFactoryOverrideFactory( |
613 | |
614 | === modified file 'shared/browser/oxide_browser_platform_integration.h' |
615 | --- shared/browser/oxide_browser_platform_integration.h 2016-01-12 16:42:49 +0000 |
616 | +++ shared/browser/oxide_browser_platform_integration.h 2016-02-19 12:04:49 +0000 |
617 | @@ -24,7 +24,6 @@ |
618 | #include "base/memory/scoped_ptr.h" |
619 | #include "base/observer_list.h" |
620 | #include "content/public/browser/browser_thread.h" |
621 | -#include "third_party/WebKit/public/platform/WebScreenInfo.h" |
622 | |
623 | class GURL; |
624 | |
625 | @@ -32,6 +31,7 @@ |
626 | class LocationProvider; |
627 | } |
628 | |
629 | + |
630 | namespace ui { |
631 | class Clipboard; |
632 | } |
633 | @@ -41,6 +41,7 @@ |
634 | class BrowserPlatformIntegrationObserver; |
635 | class GLContextDependent; |
636 | class MessagePump; |
637 | +class ScreenClient; |
638 | |
639 | // An abstract interface allowing toolkit-independent code to integrate with |
640 | // toolkit-specific features |
641 | @@ -76,8 +77,9 @@ |
642 | // Called on the UI thread |
643 | virtual intptr_t GetNativeDisplay() = 0; |
644 | |
645 | - // Return information about the default screen. Can be called on any thread |
646 | - virtual blink::WebScreenInfo GetDefaultScreenInfo() = 0; |
647 | + // Get the ScreenClient implementation. Can be called on any thread |
648 | + // FIXME(chrisccoulson): Make this UI thread only |
649 | + virtual ScreenClient* GetScreenClient() = 0; |
650 | |
651 | // Return the shared GL context provided by the application, if one exists. |
652 | // This will be used for sharing resources between the webview and UI |
653 | |
654 | === modified file 'shared/browser/oxide_render_widget_host_view.cc' |
655 | --- shared/browser/oxide_render_widget_host_view.cc 2016-01-12 16:42:49 +0000 |
656 | +++ shared/browser/oxide_render_widget_host_view.cc 2016-02-19 12:04:49 +0000 |
657 | @@ -407,8 +407,7 @@ |
658 | |
659 | void RenderWidgetHostView::GetScreenInfo(blink::WebScreenInfo* result) { |
660 | if (!container_) { |
661 | - *result = |
662 | - BrowserPlatformIntegration::GetInstance()->GetDefaultScreenInfo(); |
663 | + RenderWidgetHostViewOxide::GetDefaultScreenInfo(result); |
664 | return; |
665 | } |
666 | |
667 | |
668 | === modified file 'shared/browser/oxide_render_widget_host_view_container.h' |
669 | --- shared/browser/oxide_render_widget_host_view_container.h 2016-01-12 16:42:49 +0000 |
670 | +++ shared/browser/oxide_render_widget_host_view_container.h 2016-02-19 12:04:49 +0000 |
671 | @@ -65,6 +65,7 @@ |
672 | |
673 | virtual gfx::Rect GetViewBoundsDip() const = 0; |
674 | |
675 | + // TODO(chrisccoulson): Return a gfx::Display here |
676 | virtual blink::WebScreenInfo GetScreenInfo() const = 0; |
677 | |
678 | virtual bool HasFocus(const RenderWidgetHostView* view) const = 0; |
679 | |
680 | === added file 'shared/browser/oxide_screen_client.h' |
681 | --- shared/browser/oxide_screen_client.h 1970-01-01 00:00:00 +0000 |
682 | +++ shared/browser/oxide_screen_client.h 2016-02-19 12:04:49 +0000 |
683 | @@ -0,0 +1,37 @@ |
684 | +// vim:expandtab:shiftwidth=2:tabstop=2: |
685 | +// Copyright (C) 2016 Canonical Ltd. |
686 | + |
687 | +// This library is free software; you can redistribute it and/or |
688 | +// modify it under the terms of the GNU Lesser General Public |
689 | +// License as published by the Free Software Foundation; either |
690 | +// version 2.1 of the License, or (at your option) any later version. |
691 | + |
692 | +// This library is distributed in the hope that it will be useful, |
693 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of |
694 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
695 | +// Lesser General Public License for more details. |
696 | + |
697 | +// You should have received a copy of the GNU Lesser General Public |
698 | +// License along with this library; if not, write to the Free Software |
699 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
700 | + |
701 | +#ifndef _OXIDE_SHARED_BROWSER_SCREEN_CLIENT_H_ |
702 | +#define _OXIDE_SHARED_BROWSER_SCREEN_CLIENT_H_ |
703 | + |
704 | +#include "ui/gfx/display.h" |
705 | +#include "ui/gfx/geometry/point.h" |
706 | + |
707 | +namespace oxide { |
708 | + |
709 | +class ScreenClient { |
710 | + public: |
711 | + virtual ~ScreenClient() {} |
712 | + |
713 | + virtual gfx::Display GetPrimaryDisplay() = 0; |
714 | + |
715 | + virtual gfx::Point GetCursorScreenPoint() = 0; |
716 | +}; |
717 | + |
718 | +} // namespace oxide |
719 | + |
720 | +#endif // _OXIDE_SHARED_BROWSER_SCREEN_CLIENT_H_ |
721 | |
722 | === modified file 'shared/port/content/browser/render_widget_host_view_oxide.cc' |
723 | --- shared/port/content/browser/render_widget_host_view_oxide.cc 2015-08-04 20:44:09 +0000 |
724 | +++ shared/port/content/browser/render_widget_host_view_oxide.cc 2016-02-19 12:04:49 +0000 |
725 | @@ -1,5 +1,5 @@ |
726 | // vim:expandtab:shiftwidth=2:tabstop=2: |
727 | -// Copyright (C) 2013-2014 Canonical Ltd. |
728 | +// Copyright (C) 2013-2016 Canonical Ltd. |
729 | |
730 | // This library is free software; you can redistribute it and/or |
731 | // modify it under the terms of the GNU Lesser General Public |
732 | @@ -19,17 +19,17 @@ |
733 | |
734 | #include "base/logging.h" |
735 | #include "content/common/view_messages.h" |
736 | +#include "third_party/WebKit/public/platform/WebScreenInfo.h" |
737 | +#include "ui/gfx/display.h" |
738 | +#include "ui/gfx/screen.h" |
739 | |
740 | namespace content { |
741 | |
742 | -namespace { |
743 | -DefaultScreenInfoGetter* g_default_screen_info_getter; |
744 | -} |
745 | - |
746 | void RenderWidgetHostViewBase::GetDefaultScreenInfo( |
747 | - blink::WebScreenInfo* results) { |
748 | - DCHECK(g_default_screen_info_getter); |
749 | - *results = g_default_screen_info_getter(); |
750 | + blink::WebScreenInfo* result) { |
751 | + RenderWidgetHostViewOxide::GetWebScreenInfoForDisplay( |
752 | + gfx::Screen::GetNativeScreen()->GetPrimaryDisplay(), |
753 | + result); |
754 | } |
755 | |
756 | void RenderWidgetHostViewOxide::TextInputStateChanged( |
757 | @@ -46,8 +46,29 @@ |
758 | |
759 | RenderWidgetHostViewOxide::~RenderWidgetHostViewOxide() {} |
760 | |
761 | -void SetDefaultScreenInfoGetterOxide(DefaultScreenInfoGetter* getter) { |
762 | - g_default_screen_info_getter = getter; |
763 | +// static |
764 | +void RenderWidgetHostViewOxide::GetWebScreenInfoForDisplay( |
765 | + const gfx::Display& display, |
766 | + blink::WebScreenInfo* result) { |
767 | + result->deviceScaleFactor = display.device_scale_factor(); |
768 | + result->depth = 24; |
769 | + result->depthPerComponent = 8; |
770 | + result->isMonochrome = false; |
771 | + result->rect = display.bounds(); |
772 | + result->availableRect = display.work_area(); |
773 | + |
774 | + // The rotation angle of gfx::Display is the clockwise screen rotation, |
775 | + // whereas the orientationAngle of blink::WebScreenInfo is the clockwise |
776 | + // content rotation |
777 | + result->orientationAngle = display.RotationAsDegree(); |
778 | + if (result->orientationAngle == 90) { |
779 | + result->orientationAngle = 270; |
780 | + } else if (result->orientationAngle == 270) { |
781 | + result->orientationAngle = 90; |
782 | + } |
783 | + |
784 | + result->orientationType = |
785 | + RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); |
786 | } |
787 | |
788 | } // namespace content |
789 | |
790 | === modified file 'shared/port/content/browser/render_widget_host_view_oxide.h' |
791 | --- shared/port/content/browser/render_widget_host_view_oxide.h 2015-08-04 20:44:09 +0000 |
792 | +++ shared/port/content/browser/render_widget_host_view_oxide.h 2016-02-19 12:04:49 +0000 |
793 | @@ -1,5 +1,5 @@ |
794 | // vim:expandtab:shiftwidth=2:tabstop=2: |
795 | -// Copyright (C) 2013-2014 Canonical Ltd. |
796 | +// Copyright (C) 2013-2016 Canonical Ltd. |
797 | |
798 | // This library is free software; you can redistribute it and/or |
799 | // modify it under the terms of the GNU Lesser General Public |
800 | @@ -20,13 +20,17 @@ |
801 | |
802 | #include "content/browser/renderer_host/render_widget_host_view_base.h" |
803 | #include "content/common/content_export.h" |
804 | -#include "third_party/WebKit/public/platform/WebScreenInfo.h" |
805 | #include "ui/base/ime/text_input_type.h" |
806 | |
807 | struct ViewHostMsg_TextInputState_Params; |
808 | |
809 | +namespace blink { |
810 | +class WebScreenInfo; |
811 | +} |
812 | + |
813 | namespace gfx { |
814 | class Rect; |
815 | +class Display; |
816 | } |
817 | |
818 | namespace content { |
819 | @@ -36,6 +40,9 @@ |
820 | public: |
821 | virtual ~RenderWidgetHostViewOxide(); |
822 | |
823 | + static void GetWebScreenInfoForDisplay(const gfx::Display& display, |
824 | + blink::WebScreenInfo* result); |
825 | + |
826 | private: |
827 | // content::RenderWidgetHostViewBase implementation |
828 | void TextInputStateChanged( |
829 | @@ -50,10 +57,6 @@ |
830 | bool is_anchor_first) = 0; |
831 | }; |
832 | |
833 | -typedef blink::WebScreenInfo (DefaultScreenInfoGetter)(); |
834 | -CONTENT_EXPORT void SetDefaultScreenInfoGetterOxide( |
835 | - DefaultScreenInfoGetter* getter); |
836 | - |
837 | } // namespace content |
838 | |
839 | #endif // _OXIDE_SHARED_PORT_CONTENT_BROWSER_RENDER_WIDGET_HOST_VIEW_H_ |
Sorry, but backporting code refactorings like this to a stable branch is a nack. And this needs to land on trunk first, and then next (currently 1.13) - it should have a bug report targeted to the branches it needs to land on.
Normally only security fixes and critical regressions land on the stable branch. There's still a chance we might need to spin security updates for all releases from this branch, so we don't accept changes that introduce significant risk.
The stuff you've backported is completely unnecessary - ScreenClient isn't used for retrieving display information for visible webviews, even on trunk (I'm currently doing some work to refactor how this works). Screen information comes directly from the webview itself.