My Project
MirSurfaceInterface.h
1 /*
2  * Copyright (C) 2015-2016 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 UNITY_SHELL_APPLICATION_MIRSURFACE_H
18 #define UNITY_SHELL_APPLICATION_MIRSURFACE_H
19 
20 #include <QObject>
21 #include <QRect>
22 #include <QSize>
23 
24 #include "Mir.h"
25 
26 namespace unity
27 {
28 namespace shell
29 {
30 namespace application
31 {
32 
33 class MirSurfaceListInterface;
34 
41 class MirSurfaceInterface : public QObject
42 {
43  Q_OBJECT
44 
48  Q_PROPERTY(Mir::Type type READ type NOTIFY typeChanged)
49 
50 
53  Q_PROPERTY(QString name READ name NOTIFY nameChanged)
54 
58  Q_PROPERTY(QString persistentId READ persistentId CONSTANT)
59 
63  Q_PROPERTY(QString appId READ appId CONSTANT)
64 
68  Q_PROPERTY(QPoint position READ position NOTIFY positionChanged)
69 
73  Q_PROPERTY(QPoint requestedPosition READ requestedPosition WRITE setRequestedPosition NOTIFY requestedPositionChanged)
74 
78  Q_PROPERTY(QSize size READ size NOTIFY sizeChanged)
79 
83  Q_PROPERTY(Mir::State state READ state NOTIFY stateChanged)
84 
89  Q_PROPERTY(bool live READ live NOTIFY liveChanged)
90 
94  Q_PROPERTY(bool visible READ visible NOTIFY visibleChanged)
95 
101  Q_PROPERTY(Mir::OrientationAngle orientationAngle READ orientationAngle WRITE setOrientationAngle
102  NOTIFY orientationAngleChanged DESIGNABLE false)
103 
108  Q_PROPERTY(int minimumWidth READ minimumWidth NOTIFY minimumWidthChanged)
109 
114  Q_PROPERTY(int minimumHeight READ minimumHeight NOTIFY minimumHeightChanged)
115 
120  Q_PROPERTY(int maximumWidth READ maximumWidth NOTIFY maximumWidthChanged)
121 
126  Q_PROPERTY(int maximumHeight READ maximumHeight NOTIFY maximumHeightChanged)
127 
132  Q_PROPERTY(int widthIncrement READ widthIncrement NOTIFY widthIncrementChanged)
133 
138  Q_PROPERTY(int heightIncrement READ heightIncrement NOTIFY heightIncrementChanged)
139 
143  Q_PROPERTY(Mir::ShellChrome shellChrome READ shellChrome NOTIFY shellChromeChanged)
144 
149  Q_PROPERTY(QString keymap READ keymap WRITE setKeymap NOTIFY keymapChanged)
150 
156  Q_PROPERTY(bool focused READ focused NOTIFY focusedChanged)
157 
163  Q_PROPERTY(QRect inputBounds READ inputBounds NOTIFY inputBoundsChanged)
164 
170  Q_PROPERTY(bool confinesMousePointer READ confinesMousePointer NOTIFY confinesMousePointerChanged)
171 
177  Q_PROPERTY(bool allowClientResize READ allowClientResize WRITE setAllowClientResize NOTIFY allowClientResizeChanged)
178 
183 
190  Q_PROPERTY(unity::shell::application::MirSurfaceListInterface* childSurfaceList READ childSurfaceList CONSTANT)
191 
192 public:
194  MirSurfaceInterface(QObject *parent = nullptr) : QObject(parent) {}
195  virtual ~MirSurfaceInterface() {}
196 
197  virtual Mir::Type type() const = 0;
198 
199  virtual QString name() const = 0;
200 
201  virtual QString persistentId() const = 0;
202 
203  virtual QString appId() const = 0;
204 
205  virtual QPoint position() const = 0;
206 
207  virtual QSize size() const = 0;
208  virtual void resize(int width, int height) = 0;
209  virtual void resize(const QSize &size) = 0;
210 
211  virtual Mir::State state() const = 0;
212 
213  virtual bool live() const = 0;
214 
215  virtual bool visible() const = 0;
216 
217  virtual Mir::OrientationAngle orientationAngle() const = 0;
218  virtual void setOrientationAngle(Mir::OrientationAngle angle) = 0;
219 
220  virtual int minimumWidth() const = 0;
221  virtual int minimumHeight() const = 0;
222  virtual int maximumWidth() const = 0;
223  virtual int maximumHeight() const = 0;
224  virtual int widthIncrement() const = 0;
225  virtual int heightIncrement() const = 0;
226 
227  virtual void setKeymap(const QString &) = 0;
228  virtual QString keymap() const = 0;
229 
230  virtual Mir::ShellChrome shellChrome() const = 0;
231 
232  virtual bool focused() const = 0;
233 
234  virtual QRect inputBounds() const = 0;
235 
236  virtual bool confinesMousePointer() const = 0;
237 
238  virtual bool allowClientResize() const = 0;
239  virtual void setAllowClientResize(bool) = 0;
240 
241  virtual QPoint requestedPosition() const = 0;
242  virtual void setRequestedPosition(const QPoint &) = 0;
243 
244  virtual MirSurfaceInterface* parentSurface() const = 0;
245 
248 
253  Q_INVOKABLE virtual void close() = 0;
254 
260  Q_INVOKABLE virtual void activate() = 0;
261 
262 public Q_SLOTS:
266  virtual void requestState(Mir::State state) = 0;
267 
268 Q_SIGNALS:
270  void typeChanged(Mir::Type value);
271  void liveChanged(bool value);
272  void visibleChanged(bool visible);
273  void stateChanged(Mir::State value);
274  void orientationAngleChanged(Mir::OrientationAngle value);
275  void positionChanged(QPoint position);
276  void requestedPositionChanged(QPoint position);
277  void sizeChanged(const QSize &value);
278  void nameChanged(const QString &name);
279  void minimumWidthChanged(int value);
280  void minimumHeightChanged(int value);
281  void maximumWidthChanged(int value);
282  void maximumHeightChanged(int value);
283  void widthIncrementChanged(int value);
284  void heightIncrementChanged(int value);
285  void shellChromeChanged(Mir::ShellChrome value);
286  void keymapChanged(const QString &value);
287  void focusedChanged(bool value);
288  void inputBoundsChanged(QRect value);
289  void confinesMousePointerChanged(bool value);
290  void allowClientResizeChanged(bool value);
292 
298  void focusRequested();
299 
303  void closeRequested();
304 };
305 
306 } // namespace application
307 } // namespace shell
308 } // namespace unity
309 
311 
312 #endif // UNITY_SHELL_APPLICATION_MIRSURFACE_H
Mir::OrientationAngle
OrientationAngle
Surface orientation angle.
Definition: Mir.h:85
unity::shell::application::MirSurfaceInterface::requestState
virtual void requestState(Mir::State state)=0
Requests a change to the specified state.
Mir::ShellChrome
ShellChrome
Shell chrome.
Definition: Mir.h:96
unity::shell::application::MirSurfaceInterface::activate
virtual Q_INVOKABLE void activate()=0
Activates this surface.
unity::shell::application::MirSurfaceInterface::requestedPosition
QPoint requestedPosition
Requested position of the current surface buffer, in pixels.
Definition: MirSurfaceInterface.h:73
unity::shell::application::MirSurfaceInterface::close
virtual Q_INVOKABLE void close()=0
Sends a close request.
Mir
Acting mostly as a namespace to hold enums and such for use in QML.
Definition: Mir.h:25
unity::shell::application::MirSurfaceInterface::focused
bool focused
Whether the surface is focused.
Definition: MirSurfaceInterface.h:156
unity::shell::application::MirSurfaceInterface::live
bool live
True if it has a mir client bound to it. A "zombie" (live == false) surface never becomes alive again...
Definition: MirSurfaceInterface.h:89
unity::shell::application::MirSurfaceInterface::widthIncrement
int widthIncrement
The requested width increment for the surface Zero if not set.
Definition: MirSurfaceInterface.h:132
unity::shell::application::MirSurfaceInterface::shellChrome
Mir::ShellChrome shellChrome
The Shell chrome mode.
Definition: MirSurfaceInterface.h:143
unity::shell::application::MirSurfaceInterface::childSurfaceList
unity::shell::application::MirSurfaceListInterface childSurfaceList
The list of child surfaces.
Definition: MirSurfaceInterface.h:190
unity::shell::application::MirSurfaceInterface::orientationAngle
Mir::OrientationAngle orientationAngle
Orientation angle of the surface.
Definition: MirSurfaceInterface.h:102
unity::shell::application::MirSurfaceInterface
Holds a Mir surface. Pretty much an opaque class.
Definition: MirSurfaceInterface.h:41
unity::shell::application::MirSurfaceInterface::persistentId
QString persistentId
Persistent Id of the surface.
Definition: MirSurfaceInterface.h:58
unity::shell::application::MirSurfaceInterface::size
QSize size
Size of the current surface buffer, in pixels.
Definition: MirSurfaceInterface.h:78
unity
Top-level namespace for all things Unity-related.
Definition: Version.h:37
unity::shell::application::MirSurfaceInterface::minimumWidth
int minimumWidth
The requested minimum width for the surface Zero if not set.
Definition: MirSurfaceInterface.h:108
unity::shell::application::MirSurfaceInterface::maximumWidth
int maximumWidth
The requested maximum width for the surface Zero if not set.
Definition: MirSurfaceInterface.h:120
unity::shell::application::MirSurfaceInterface::maximumHeight
int maximumHeight
The requested maximum height for the surface Zero if not set.
Definition: MirSurfaceInterface.h:126
unity::shell::application::MirSurfaceInterface::allowClientResize
bool allowClientResize
Whether to comply to resize requests coming from the client side.
Definition: MirSurfaceInterface.h:177
unity::shell::application::MirSurfaceInterface::closeRequested
void closeRequested()
Emitted when close() is called.
unity::shell::application::MirSurfaceListInterface
Interface for a list model of MirSurfaces.
Definition: MirSurfaceListInterface.h:31
unity::shell::application::MirSurfaceInterface::position
QPoint position
Position of the current surface buffer, in pixels.
Definition: MirSurfaceInterface.h:68
unity::shell::application::MirSurfaceInterface::inputBounds
QRect inputBounds
Input bounds.
Definition: MirSurfaceInterface.h:163
unity::shell::application::MirSurfaceInterface::appId
QString appId
App Id of the app this surface belongs to.
Definition: MirSurfaceInterface.h:63
unity::shell::application::MirSurfaceInterface::heightIncrement
int heightIncrement
The requested height increment for the surface Zero if not set.
Definition: MirSurfaceInterface.h:138
unity::shell::application::MirSurfaceInterface::confinesMousePointer
bool confinesMousePointer
Whether the surface wants to confine the mouse pointer within its boundaries.
Definition: MirSurfaceInterface.h:170
unity::shell::application::MirSurfaceInterface::keymap
QString keymap
The requested keymap for this surface Its format is "layout+variant".
Definition: MirSurfaceInterface.h:149
unity::shell::application::MirSurfaceInterface::visible
bool visible
Visibility of the surface.
Definition: MirSurfaceInterface.h:94
unity::shell::application::MirSurfaceInterface::name
QString name
Name of the surface, given by the client application.
Definition: MirSurfaceInterface.h:53
unity::shell::application::MirSurfaceInterface::state
Mir::State state
State of the surface.
Definition: MirSurfaceInterface.h:83
Mir::Type
Type
Surface type.
Definition: Mir.h:47
unity::shell::application::MirSurfaceInterface::focusRequested
void focusRequested()
Emitted in response to a requestFocus() call.
unity::shell::application::MirSurfaceInterface::minimumHeight
int minimumHeight
The requested minimum height for the surface Zero if not set.
Definition: MirSurfaceInterface.h:114
unity::shell::application::MirSurfaceInterface::type
Mir::Type type
The surface type.
Definition: MirSurfaceInterface.h:48
Mir::State
State
Surface state.
Definition: Mir.h:64
unity::shell::application::MirSurfaceInterface::parentSurface
MirSurfaceInterface parentSurface
The parent MirSurface or null if this is a top-level surface.
Definition: MirSurfaceInterface.h:182