Lomiri
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 constrainedChanged (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
bool constrained () const
int id () const
lomiri::shell::application::MirSurfaceInterface * surface () const
void setSurface (lomiri::shell::application::MirSurfaceInterface *surface)
void setFocused (bool value)
void setConstrained (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.
bool constrained
 Whether the surface has been constrained in screen bounds already.
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 142 of file Window.cpp.

143{
144 DEBUG_MSG << "()";
145 if (m_surface) {
146 m_surface->activate();
147 } else {
148 Q_EMIT emptyWindowActivated();
149 }
150}

◆ 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 133 of file Window.cpp.

134{
135 if (m_surface) {
136 m_surface->close();
137 } else {
138 Q_EMIT closeRequested();
139 }
140}

◆ 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}

◆ constrained()

bool Window::constrained ( ) const

Definition at line 107 of file Window.cpp.

108{
109 return m_constrained;
110}

◆ 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 112 of file Window.cpp.

113{
114 return m_id;
115}

◆ 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 122 of file Window.cpp.

123{
124 m_stateRequested = true;
125 if (m_surface) {
126 m_surface->requestState(state);
127 } else if (m_state != state) {
128 m_state = state;
129 Q_EMIT stateChanged(m_state);
130 }
131}
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}

◆ setConstrained()

void Window::setConstrained ( bool value)

Definition at line 254 of file Window.cpp.

255{
256 if (value != m_constrained) {
257 DEBUG_MSG << "(" << value << ")";
258 m_constrained = value;
259 Q_EMIT constrainedChanged(m_constrained);
260 }
261}

◆ setFocused()

void Window::setFocused ( bool value)

Definition at line 243 of file Window.cpp.

244{
245 if (value != m_focused) {
246 DEBUG_MSG << "(" << value << ")";
247 m_focused = value;
248 Q_EMIT focusedChanged(m_focused);
249 // when we have a surface we get focus changes from updateFocused() instead
250 Q_ASSERT(!m_surface);
251 }
252}

◆ 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 152 of file Window.cpp.

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

◆ 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 117 of file Window.cpp.

118{
119 return m_surface;
120}

◆ toString()

QString Window::toString ( ) const

Definition at line 263 of file Window.cpp.

264{
265 QString result;
266 {
267 QTextStream stream(&result);
268 stream << "Window["<<(void*)this<<", id="<<id()<<", ";
269 if (surface()) {
270 stream << "MirSurface["<<(void*)surface()<<",\""<<surface()->name()<<"\"]";
271 } else {
272 stream << "null";
273 }
274 stream << "]";
275 }
276 return result;
277}

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 106 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.

◆ constrained

bool Window::constrained
readwrite

Whether the surface has been constrained in screen bounds already.

If false, the window state saver will constrain the window in bounds, and then set this property to true.

Definition at line 85 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 91 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 99 of file Window.h.


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