Merge lp:~gerboland/qtubuntu/make-up-physical-size-if-mir-says-0x0 into lp:qtubuntu

Proposed by Gerry Boland
Status: Work in progress
Proposed branch: lp:~gerboland/qtubuntu/make-up-physical-size-if-mir-says-0x0
Merge into: lp:qtubuntu
Diff against target: 94 lines (+28/-14)
2 files modified
src/ubuntumirclient/screen.cpp (+27/-13)
src/ubuntumirclient/screen.h (+1/-1)
To merge this branch: bzr merge lp:~gerboland/qtubuntu/make-up-physical-size-if-mir-says-0x0
Reviewer Review Type Date Requested Status
Nick Dedekind (community) Needs Fixing
Unity8 CI Bot continuous-integration Approve
Review via email: mp+302578@code.launchpad.net

Commit message

Check if physical display size is zero and if so, guess something more suitable.

Remove unused "nativeGeometry" variable

To post a comment you must log in.
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:335
https://unity8-jenkins.ubuntu.com/job/lp-qtubuntu-ci/104/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/2533
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/2561
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/2442
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/2442
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/2442
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/2435
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/2435/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2435
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/2435/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/2435
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=yakkety/2435/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/2435
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/2435/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2435
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/2435/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/2435
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=yakkety/2435/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/2435
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/2435/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/2435
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/2435/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/2435
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=yakkety/2435/artifact/output/*zip*/output.zip

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

review: Approve (continuous-integration)
Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

Looks ok; just one comment.

review: Needs Fixing
Revision history for this message
Gerry Boland (gerboland) wrote :

I'm not convinced this is useful, marking WiP

Unmerged revisions

335. By Gerry Boland

Check if physical display size is zero and if so, guess something more suitable.

Remove unused "nativeGeometry"

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/ubuntumirclient/screen.cpp'
2--- src/ubuntumirclient/screen.cpp 2016-04-28 14:09:54 +0000
3+++ src/ubuntumirclient/screen.cpp 2016-08-10 16:28:11 +0000
4@@ -32,6 +32,7 @@
5
6 #include <memory>
7
8+namespace {
9 static const int overrideDevicePixelRatio = qgetenv("QT_DEVICE_PIXEL_RATIO").toInt();
10
11 static const char *orientationToStr(Qt::ScreenOrientation orientation) {
12@@ -51,6 +52,24 @@
13 }
14 }
15
16+QSizeF setPhysicalSize(QSize size_mm, QSize resolution)
17+{
18+ float width_mm = size_mm.width();
19+ float height_mm = size_mm.height();
20+
21+ if (width_mm <= 0 || height_mm <= 0) {
22+ // Mir cannot determine the physical dimentions of the display, either because it has
23+ // no such measurement (i.e. projector) or is a virtual machine. In that case, guess
24+ // something reasonable
25+ const int dpi = 100;
26+ width_mm = qRound(resolution.width() * 25.4 / dpi);
27+ height_mm = qRound(resolution.height() * 25.4 / dpi);
28+ }
29+
30+ return QSizeF(width_mm, height_mm);
31+}
32+} // namespace {
33+
34 const QEvent::Type OrientationChangeEvent::mType =
35 static_cast<QEvent::Type>(QEvent::registerEventType());
36
37@@ -143,10 +162,6 @@
38
39 void UbuntuScreen::setMirOutput(const MirOutput *output)
40 {
41- // Physical screen size (in mm)
42- mPhysicalSize.setWidth(mir_output_get_physical_width_mm(output));
43- mPhysicalSize.setHeight(mir_output_get_physical_height_mm(output));
44-
45 // Pixel Format
46 // mFormat = qImageFormatFromMirPixelFormat(mir_output_get_current_pixel_format(output)); // GERRY: TODO
47
48@@ -155,13 +170,17 @@
49
50 // Mode = Resolution & refresh rate
51 const MirOutputMode *mode = mir_output_get_current_mode(output);
52- mNativeGeometry.setX(mir_output_get_position_x(output));
53- mNativeGeometry.setY(mir_output_get_position_y(output));
54- mNativeGeometry.setWidth(mir_output_mode_get_width(mode));
55- mNativeGeometry.setHeight(mir_output_mode_get_height(mode));
56+ mGeometry.setX(mir_output_get_position_x(output));
57+ mGeometry.setY(mir_output_get_position_y(output));
58+ mGeometry.setWidth(mir_output_mode_get_width(mode));
59+ mGeometry.setHeight(mir_output_mode_get_height(mode));
60
61 mRefreshRate = mir_output_mode_get_refresh_rate(mode);
62
63+ // Physical screen size (in mm)
64+ QSize mirPhysicalSize(mir_output_get_physical_width_mm(output), mir_output_get_physical_height_mm(output));
65+ mPhysicalSize = setPhysicalSize(mirPhysicalSize, mGeometry.size());
66+
67 // UI scale & DPR
68 mScale = mir_output_get_scale_factor(output);
69 if (overrideDevicePixelRatio > 0) {
70@@ -174,11 +193,6 @@
71
72 mOutputId = mir_output_get_id(output);
73
74- mGeometry.setX(mNativeGeometry.x());
75- mGeometry.setY(mNativeGeometry.y());
76- mGeometry.setWidth(mNativeGeometry.width());
77- mGeometry.setHeight(mNativeGeometry.height());
78-
79 // Set the default orientation based on the initial screen dimensions.
80 mNativeOrientation = (mGeometry.width() >= mGeometry.height()) ? Qt::LandscapeOrientation : Qt::PortraitOrientation;
81
82
83=== modified file 'src/ubuntumirclient/screen.h'
84--- src/ubuntumirclient/screen.h 2016-04-28 14:09:54 +0000
85+++ src/ubuntumirclient/screen.h 2016-08-10 16:28:11 +0000
86@@ -62,7 +62,7 @@
87 private:
88 void setMirOutput(const MirOutput *output);
89
90- QRect mGeometry, mNativeGeometry;
91+ QRect mGeometry;
92 QSizeF mPhysicalSize;
93 qreal mDevicePixelRatio;
94 Qt::ScreenOrientation mNativeOrientation;

Subscribers

People subscribed via source and target branches