Loading...
Searching...
No Matches
Window Class Reference

A slightly higher concept than MirSurface. More...

`#include <plugins/WindowManager/Window.h>`

## Public Slots

void | requestState (Mir::State state)
| Requests a change to the specified state.
void | close ()
| Sends a close request.
void | activate ()
| Focuses and raises the window.

## Signals

void | closeRequested ()
void | emptyWindowActivated ()
void | positionChanged (QPoint position)
void | requestedPositionChanged (QPoint position)
void | stateChanged (Mir::State value)
void | focusedChanged (bool value)
void | confinesMousePointerChanged (bool value)
void | surfaceChanged (lomiri::shell::application::MirSurfaceInterface *surface)
void | allowClientResizeChanged (bool value)
void | liveChanged (bool value)
void | focusRequested ()
| Emitted when focus for this window is requested by an external party.

## Public Member Functions

| Window (int id, QObject *parent=nullptr)
QPoint | position () const
QPoint | requestedPosition () const
void | setRequestedPosition (const QPoint &)
Mir::State | state () const
bool | focused () const
bool | confinesMousePointer () const
int | id () const
lomiri::shell::application::MirSurfaceInterface * | surface () const
void | setSurface (lomiri::shell::application::MirSurfaceInterface *surface)
void | setFocused (bool value)
bool | allowClientResize () const
void | setAllowClientResize (bool)
QString | toString () const

## Properties

QPoint | position
| Position of the current surface buffer, in pixels.
QPoint | requestedPosition
| Requested position of the current surface buffer, in pixels.
Mir::State | state
| State of the surface.
bool | focused
| Whether the surface is focused.
bool | confinesMousePointer
| Whether the surface wants to confine the mouse pointer within its boundaries.
int | id
| A unique identifier for this window. Useful for telling windows apart in a list model as they get moved around.
lomiri::shell::application::MirSurfaceInterface * | surface
| Surface backing up this window It might be null if a surface hasn't been created yet (application is starting up) or if the corresponding application has been killed (but can still get restarted to continue from where it left).
bool | allowClientResize
| Whether to comply to resize requests coming from the client side.

## Detailed Description

A slightly higher concept than MirSurface.

A Window exists before its MirSurface gets created (for splashscreen purposes) and might also hang around after the backing surface is gone (In case the application was killed to free up memory, as it should still remain in the window list since the user did not explicitly close it).

Definition at line 47 of file Window.h.

## Constructor & Destructor Documentation

## Window()

Window::Window | ( | int | id,
|  | QObject * | parent = nullptr )

Definition at line 32 of file Window.cpp.

: QObject(parent)
, m_id(id)
{
DEBUG_MSG << "()";
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
}

## ~Window()

Window::~Window | ( |  | ) |

virtual

Definition at line 40 of file Window.cpp.

{
DEBUG_MSG << "()";
}

## Member Function Documentation

## activate

void Window::activate | ( |  | ) |

slot

Focuses and raises the window.

Definition at line 137 of file Window.cpp.

{
DEBUG_MSG << "()";
if (m_surface) {
m_surface->activate();
} else {
Q_EMIT emptyWindowActivated();
}
}

## allowClientResize()

bool Window::allowClientResize | ( |  | ) | const

Definition at line 71 of file Window.cpp.

{
return m_allowClientResize;
}

## close

void Window::close | ( |  | ) |

slot

Sends a close request.

Definition at line 128 of file Window.cpp.

{
if (m_surface) {
m_surface->close();
} else {
Q_EMIT closeRequested();
}
}

## confinesMousePointer()

bool Window::confinesMousePointer | ( |  | ) | const

Definition at line 98 of file Window.cpp.

{
if (m_surface) {
return m_surface->confinesMousePointer();
} else {
return false;
}
}

## focused()

bool Window::focused | ( |  | ) | const

Definition at line 93 of file Window.cpp.

{
return m_focused;
}

## id()

int Window::id | ( |  | ) | const

Definition at line 107 of file Window.cpp.

{
return m_id;
}

## position()

QPoint Window::position | ( |  | ) | const

Definition at line 45 of file Window.cpp.

{
return m_position;
}

## requestedPosition()

QPoint Window::requestedPosition | ( |  | ) | const

Definition at line 50 of file Window.cpp.

{
return m_requestedPosition;
}

## requestState

void Window::requestState | ( | Mir::State | state | ) |

slot

Requests a change to the specified state.

Definition at line 117 of file Window.cpp.

{
m_stateRequested = true;
if (m_surface) {
m_surface->requestState(state);
} else if (m_state != state) {
m_state = state;
Q_EMIT stateChanged(m_state);
}
}
Window::state
Mir::State state
State of the surface.
Definition Window.h:64

## setAllowClientResize()

void Window::setAllowClientResize | ( | bool | value | ) |

Definition at line 76 of file Window.cpp.

{
if (value != m_allowClientResize) {
DEBUG_MSG << "("<<value<<")";
m_allowClientResize = value;
if (m_surface) {
m_surface->setAllowClientResize(value);
}
Q_EMIT allowClientResizeChanged(m_allowClientResize);
}
}

## setFocused()

void Window::setFocused | ( | bool | value | ) |

Definition at line 238 of file Window.cpp.

{
if (value != m_focused) {
DEBUG_MSG << "(" << value << ")";
m_focused = value;
Q_EMIT focusedChanged(m_focused);
// when we have a surface we get focus changes from updateFocused() instead
Q_ASSERT(!m_surface);
}
}

## setRequestedPosition()

void Window::setRequestedPosition | ( | const QPoint & | value | ) |

Definition at line 55 of file Window.cpp.

{
m_positionRequested = true;
if (value != m_requestedPosition) {
m_requestedPosition = value;
Q_EMIT requestedPositionChanged(m_requestedPosition);
if (m_surface) {
m_surface->setRequestedPosition(value);
} else {
// fake-miral: always comply
m_position = m_requestedPosition;
Q_EMIT positionChanged(m_position);
}
}
}

## setSurface()

void Window::setSurface | ( | lomiri::shell::application::MirSurfaceInterface * | surface | ) |

Definition at line 147 of file Window.cpp.

{
DEBUG_MSG << "(" << surface << ")";
if (m_surface) {
disconnect(m_surface, 0, this, 0);
}
m_surface = surface;
if (m_surface) {
connect(surface, &lomiriapi::MirSurfaceInterface::focusRequested, this, [this]() {
Q_EMIT focusRequested();
});
connect(surface, &lomiriapi::MirSurfaceInterface::closeRequested, this, &Window::closeRequested);
connect(surface, &lomiriapi::MirSurfaceInterface::positionChanged, this, [this]() {
updatePosition();
});
connect(surface, &lomiriapi::MirSurfaceInterface::stateChanged, this, [this]() {
updateState();
});
connect(surface, &lomiriapi::MirSurfaceInterface::focusedChanged, this, [this]() {
updateFocused();
});
connect(surface, &lomiriapi::MirSurfaceInterface::allowClientResizeChanged, this, [this]() {
if (m_surface->allowClientResize() != m_allowClientResize) {
m_allowClientResize = m_surface->allowClientResize();
Q_EMIT allowClientResizeChanged(m_allowClientResize);
}
});
connect(surface, &lomiriapi::MirSurfaceInterface::liveChanged, this, &Window::liveChanged);
connect(surface, &QObject::destroyed, this, [this]() {
setSurface(nullptr);
});
// Surface should never be focused at this point!
if (m_surface->focused()) {
WARNING_MSG << "Initial surface is focused!";
}
// bring it up to speed
if (m_focused) {
m_surface->activate();
}
if (m_positionRequested) {
m_surface->setRequestedPosition(m_requestedPosition);
}
if (m_stateRequested && m_surface->state() == Mir::RestoredState) {
m_surface->requestState(m_state);
}
m_surface->setAllowClientResize(m_allowClientResize);
// and sync with surface
updatePosition();
updateState();
updateFocused();
}
Q_EMIT surfaceChanged(surface);
}
Window::focusRequested
void focusRequested()
Emitted when focus for this window is requested by an external party.
Window::surface
lomiri::shell::application::MirSurfaceInterface * surface
Surface backing up this window It might be null if a surface hasn't been created yet (application is ...
Definition Window.h:92

## state()

Mir::State Window::state | ( |  | ) | const

Definition at line 88 of file Window.cpp.

{
return m_state;
}

## surface()

lomiriapi::MirSurfaceInterface * Window::surface | ( |  | ) | const

Definition at line 112 of file Window.cpp.

{
return m_surface;
}

## toString()

QString Window::toString | ( |  | ) | const

Definition at line 249 of file Window.cpp.

{
QString result;
{
QTextStream stream(&result);
stream << "Window["<<(void*)this<<", id="<<id()<<", ";
if (surface()) {
stream << "MirSurface["<<(void*)surface()<<",\""<<surface()->name()<<"\"]";
} else {
stream << "null";
}
stream << "]";
}
return result;
}

## Property Documentation

## allowClientResize

bool Window::allowClientResize

read write

Whether to comply to resize requests coming from the client side.

It's true by default

Definition at line 99 of file Window.h.

## confinesMousePointer

bool Window::confinesMousePointer

read

Whether the surface wants to confine the mouse pointer within its boundaries.

If true, the surface doesn't want the mouse pointer to leave its boundaries while it's focused.

Definition at line 78 of file Window.h.

## focused

bool Window::focused

read

Whether the surface is focused.

It will be true if this surface is MirFocusControllerInterface::focusedSurface

Definition at line 71 of file Window.h.

## id

int Window::id

read

A unique identifier for this window. Useful for telling windows apart in a list model as they get moved around.

Definition at line 84 of file Window.h.

## position

QPoint Window::position

read

Position of the current surface buffer, in pixels.

Definition at line 54 of file Window.h.

## requestedPosition

QPoint Window::requestedPosition

read write

Requested position of the current surface buffer, in pixels.

Definition at line 59 of file Window.h.

## state

Mir::State Window::state

read

State of the surface.

Definition at line 64 of file Window.h.

## surface

lomiri::shell::application::MirSurfaceInterface* Window::surface

read

Surface backing up this window It might be null if a surface hasn't been created yet (application is starting up) or if the corresponding application has been killed (but can still get restarted to continue from where it left).

Definition at line 92 of file Window.h.

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

- plugins/WindowManager/Window.h
- plugins/WindowManager/Window.cpp