2
* Copyright (C) 2014-2015 Canonical, Ltd.
4
* This program is free software: you can redistribute it and/or modify it under
5
* the terms of the GNU Lesser General Public License version 3, as published by
6
* the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but WITHOUT
9
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
* Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
#ifndef SESSION_INTERFACE_H
18
#define SESSION_INTERFACE_H
24
#include <unity/shell/application/ApplicationInfoInterface.h>
27
#include "objectlistmodel.h"
28
#include "sessionmodel.h"
31
#include <QQmlListProperty>
41
class MirSurfaceInterface;
42
class MirSurfaceListModel;
45
class SessionInterface : public QObject {
48
Q_PROPERTY(unity::shell::application::ApplicationInfoInterface* application READ application NOTIFY applicationChanged DESIGNABLE false)
49
Q_PROPERTY(SessionModel* childSessions READ childSessions DESIGNABLE false CONSTANT)
50
Q_PROPERTY(bool fullscreen READ fullscreen NOTIFY fullscreenChanged)
51
Q_PROPERTY(bool live READ live NOTIFY liveChanged)
53
SessionInterface(QObject *parent = 0) : QObject(parent) {}
54
virtual ~SessionInterface() {}
65
virtual QString name() const = 0;
66
virtual unity::shell::application::ApplicationInfoInterface* application() const = 0;
68
// List of surfaces in this session. Surfaces that are being forcibly closed are not present in this list
69
virtual MirSurfaceListModel* surfaceList() = 0;
71
// List of prompt surfaces under this session (and its children)
72
virtual MirSurfaceListModel* promptSurfaceList() = 0;
74
virtual SessionModel* childSessions() const = 0;
75
virtual State state() const = 0;
76
virtual bool fullscreen() const = 0;
77
virtual bool live() const = 0;
79
virtual std::shared_ptr<mir::scene::Session> session() const = 0;
83
virtual void registerSurface(MirSurfaceInterface* surface) = 0;
85
// For Application use
87
virtual void setApplication(unity::shell::application::ApplicationInfoInterface* item) = 0;
88
virtual void suspend() = 0;
89
virtual void resume() = 0;
90
virtual void close() = 0;
91
virtual void stop() = 0;
92
virtual bool hadSurface() const = 0; // whether this session ever had any surface (currently or in the past)
93
virtual bool hasClosingSurfaces() const = 0; // whether it has surfaces being forcibly closed
94
virtual bool focused() const = 0; // whether any surface in its list is focused()
96
// Whether any of its MirSurfaces has activeFocus()
97
// See qtmir::MirSurfaceInterface::activeFocus
98
virtual bool activeFocus() const = 0;
100
virtual pid_t pid() const = 0;
102
// For SessionManager use
104
virtual void addChildSession(SessionInterface* session) = 0;
105
virtual void insertChildSession(uint index, SessionInterface* session) = 0;
106
virtual void removeChildSession(SessionInterface* session) = 0;
107
virtual void foreachChildSession(const std::function<void(SessionInterface* session)>& f) const = 0;
109
virtual PromptSession activePromptSession() const = 0;
110
virtual void foreachPromptSession(const std::function<void(const PromptSession&)>& f) const = 0;
112
virtual void setFullscreen(bool fullscreen) = 0;
113
virtual void setLive(const bool) = 0;
114
virtual void appendPromptSession(const PromptSession& session) = 0;
115
virtual void removePromptSession(const PromptSession& session) = 0;
118
void applicationChanged(unity::shell::application::ApplicationInfoInterface* application);
119
void stateChanged(State state);
120
void fullscreenChanged(bool fullscreen);
121
void liveChanged(bool live);
122
void focusedChanged(bool focused);
124
// Emitted when any surface in this session emits focusRequested()
125
void focusRequested();
127
// For Application use
128
void hasClosingSurfacesChanged();
133
Q_DECLARE_METATYPE(qtmir::SessionInterface*)
134
Q_DECLARE_METATYPE(qtmir::ObjectListModel<qtmir::MirSurfaceInterface>*)
136
#endif // SESSION_INTERFACE_H