Mir

Merge lp:~raof/mir/cursoring into lp:mir

Proposed by Chris Halse Rogers
Status: Merged
Merged at revision: 1664
Proposed branch: lp:~raof/mir/cursoring
Merge into: lp:mir
Diff against target: 153 lines (+60/-25)
4 files modified
src/platform/graphics/mesa/cursor.cpp (+10/-2)
src/platform/graphics/mesa/cursor.h (+2/-1)
src/platform/graphics/mesa/display.cpp (+3/-3)
tests/unit-tests/graphics/mesa/test_cursor.cpp (+45/-19)
To merge this branch: bzr merge lp:~raof/mir/cursoring
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Alexandros Frantzis (community) Approve
Alan Griffiths Approve
Daniel van Vugt Approve
Brandon Schaefer (community) Approve
Review via email: mp+220951@code.launchpad.net

Commit message

Add suspend()/resume() to Mesa::Cursor, replacing .show_at_last_position().

This is conceptually what show_at_last_position() was trying to do, and
with an explicit suspend/resume interface we can save whether or not the
cursor was hidden across VT switches.

Fixes: LP: #1323225

Description of the change

Make the cursor retain its shown/hidden state over VT switches

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Confirmed fixes the issue.

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

108 +TEST_F(MesaCursorTest, cursor_is_shown_at_correct_locaiton_after_suspend_resume)

typo 'location'

18 +void mir::graphics::mesa::Cursor::suspend()
19 +{
20 + output_container.for_each_output(
21 + [&](KMSOutput& output) { output.clear_cursor(); });
22 +}

Lock needed (although with the current code I don't think we can hit a race here, but of course the situation can easily change).

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

Works for me.

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

LGTM

review: Approve
Revision history for this message
Alexandros Frantzis (afrantzis) :
review: Approve
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) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/platform/graphics/mesa/cursor.cpp'
2--- src/platform/graphics/mesa/cursor.cpp 2014-05-22 11:31:21 +0000
3+++ src/platform/graphics/mesa/cursor.cpp 2014-05-27 08:08:21 +0000
4@@ -83,7 +83,7 @@
5 {
6 show(*initial_image);
7
8- show_at_last_known_position();
9+ resume();
10 }
11
12 mgm::Cursor::~Cursor() noexcept
13@@ -116,7 +116,15 @@
14 place_cursor_at(position, UpdateState);
15 }
16
17-void mgm::Cursor::show_at_last_known_position()
18+void mir::graphics::mesa::Cursor::suspend()
19+{
20+ std::lock_guard<std::mutex> lg(guard);
21+
22+ output_container.for_each_output(
23+ [&](KMSOutput& output) { output.clear_cursor(); });
24+}
25+
26+void mgm::Cursor::resume()
27 {
28 place_cursor_at(current_position, ForceState);
29 }
30
31=== modified file 'src/platform/graphics/mesa/cursor.h'
32--- src/platform/graphics/mesa/cursor.h 2014-05-22 11:31:21 +0000
33+++ src/platform/graphics/mesa/cursor.h 2014-05-27 08:08:21 +0000
34@@ -75,7 +75,8 @@
35
36 void move_to(geometry::Point position);
37
38- void show_at_last_known_position();
39+ void suspend();
40+ void resume();
41
42 private:
43 enum ForceCursorState { UpdateState, ForceState };
44
45=== modified file 'src/platform/graphics/mesa/display.cpp'
46--- src/platform/graphics/mesa/display.cpp 2014-05-07 02:56:33 +0000
47+++ src/platform/graphics/mesa/display.cpp 2014-05-27 08:08:21 +0000
48@@ -224,7 +224,7 @@
49 clear_connected_unused_outputs();
50 }
51
52- if (auto c = cursor.lock()) c->show_at_last_known_position();
53+ if (auto c = cursor.lock()) c->resume();
54 }
55
56 void mgm::Display::register_configuration_change_handler(
57@@ -255,7 +255,7 @@
58 {
59 try
60 {
61- if (auto c = cursor.lock()) c->hide();
62+ if (auto c = cursor.lock()) c->suspend();
63 platform->drm.drop_master();
64 }
65 catch(std::runtime_error const& e)
66@@ -291,7 +291,7 @@
67 clear_connected_unused_outputs();
68 }
69
70- if (auto c = cursor.lock()) c->show_at_last_known_position();
71+ if (auto c = cursor.lock()) c->resume();
72 }
73
74 auto mgm::Display::create_hardware_cursor(std::shared_ptr<mg::CursorImage> const& initial_image) -> std::shared_ptr<graphics::Cursor>
75
76=== modified file 'tests/unit-tests/graphics/mesa/test_cursor.cpp'
77--- tests/unit-tests/graphics/mesa/test_cursor.cpp 2014-05-22 11:31:21 +0000
78+++ tests/unit-tests/graphics/mesa/test_cursor.cpp 2014-05-27 08:08:21 +0000
79@@ -374,25 +374,6 @@
80 output_container.verify_and_clear_expectations();
81 }
82
83-TEST_F(MesaCursorTest, shows_at_last_known_position)
84-{
85- using namespace testing;
86-
87- EXPECT_CALL(*output_container.outputs[10], move_cursor(geom::Point{150,75}));
88- EXPECT_CALL(*output_container.outputs[11], move_cursor(geom::Point{50,25}));
89-
90- cursor.move_to({150, 75});
91-
92- output_container.verify_and_clear_expectations();
93-
94- EXPECT_CALL(*output_container.outputs[10], move_cursor(geom::Point{150,75}));
95- EXPECT_CALL(*output_container.outputs[11], move_cursor(geom::Point{50,25}));
96-
97- cursor.show_at_last_known_position();
98-
99- output_container.verify_and_clear_expectations();
100-}
101-
102 TEST_F(MesaCursorTest, moves_properly_to_and_inside_left_rotated_output)
103 {
104 using namespace testing;
105@@ -478,3 +459,48 @@
106 EXPECT_CALL(*output_container.outputs[11], clear_cursor());
107 EXPECT_CALL(*output_container.outputs[12], clear_cursor());
108 }
109+
110+TEST_F(MesaCursorTest, cursor_is_shown_at_correct_location_after_suspend_resume)
111+{
112+ using namespace testing;
113+
114+ EXPECT_CALL(*output_container.outputs[10], move_cursor(geom::Point{150,75}));
115+ EXPECT_CALL(*output_container.outputs[11], move_cursor(geom::Point{50,25}));
116+ EXPECT_CALL(*output_container.outputs[10], clear_cursor());
117+ EXPECT_CALL(*output_container.outputs[11], clear_cursor());
118+ EXPECT_CALL(*output_container.outputs[12], clear_cursor());
119+
120+ cursor.move_to({150, 75});
121+ cursor.suspend();
122+
123+ output_container.verify_and_clear_expectations();
124+
125+ EXPECT_CALL(*output_container.outputs[10], set_cursor(_));
126+ EXPECT_CALL(*output_container.outputs[11], set_cursor(_));
127+ EXPECT_CALL(*output_container.outputs[10], move_cursor(geom::Point{150,75}));
128+ EXPECT_CALL(*output_container.outputs[11], move_cursor(geom::Point{50,25}));
129+
130+ cursor.resume();
131+ output_container.verify_and_clear_expectations();
132+}
133+
134+TEST_F(MesaCursorTest, hidden_cursor_is_not_shown_after_suspend_resume)
135+{
136+ using namespace testing;
137+
138+ EXPECT_CALL(*output_container.outputs[10], clear_cursor()).Times(AnyNumber());
139+ EXPECT_CALL(*output_container.outputs[11], clear_cursor()).Times(AnyNumber());
140+ EXPECT_CALL(*output_container.outputs[12], clear_cursor()).Times(AnyNumber());
141+
142+ cursor.hide();
143+ cursor.suspend();
144+
145+ output_container.verify_and_clear_expectations();
146+
147+ EXPECT_CALL(*output_container.outputs[10], set_cursor(_)).Times(0);
148+ EXPECT_CALL(*output_container.outputs[11], set_cursor(_)).Times(0);
149+ EXPECT_CALL(*output_container.outputs[12], set_cursor(_)).Times(0);
150+
151+ cursor.resume();
152+ output_container.verify_and_clear_expectations();
153+}

Subscribers

People subscribed via source and target branches