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
1=== modified file 'src/modules/Unity/Application/application_manager.cpp'
2--- src/modules/Unity/Application/application_manager.cpp 2014-05-19 15:30:15 +0000
3+++ src/modules/Unity/Application/application_manager.cpp 2014-05-26 12:30:05 +0000
4@@ -862,6 +862,8 @@
5 DLOG("Invalid application focused, discarding the event");
6 if (nullptr != m_focusedApplication)
7 focusApplication(m_focusedApplication->appId());
8+ else
9+ m_focusController->set_focus_to(nullptr);
10 }
11 }
12 }
13
14=== modified file 'tests/application_manager_test.cpp'
15--- tests/application_manager_test.cpp 2014-05-20 10:21:20 +0000
16+++ tests/application_manager_test.cpp 2014-05-26 12:30:05 +0000
17@@ -142,6 +142,36 @@
18 }
19 }
20
21+TEST_F(ApplicationManagerTests, focus_on_invalid_app_falls_back_to_focused_app)
22+{
23+ using namespace ::testing;
24+ quint64 a_procId = 5921;
25+ QByteArray a_cmd( "/usr/bin/app1 --desktop_file_hint=some_app");
26+ std::shared_ptr<mir::scene::Surface> aSurface(nullptr);
27+
28+ ON_CALL(procInfo,command_line(_)).WillByDefault(Return(a_cmd));
29+
30+ bool authed = true;
31+
32+ std::shared_ptr<mir::scene::Session> first_session = std::make_shared<MockSession>("", a_procId);
33+ applicationManager.authorizeSession(a_procId, authed);
34+ applicationManager.onSessionStarting(first_session);
35+ applicationManager.onSessionCreatedSurface(first_session.get(), aSurface);
36+
37+ EXPECT_CALL(focusController, set_focus_to(first_session)).Times(1);
38+
39+ applicationManager.onSessionFocused(nullptr);
40+}
41+
42+TEST_F(ApplicationManagerTests, focus_on_invalid_app_falls_back_to_default_session)
43+{
44+ using namespace ::testing;
45+
46+ std::shared_ptr<mir::scene::Session> null_session = nullptr;
47+ EXPECT_CALL(focusController, set_focus_to(null_session)).Times(1);
48+
49+ applicationManager.onSessionFocused(nullptr);
50+}
51
52 TEST_F(ApplicationManagerTests,bug_case_1240400_second_dialer_app_fails_to_authorize_and_gets_mixed_up_with_first_one)
53 {

Subscribers

People subscribed via source and target branches