~alan-griffiths/miral/fix-1645284

« back to all changes in this revision

Viewing changes to miral-qt/src/modules/Unity/Application/session_interface.h

  • Committer: Alan Griffiths
  • Date: 2016-11-07 17:59:19 UTC
  • mfrom: (436.1.1 miral2)
  • Revision ID: alan@octopull.co.uk-20161107175919-stbb64i7j1htgog2
[miral-qt] delete all as qtmir work on MirAL has shifted to lp:~unity-team/qtmir/miral-qt-integration and this is a needless distration

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2014-2015 Canonical, Ltd.
3
 
 *
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.
7
 
 *
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.
12
 
 *
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/>.
15
 
 */
16
 
 
17
 
#ifndef SESSION_INTERFACE_H
18
 
#define SESSION_INTERFACE_H
19
 
 
20
 
#include <functional>
21
 
#include <memory>
22
 
 
23
 
// Unity API
24
 
#include <unity/shell/application/ApplicationInfoInterface.h>
25
 
 
26
 
// local
27
 
#include "objectlistmodel.h"
28
 
#include "sessionmodel.h"
29
 
 
30
 
// Qt
31
 
#include <QQmlListProperty>
32
 
 
33
 
namespace mir {
34
 
    namespace scene {
35
 
        class Session;
36
 
    }
37
 
}
38
 
 
39
 
namespace qtmir {
40
 
 
41
 
class MirSurfaceInterface;
42
 
class MirSurfaceListModel;
43
 
class PromptSession;
44
 
 
45
 
class SessionInterface : public QObject {
46
 
    Q_OBJECT
47
 
 
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)
52
 
public:
53
 
    SessionInterface(QObject *parent = 0) : QObject(parent) {}
54
 
    virtual ~SessionInterface() {}
55
 
 
56
 
    enum State {
57
 
        Starting,
58
 
        Running,
59
 
        Suspending,
60
 
        Suspended,
61
 
        Stopped
62
 
    };
63
 
 
64
 
    //getters
65
 
    virtual QString name() const = 0;
66
 
    virtual unity::shell::application::ApplicationInfoInterface* application() const = 0;
67
 
 
68
 
    // List of surfaces in this session. Surfaces that are being forcibly closed are not present in this list
69
 
    virtual MirSurfaceListModel* surfaceList() = 0;
70
 
 
71
 
    // List of prompt surfaces under this session (and its children)
72
 
    virtual MirSurfaceListModel* promptSurfaceList() = 0;
73
 
 
74
 
    virtual SessionModel* childSessions() const = 0;
75
 
    virtual State state() const = 0;
76
 
    virtual bool fullscreen() const = 0;
77
 
    virtual bool live() const = 0;
78
 
 
79
 
    virtual std::shared_ptr<mir::scene::Session> session() const = 0;
80
 
 
81
 
    // For MirSurface use
82
 
 
83
 
    virtual void registerSurface(MirSurfaceInterface* surface) = 0;
84
 
 
85
 
    // For Application use
86
 
 
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()
95
 
 
96
 
    // Whether any of its MirSurfaces has activeFocus()
97
 
    // See qtmir::MirSurfaceInterface::activeFocus
98
 
    virtual bool activeFocus() const = 0;
99
 
 
100
 
    virtual pid_t pid() const = 0;
101
 
 
102
 
    // For SessionManager use
103
 
 
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;
108
 
 
109
 
    virtual PromptSession activePromptSession() const = 0;
110
 
    virtual void foreachPromptSession(const std::function<void(const PromptSession&)>& f) const = 0;
111
 
 
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;
116
 
 
117
 
Q_SIGNALS:
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);
123
 
 
124
 
    // Emitted when any surface in this session emits focusRequested()
125
 
    void focusRequested();
126
 
 
127
 
    // For Application use
128
 
    void hasClosingSurfacesChanged();
129
 
};
130
 
 
131
 
} // namespace qtmir
132
 
 
133
 
Q_DECLARE_METATYPE(qtmir::SessionInterface*)
134
 
Q_DECLARE_METATYPE(qtmir::ObjectListModel<qtmir::MirSurfaceInterface>*)
135
 
 
136
 
#endif // SESSION_INTERFACE_H