on xenial help sign in
improve the whole async DashCommunicator logic
720d0eeMichael Zanetti
plugins/Unity/DashCommunicator/dashcommunicator.cpp+11−5
@@ -47,6 +47,8 @@ void DashCommunicator::setCurrentScope(const QString &scopeId, bool animate, boo
47 }
47 }
48
48
49 if (m_dashInterface && m_dashInterface->isValid()) {
49 if (m_dashInterface && m_dashInterface->isValid()) {
50+ // Using an async call just in case the Dash would fail to wake up from suspend
51+ // We don't want to hang the whole shell waiting for reply.
50 m_dashInterface->asyncCall("SetCurrentScope", scopeId, animate, isSwipe);
52 m_dashInterface->asyncCall("SetCurrentScope", scopeId, animate, isSwipe);
51 }
53 }
52}
54}
@@ -60,6 +62,7 @@ void DashCommunicator::connectToDash()
60
62
61 if (m_applicationManager) {
63 if (m_applicationManager) {
62 ApplicationInfoInterface *dash = m_applicationManager->findApplication("unity8-dash");
64 ApplicationInfoInterface *dash = m_applicationManager->findApplication("unity8-dash");
65+ // Don't try to connect to the Dash while its suspended, it would hang the shell waiting for a reply.
63 if (dash && dash->state() == ApplicationInfoInterface::Running) {
66 if (dash && dash->state() == ApplicationInfoInterface::Running) {
64 QDBusConnection connection = QDBusConnection::sessionBus();
67 QDBusConnection connection = QDBusConnection::sessionBus();
65 m_dashInterface = new QDBusInterface("com.canonical.UnityDash",
68 m_dashInterface = new QDBusInterface("com.canonical.UnityDash",
@@ -85,9 +88,10 @@ void DashCommunicator::setApplicationManager(unity::shell::application::Applicat
85
88
86 connect(m_applicationManager, &unity::shell::application::ApplicationManagerInterface::applicationAdded, this, &DashCommunicator::applicationAdded);
89 connect(m_applicationManager, &unity::shell::application::ApplicationManagerInterface::applicationAdded, this, &DashCommunicator::applicationAdded);
87 connect(m_applicationManager, &unity::shell::application::ApplicationManagerInterface::applicationRemoved, this, &DashCommunicator::applicationRemoved);
90 connect(m_applicationManager, &unity::shell::application::ApplicationManagerInterface::applicationRemoved, this, &DashCommunicator::applicationRemoved);
88−
91+
92+ // If the Dash is around already, immediately try to connect
89 if (m_applicationManager->findApplication("unity8-dash")) {
93 if (m_applicationManager->findApplication("unity8-dash")) {
90− applicationAdded("unity8-dash");
94+ connectToDash();
91 }
95 }
92 }
96 }
93}
97}
@@ -99,7 +103,7 @@ void DashCommunicator::applicationAdded(const QString &appId)
99 }
103 }
100 ApplicationInfoInterface *app = m_applicationManager->findApplication(appId);
104 ApplicationInfoInterface *app = m_applicationManager->findApplication(appId);
101 if (!app) {
105 if (!app) {
102− qWarning() << "DashCommunicator received an applicationAdded signal for dash, but there's no dash!";
106+ qWarning() << "DashCommunicator received an applicationAdded signal for the dash, but there's no dash around!";
103 return;
107 return;
104 }
108 }
105 connectToDash();
109 connectToDash();
@@ -110,6 +114,8 @@ void DashCommunicator::applicationRemoved(const QString &appId)
110 if (appId != "unity8-dash") {
114 if (appId != "unity8-dash") {
111 return;
115 return;
112 }
116 }
117+ if (m_dashInterface) {
113− m_dashInterface->deleteLater();
118+ m_dashInterface->deleteLater();
114− m_dashInterface = nullptr;
119+ m_dashInterface = nullptr;
120+ }
115}
121}
qml/Shell.qml+7
@@ -106,6 +106,13 @@ Item {
106 applicationManager: ApplicationManager
106 applicationManager: ApplicationManager
107 }
107 }
108
108
109+ Binding {
110+ target: ApplicationManager
111+ property: "dashActive"
112+ value: launcher.shown || launcher.dashSwipe
113+ }
114+
115+
109 WindowKeysFilter {
116 WindowKeysFilter {
110 // Handle but do not filter out volume keys
117 // Handle but do not filter out volume keys
111 Keys.onVolumeUpPressed: { volumeControl.volumeUp(); event.accepted = false; }
118 Keys.onVolumeUpPressed: { volumeControl.volumeUp(); event.accepted = false; }