18 #ifndef TOPLEVELWINDOWMODEL_H 19 #define TOPLEVELWINDOWMODEL_H 21 #include <QAbstractListModel> 22 #include <QAtomicInteger> 23 #include <QLoggingCategory> 27 #include "WindowManagerGlobal.h" 29 Q_DECLARE_LOGGING_CATEGORY(TOPLEVELWINDOWMODEL)
34 namespace
miral {
class Workspace; }
38 namespace application {
39 class ApplicationInfoInterface;
40 class ApplicationManagerInterface;
41 class MirSurfaceInterface;
42 class SurfaceManagerInterface;
68 Q_PROPERTY(
int count READ rowCount NOTIFY countChanged)
75 Q_PROPERTY(
unity::shell::application::MirSurfaceInterface* inputMethodSurface READ inputMethodSurface NOTIFY inputMethodSurfaceChanged)
80 Q_PROPERTY(
Window* focusedWindow READ focusedWindow NOTIFY focusedWindowChanged)
86 Q_PROPERTY(
int nextId READ nextId)
107 Q_PROPERTY(
bool rootFocus READ rootFocus WRITE setRootFocus NOTIFY rootFocusChanged)
117 WindowRole = Qt::UserRole,
118 ApplicationRole = Qt::UserRole + 1,
125 int rowCount(
const QModelIndex &parent = QModelIndex())
const override;
126 QVariant data(
const QModelIndex& index,
int role)
const override;
127 QHash<int, QByteArray> roleNames()
const override {
128 QHash<int, QByteArray> roleNames { {WindowRole,
"window"},
129 {ApplicationRole,
"application"} };
135 unity::shell::application::MirSurfaceInterface* inputMethodSurface()
const;
136 Window* focusedWindow()
const;
138 int nextId()
const {
return m_nextId.load(); }
149 Q_INVOKABLE unity::shell::application::MirSurfaceInterface *surfaceAt(
int index)
const;
156 Q_INVOKABLE
Window *windowAt(
int index)
const;
161 Q_INVOKABLE unity::shell::application::ApplicationInfoInterface *applicationAt(
int index)
const;
166 Q_INVOKABLE
int idAt(
int index)
const;
173 Q_INVOKABLE
int indexForId(
int id)
const;
178 Q_INVOKABLE
void raiseId(
int id);
183 Q_INVOKABLE
void closeAllWindows();
188 Q_INVOKABLE
void pendingActivation();
190 void setApplicationManager(unity::shell::application::ApplicationManagerInterface*);
191 void setSurfaceManager(unity::shell::application::SurfaceManagerInterface*);
192 void setRootFocus(
bool focus);
197 void inputMethodSurfaceChanged(unity::shell::application::MirSurfaceInterface* inputMethodSurface);
198 void focusedWindowChanged(
Window *focusedWindow);
207 void closedAllWindows();
209 void rootFocusChanged();
212 void onSurfacesAddedToWorkspace(
const std::shared_ptr<miral::Workspace>& workspace,
213 const QVector<unity::shell::application::MirSurfaceInterface*> surfaces);
214 void onSurfacesRaised(
const QVector<unity::shell::application::MirSurfaceInterface*> &surfaces);
216 void onModificationsStarted();
217 void onModificationsEnded();
220 void doRaiseId(
int id);
222 int nextFreeId(
int candidateId,
const int latestId);
223 int nextId(
int id)
const;
225 int indexOf(unity::shell::application::MirSurfaceInterface *surface);
227 void setInputMethodWindow(
Window *window);
228 void setFocusedWindow(
Window *window);
229 void removeInputMethodWindow();
230 void deleteAt(
int index);
231 void removeAt(
int index);
232 void removeSurfaces(
const QVector<unity::shell::application::MirSurfaceInterface *> surfaces);
234 void addApplication(unity::shell::application::ApplicationInfoInterface *application);
235 void removeApplication(unity::shell::application::ApplicationInfoInterface *application);
237 void prependPlaceholder(unity::shell::application::ApplicationInfoInterface *application);
238 void prependSurface(unity::shell::application::MirSurfaceInterface *surface,
239 unity::shell::application::ApplicationInfoInterface *application);
240 void prependSurfaceHelper(unity::shell::application::MirSurfaceInterface *surface,
241 unity::shell::application::ApplicationInfoInterface *application);
242 void prependWindow(
Window *window, unity::shell::application::ApplicationInfoInterface *application);
244 void connectWindow(
Window *window);
245 void connectSurface(unity::shell::application::MirSurfaceInterface *surface);
247 void onSurfaceDied(unity::shell::application::MirSurfaceInterface *surface);
248 void onSurfaceDestroyed(unity::shell::application::MirSurfaceInterface *surface);
250 void move(
int from,
int to);
252 void activateEmptyWindow(
Window *window);
254 void activateTopMostWindowWithoutId(
int forbiddenId);
255 void refreshWindows();
258 Window *createWindow(unity::shell::application::MirSurfaceInterface *surface);
259 Window *createWindowWithId(unity::shell::application::MirSurfaceInterface *surface,
int id);
260 Window *createNullWindow();
264 ModelEntry(
Window *window,
265 unity::shell::application::ApplicationInfoInterface *application)
266 : window(window), application(application) {}
268 unity::shell::application::ApplicationInfoInterface *application{
nullptr};
269 bool removeOnceSurfaceDestroyed{
false};
272 QVector<ModelEntry> m_windowModel;
273 Window* m_inputMethodWindow{
nullptr};
274 Window* m_focusedWindow{
nullptr};
276 Workspace* m_workspace{
nullptr};
278 QSet<unity::shell::application::MirSurfaceInterface*> m_allSurfaces;
279 Window* m_previousWindow{
nullptr};
280 bool m_pendingActivation;
282 QAtomicInteger<int> m_nextId{1};
284 unity::shell::application::ApplicationManagerInterface* m_applicationManager{
nullptr};
285 unity::shell::application::SurfaceManagerInterface *m_surfaceManager{
nullptr};
286 bool m_surfaceManagerBusy;
295 ModelState m_modelState{IdleState};
298 bool m_focusedWindowCleared{
false};
300 bool m_closingAllApps{
false};
303 #endif // TOPLEVELWINDOWMODEL_H A slightly higher concept than MirSurface.
Roles
The Roles supported by the model.
A model of top-level surfaces.