Merge lp:~ricmm/unity-mir/respect-lifecycle-stages into lp:unity-mir

Proposed by Ricardo Mendoza
Status: Merged
Approved by: Gerry Boland
Approved revision: 168
Merged at revision: 168
Proposed branch: lp:~ricmm/unity-mir/respect-lifecycle-stages
Merge into: lp:unity-mir
Diff against target: 85 lines (+21/-16)
2 files modified
src/modules/Unity/Application/application_manager.cpp (+20/-16)
src/modules/Unity/Application/application_manager.h (+1/-0)
To merge this branch: bzr merge lp:~ricmm/unity-mir/respect-lifecycle-stages
Reviewer Review Type Date Requested Status
Łukasz Zemczak Approve
Gerry Boland (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+201913@code.launchpad.net

Commit message

Correctly respect lifecycle exceptions in the new sidestage model.

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
Gerry Boland (gerboland) wrote :

Tested on mako & manta, works fine. Code logical. Approved

review: Approve
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

+1, the code looks good as well.

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-01-09 15:34:29 +0000
3+++ src/modules/Unity/Application/application_manager.cpp 2014-01-16 12:04:26 +0000
4@@ -203,6 +203,19 @@
5 }
6 }
7
8+void ApplicationManager::suspendApplication(Application *application)
9+{
10+ if (application == nullptr)
11+ return;
12+
13+ // Present in exceptions list, return.
14+ if (!m_lifecycleExceptions.filter(application->appId().section('_',0,0)).empty())
15+ return;
16+
17+ if (application->state() == Application::Running)
18+ application->setState(Application::Suspended);
19+}
20+
21 bool ApplicationManager::focusApplication(const QString &appId)
22 {
23 DLOG("ApplicationManager::focusApplication (this=%p, appId=%s)", this, qPrintable(appId));
24@@ -213,10 +226,8 @@
25 return false;
26 }
27
28- if (application->stage() == Application::MainStage && m_sideStageApplication &&
29- (m_sideStageApplication->state() == Application::Running)) {
30- m_sideStageApplication->setState(Application::Suspended);
31- }
32+ if (application->stage() == Application::MainStage && m_sideStageApplication)
33+ suspendApplication(m_sideStageApplication);
34
35 if (application->stage() == Application::MainStage)
36 m_msApplicationToBeFocused = application;
37@@ -244,11 +255,8 @@
38 {
39 DLOG("ApplicationManager::unfocusCurrentApplication (this=%p)", this);
40
41- if (m_sideStageApplication)
42- m_sideStageApplication->setState(Application::Suspended);
43-
44- if (m_mainStageApplication)
45- m_mainStageApplication->setState(Application::Suspended);
46+ suspendApplication(m_sideStageApplication);
47+ suspendApplication(m_mainStageApplication);
48
49 // Clear both stages
50 m_msApplicationToBeFocused = nullptr;
51@@ -615,11 +623,8 @@
52 if (NULL != m_focusedApplication) {
53 Q_ASSERT(m_focusedApplication->focused());
54 m_focusedApplication->setFocused(false);
55-
56- if (m_lifecycleExceptions.filter(m_focusedApplication->appId().section('_',0,0)).empty()
57- && m_focusedApplication->state() != Application::Suspended) {
58- m_focusedApplication->setState(Application::Suspended);
59- }
60+
61+ suspendApplication(m_focusedApplication);
62
63 m_focusedApplication = NULL;
64 Q_EMIT focusedApplicationIdChanged();
65@@ -656,8 +661,7 @@
66 // set state of previously focused app to suspended
67 if (m_focusedApplication && m_lifecycleExceptions.filter(m_focusedApplication->appId().section('_',0,0)).empty()) {
68 Application *lastApplication = applicationForStage(application->stage());
69- if (lastApplication && lastApplication->state() == Application::Running)
70- lastApplication->setState(Application::Suspended);
71+ suspendApplication(lastApplication);
72 }
73
74 if (application->stage() == Application::MainStage)
75
76=== modified file 'src/modules/Unity/Application/application_manager.h'
77--- src/modules/Unity/Application/application_manager.h 2013-12-20 03:38:43 +0000
78+++ src/modules/Unity/Application/application_manager.h 2014-01-16 12:04:26 +0000
79@@ -86,6 +86,7 @@
80 Application* findApplicationWithPid(const qint64 pid);
81
82 // Internal helpers
83+ void suspendApplication(Application *application);
84 int panelHeight();
85 QSize displaySize() const { return m_displaySize; }
86

Subscribers

People subscribed via source and target branches