18#include "TopLevelWindowModel.h"
19#include "WindowManagerObjects.h"
22#include <lomiri/shell/application/ApplicationInfoInterface.h>
23#include <lomiri/shell/application/ApplicationManagerInterface.h>
24#include <lomiri/shell/application/MirSurfaceInterface.h>
25#include <lomiri/shell/application/MirSurfaceListInterface.h>
26#include <lomiri/shell/application/SurfaceManagerInterface.h>
34#include "InputMethodManager.h"
36Q_LOGGING_CATEGORY(TOPLEVELWINDOWMODEL,
"toplevelwindowmodel", QtInfoMsg)
38#define DEBUG_MSG qCDebug(TOPLEVELWINDOWMODEL).nospace().noquote() << __func__
39#define INFO_MSG qCInfo(TOPLEVELWINDOWMODEL).nospace().noquote() << __func__
41namespace lomiriapi = lomiri::shell::application;
43TopLevelWindowModel::TopLevelWindowModel(Workspace* workspace)
44 : m_nullWindow(createWindow(nullptr)),
45 m_workspace(workspace),
46 m_surfaceManagerBusy(false)
48 connect(WindowManagerObjects::instance(), &WindowManagerObjects::applicationManagerChanged,
49 this, &TopLevelWindowModel::setApplicationManager);
50 connect(WindowManagerObjects::instance(), &WindowManagerObjects::surfaceManagerChanged,
51 this, &TopLevelWindowModel::setSurfaceManager);
53 setApplicationManager(WindowManagerObjects::instance()->applicationManager());
54 setSurfaceManager(WindowManagerObjects::instance()->surfaceManager());
56 connect(m_nullWindow, &Window::focusedChanged,
this, [
this] {
57 Q_EMIT rootFocusChanged();
61TopLevelWindowModel::~TopLevelWindowModel()
65void TopLevelWindowModel::setApplicationManager(lomiriapi::ApplicationManagerInterface* value)
67 if (m_applicationManager == value) {
71 DEBUG_MSG <<
"(" << value <<
")";
73 Q_ASSERT(m_modelState == IdleState);
74 m_modelState = ResettingState;
78 if (m_applicationManager) {
79 disconnect(m_applicationManager, 0,
this, 0);
82 m_applicationManager = value;
84 if (m_applicationManager) {
85 connect(m_applicationManager, &QAbstractItemModel::rowsInserted,
86 this, [
this](
const QModelIndex &,
int first,
int last) {
87 if (!m_workspace || !m_workspace->isActive())
90 for (
int i = first; i <= last; ++i) {
91 auto application = m_applicationManager->get(i);
92 addApplication(application);
96 connect(m_applicationManager, &QAbstractItemModel::rowsAboutToBeRemoved,
97 this, [
this](
const QModelIndex &,
int first,
int last) {
98 for (
int i = first; i <= last; ++i) {
99 auto application = m_applicationManager->get(i);
100 removeApplication(application);
108 m_modelState = IdleState;
111void TopLevelWindowModel::setSurfaceManager(lomiriapi::SurfaceManagerInterface *surfaceManager)
113 if (surfaceManager == m_surfaceManager) {
117 DEBUG_MSG <<
"(" << surfaceManager <<
")";
119 Q_ASSERT(m_modelState == IdleState);
120 m_modelState = ResettingState;
124 if (m_surfaceManager) {
125 disconnect(m_surfaceManager, 0,
this, 0);
128 m_surfaceManager = surfaceManager;
130 if (m_surfaceManager) {
131 connect(m_surfaceManager, &lomiriapi::SurfaceManagerInterface::surfacesAddedToWorkspace,
this, &TopLevelWindowModel::onSurfacesAddedToWorkspace);
132 connect(m_surfaceManager, &lomiriapi::SurfaceManagerInterface::surfacesRaised,
this, &TopLevelWindowModel::onSurfacesRaised);
133 connect(m_surfaceManager, &lomiriapi::SurfaceManagerInterface::surfaceRemoved,
this, &TopLevelWindowModel::onSurfaceDestroyed);
134 connect(m_surfaceManager, &lomiriapi::SurfaceManagerInterface::modificationsStarted,
this, &TopLevelWindowModel::onModificationsStarted);
135 connect(m_surfaceManager, &lomiriapi::SurfaceManagerInterface::modificationsEnded,
this, &TopLevelWindowModel::onModificationsEnded);
141 m_modelState = IdleState;
144void TopLevelWindowModel::addApplication(lomiriapi::ApplicationInfoInterface *application)
146 DEBUG_MSG <<
"(" << application->appId() <<
")";
148 if (application->state() != lomiriapi::ApplicationInfoInterface::Stopped && application->surfaceList()->count() == 0) {
149 prependPlaceholder(application);
153void TopLevelWindowModel::removeApplication(lomiriapi::ApplicationInfoInterface *application)
155 DEBUG_MSG <<
"(" << application->appId() <<
")";
157 Q_ASSERT(m_modelState == IdleState);
160 while (i < m_windowModel.count()) {
161 if (m_windowModel.at(i).application == application) {
169void TopLevelWindowModel::prependPlaceholder(lomiriapi::ApplicationInfoInterface *application)
171 DEBUG_MSG <<
"(" << application->appId() <<
")";
173 if (!application->showSplash())
176 prependSurfaceHelper(
nullptr, application);
182inline bool fuzzyNameCompare(
const QString& appId,
const QString& surfaceAppId)
184 QString::const_iterator it =
nullptr;
185 const QString appName = appId.mid(appId.indexOf(
"_") + 1).toLower();
186 const QString surfaceName = surfaceAppId.toLower();
187 const int minSuccess = std::min<int>(surfaceName.length(), 5);
188 int sameLetterFound = 0;
190 DEBUG_MSG <<
"appName: " << appName <<
" surfaceName: " << surfaceName;
192 it = appName.cbegin();
193 for (
const auto& c : surfaceName) {
194 QString::const_iterator tmpIt = std::find(it, appName.cend(), c);
195 if (tmpIt != appName.end() && tmpIt >= it) {
196 DEBUG_MSG <<
"fuzzy match letter: " << c;
202 return sameLetterFound >= minSuccess;
205void TopLevelWindowModel::prependSurface(lomiriapi::MirSurfaceInterface *surface, lomiriapi::ApplicationInfoInterface *application)
207 Q_ASSERT(surface !=
nullptr);
209 connectSurface(surface);
210 m_allSurfaces.insert(surface);
212 bool filledPlaceholder =
false;
213 for (
int i = 0; i < m_windowModel.count() && !filledPlaceholder; ++i) {
214 ModelEntry &entry = m_windowModel[i];
215 if (entry.application == application && (entry.window->surface() ==
nullptr || !entry.window->surface()->live())) {
216 entry.window->setSurface(surface);
217 DEBUG_MSG <<
" appId=" << application->appId() <<
" surface=" << surface
218 <<
", filling out placeholder. after: " << toString();
219 filledPlaceholder =
true;
226 if (!filledPlaceholder && application->appId() == QStringLiteral(
"xwayland.qtmir")) {
229 for (
int i = 0; i < m_windowModel.count() && !filledPlaceholder; ++i) {
230 ModelEntry &entry = m_windowModel[i];
231 if ((!entry.window->surface() || !entry.window->surface()->live()) &&
232 entry.application->appId().contains(surface->appId()))
234 entry.window->setSurface(surface);
235 DEBUG_MSG <<
" Xwayland app " << entry.application->appId() <<
" contains surface=" << surface->appId()
236 <<
", filling out placeholder. after: " << toString();
237 filledPlaceholder =
true;
242 unsigned int candidates = 0;
243 int selectedCandidate = -1;
244 for (
int i = 0; i < m_windowModel.count() && !filledPlaceholder; ++i) {
245 ModelEntry &entry = m_windowModel[i];
246 if ((!entry.window->surface() || !entry.window->surface()->live()) &&
247 fuzzyNameCompare(entry.application->appId(), surface->appId()))
250 selectedCandidate = i;
255 if (candidates == 1 && !filledPlaceholder) {
256 ModelEntry &entry = m_windowModel[selectedCandidate];
257 entry.window->setSurface(surface);
258 DEBUG_MSG <<
" Xwayland app " << entry.application->appId() <<
" fuzzy match surface=" << surface->appId()
259 <<
", filling out placeholder. after: " << toString();
260 filledPlaceholder =
true;
264 if (!filledPlaceholder) {
265 DEBUG_MSG <<
" appId=" << application->appId() <<
" surface=" << surface <<
", adding new row";
266 prependSurfaceHelper(surface, application);
270void TopLevelWindowModel::prependSurfaceHelper(lomiriapi::MirSurfaceInterface *surface, lomiriapi::ApplicationInfoInterface *application)
273 Window *window = createWindow(surface);
275 connect(window, &Window::stateChanged,
this, [=](Mir::State newState) {
276 if (newState == Mir::HiddenState) {
282 auto *application = m_applicationManager->findApplicationWithSurface(window->
surface());
283 Q_ASSERT(application);
284 prependWindow(window, application);
289 prependWindow(window, application);
294 DEBUG_MSG <<
" after " << toString();
297void TopLevelWindowModel::prependWindow(
Window *window, lomiriapi::ApplicationInfoInterface *application)
299 if (m_modelState == IdleState) {
300 m_modelState = InsertingState;
301 beginInsertRows(QModelIndex(), 0 , 0 );
303 Q_ASSERT(m_modelState == ResettingState);
307 m_windowModel.prepend(ModelEntry(window, application));
309 if (m_modelState == InsertingState) {
311 Q_EMIT countChanged();
313 m_modelState = IdleState;
317void TopLevelWindowModel::connectWindow(
Window *window)
321 activateEmptyWindow(window);
325 connect(window, &Window::focusedChanged,
this, [
this, window](
bool focused) {
328 setFocusedWindow(window);
329 m_focusedWindowCleared = false;
330 }
else if (m_focusedWindow == window) {
334 m_focusedWindowCleared =
true;
342 connect(window, &Window::closeRequested,
this, [
this, window]() {
345 int id = window->id();
346 int index = indexForId(id);
347 bool focusOther = false;
348 Q_ASSERT(index >= 0);
349 if (window->focused()) {
352 m_windowModel[index].application->close();
354 activateTopMostWindowWithoutId(
id);
359 connect(window, &Window::emptyWindowActivated,
this, [
this, window]() {
360 activateEmptyWindow(window);
363 connect(window, &Window::liveChanged,
this, [
this, window](
bool isAlive) {
364 if (!isAlive && window->
state() == Mir::HiddenState) {
371void TopLevelWindowModel::activateEmptyWindow(
Window *window)
374 DEBUG_MSG <<
"(" << window <<
")";
379 window->setFocused(
true);
381 Window *previousWindow = m_focusedWindow;
382 setFocusedWindow(window);
383 if (previousWindow && previousWindow->
surface() && previousWindow->
surface()->focused()) {
384 m_surfaceManager->activate(
nullptr);
388void TopLevelWindowModel::connectSurface(lomiriapi::MirSurfaceInterface *surface)
390 connect(surface, &lomiriapi::MirSurfaceInterface::liveChanged,
this, [
this, surface](
bool live){
392 onSurfaceDied(surface);
395 connect(surface, &QObject::destroyed,
this, [
this, surface](QObject*){
396 this->onSurfaceDestroyed(surface);
400int TopLevelWindowModel::countWindowsWithApplication(lomiri::shell::application::ApplicationInfoInterface *application)
404 for (
const auto & item : qAsConst(m_windowModel)) {
405 if (item.application == application)
412void TopLevelWindowModel::onSurfaceDied(lomiriapi::MirSurfaceInterface *surface)
414 if (surface->type() == Mir::InputMethodType) {
415 removeInputMethodWindow();
419 int i = indexOf(surface);
424 auto application = m_windowModel[i].application;
426 DEBUG_MSG <<
" application->name()=" << application->name()
427 <<
" application->state()=" << application->state();
433 if (application->isTouchApp() && countWindowsWithApplication(application) == 1)
434 m_windowModel[i].removeOnceSurfaceDestroyed =
false;
436 m_windowModel[i].removeOnceSurfaceDestroyed =
true;
439void TopLevelWindowModel::onSurfaceDestroyed(lomiriapi::MirSurfaceInterface *surface)
441 int i = indexOf(surface);
446 auto application = m_windowModel[i].application;
450 if (application->appId() == QStringLiteral(
"xwayland.qtmir") || !application->isTouchApp()) {
451 m_windowModel[i].removeOnceSurfaceDestroyed =
true;
454 if (m_windowModel[i].removeOnceSurfaceDestroyed) {
457 auto window = m_windowModel[i].window;
458 window->setFocused(
false);
459 m_allSurfaces.remove(surface);
460 DEBUG_MSG <<
" Removed surface from entry. After: " << toString();
464Window *TopLevelWindowModel::createWindow(lomiriapi::MirSurfaceInterface *surface)
466 int id = m_nextId.fetchAndAddAcquire(1);
467 return createWindowWithId(surface,
id);
470Window *TopLevelWindowModel::createNullWindow()
472 return createWindowWithId(
nullptr, 0);
475Window *TopLevelWindowModel::createWindowWithId(lomiriapi::MirSurfaceInterface *surface,
int id)
478 connectWindow(qmlWindow);
480 qmlWindow->setSurface(surface);
485void TopLevelWindowModel::onSurfacesAddedToWorkspace(
const std::shared_ptr<miral::Workspace>& workspace,
486 const QVector<lomiri::shell::application::MirSurfaceInterface*> surfaces)
488 if (!m_workspace || !m_applicationManager)
return;
489 if (workspace != m_workspace->workspace()) {
490 removeSurfaces(surfaces);
494 Q_FOREACH(
auto surface, surfaces) {
495 if (m_allSurfaces.contains(surface))
continue;
497 if (surface->parentSurface()) {
499 Window *window = createWindow(surface);
500 connect(surface, &QObject::destroyed, window, [=](){
501 window->setSurface(
nullptr);
502 window->deleteLater();
505 if (surface->type() == Mir::InputMethodType) {
506 connectSurface(surface);
507 setInputMethodWindow(createWindow(surface));
509 auto *application = m_applicationManager->findApplicationWithSurface(surface);
511 if (surface->state() == Mir::HiddenState) {
513 connect(surface, &lomiriapi::MirSurfaceInterface::stateChanged,
this, [=](Mir::State newState) {
514 Q_ASSERT(newState != Mir::HiddenState);
515 disconnect(surface, &lomiriapi::MirSurfaceInterface::stateChanged,
this, 0);
516 prependSurface(surface, application);
519 prependSurface(surface, application);
525 Window *promptWindow = createWindow(surface);
526 connect(surface, &QObject::destroyed, promptWindow, [=](){
527 promptWindow->setSurface(
nullptr);
528 promptWindow->deleteLater();
536void TopLevelWindowModel::removeSurfaces(
const QVector<lomiri::shell::application::MirSurfaceInterface *> surfaces)
540 for (
auto iter = surfaces.constBegin(); iter != surfaces.constEnd();) {
541 auto surface = *iter;
545 start = end = indexOf(surface);
548 m_allSurfaces.remove(surface);
551 while(iter != surfaces.constEnd()) {
552 int index = indexOf(*iter);
553 if (index != end+1) {
560 if (m_modelState == IdleState) {
561 beginRemoveRows(QModelIndex(), start, end);
562 m_modelState = RemovingState;
564 Q_ASSERT(m_modelState == ResettingState);
568 for (
int index = start; index <= end; index++) {
569 auto window = m_windowModel[start].window;
570 window->setSurface(
nullptr);
571 window->setFocused(
false);
573 if (window == m_previousWindow) {
574 m_previousWindow =
nullptr;
577 m_windowModel.removeAt(start);
578 m_allSurfaces.remove(surface);
581 if (m_modelState == RemovingState) {
583 Q_EMIT countChanged();
585 m_modelState = IdleState;
590void TopLevelWindowModel::deleteAt(
int index)
592 auto window = m_windowModel[index].window;
596 window->setSurface(
nullptr);
601void TopLevelWindowModel::removeAt(
int index)
603 if (m_modelState == IdleState) {
604 beginRemoveRows(QModelIndex(), index, index);
605 m_modelState = RemovingState;
607 Q_ASSERT(m_modelState == ResettingState);
611 auto window = m_windowModel[index].window;
612 auto surface = window->
surface();
615 window->setFocused(
false);
618 if (window == m_previousWindow) {
619 m_previousWindow =
nullptr;
622 m_windowModel.removeAt(index);
623 m_allSurfaces.remove(surface);
625 if (m_modelState == RemovingState) {
627 Q_EMIT countChanged();
629 m_modelState = IdleState;
632 if (m_focusedWindow == window) {
633 setFocusedWindow(
nullptr);
634 m_focusedWindowCleared =
false;
637 if (m_previousWindow == window) {
638 m_previousWindow =
nullptr;
641 if (m_closingAllApps) {
642 if (m_windowModel.isEmpty()) {
643 Q_EMIT closedAllWindows();
647 DEBUG_MSG <<
" after " << toString() <<
" apps left " << m_windowModel.count();
650void TopLevelWindowModel::setInputMethodWindow(
Window *window)
652 if (m_inputMethodWindow) {
653 qWarning(
"Multiple Input Method Surfaces created, removing the old one!");
654 delete m_inputMethodWindow;
656 m_inputMethodWindow = window;
657 Q_EMIT inputMethodSurfaceChanged(m_inputMethodWindow->
surface());
658 InputMethodManager::instance()->setWindow(window);
661void TopLevelWindowModel::removeInputMethodWindow()
663 if (m_inputMethodWindow) {
664 auto surface = m_inputMethodWindow->
surface();
666 m_allSurfaces.remove(surface);
668 if (m_focusedWindow == m_inputMethodWindow) {
669 setFocusedWindow(
nullptr);
670 m_focusedWindowCleared =
false;
673 delete m_inputMethodWindow;
674 m_inputMethodWindow =
nullptr;
675 Q_EMIT inputMethodSurfaceChanged(
nullptr);
676 InputMethodManager::instance()->setWindow(
nullptr);
680void TopLevelWindowModel::onSurfacesRaised(
const QVector<lomiriapi::MirSurfaceInterface*> &surfaces)
682 DEBUG_MSG <<
"(" << surfaces <<
")";
683 const int raiseCount = surfaces.size();
684 for (
int i = 0; i < raiseCount; i++) {
685 int fromIndex = indexOf(surfaces[i]);
686 if (fromIndex != -1) {
692int TopLevelWindowModel::rowCount(
const QModelIndex &)
const
694 return m_windowModel.count();
697QVariant TopLevelWindowModel::data(
const QModelIndex& index,
int role)
const
699 if (index.row() < 0 || index.row() >= m_windowModel.size())
702 if (role == WindowRole) {
703 Window *window = m_windowModel.at(index.row()).window;
704 return QVariant::fromValue(window);
705 }
else if (role == ApplicationRole) {
706 return QVariant::fromValue(m_windowModel.at(index.row()).application);
712QString TopLevelWindowModel::toString()
715 for (
int i = 0; i < m_windowModel.count(); ++i) {
716 auto item = m_windowModel.at(i);
718 QString itemStr = QString(
"(index=%1,appId=%2,surface=0x%3,id=%4)")
719 .arg(QString::number(i),
720 item.application->appId(),
721 QString::number((qintptr)item.window->surface(), 16),
722 QString::number(item.window->id()));
732int TopLevelWindowModel::indexOf(lomiriapi::MirSurfaceInterface *surface)
734 for (
int i = 0; i < m_windowModel.count(); ++i) {
735 if (m_windowModel.at(i).window->surface() == surface) {
744 for (
int i = 0; i < m_windowModel.count(); ++i) {
745 if (m_windowModel[i].window->
id() ==
id) {
754 if (index >=0 && index < m_windowModel.count()) {
755 return m_windowModel[index].window;
763 if (index >=0 && index < m_windowModel.count()) {
764 return m_windowModel[index].window->surface();
772 if (index >=0 && index < m_windowModel.count()) {
773 return m_windowModel[index].application;
781 if (index >=0 && index < m_windowModel.count()) {
782 return m_windowModel[index].window->id();
790 if (m_modelState == IdleState) {
791 DEBUG_MSG <<
"(id=" <<
id <<
") - do it now.";
794 DEBUG_MSG <<
"(id=" <<
id <<
") - Model busy (modelState=" << m_modelState <<
"). Try again in the next event loop.";
800 QMetaObject::invokeMethod(
this,
"raiseId", Qt::QueuedConnection, Q_ARG(
int,
id));
804void TopLevelWindowModel::doRaiseId(
int id)
808 if (fromIndex != -1 && fromIndex != 0) {
809 auto surface = m_windowModel[fromIndex].window->surface();
810 if (surface && surface->live()) {
811 m_surfaceManager->raise(surface);
820void TopLevelWindowModel::setFocusedWindow(
Window *window)
822 if (window != m_focusedWindow) {
823 DEBUG_MSG <<
"(" << window <<
")";
825 m_previousWindow = m_focusedWindow;
827 m_focusedWindow = window;
828 Q_EMIT focusedWindowChanged(m_focusedWindow);
830 if (m_previousWindow && m_previousWindow->
focused() && !m_previousWindow->
surface()) {
832 m_previousWindow->setFocused(
false);
837 m_pendingActivation =
false;
842 return m_inputMethodWindow ? m_inputMethodWindow->
surface() :
nullptr;
847 return m_focusedWindow;
850void TopLevelWindowModel::move(
int from,
int to)
852 if (from == to)
return;
853 DEBUG_MSG <<
" from=" << from <<
" to=" << to;
855 if (from >= 0 && from < m_windowModel.size() && to >= 0 && to < m_windowModel.size()) {
861 Q_ASSERT(m_modelState == IdleState);
862 m_modelState = MovingState;
864 beginMoveRows(parent, from, from, parent, to + (to > from ? 1 : 0));
865#if QT_VERSION < QT_VERSION_CHECK(5, 6, 0)
866 const auto &window = m_windowModel.takeAt(from);
867 m_windowModel.insert(to, window);
869 m_windowModel.move(from, to);
874 m_modelState = IdleState;
876 DEBUG_MSG <<
" after " << toString();
879void TopLevelWindowModel::onModificationsStarted()
881 m_surfaceManagerBusy =
true;
884void TopLevelWindowModel::onModificationsEnded()
886 if (m_focusedWindowCleared) {
887 setFocusedWindow(
nullptr);
890 m_focusedWindowCleared =
false;
891 m_surfaceManagerBusy =
false;
894void TopLevelWindowModel::activateTopMostWindowWithoutId(
int forbiddenId)
896 DEBUG_MSG <<
"(" << forbiddenId <<
")";
898 for (
int i = 0; i < m_windowModel.count(); ++i) {
899 Window *window = m_windowModel[i].window;
900 if (window->
id() != forbiddenId) {
907void TopLevelWindowModel::refreshWindows()
912 if (!m_workspace || !m_applicationManager || !m_surfaceManager)
return;
914 m_surfaceManager->forEachSurfaceInWorkspace(m_workspace->workspace(), [
this](lomiri::shell::application::MirSurfaceInterface* surface) {
915 if (surface->parentSurface()) {
917 Window *window = createWindow(surface);
918 connect(surface, &QObject::destroyed, window, [=](){
919 window->setSurface(nullptr);
920 window->deleteLater();
923 if (surface->type() == Mir::InputMethodType) {
924 setInputMethodWindow(createWindow(surface));
926 auto *application = m_applicationManager->findApplicationWithSurface(surface);
928 prependSurface(surface, application);
933 Window *promptWindow = createWindow(surface);
934 connect(surface, &QObject::destroyed, promptWindow, [=](){
935 promptWindow->setSurface(nullptr);
936 promptWindow->deleteLater();
944void TopLevelWindowModel::clear()
948 while(m_windowModel.count() > 0) {
949 ModelEntry entry = m_windowModel.takeAt(0);
950 disconnect(entry.window, 0,
this, 0);
953 m_allSurfaces.clear();
954 setFocusedWindow(
nullptr);
955 m_focusedWindowCleared =
false;
956 m_previousWindow =
nullptr;
961 m_closingAllApps =
true;
962 for (
auto win : m_windowModel) {
968 if (m_windowModel.isEmpty()) {
969 Q_EMIT closedAllWindows();
975 return !m_nullWindow->
focused();
978void TopLevelWindowModel::setRootFocus(
bool focus)
980 DEBUG_MSG <<
"(" << focus <<
"), surfaceManagerBusy is " << m_surfaceManagerBusy;
982 if (m_surfaceManagerBusy) {
992 if (m_previousWindow && !m_previousWindow->
focused() && !m_pendingActivation &&
993 m_nullWindow == m_focusedWindow && m_previousWindow != m_nullWindow) {
995 }
else if (!m_pendingActivation) {
997 activateTopMostWindowWithoutId(-1);
1000 if (!m_nullWindow->
focused()) {
1013 m_pendingActivation =
true;
Q_INVOKABLE void raiseId(int id)
Raises the row with the given id to the top of the window stack (index == count-1)
bool rootFocus
Sets whether a user Window or "nothing" should be focused.
Q_INVOKABLE Window * windowAt(int index) const
Returns the window at the given index.
Q_INVOKABLE lomiri::shell::application::MirSurfaceInterface * surfaceAt(int index) const
Returns the surface at the given index.
Q_INVOKABLE void pendingActivation()
Sets pending activation flag.
Q_INVOKABLE int indexForId(int id) const
Returns the index where the row with the given id is located.
lomiri::shell::application::MirSurfaceInterface * inputMethodSurface
The input method surface, if any.
Q_INVOKABLE int idAt(int index) const
Returns the unique id of the element at the given index.
Q_INVOKABLE void closeAllWindows()
Closes all windows, emits closedAllWindows when done.
int count
Number of top-level surfaces in this model.
void listChanged()
Emitted when the list changes.
Q_INVOKABLE lomiri::shell::application::ApplicationInfoInterface * applicationAt(int index) const
Returns the application at the given index.
Window * focusedWindow
The currently focused window, if any.
A slightly higher concept than MirSurface.
int id
A unique identifier for this window. Useful for telling windows apart in a list model as they get mov...
void focusRequested()
Emitted when focus for this window is requested by an external party.
lomiri::shell::application::MirSurfaceInterface * surface
Surface backing up this window It might be null if a surface hasn't been created yet (application is ...
bool focused
Whether the surface is focused.
void activate()
Focuses and raises the window.
Mir::State state
State of the surface.