blob: bb2e4d6628a71deb320e1da7987c016d4b26984f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
/*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License version 3, as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <Unity/Application/session_interface.h>
#ifndef QTMIR_FAKE_SESSION_H
#define QTMIR_FAKE_SESSION_H
namespace qtmir {
class FakeSession : public SessionInterface {
Q_OBJECT
public:
FakeSession()
: SessionInterface(0)
, m_state(Starting)
{
}
// For QML use
void release() override {}
QString name() const override { return QString("foo-session"); }
unity::shell::application::ApplicationInfoInterface* application() const override { return m_application; }
MirSurfaceItemInterface* surface() const override { return nullptr; }
SessionInterface* parentSession() const override { return nullptr; }
SessionModel* childSessions() const override { return nullptr; }
State state() const override { return m_state; }
bool fullscreen() const override { return false; }
bool live() const override { return true; }
std::shared_ptr<mir::scene::Session> session() const override { return nullptr; }
// For MirSurfaceItem and MirSurfaceManager use
void setSurface(MirSurfaceItemInterface*) override {}
// For Application use
void setApplication(unity::shell::application::ApplicationInfoInterface* app) override {
if (m_application != app) {
m_application = app;
Q_EMIT applicationChanged(m_application);
}
}
void suspend() override {
if (m_state == Running) {
setState(Suspending);
}
}
void resume() override {
if (m_state == Suspending || m_state == Suspended) {
setState(Running);
}
}
void stop() override {
setState(Stopped);
}
// For SessionManager use
void addChildSession(SessionInterface*) override {}
void insertChildSession(uint, SessionInterface*) override {}
void removeChildSession(SessionInterface*) override {}
void foreachChildSession(std::function<void(SessionInterface* session)>) const override {}
std::shared_ptr<mir::scene::PromptSession> activePromptSession() const override {
return std::shared_ptr<mir::scene::PromptSession>();
}
void foreachPromptSession(std::function<void(const std::shared_ptr<mir::scene::PromptSession>&)>) const override {}
void setFullscreen(bool) override {}
void setLive(const bool) override {}
void appendPromptSession(const std::shared_ptr<mir::scene::PromptSession>&) override {}
void removePromptSession(const std::shared_ptr<mir::scene::PromptSession>&) override {}
// For tests
void setState(State state) {
if (m_state != state) {
m_state = state;
Q_EMIT stateChanged(m_state);
}
}
private:
unity::shell::application::ApplicationInfoInterface* m_application;
State m_state;
};
} // namespace qtmi
#endif // QTMIR_FAKE_SESSION_H
|