Merge lp:~mterry/unity-mir/no-focus into lp:unity-mir

Proposed by Michael Terry
Status: Merged
Approved by: Michael Terry
Approved revision: 226
Merged at revision: 225
Proposed branch: lp:~mterry/unity-mir/no-focus
Merge into: lp:unity-mir
Diff against target: 53 lines (+32/-0)
2 files modified
src/modules/Unity/Application/application_manager.cpp (+2/-0)
tests/application_manager_test.cpp (+30/-0)
To merge this branch: bzr merge lp:~mterry/unity-mir/no-focus
Reviewer Review Type Date Requested Status
Gerry Boland (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Michał Sawicz Needs Information
Review via email: mp+220718@code.launchpad.net

Commit message

If no app has focus when we get a un-actionable onSessionFocused event, still re-set focus to the shell.

Description of the change

If no app has focus when we get a un-actionable onSessionFocused event, still re-set focus to the shell.

During testing of split greeter, Saviq noticed that the volume up/down buttons didn't work. Some digging discovered that the android input layer thought nothing was focused and that it only happens after maliit-server is running.

Digging into unity-mir, it seems we discard onSessionFocused events that don't relate to an application (like maliit-server was generating). But apparently, android-input is a little confused at that point, and there is code in the function for re-setting the focus for the focused app.

But if no app has focus, we did nothing. In the case where no app has focus, we should also re-set the focus onto the shell. This fixed the volume bug for me.

== Checklist ==

 * Are there any related MPs required for this MP to build/function as expected? Please list.
 - No

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

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
 - NA

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
Michał Sawicz (saviq) wrote :

Could we have a test for this?

review: Needs Information
Revision history for this message
Gerry Boland (gerboland) wrote :

+1 on the test request

lp:~mterry/unity-mir/no-focus updated
225. By Michael Terry

Add tests

Revision history for this message
Michael Terry (mterry) wrote :

Tests added.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

 DLOG("Invalid application focused, discarding the event");
not correct any more, please update comment

Please add the checklist too
https://wiki.ubuntu.com/Process/Merges/Checklists/Unity-Mir

review: Needs Fixing
Revision history for this message
Gerry Boland (gerboland) wrote :

"Oo" <- as before please just make empty string

Revision history for this message
Gerry Boland (gerboland) wrote :

Testing this, everything seems ok

lp:~mterry/unity-mir/no-focus updated
226. By Michael Terry

simplify test

Revision history for this message
Michael Terry (mterry) wrote :

> DLOG("Invalid application focused, discarding the event");
> not correct any more, please update comment

I disagree. It means discarding the request to focus the new app. The code that follows is just rolling back any side effects of handling the request. I only added a special case to that code anyway, rather than change its meaning.

I could change the comment to "refocusing previous focus" or something like that. But it sounds like a wordier version of the "not doing anything" meaning we already have.

> Please add the checklist too
> https://wiki.ubuntu.com/Process/Merges/Checklists/Unity-Mir

Done.

> "Oo" <- as before please just make empty string

Done.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

> > DLOG("Invalid application focused, discarding the event");
> > not correct any more, please update comment
>
> I disagree. It means discarding the request to focus the new app.

Ok. Approved!

review: Approve
Revision history for this message
Gerry Boland (gerboland) wrote :

 * Did you perform an exploratory manual test run of the code change and any related functionality?
Y
 * Did CI run pass? If not, please explain why.
Y

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/modules/Unity/Application/application_manager.cpp'
--- src/modules/Unity/Application/application_manager.cpp 2014-05-19 15:30:15 +0000
+++ src/modules/Unity/Application/application_manager.cpp 2014-05-26 12:30:05 +0000
@@ -862,6 +862,8 @@
862 DLOG("Invalid application focused, discarding the event");862 DLOG("Invalid application focused, discarding the event");
863 if (nullptr != m_focusedApplication)863 if (nullptr != m_focusedApplication)
864 focusApplication(m_focusedApplication->appId());864 focusApplication(m_focusedApplication->appId());
865 else
866 m_focusController->set_focus_to(nullptr);
865 }867 }
866 }868 }
867}869}
868870
=== modified file 'tests/application_manager_test.cpp'
--- tests/application_manager_test.cpp 2014-05-20 10:21:20 +0000
+++ tests/application_manager_test.cpp 2014-05-26 12:30:05 +0000
@@ -142,6 +142,36 @@
142 }142 }
143}143}
144144
145TEST_F(ApplicationManagerTests, focus_on_invalid_app_falls_back_to_focused_app)
146{
147 using namespace ::testing;
148 quint64 a_procId = 5921;
149 QByteArray a_cmd( "/usr/bin/app1 --desktop_file_hint=some_app");
150 std::shared_ptr<mir::scene::Surface> aSurface(nullptr);
151
152 ON_CALL(procInfo,command_line(_)).WillByDefault(Return(a_cmd));
153
154 bool authed = true;
155
156 std::shared_ptr<mir::scene::Session> first_session = std::make_shared<MockSession>("", a_procId);
157 applicationManager.authorizeSession(a_procId, authed);
158 applicationManager.onSessionStarting(first_session);
159 applicationManager.onSessionCreatedSurface(first_session.get(), aSurface);
160
161 EXPECT_CALL(focusController, set_focus_to(first_session)).Times(1);
162
163 applicationManager.onSessionFocused(nullptr);
164}
165
166TEST_F(ApplicationManagerTests, focus_on_invalid_app_falls_back_to_default_session)
167{
168 using namespace ::testing;
169
170 std::shared_ptr<mir::scene::Session> null_session = nullptr;
171 EXPECT_CALL(focusController, set_focus_to(null_session)).Times(1);
172
173 applicationManager.onSessionFocused(nullptr);
174}
145175
146TEST_F(ApplicationManagerTests,bug_case_1240400_second_dialer_app_fails_to_authorize_and_gets_mixed_up_with_first_one)176TEST_F(ApplicationManagerTests,bug_case_1240400_second_dialer_app_fails_to_authorize_and_gets_mixed_up_with_first_one)
147{177{

Subscribers

People subscribed via source and target branches