Lomiri
Loading...
Searching...
No Matches
Window.h
1/*
2 * Copyright (C) 2016-2017 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef LOMIRI_WINDOW_H
18#define LOMIRI_WINDOW_H
19
20#include <QLoggingCategory>
21#include <QObject>
22#include <QPoint>
23
24// Lomiri API
25#include <lomiri/shell/application/Mir.h>
26
27#include "WindowManagerGlobal.h"
28
29namespace lomiri {
30 namespace shell {
31 namespace application {
32 class MirSurfaceInterface;
33 }
34 }
35}
36
37Q_DECLARE_LOGGING_CATEGORY(LOMIRI_WINDOW)
38
39
47class WINDOWMANAGERQML_EXPORT Window : public QObject
48{
49 Q_OBJECT
50
54 Q_PROPERTY(QPoint position READ position NOTIFY positionChanged)
55
56
59 Q_PROPERTY(QPoint requestedPosition READ requestedPosition WRITE setRequestedPosition NOTIFY requestedPositionChanged)
60
64 Q_PROPERTY(Mir::State state READ state NOTIFY stateChanged)
65
71 Q_PROPERTY(bool focused READ focused NOTIFY focusedChanged)
72
78 Q_PROPERTY(bool confinesMousePointer READ confinesMousePointer NOTIFY confinesMousePointerChanged)
79
85 Q_PROPERTY(bool constrained READ constrained WRITE setConstrained NOTIFY constrainedChanged)
86
91 Q_PROPERTY(int id READ id CONSTANT)
92
99 Q_PROPERTY(lomiri::shell::application::MirSurfaceInterface* surface READ surface NOTIFY surfaceChanged)
100
106 Q_PROPERTY(bool allowClientResize READ allowClientResize WRITE setAllowClientResize NOTIFY allowClientResizeChanged)
107
108public:
109 Window(int id, QObject *parent = nullptr);
110 virtual ~Window();
111 QPoint position() const;
112 QPoint requestedPosition() const;
113 void setRequestedPosition(const QPoint &);
114 Mir::State state() const;
115 bool focused() const;
116 bool confinesMousePointer() const;
117 bool constrained() const;
118 int id() const;
119 lomiri::shell::application::MirSurfaceInterface* surface() const;
120
121 void setSurface(lomiri::shell::application::MirSurfaceInterface *surface);
122 void setFocused(bool value);
123 void setConstrained(bool value);
124
125 bool allowClientResize() const;
126 void setAllowClientResize(bool);
127
128 QString toString() const;
129
130public Q_SLOTS:
134 void requestState(Mir::State state);
135
140 void close();
141
145 void activate();
146
147Q_SIGNALS:
148 void closeRequested();
149 void emptyWindowActivated();
150
151 void positionChanged(QPoint position);
152 void requestedPositionChanged(QPoint position);
153 void stateChanged(Mir::State value);
154 void focusedChanged(bool value);
155 void confinesMousePointerChanged(bool value);
156 void constrainedChanged(bool value);
157 void surfaceChanged(lomiri::shell::application::MirSurfaceInterface *surface);
158 void allowClientResizeChanged(bool value);
159 void liveChanged(bool value);
160
165
166private:
167 void updatePosition();
168 void updateState();
169 void updateFocused();
170
171 QPoint m_position;
172 QPoint m_requestedPosition;
173 bool m_positionRequested{false};
174 bool m_focused{false};
175 bool m_constrained{false};
176 int m_id;
177 Mir::State m_state{Mir::RestoredState};
178 bool m_stateRequested{false};
179 lomiri::shell::application::MirSurfaceInterface *m_surface{nullptr};
180
181 bool m_allowClientResize{true};
182};
183
184QDebug operator<<(QDebug dbg, const Window *window);
185
186Q_DECLARE_METATYPE(Window*)
187#endif // LOMIRI_WINDOW_H
A slightly higher concept than MirSurface.
Definition Window.h:48
bool allowClientResize
Whether to comply to resize requests coming from the client side.
Definition Window.h:106
void requestState(Mir::State state)
Requests a change to the specified state.
Definition Window.cpp:122
void focusRequested()
Emitted when focus for this window is requested by an external party.
void close()
Sends a close request.
Definition Window.cpp:133
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
QPoint requestedPosition
Requested position of the current surface buffer, in pixels.
Definition Window.h:59
bool confinesMousePointer
Whether the surface wants to confine the mouse pointer within its boundaries.
Definition Window.h:78
QPoint position
Position of the current surface buffer, in pixels.
Definition Window.h:54
bool focused
Whether the surface is focused.
Definition Window.h:71
bool constrained
Whether the surface has been constrained in screen bounds already.
Definition Window.h:85
void activate()
Focuses and raises the window.
Definition Window.cpp:142
Mir::State state
State of the surface.
Definition Window.h:64