Unity 8
TopLevelWindowModel Class Reference

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 (unity::shell::application::MirSurfaceInterface *inputMethodSurface)
 
void focusedWindowChanged (Window *focusedWindow)
 
void applicationManagerChanged (unity::shell::application::ApplicationManagerInterface *)
 
void surfaceManagerChanged (unity::shell::application::SurfaceManagerInterface *)
 
void listChanged ()
 Emitted when the list changes. More...
 
void closedAllWindows ()
 
void rootFocusChanged ()
 

Public Member Functions

int rowCount (const QModelIndex &parent=QModelIndex()) const override
 
QVariant data (const QModelIndex &index, int role) const override
 
QHash< int, QByteArray > roleNames () const override
 
unity::shell::application::MirSurfaceInterface * inputMethodSurface () const
 
WindowfocusedWindow () const
 
unity::shell::application::ApplicationManagerInterface * applicationManager () const
 
void setApplicationManager (unity::shell::application::ApplicationManagerInterface *)
 
unity::shell::application::SurfaceManagerInterface * surfaceManager () const
 
void setSurfaceManager (unity::shell::application::SurfaceManagerInterface *)
 
int nextId () const
 
Q_INVOKABLE unity::shell::application::MirSurfaceInterface * surfaceAt (int index) const
 Returns the surface at the given index. More...
 
Q_INVOKABLE WindowwindowAt (int index) const
 Returns the window at the given index. More...
 
Q_INVOKABLE unity::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. More...
 
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 setRootFocus (bool focus)
 
bool rootFocus ()
 

Properties

int count
 Number of top-level surfaces in this model. More...
 
unity::shell::application::MirSurfaceInterface inputMethodSurface
 The input method surface, if any. More...
 
Window focusedWindow
 The currently focused window, if any.
 
unity::shell::application::SurfaceManagerInterface surfaceManager
 
unity::shell::application::ApplicationManagerInterface applicationManager
 
int nextId
 
bool rootFocus
 Sets whether a user Window or "nothing" should be focused. More...
 

Detailed Description

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 54 of file TopLevelWindowModel.h.

Member Enumeration Documentation

The Roles supported by the model.

WindowRole - A Window. ApplicationRole - An ApplicationInfoInterface

Definition at line 121 of file TopLevelWindowModel.h.

121  {
122  WindowRole = Qt::UserRole,
123  ApplicationRole = Qt::UserRole + 1,
124  };

Member Function Documentation

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 561 of file TopLevelWindowModel.cpp.

562 {
563  for (int i = 0; i < m_windowModel.count(); ++i) {
564  if (m_windowModel[i].window->id() == id) {
565  return i;
566  }
567  }
568  return -1;
569 }
void TopLevelWindowModel::listChanged ( )
signal

Emitted when the list changes.

Emitted when model gains an element, loses an element or when elements exchange positions.

unityapi::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 580 of file TopLevelWindowModel.cpp.

581 {
582  if (index >=0 && index < m_windowModel.count()) {
583  return m_windowModel[index].window->surface();
584  } else {
585  return nullptr;
586  }
587 }
Window * TopLevelWindowModel::windowAt ( int  index) const

Returns the window at the given index.

Will always be valid

Definition at line 571 of file TopLevelWindowModel.cpp.

572 {
573  if (index >=0 && index < m_windowModel.count()) {
574  return m_windowModel[index].window;
575  } else {
576  return nullptr;
577  }
578 }

Property Documentation

int TopLevelWindowModel::count
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 63 of file TopLevelWindowModel.h.

unityapi::MirSurfaceInterface * TopLevelWindowModel::inputMethodSurface
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 70 of file TopLevelWindowModel.h.

int TopLevelWindowModel::nextId
read

The id to be used on the next entry created Useful for tests

Definition at line 91 of file TopLevelWindowModel.h.

bool TopLevelWindowModel::rootFocus
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 112 of file TopLevelWindowModel.h.


The documentation for this class was generated from the following files: