@@ -25,7 +25,7 @@ Q_LOGGING_CATEGORY(UNITY_TOPSURFACELIST, "unity.topsurfacelist")
26#define DEBUG_MSG qCDebug(UNITY_TOPSURFACELIST).nospace().noquote() << __func__
26#define DEBUG_MSG qCDebug(UNITY_TOPSURFACELIST).nospace().noquote() << __func__
28−namespace unityapi = unity::shell::application;
28+using namespace unity::shell::application;
30TopLevelSurfaceList::TopLevelSurfaceList(QObject *parent) :
30TopLevelSurfaceList::TopLevelSurfaceList(QObject *parent) :
31 QAbstractListModel(parent)
31 QAbstractListModel(parent)
@@ -49,7 +49,7 @@ QVariant TopLevelSurfaceList::data(const QModelIndex& index, int role) const
49 return QVariant();
49 return QVariant();
51 if (role == SurfaceRole) {
51 if (role == SurfaceRole) {
52− unityapi::MirSurfaceInterface *surface = m_surfaceList.at(index.row()).surface;
52+ MirSurfaceInterface *surface = m_surfaceList.at(index.row()).surface;
53 return QVariant::fromValue(surface);
53 return QVariant::fromValue(surface);
54 } else if (role == ApplicationRole) {
54 } else if (role == ApplicationRole) {
55 return QVariant::fromValue(m_surfaceList.at(index.row()).application);
55 return QVariant::fromValue(m_surfaceList.at(index.row()).application);
@@ -60,7 +60,7 @@ QVariant TopLevelSurfaceList::data(const QModelIndex& index, int role) const
63−void TopLevelSurfaceList::raise(unityapi::MirSurfaceInterface *surface)
63+void TopLevelSurfaceList::raise(MirSurfaceInterface *surface)
65 if (!surface)
65 if (!surface)
@@ -73,13 +73,13 @@ void TopLevelSurfaceList::raise(unityapi::MirSurfaceInterface *surface)
76−void TopLevelSurfaceList::prependPlaceholder(unityapi::ApplicationInfoInterface *application)
76+void TopLevelSurfaceList::prependPlaceholder(ApplicationInfoInterface *application)
78 DEBUG_MSG << "(" << application->appId() << ")";
78 DEBUG_MSG << "(" << application->appId() << ")";
79 prependSurfaceHelper(nullptr, application);
79 prependSurfaceHelper(nullptr, application);
82−void TopLevelSurfaceList::prependSurface(unityapi::MirSurfaceInterface *surface, unityapi::ApplicationInfoInterface *application)
82+void TopLevelSurfaceList::prependSurface(MirSurfaceInterface *surface, ApplicationInfoInterface *application)
84 Q_ASSERT(surface != nullptr);
84 Q_ASSERT(surface != nullptr);
@@ -101,7 +101,7 @@ void TopLevelSurfaceList::prependSurface(unityapi::MirSurfaceInterface *surface,
104−void TopLevelSurfaceList::prependSurfaceHelper(unityapi::MirSurfaceInterface *surface, unityapi::ApplicationInfoInterface *application)
104+void TopLevelSurfaceList::prependSurfaceHelper(MirSurfaceInterface *surface, ApplicationInfoInterface *application)
106 beginInsertRows(QModelIndex(), 0 /*first*/, 0 /*last*/);
106 beginInsertRows(QModelIndex(), 0 /*first*/, 0 /*last*/);
107 int id = generateId();
107 int id = generateId();
@@ -115,14 +115,14 @@ void TopLevelSurfaceList::prependSurfaceHelper(unityapi::MirSurfaceInterface *su
115 Q_EMIT listChanged();
115 Q_EMIT listChanged();
118−void TopLevelSurfaceList::connectSurface(unityapi::MirSurfaceInterface *surface)
118+void TopLevelSurfaceList::connectSurface(MirSurfaceInterface *surface)
120− connect(surface, &unityapi::MirSurfaceInterface::focusedChanged, this, [this, surface](bool focused){
120+ connect(surface, &MirSurfaceInterface::focusedChanged, this, [this, surface](bool focused){
121 if (focused) {
121 if (focused) {
122 this->raise(surface);
122 this->raise(surface);
125− connect(surface, &unityapi::MirSurfaceInterface::liveChanged, this, [this, surface](bool live){
125+ connect(surface, &MirSurfaceInterface::liveChanged, this, [this, surface](bool live){
126 if (!live) {
126 if (!live) {
127 onSurfaceDied(surface);
127 onSurfaceDied(surface);
@@ -130,7 +130,7 @@ void TopLevelSurfaceList::connectSurface(unityapi::MirSurfaceInterface *surface)
130 connect(surface, &QObject::destroyed, this, [this, surface](){ this->onSurfaceDestroyed(surface); });
130 connect(surface, &QObject::destroyed, this, [this, surface](){ this->onSurfaceDestroyed(surface); });
133−void TopLevelSurfaceList::onSurfaceDied(unityapi::MirSurfaceInterface *surface)
133+void TopLevelSurfaceList::onSurfaceDied(MirSurfaceInterface *surface)
135 int i = indexOf(surface);
135 int i = indexOf(surface);
136 if (i == -1) {
136 if (i == -1) {
@@ -140,9 +140,9 @@ void TopLevelSurfaceList::onSurfaceDied(unityapi::MirSurfaceInterface *surface)
140 auto application = m_surfaceList[i].application;
140 auto application = m_surfaceList[i].application;
142 // can't be starting if it already has a surface
142 // can't be starting if it already has a surface
143− Q_ASSERT(application->state() != unityapi::ApplicationInfoInterface::Starting);
143+ Q_ASSERT(application->state() != ApplicationInfoInterface::Starting);
145− if (application->state() == unityapi::ApplicationInfoInterface::Running) {
145+ if (application->state() == ApplicationInfoInterface::Running) {
146 m_surfaceList[i].removeOnceSurfaceDestroyed = true;
146 m_surfaceList[i].removeOnceSurfaceDestroyed = true;
148 // assume it got killed by the out-of-memory daemon.
148 // assume it got killed by the out-of-memory daemon.
@@ -153,7 +153,7 @@ void TopLevelSurfaceList::onSurfaceDied(unityapi::MirSurfaceInterface *surface)
156−void TopLevelSurfaceList::onSurfaceDestroyed(unityapi::MirSurfaceInterface *surface)
156+void TopLevelSurfaceList::onSurfaceDestroyed(MirSurfaceInterface *surface)
158 int i = indexOf(surface);
158 int i = indexOf(surface);
159 if (i == -1) {
159 if (i == -1) {
@@ -179,7 +179,7 @@ void TopLevelSurfaceList::removeAt(int index)
179 Q_EMIT listChanged();
179 Q_EMIT listChanged();
182−int TopLevelSurfaceList::indexOf(unityapi::MirSurfaceInterface *surface)
182+int TopLevelSurfaceList::indexOf(MirSurfaceInterface *surface)
184 for (int i = 0; i < m_surfaceList.count(); ++i) {
184 for (int i = 0; i < m_surfaceList.count(); ++i) {
185 if (m_surfaceList.at(i).surface == surface) {
185 if (m_surfaceList.at(i).surface == surface) {
@@ -208,7 +208,7 @@ void TopLevelSurfaceList::moveSurface(int from, int to)
211−unityapi::MirSurfaceInterface *TopLevelSurfaceList::surfaceAt(int index) const
211+MirSurfaceInterface *TopLevelSurfaceList::surfaceAt(int index) const
213 if (index >=0 && index < m_surfaceList.count()) {
213 if (index >=0 && index < m_surfaceList.count()) {
214 return m_surfaceList[index].surface;
214 return m_surfaceList[index].surface;
@@ -217,7 +217,7 @@ unityapi::MirSurfaceInterface *TopLevelSurfaceList::surfaceAt(int index) const
220−unityapi::ApplicationInfoInterface *TopLevelSurfaceList::applicationAt(int index) const
220+ApplicationInfoInterface *TopLevelSurfaceList::applicationAt(int index) const
222 if (index >=0 && index < m_surfaceList.count()) {
222 if (index >=0 && index < m_surfaceList.count()) {
223 return m_surfaceList[index].application;
223 return m_surfaceList[index].application;
@@ -296,15 +296,15 @@ QString TopLevelSurfaceList::toString()
296 return str;
296 return str;
299−void TopLevelSurfaceList::addApplication(unityapi::ApplicationInfoInterface *application)
299+void TopLevelSurfaceList::addApplication(ApplicationInfoInterface *application)
301 DEBUG_MSG << "(" << application->appId() << ")";
301 DEBUG_MSG << "(" << application->appId() << ")";
302 Q_ASSERT(!m_applications.contains(application));
302 Q_ASSERT(!m_applications.contains(application));
303 m_applications.append(application);
303 m_applications.append(application);
305− unityapi::MirSurfaceListInterface *surfaceList = application->surfaceList();
305+ MirSurfaceListInterface *surfaceList = application->surfaceList();
307− if (application->state() != unityapi::ApplicationInfoInterface::Stopped) {
307+ if (application->state() != ApplicationInfoInterface::Stopped) {
308 if (surfaceList->count() == 0) {
308 if (surfaceList->count() == 0) {
309 prependPlaceholder(application);
309 prependPlaceholder(application);
@@ -323,12 +323,12 @@ void TopLevelSurfaceList::addApplication(unityapi::ApplicationInfoInterface *app
326−void TopLevelSurfaceList::removeApplication(unityapi::ApplicationInfoInterface *application)
326+void TopLevelSurfaceList::removeApplication(ApplicationInfoInterface *application)
328 DEBUG_MSG << "(" << application->appId() << ")";
328 DEBUG_MSG << "(" << application->appId() << ")";
329 Q_ASSERT(m_applications.contains(application));
329 Q_ASSERT(m_applications.contains(application));
331− unityapi::MirSurfaceListInterface *surfaceList = application->surfaceList();
331+ MirSurfaceListInterface *surfaceList = application->surfaceList();
333 disconnect(surfaceList, 0, this, 0);
333 disconnect(surfaceList, 0, this, 0);
@@ -401,23 +401,22 @@ void TopLevelSurfaceList::setApplicationsModel(QAbstractListModel* value)
401 endResetModel();
401 endResetModel();
404−unityapi::ApplicationInfoInterface *TopLevelSurfaceList::getApplicationFromModelAt(int index)
404+ApplicationInfoInterface *TopLevelSurfaceList::getApplicationFromModelAt(int index)
406 QModelIndex modelIndex = m_applicationsModel->index(index);
406 QModelIndex modelIndex = m_applicationsModel->index(index);
408 QVariant variant = m_applicationsModel->data(modelIndex, m_applicationRole);
408 QVariant variant = m_applicationsModel->data(modelIndex, m_applicationRole);
410− // variant.value<unityapi::ApplicationInfoInterface*>() returns null for some reason.
410+ // variant.value<ApplicationInfoInterface*>() returns null for some reason.
411− return static_cast<unityapi::ApplicationInfoInterface*>(variant.value<QObject*>());
411+ return static_cast<ApplicationInfoInterface*>(variant.value<QObject*>());
414void TopLevelSurfaceList::findApplicationRole()
414void TopLevelSurfaceList::findApplicationRole()
416 QHash<int, QByteArray> namesHash = m_applicationsModel->roleNames();
416 QHash<int, QByteArray> namesHash = m_applicationsModel->roleNames();
417− QHash<int, QByteArray>::iterator i;
419 m_applicationRole = -1;
418 m_applicationRole = -1;
420− for (i = namesHash.begin(); i != namesHash.end() && m_applicationRole == -1; ++i) {
419+ for (auto i = namesHash.begin(); i != namesHash.end() && m_applicationRole == -1; ++i) {
421 if (i.value() == "application") {
420 if (i.value() == "application") {
422 m_applicationRole = i.key();
421 m_applicationRole = i.key();