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

A slightly higher concept than MirSurface. More...

#include <plugins/WindowManager/Window.h>

Inherits QObject.

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.

33 : QObject(parent)
34 , m_id(id)
35{
36 DEBUG_MSG << "()";
37 QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
38}

◆ ~Window()

Window::~Window ( )
virtual

Definition at line 40 of file Window.cpp.

41{
42 DEBUG_MSG << "()";
43}

Member Function Documentation

◆ activate

void Window::activate ( )
slot

Focuses and raises the window.

Definition at line 137 of file Window.cpp.

138{
139 DEBUG_MSG << "()";
140 if (m_surface) {
141 m_surface->activate();
142 } else {
143 Q_EMIT emptyWindowActivated();
144 }
145}

◆ allowClientResize()

bool Window::allowClientResize ( ) const

Definition at line 71 of file Window.cpp.

72{
73 return m_allowClientResize;
74}

◆ close

void Window::close ( )
slot

Sends a close request.

Definition at line 128 of file Window.cpp.

129{
130 if (m_surface) {
131 m_surface->close();
132 } else {
133 Q_EMIT closeRequested();
134 }
135}

◆ confinesMousePointer()

bool Window::confinesMousePointer ( ) const

Definition at line 98 of file Window.cpp.

99{
100 if (m_surface) {
101 return m_surface->confinesMousePointer();
102 } else {
103 return false;
104 }
105}

◆ focused()

bool Window::focused ( ) const

Definition at line 93 of file Window.cpp.

94{
95 return m_focused;
96}

◆ id()

int Window::id ( ) const

Definition at line 107 of file Window.cpp.

108{
109 return m_id;
110}

◆ position()

QPoint Window::position ( ) const

Definition at line 45 of file Window.cpp.

46{
47 return m_position;
48}

◆ requestedPosition()

QPoint Window::requestedPosition ( ) const

Definition at line 50 of file Window.cpp.

51{
52 return m_requestedPosition;
53}

◆ requestState

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

Requests a change to the specified state.

Definition at line 117 of file Window.cpp.

118{
119 m_stateRequested = true;
120 if (m_surface) {
121 m_surface->requestState(state);
122 } else if (m_state != state) {
123 m_state = state;
124 Q_EMIT stateChanged(m_state);
125 }
126}
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.

77{
78 if (value != m_allowClientResize) {
79 DEBUG_MSG << "("<<value<<")";
80 m_allowClientResize = value;
81 if (m_surface) {
82 m_surface->setAllowClientResize(value);
83 }
84 Q_EMIT allowClientResizeChanged(m_allowClientResize);
85 }
86}

◆ setFocused()

void Window::setFocused ( bool  value)

Definition at line 238 of file Window.cpp.

239{
240 if (value != m_focused) {
241 DEBUG_MSG << "(" << value << ")";
242 m_focused = value;
243 Q_EMIT focusedChanged(m_focused);
244 // when we have a surface we get focus changes from updateFocused() instead
245 Q_ASSERT(!m_surface);
246 }
247}

◆ setRequestedPosition()

void Window::setRequestedPosition ( const QPoint &  value)

Definition at line 55 of file Window.cpp.

56{
57 m_positionRequested = true;
58 if (value != m_requestedPosition) {
59 m_requestedPosition = value;
60 Q_EMIT requestedPositionChanged(m_requestedPosition);
61 if (m_surface) {
62 m_surface->setRequestedPosition(value);
63 } else {
64 // fake-miral: always comply
65 m_position = m_requestedPosition;
66 Q_EMIT positionChanged(m_position);
67 }
68 }
69}

◆ setSurface()

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

Definition at line 147 of file Window.cpp.

148{
149 DEBUG_MSG << "(" << surface << ")";
150 if (m_surface) {
151 disconnect(m_surface, 0, this, 0);
152 }
153
154 m_surface = surface;
155
156 if (m_surface) {
157 connect(surface, &lomiriapi::MirSurfaceInterface::focusRequested, this, [this]() {
158 Q_EMIT focusRequested();
159 });
160
161 connect(surface, &lomiriapi::MirSurfaceInterface::closeRequested, this, &Window::closeRequested);
162
163 connect(surface, &lomiriapi::MirSurfaceInterface::positionChanged, this, [this]() {
164 updatePosition();
165 });
166
167 connect(surface, &lomiriapi::MirSurfaceInterface::stateChanged, this, [this]() {
168 updateState();
169 });
170
171 connect(surface, &lomiriapi::MirSurfaceInterface::focusedChanged, this, [this]() {
172 updateFocused();
173 });
174
175 connect(surface, &lomiriapi::MirSurfaceInterface::allowClientResizeChanged, this, [this]() {
176 if (m_surface->allowClientResize() != m_allowClientResize) {
177 m_allowClientResize = m_surface->allowClientResize();
178 Q_EMIT allowClientResizeChanged(m_allowClientResize);
179 }
180 });
181
182 connect(surface, &lomiriapi::MirSurfaceInterface::liveChanged, this, &Window::liveChanged);
183
184 connect(surface, &QObject::destroyed, this, [this]() {
185 setSurface(nullptr);
186 });
187
188 // Surface should never be focused at this point!
189 if (m_surface->focused()) {
190 WARNING_MSG << "Initial surface is focused!";
191 }
192
193 // bring it up to speed
194 if (m_focused) {
195 m_surface->activate();
196 }
197 if (m_positionRequested) {
198 m_surface->setRequestedPosition(m_requestedPosition);
199 }
200 if (m_stateRequested && m_surface->state() == Mir::RestoredState) {
201 m_surface->requestState(m_state);
202 }
203 m_surface->setAllowClientResize(m_allowClientResize);
204
205 // and sync with surface
206 updatePosition();
207 updateState();
208 updateFocused();
209 }
210
211 Q_EMIT surfaceChanged(surface);
212}
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 ...
Definition Window.h:92

◆ state()

Mir::State Window::state ( ) const

Definition at line 88 of file Window.cpp.

89{
90 return m_state;
91}

◆ surface()

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

Definition at line 112 of file Window.cpp.

113{
114 return m_surface;
115}

◆ toString()

QString Window::toString ( ) const

Definition at line 249 of file Window.cpp.

250{
251 QString result;
252 {
253 QTextStream stream(&result);
254 stream << "Window["<<(void*)this<<", id="<<id()<<", ";
255 if (surface()) {
256 stream << "MirSurface["<<(void*)surface()<<",\""<<surface()->name()<<"\"]";
257 } else {
258 stream << "null";
259 }
260 stream << "]";
261 }
262 return result;
263}

Property Documentation

◆ allowClientResize

bool Window::allowClientResize
readwrite

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
readwrite

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: