Mir

Merge lp:~afrantzis/mir/maybe-fix-1511095 into lp:mir

Proposed by Alexandros Frantzis
Status: Merged
Approved by: Alexandros Frantzis
Approved revision: no longer in the source branch.
Merged at revision: 3085
Proposed branch: lp:~afrantzis/mir/maybe-fix-1511095
Merge into: lp:mir
Diff against target: 34 lines (+15/-1)
2 files modified
src/server/input/display_input_region.cpp (+4/-1)
tests/unit-tests/input/test_display_input_region.cpp (+11/-0)
To merge this branch: bzr merge lp:~afrantzis/mir/maybe-fix-1511095
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Daniel van Vugt Abstain
Alberto Aguirre (community) Approve
Alan Griffiths Approve
Review via email: mp+276239@code.launchpad.net

Commit message

input: Return an empty input region bounding rectangle when there are no outputs

Description of the change

input: Return an empty input region bounding rectangle when there are no outputs

This MP *may* fix bug 1511095, but even if it turns out not to be a complete fix for that bug, it is definitely an improvement.

To post a comment you must log in.
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

definitely avoids undefined behaviour

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

LGTM.

review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Looks like it will avoid a crash (or undefined behaviour) if nothing else.

review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Hmm, or would "rectangles.bounding_rectangle()" be better?

review: Needs Information
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

rectangles.begin() was rectangles.bounding_rectangle() some time ago, but it was changed because the latter caused incorrect input scaling (https://bugs.launchpad.net/mir/+bug/1498540).

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Hmm mi::DisplayInputRegion::bounding_rectangle() needs some revising I think. It makes a list of rectangles only to use the first one and then destroys the list.

Revision history for this message
Daniel van Vugt (vanvugt) :
review: Abstain
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) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/server/input/display_input_region.cpp'
2--- src/server/input/display_input_region.cpp 2015-09-24 02:16:12 +0000
3+++ src/server/input/display_input_region.cpp 2015-10-30 10:29:34 +0000
4@@ -51,7 +51,10 @@
5 // to group a touchscreen with a display. So for now, just return the view area
6 // of the first display, as that matches the most common systems (laptops with touchscreens,
7 // phone/tablets with touchscreens).
8- return *rectangles.begin();
9+ if (rectangles.size() != 0)
10+ return *rectangles.begin();
11+ else
12+ return geom::Rectangle{};
13 }
14
15 void mi::DisplayInputRegion::confine(geom::Point& point)
16
17=== modified file 'tests/unit-tests/input/test_display_input_region.cpp'
18--- tests/unit-tests/input/test_display_input_region.cpp 2015-09-24 02:16:12 +0000
19+++ tests/unit-tests/input/test_display_input_region.cpp 2015-10-30 10:29:34 +0000
20@@ -80,3 +80,14 @@
21 }
22
23 }
24+
25+TEST(DisplayInputRegionTest, returns_empty_bounding_rectangle_when_there_are_no_outputs)
26+{
27+ geom::Rectangle const empty_rect{};
28+ auto const stub_display = std::make_shared<mtd::StubDisplay>(0);
29+
30+ mi::DisplayInputRegion input_region{stub_display};
31+
32+ auto const bounding_rect = input_region.bounding_rectangle();
33+ EXPECT_EQ(empty_rect, bounding_rect);
34+}

Subscribers

People subscribed via source and target branches