Mir

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

Proposed by Daniel van Vugt
Status: Merged
Merged at revision: 2131
Proposed branch: lp:~vanvugt/mir/fix-1400218
Merge into: lp:mir
Diff against target: 98 lines (+48/-1)
2 files modified
src/server/scene/basic_surface.cpp (+1/-1)
tests/unit-tests/scene/test_basic_surface.cpp (+47/-0)
To merge this branch: bzr merge lp:~vanvugt/mir/fix-1400218
Reviewer Review Type Date Requested Status
Kevin DuBois (community) Approve
Cemil Azizoglu (community) Approve
Alan Griffiths Approve
Alexandros Frantzis (community) Approve
Review via email: mp+243947@code.launchpad.net

Commit message

Ensure surfaces can't consume/steal input events while they themselves
are invisible (e.g. no frame posted yet, or [soon] while minimized).
(LP: #1400218)

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

OK.

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

Yes

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

Ok.

review: Approve
Revision history for this message
Kevin DuBois (kdub) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/server/scene/basic_surface.cpp'
2--- src/server/scene/basic_surface.cpp 2014-12-05 03:26:03 +0000
3+++ src/server/scene/basic_surface.cpp 2014-12-08 07:16:27 +0000
4@@ -293,7 +293,7 @@
5 {
6 std::unique_lock<std::mutex> lock(guard);
7
8- if (hidden)
9+ if (!visible(lock))
10 return false;
11
12 // Restrict to bounding rectangle
13
14=== modified file 'tests/unit-tests/scene/test_basic_surface.cpp'
15--- tests/unit-tests/scene/test_basic_surface.cpp 2014-12-05 03:26:03 +0000
16+++ tests/unit-tests/scene/test_basic_surface.cpp 2014-12-08 07:16:27 +0000
17@@ -85,6 +85,17 @@
18 void attribute_set(ms::Surface const&, MirSurfaceAttrib, int) override { }
19 };
20
21+void post_a_frame(ms::BasicSurface& surface)
22+{
23+ /*
24+ * Make sure there's a frame ready. Otherwise visible()==false and the
25+ * input_area will never report it containing anything for all the tests
26+ * that use it.
27+ */
28+ mtd::StubBuffer buffer;
29+ surface.swap_buffers(&buffer, [&](mir::graphics::Buffer*){});
30+}
31+
32 struct BasicSurfaceTest : public testing::Test
33 {
34 std::string const name{"aa"};
35@@ -113,6 +124,11 @@
36 stub_configurator,
37 std::shared_ptr<mg::CursorImage>(),
38 report};
39+
40+ BasicSurfaceTest()
41+ {
42+ post_a_frame(surface);
43+ }
44 };
45
46 }
47@@ -264,6 +280,18 @@
48 mir::graphics::Buffer* buffer = nullptr;
49 auto const callback = [&](mir::graphics::Buffer* new_buffer) { buffer = new_buffer; };
50
51+ // Must be a fresh surface to guarantee no frames posted yet...
52+ ms::BasicSurface surface{
53+ name,
54+ rect,
55+ false,
56+ mock_buffer_stream,
57+ std::shared_ptr<mi::InputChannel>(),
58+ stub_input_sender,
59+ stub_configurator,
60+ std::shared_ptr<mg::CursorImage>(),
61+ report};
62+
63 //not visible by default
64 EXPECT_FALSE(surface.visible());
65
66@@ -330,6 +358,7 @@
67 report};
68
69 surface.add_observer(observer);
70+ post_a_frame(surface);
71
72 std::vector<geom::Point> contained_pt
73 {
74@@ -354,6 +383,24 @@
75 }
76 }
77
78+TEST_F(BasicSurfaceTest, default_invisible_surface_doesnt_get_input)
79+{
80+ ms::BasicSurface surface{
81+ name,
82+ geom::Rectangle{{0,0}, {100,100}},
83+ false,
84+ mock_buffer_stream,
85+ std::shared_ptr<mi::InputChannel>(),
86+ stub_input_sender,
87+ stub_configurator,
88+ std::shared_ptr<mg::CursorImage>(),
89+ report};
90+
91+ EXPECT_FALSE(surface.input_area_contains({50,50}));
92+ post_a_frame(surface);
93+ EXPECT_TRUE(surface.input_area_contains({50,50}));
94+}
95+
96 TEST_F(BasicSurfaceTest, set_input_region)
97 {
98 std::vector<geom::Rectangle> const rectangles = {

Subscribers

People subscribed via source and target branches