Unity 8
Window.h
1 /*
2  * Copyright (C) 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_WINDOW_H
18 #define UNITY_WINDOW_H
19 
20 #include <QLoggingCategory>
21 #include <QObject>
22 #include <QPoint>
23 
24 // Unity API
25 #include <unity/shell/application/Mir.h>
26 
27 namespace unity {
28  namespace shell {
29  namespace application {
30  class MirSurfaceInterface;
31  }
32  }
33 }
34 
35 
36 Q_DECLARE_LOGGING_CATEGORY(UNITY_WINDOW)
37 
38 
46 class Window : public QObject
47 {
48  Q_OBJECT
49 
53  Q_PROPERTY(QPoint position READ position NOTIFY positionChanged)
54 
55 
58  Q_PROPERTY(QPoint requestedPosition READ requestedPosition WRITE setRequestedPosition NOTIFY requestedPositionChanged)
59 
63  Q_PROPERTY(Mir::State state READ state NOTIFY stateChanged)
64 
70  Q_PROPERTY(bool focused READ focused NOTIFY focusedChanged)
71 
77  Q_PROPERTY(bool confinesMousePointer READ confinesMousePointer NOTIFY confinesMousePointerChanged)
78 
83  Q_PROPERTY(int id READ id CONSTANT)
84 
91  Q_PROPERTY(unity::shell::application::MirSurfaceInterface* surface READ surface NOTIFY surfaceChanged)
92 
93 public:
94  Window(int id, QObject *parent = nullptr);
95  virtual ~Window();
96  QPoint position() const;
97  QPoint requestedPosition() const;
98  void setRequestedPosition(const QPoint &);
99  Mir::State state() const;
100  bool focused() const;
101  bool confinesMousePointer() const;
102  int id() const;
103  unity::shell::application::MirSurfaceInterface* surface() const;
104 
105  void setSurface(unity::shell::application::MirSurfaceInterface *surface);
106  void setFocused(bool value);
107 
108  QString toString() const;
109 
110 public Q_SLOTS:
114  void requestState(Mir::State state);
115 
120  void close();
121 
125  void activate();
126 
127 Q_SIGNALS:
128  void closeRequested();
129  void emptyWindowActivated();
130 
131  void positionChanged(QPoint position);
132  void requestedPositionChanged(QPoint position);
133  void stateChanged(Mir::State value);
134  void focusedChanged(bool value);
135  void confinesMousePointerChanged(bool value);
136  void surfaceChanged(unity::shell::application::MirSurfaceInterface *surface);
137 
141  void focusRequested();
142 
143 private:
144  void updatePosition();
145  void updateState();
146  void updateFocused();
147 
148  QPoint m_position;
149  QPoint m_requestedPosition;
150  bool m_positionRequested{false};
151  bool m_focused{false};
152  int m_id;
153  Mir::State m_state{Mir::RestoredState};
154  bool m_stateRequested{false};
155  unity::shell::application::MirSurfaceInterface *m_surface{nullptr};
156 };
157 
158 QDebug operator<<(QDebug dbg, const Window *window);
159 
160 Q_DECLARE_METATYPE(Window*)
161 #endif // UNITY_WINDOW_H
A slightly higher concept than MirSurface.
Definition: Window.h:46