Lomiri
|
A model of top-level surfaces. More...
#include <plugins/WindowManager/TopLevelWindowModel.h>
Inherits QAbstractListModel.
Public Types | |
enum | Roles { WindowRole = Qt::UserRole , ApplicationRole = Qt::UserRole + 1 } |
The Roles supported by the model. More... | |
Signals | |
void | countChanged () |
void | inputMethodSurfaceChanged (lomiri::shell::application::MirSurfaceInterface *inputMethodSurface) |
void | focusedWindowChanged (Window *focusedWindow) |
void | listChanged () |
Emitted when the list changes. | |
void | closedAllWindows () |
void | rootFocusChanged () |
Public Member Functions | |
TopLevelWindowModel (Workspace *workspace) | |
int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
QVariant | data (const QModelIndex &index, int role) const override |
QHash< int, QByteArray > | roleNames () const override |
lomiri::shell::application::MirSurfaceInterface * | inputMethodSurface () const |
Window * | focusedWindow () const |
int | nextId () const |
Q_INVOKABLE lomiri::shell::application::MirSurfaceInterface * | surfaceAt (int index) const |
Returns the surface at the given index. | |
Q_INVOKABLE Window * | windowAt (int index) const |
Returns the window at the given index. | |
Q_INVOKABLE lomiri::shell::application::ApplicationInfoInterface * | applicationAt (int index) const |
Returns the application at the given index. | |
Q_INVOKABLE int | idAt (int index) const |
Returns the unique id of the element at the given index. | |
Q_INVOKABLE int | indexForId (int id) const |
Returns the index where the row with the given id is located. | |
Q_INVOKABLE void | raiseId (int id) |
Raises the row with the given id to the top of the window stack (index == count-1) | |
Q_INVOKABLE void | closeAllWindows () |
Closes all windows, emits closedAllWindows when done. | |
Q_INVOKABLE void | pendingActivation () |
Sets pending activation flag. | |
void | setApplicationManager (lomiri::shell::application::ApplicationManagerInterface *) |
void | setSurfaceManager (lomiri::shell::application::SurfaceManagerInterface *) |
void | setRootFocus (bool focus) |
bool | rootFocus () |
Properties | |
int | count |
Number of top-level surfaces in this model. | |
lomiri::shell::application::MirSurfaceInterface * | inputMethodSurface |
The input method surface, if any. | |
Window * | focusedWindow |
The currently focused window, if any. | |
int | nextId |
bool | rootFocus |
Sets whether a user Window or "nothing" should be focused. | |
A model of top-level surfaces.
It's an abstraction of top-level application windows.
When an entry first appears, it normaly doesn't have a surface yet, meaning that the application is still starting up. A shell should then display a splash screen or saved screenshot of the application until its surface comes up.
As applications can have multiple surfaces and you can also have entries without surfaces at all, the only way to unambiguously refer to an entry in this model is through its id.
Definition at line 59 of file TopLevelWindowModel.h.
The Roles supported by the model.
WindowRole - A Window. ApplicationRole - An ApplicationInfoInterface
Definition at line 116 of file TopLevelWindowModel.h.
TopLevelWindowModel::TopLevelWindowModel | ( | Workspace * | workspace | ) |
Definition at line 43 of file TopLevelWindowModel.cpp.
TopLevelWindowModel::~TopLevelWindowModel | ( | ) |
Definition at line 61 of file TopLevelWindowModel.cpp.
lomiriapi::ApplicationInfoInterface * TopLevelWindowModel::applicationAt | ( | int | index | ) | const |
Returns the application at the given index.
Definition at line 686 of file TopLevelWindowModel.cpp.
void TopLevelWindowModel::closeAllWindows | ( | ) |
Closes all windows, emits closedAllWindows when done.
Definition at line 875 of file TopLevelWindowModel.cpp.
|
override |
Definition at line 613 of file TopLevelWindowModel.cpp.
Window * TopLevelWindowModel::focusedWindow | ( | ) | const |
Definition at line 761 of file TopLevelWindowModel.cpp.
int TopLevelWindowModel::idAt | ( | int | index | ) | const |
Returns the unique id of the element at the given index.
Definition at line 695 of file TopLevelWindowModel.cpp.
int TopLevelWindowModel::indexForId | ( | int | id | ) | const |
Returns the index where the row with the given id is located.
Returns -1 if there's no row with the given id.
Definition at line 658 of file TopLevelWindowModel.cpp.
lomiriapi::MirSurfaceInterface * TopLevelWindowModel::inputMethodSurface | ( | ) | const |
Definition at line 756 of file TopLevelWindowModel.cpp.
|
signal |
Emitted when the list changes.
Emitted when model gains an element, loses an element or when elements exchange positions.
|
inline |
Definition at line 139 of file TopLevelWindowModel.h.
void TopLevelWindowModel::pendingActivation | ( | ) |
Sets pending activation flag.
Definition at line 927 of file TopLevelWindowModel.cpp.
void TopLevelWindowModel::raiseId | ( | int | id | ) |
Raises the row with the given id to the top of the window stack (index == count-1)
Definition at line 704 of file TopLevelWindowModel.cpp.
|
inlineoverride |
Definition at line 127 of file TopLevelWindowModel.h.
|
override |
Definition at line 608 of file TopLevelWindowModel.cpp.
void TopLevelWindowModel::setApplicationManager | ( | lomiri::shell::application::ApplicationManagerInterface * | ) |
Definition at line 65 of file TopLevelWindowModel.cpp.
void TopLevelWindowModel::setRootFocus | ( | bool | focus | ) |
Definition at line 894 of file TopLevelWindowModel.cpp.
void TopLevelWindowModel::setSurfaceManager | ( | lomiri::shell::application::SurfaceManagerInterface * | ) |
Definition at line 111 of file TopLevelWindowModel.cpp.
lomiriapi::MirSurfaceInterface * TopLevelWindowModel::surfaceAt | ( | int | index | ) | const |
Returns the surface at the given index.
It will be a nullptr if the application is still starting up and thus hasn't yet created and drawn into a surface.
Same as windowAt(index).surface()
Definition at line 677 of file TopLevelWindowModel.cpp.
Window * TopLevelWindowModel::windowAt | ( | int | index | ) | const |
Returns the window at the given index.
Will always be valid
Definition at line 668 of file TopLevelWindowModel.cpp.
|
read |
Number of top-level surfaces in this model.
This is the same as rowCount, added in order to keep compatibility with QML ListModels.
Definition at line 68 of file TopLevelWindowModel.h.
|
read |
The currently focused window, if any.
Definition at line 80 of file TopLevelWindowModel.h.
|
read |
The input method surface, if any.
The surface of a onscreen keyboard (akak "virtual keyboard") would be kept here and not in the model itself.
Definition at line 75 of file TopLevelWindowModel.h.
|
read |
The id to be used on the next entry created Useful for tests
Definition at line 86 of file TopLevelWindowModel.h.
|
readwrite |
Sets whether a user Window or "nothing" should be focused.
This implementation of TLWM must have something focused. However, the user may wish to have nothing in some cases - for example, when they minimize all their windows on the desktop or unfocus the app they're using by clicking the background or indicators.
Unsetting rootFocus effectively focuses "nothing" by setting up a Window that has no displayable Surfaces and bringing it into focus.
Setting rootFocus attempts to focus the Window which was focused last - unless another app is attempting to gain focus (as determined by pendingActivation) and that's why we got rootFocus.
If the previously-focused Window was closed before rootFocus was set, the next available window will be focused.
Definition at line 107 of file TopLevelWindowModel.h.