Mir

Merge lp:~vanvugt/mir/fix-1398294 into lp:mir

Proposed by Daniel van Vugt
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 2130
Proposed branch: lp:~vanvugt/mir/fix-1398294
Merge into: lp:mir
Diff against target: 95 lines (+33/-15)
2 files modified
src/server/shell/graphics_display_layout.cpp (+19/-13)
tests/unit-tests/shell/test_graphics_display_layout.cpp (+14/-2)
To merge this branch: bzr merge lp:~vanvugt/mir/fix-1398294
Reviewer Review Type Date Requested Status
Cemil Azizoglu (community) Approve
Alan Griffiths Approve
Alexandros Frantzis (community) Needs Information
Review via email: mp+243765@code.launchpad.net

Commit message

Ensure fullscreen'ing always succeeds in choosing a screen, if there
are any. (LP: #1398294)

Also ensure we pick the most appropriate one.

To post a comment you must log in.
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

33 + geometry::Rectangle best = rect;

Don't we want get_output_for() to return an empty rectangle (i.e. no output) if the window doesn't intersect with any screen?

review: Needs Information
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

19 rect.size =
22 + geom::Size{br_closed.x.as_int() - tl_closed.x.as_int() + 1,
23 + br_closed.y.as_int() - tl_closed.y.as_int() + 1};

Isn't that easier to read as:

     rect.size = geom::Point{1, 1} + (br_closed - tl_closed);

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

Alexandros:
Nope. In the worst evil case where there are no displays, I think it's better to fail to fullscreen (leave the window unchanged) than to resize to 0x0 (which becomes 1x1 due to the resize policy). Although noutputs==0 is not an important use case. I'll make fullscreening-to-zero-outputs a resize to 0x0 again if you think it's really preferable.

Alan:
I noticed that too. There might be room for simplification but I was going for the smallest diff being a bug fix.

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

Alexandros:
To answer your question more precisely - The case of the window not intersecting any screen (where nscreens > 0) is handled already. In that case it goes fullscreen on the first screen (because an overlap area of 0 is greater than the default max_area of -1).

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

I guess the needless verbosity mentioned above and that in the tests (which is also rife with "magic numbers") can be argued as "pre-existing". (I still think it ought to be fixed though - even if not on this MP.)

review: Approve
Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

Ok.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/server/shell/graphics_display_layout.cpp'
2--- src/server/shell/graphics_display_layout.cpp 2014-12-04 03:22:52 +0000
3+++ src/server/shell/graphics_display_layout.cpp 2014-12-05 09:23:19 +0000
4@@ -44,17 +44,19 @@
5 if (output.size.width > geom::Width{0} && output.size.height > geom::Height{0} &&
6 rect.size.width > geom::Width{0} && rect.size.height > geom::Height{0})
7 {
8- auto tl = rect.top_left;
9+ auto tl_closed = rect.top_left;
10 auto br_closed = rect.bottom_right() - geom::Displacement{1,1};
11
12 geom::Rectangles rectangles;
13 rectangles.add(output);
14
15+ rectangles.confine(tl_closed);
16 rectangles.confine(br_closed);
17
18+ rect.top_left = tl_closed;
19 rect.size =
20- geom::Size{br_closed.x.as_int() - tl.x.as_int() + 1,
21- br_closed.y.as_int() - tl.y.as_int() + 1};
22+ geom::Size{br_closed.x.as_int() - tl_closed.x.as_int() + 1,
23+ br_closed.y.as_int() - tl_closed.y.as_int() + 1};
24 }
25 else
26 {
27@@ -93,19 +95,23 @@
28
29 geom::Rectangle msh::GraphicsDisplayLayout::get_output_for(geometry::Rectangle& rect)
30 {
31- geom::Rectangle output;
32+ int max_area = -1;
33+ geometry::Rectangle best = rect;
34
35- /*
36- * TODO: We need a better heuristic to decide in which output a
37- * rectangle/surface belongs.
38- */
39 display->for_each_display_buffer(
40- [&output,&rect](mg::DisplayBuffer const& db)
41+ [&](mg::DisplayBuffer const& db)
42 {
43- auto view_area = db.view_area();
44- if (view_area.contains(rect.top_left))
45- output = view_area;
46+ auto const& screen = db.view_area();
47+ auto const& overlap = rect.intersection_with(screen);
48+ int area = overlap.size.width.as_int() *
49+ overlap.size.height.as_int();
50+
51+ if (area > max_area)
52+ {
53+ best = screen;
54+ max_area = area;
55+ }
56 });
57
58- return output;
59+ return best;
60 }
61
62=== modified file 'tests/unit-tests/shell/test_graphics_display_layout.cpp'
63--- tests/unit-tests/shell/test_graphics_display_layout.cpp 2014-12-05 03:26:03 +0000
64+++ tests/unit-tests/shell/test_graphics_display_layout.cpp 2014-12-05 09:23:19 +0000
65@@ -66,7 +66,7 @@
66 geom::Rectangle{geom::Point{899,99}, geom::Size{1,1}}),
67 std::make_tuple(
68 geom::Rectangle{geom::Point{-1,-1}, geom::Size{100,100}},
69- geom::Rectangle{geom::Point{-1,-1}, geom::Size{0,0}})
70+ geom::Rectangle{geom::Point{0,0}, geom::Size{99,99}})
71 };
72
73 for (auto const& t : rect_tuples)
74@@ -95,8 +95,20 @@
75 geom::Rectangle{geom::Point{899,99}, geom::Size{30,40}},
76 geom::Rectangle{geom::Point{800,0}, geom::Size{100,100}}),
77 std::make_tuple(
78+ geom::Rectangle{geom::Point{850,-10}, geom::Size{30,40}},
79+ geom::Rectangle{geom::Point{800,0}, geom::Size{100,100}}),
80+ std::make_tuple(
81+ geom::Rectangle{geom::Point{749,20}, geom::Size{60,60}},
82+ geom::Rectangle{geom::Point{0,0}, geom::Size{800,600}}),
83+ std::make_tuple(
84+ geom::Rectangle{geom::Point{790,20}, geom::Size{60,60}},
85+ geom::Rectangle{geom::Point{800,0}, geom::Size{100,100}}),
86+ std::make_tuple(
87+ geom::Rectangle{geom::Point{-1000,-1000}, geom::Size{100,100}},
88+ geom::Rectangle{geom::Point{0,0}, geom::Size{800,600}}),
89+ std::make_tuple(
90 geom::Rectangle{geom::Point{-1,-1}, geom::Size{100,100}},
91- geom::Rectangle{geom::Point{0,0}, geom::Size{0,0}})
92+ geom::Rectangle{geom::Point{0,0}, geom::Size{800,600}})
93 };
94
95 for (auto const& t : rect_tuples)

Subscribers

People subscribed via source and target branches