Merge lp:~gerboland/qtmir/fix-orientation-after-unplug into lp:qtmir

Proposed by Gerry Boland
Status: Merged
Approved by: Michael Zanetti
Approved revision: 443
Merged at revision: 456
Proposed branch: lp:~gerboland/qtmir/fix-orientation-after-unplug
Merge into: lp:qtmir
Diff against target: 95 lines (+37/-8)
3 files modified
src/platforms/mirserver/screen.cpp (+17/-4)
src/platforms/mirserver/screen.h (+3/-1)
tests/mirserver/Screen/screen_test.cpp (+17/-3)
To merge this branch: bzr merge lp:~gerboland/qtmir/fix-orientation-after-unplug
Reviewer Review Type Date Requested Status
Michael Zanetti (community) Approve
Unity8 CI Bot (community) continuous-integration Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+286065@code.launchpad.net

Commit message

Screen: only enable orientation sensor for internal display.

It's not great, but works around orientation sensor not working after device unplug from monitor. I believe this is because QtUbuntu-Sensors and Platform-api are not dealing properly with multiple accessors of the sensors. Instead only the last accessor gets correct state, and the earlier ones get nothing.

To post a comment you must log in.
Revision history for this message
Gerry Boland (gerboland) wrote :
Revision history for this message
MichaƂ Sawicz (saviq) wrote :

+TODO?

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
442. By Gerry Boland

Consider eDP connector internal too

443. By Gerry Boland

Update test to check both cases

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote :

 * Did you perform an exploratory manual test run of the code change and any related functionality?

in silo 10, so yes

 * Did CI run pass? If not, please explain why.

it did

 * Did you make sure that the branch does not contain spurious tags?

needs tags stripping.

lp:~gerboland/qtmir/fix-orientation-after-unplug: would delete 0.4.7+16.04.20160205-0ubuntu1,0.4.7+16.04.20160121.2-0ubuntu1,0.4.7+16.04.20160126.2-0ubuntu1,0.4.7+16.04.20160204.2-0ubuntu1,0.4.7+16.04.20160204-0ubuntu1,0.4.7+16.04.20160126-0ubuntu1,0.4.7+16.04.20160127-0ubuntu1,0.4.7+16.04.20160121-0ubuntu1,0.4.7+16.04.20160126.1-0ubuntu1,0.4.7+16.04.20160121.1-0ubuntu1,0.4.7+16.04.20160204.1-0ubuntu1

review: Needs Fixing
Revision history for this message
Michael Zanetti (mzanetti) wrote :

Tags stripped now. lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/platforms/mirserver/screen.cpp'
2--- src/platforms/mirserver/screen.cpp 2015-10-14 22:59:04 +0000
3+++ src/platforms/mirserver/screen.cpp 2016-02-15 16:02:31 +0000
4@@ -135,9 +135,11 @@
5 ? Qt::LandscapeOrientation : Qt::PortraitOrientation;
6 qCDebug(QTMIR_SENSOR_MESSAGES) << "Screen - initial currentOrientation is:" << m_currentOrientation;
7
8- QObject::connect(m_orientationSensor, &QOrientationSensor::readingChanged,
9- this, &Screen::onOrientationReadingChanged);
10- m_orientationSensor->start();
11+ if (internalDisplay()) { // only enable orientation sensor for device-internal display
12+ QObject::connect(m_orientationSensor, &QOrientationSensor::readingChanged,
13+ this, &Screen::onOrientationReadingChanged);
14+ m_orientationSensor->start();
15+ }
16
17 if (!skipDBusRegistration) {
18 // FIXME This is a unity8 specific dbus call and shouldn't be in qtmir
19@@ -171,7 +173,9 @@
20 void Screen::onDisplayPowerStateChanged(int status, int reason)
21 {
22 Q_UNUSED(reason);
23- toggleSensors(status);
24+ if (internalDisplay()) {
25+ toggleSensors(status);
26+ }
27 }
28
29 void Screen::setMirDisplayConfiguration(const mir::graphics::DisplayConfigurationOutput &screen)
30@@ -334,3 +338,12 @@
31 {
32 m_renderTarget->release_current();
33 }
34+
35+bool Screen::internalDisplay() const
36+{
37+ using namespace mir::graphics;
38+ if (m_type == DisplayConfigurationOutputType::lvds || m_type == DisplayConfigurationOutputType::edp) {
39+ return true;
40+ }
41+ return false;
42+}
43
44=== modified file 'src/platforms/mirserver/screen.h'
45--- src/platforms/mirserver/screen.h 2015-10-14 22:59:04 +0000
46+++ src/platforms/mirserver/screen.h 2016-02-15 16:02:31 +0000
47@@ -53,7 +53,6 @@
48 Qt::ScreenOrientation orientation() const override { return m_currentOrientation; }
49 QPlatformCursor *cursor() const override;
50
51- void toggleSensors(const bool enable) const;
52 mir::graphics::DisplayConfigurationOutputType outputType() const { return m_type; }
53
54 ScreenWindow* window() const;
55@@ -79,6 +78,9 @@
56 void doneCurrent();
57
58 private:
59+ void toggleSensors(const bool enable) const;
60+ bool internalDisplay() const;
61+
62 QRect m_geometry;
63 int m_depth;
64 QImage::Format m_format;
65
66=== modified file 'tests/mirserver/Screen/screen_test.cpp'
67--- tests/mirserver/Screen/screen_test.cpp 2015-10-14 22:59:04 +0000
68+++ tests/mirserver/Screen/screen_test.cpp 2016-02-15 16:02:31 +0000
69@@ -42,9 +42,23 @@
70 Screen::skipDBusRegistration = true;
71 }
72
73-TEST_F(ScreenTest, OrientationSensor)
74-{
75- Screen *screen = new Screen(fakeOutput1);
76+TEST_F(ScreenTest, OrientationSensorForExternalDisplay)
77+{
78+ Screen *screen = new Screen(fakeOutput1); // is external display (dvi)
79+
80+ // Default state should be disabled
81+ ASSERT_FALSE(screen->orientationSensorEnabled());
82+
83+ screen->onDisplayPowerStateChanged(0,0);
84+ ASSERT_FALSE(screen->orientationSensorEnabled());
85+
86+ screen->onDisplayPowerStateChanged(1,0);
87+ ASSERT_FALSE(screen->orientationSensorEnabled());
88+}
89+
90+TEST_F(ScreenTest, OrientationSensorForInternalDisplay)
91+{
92+ Screen *screen = new Screen(fakeOutput2); // is internal display
93
94 // Default state should be active
95 ASSERT_TRUE(screen->orientationSensorEnabled());

Subscribers

People subscribed via source and target branches