Merge lp:~josharenson/qtmir/allow_duplicate_focusing into lp:qtmir

Proposed by Josh Arenson
Status: Merged
Approved by: Gerry Boland
Approved revision: 250
Merged at revision: 258
Proposed branch: lp:~josharenson/qtmir/allow_duplicate_focusing
Merge into: lp:qtmir
Diff against target: 52 lines (+29/-2)
2 files modified
src/modules/Unity/Application/application_manager.cpp (+0/-2)
tests/modules/ApplicationManager/application_manager_test.cpp (+29/-0)
To merge this branch: bzr merge lp:~josharenson/qtmir/allow_duplicate_focusing
Reviewer Review Type Date Requested Status
Gerry Boland (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+234556@code.launchpad.net

Commit message

Remove check to see if application is already focused before focusing.

Work around lp:1362017 by removing a check to see if an application is already focused before focusing. This forces all applications to go through all steps of obtaining focus, even if the application was already focused.

Description of the change

* 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, and ran unit tests

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

Fix lp:1362017

This works around an issue where the panel stays in the foreground when it is used to open an app behind it that already has focus by allowing an application that already has focus, to request it again.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:249
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https://code.launchpad.net/~josharenson/qtmir/allow_duplicate_focusing/+merge/234556/+edit-commit-message

http://jenkins.qa.ubuntu.com/job/qtmir-ci/70/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/qtmir-utopic-amd64-ci/70
    FAILURE: http://jenkins.qa.ubuntu.com/job/qtmir-utopic-armhf-ci/70/console

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/qtmir-ci/70/rebuild

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

CI not happy as you're missing a commit message. Also please attach this MR to the bug.

You can do this via command line with bzr commit --fixes=lp:12345678
or just by opening the bug and using the "Link a related branch" link

Please add a test.
Please add the bits of the MR checklist: https://wiki.ubuntu.com/Process/Merges/Checklists/QtMir

review: Needs Fixing
Revision history for this message
Josh Arenson (josharenson) wrote :

While this workaround works, and I don't really have any issues with it, the underlying cause could be related to lp:1353593 as the underlying surface _is_ losing focus (log output below) but the settings application still thinks it has focus.

qtmir.surfaces: MirSurfaceItem::updateMirSurfaceFocus false
qtmir.surfaces: MirSurfaceManager::onSurfaceAttributeChanged - surface= 0xad9066e0 focus=unfocused

If the application was aware of this, the application would _not_ report as already focused, and this WAR wouldn't be needed (bug should resolve itself). Thoughts?

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

Don't forget, "surface focus" and "application focus" are different concepts!

250. By Josh Arenson

Add unit test

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

Works! Thanks

 * 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

review: Approve

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-09-04 11:11:26 +0000
3+++ src/modules/Unity/Application/application_manager.cpp 2014-09-16 00:28:14 +0000
4@@ -358,8 +358,6 @@
5 }
6
7 resumeApplication(application);
8- if (application == m_focusedApplication)
9- return true;
10
11 // set state of previously focused app to suspended
12 if (m_focusedApplication) {
13
14=== modified file 'tests/modules/ApplicationManager/application_manager_test.cpp'
15--- tests/modules/ApplicationManager/application_manager_test.cpp 2014-08-29 10:18:57 +0000
16+++ tests/modules/ApplicationManager/application_manager_test.cpp 2014-09-16 00:28:14 +0000
17@@ -402,6 +402,35 @@
18 EXPECT_EQ(first_session, the_app->session()->session());
19 }
20
21+TEST_F(ApplicationManagerTests, focused_app_can_rerequest_focus)
22+{
23+ using namespace ::testing;
24+ quint64 a_procId = 5921;
25+ const char an_app_id[] = "some_app";
26+ QByteArray a_cmd("/usr/bin/app1 --desktop_file_hint=some_app");
27+ std::shared_ptr<mir::scene::Surface> aSurface(nullptr);
28+
29+ ON_CALL(procInfo, command_line(_)).WillByDefault(Return(a_cmd));
30+ ON_CALL(appController, appIdHasProcessId(_,_)).WillByDefault(Return(false));
31+
32+ bool authed = true;
33+
34+ std::shared_ptr<mir::scene::Session> a_session = std::make_shared<MockSession>("Oo", a_procId);
35+
36+ applicationManager.authorizeSession(a_procId, authed);
37+ onSessionStarting(a_session);
38+ applicationManager.onSessionCreatedSurface(a_session.get(), aSurface);
39+
40+ Application * the_app = applicationManager.findApplication(an_app_id);
41+ applicationManager.focusApplication(an_app_id);
42+
43+ EXPECT_EQ(Application::Running, the_app->state());
44+ EXPECT_EQ(true, the_app->focused());
45+
46+ applicationManager.focusApplication(an_app_id);
47+ EXPECT_EQ(true, the_app->focused());
48+}
49+
50 TEST_F(ApplicationManagerTests,suspended_suspends_focused_app_and_marks_it_unfocused_in_the_model)
51 {
52 using namespace ::testing;

Subscribers

People subscribed via source and target branches