2 * Copyright (C) 2014 Canonical, Ltd.
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.
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.
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/>.
18#include "ApplicationInfo.h"
19#include "SurfaceManager.h"
25Session::Session(const QString &name,
26 const QUrl& screenshot,
30 , m_screenshot(screenshot)
31 , m_application(nullptr)
33 , m_parentSession(nullptr)
34 , m_children(new SessionModel(this))
35 , m_manualSurfaceCreation(false)
37 qDebug() << "Session::Session() " << this->name();
39 QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
44 qDebug() << "Session::~Session() " << name();
46 QList<Session*> children(m_children->list());
47 for (Session* child : children) {
50 if (m_parentSession) {
51 m_parentSession->removeChildSession(this);
54 m_application->setSession(nullptr);
60void Session::release()
62 qDebug() << "Session::release " << name();
63 Q_EMIT aboutToBeDestroyed();
65 if (m_parentSession) {
66 m_parentSession->removeChildSession(this);
69 m_application->setSession(nullptr);
76void Session::setApplication(ApplicationInfo* application)
78 if (m_application == application)
82 disconnect(m_application, 0, this, 0);
85 m_application = application;
88 connect(m_application, &ApplicationInfo::stateChanged, this, [this](ApplicationInfo::State state) {
89 if (!m_manualSurfaceCreation && state == ApplicationInfo::Running) {
90 QTimer::singleShot(500, this, SLOT(createSurface()));
93 if (!m_manualSurfaceCreation && m_application->state() == ApplicationInfo::Running) {
94 QTimer::singleShot(500, this, SLOT(createSurface()));
99void Session::setSurface(MirSurfaceItem* surface)
101 qDebug() << "Session::setSurface - session=" << name() << "surface=" << surface;
102 if (m_surface == surface)
106 m_surface->setSession(nullptr);
107 m_surface->setParent(nullptr);
113 m_surface->setSession(this);
114 m_surface->setParent(this);
117 Q_EMIT surfaceChanged(m_surface);
120void Session::setScreenshot(const QUrl& screenshot)
122 if (screenshot != m_screenshot) {
123 m_screenshot = screenshot;
125 m_surface->setScreenshot(m_screenshot);
130void Session::setParentSession(Session* session)
132 if (m_parentSession == session || session == this)
135 m_parentSession = session;
136 Q_EMIT parentSessionChanged(session);
139void Session::createSurface()
141 if (m_surface) return;
143 setSurface(SurfaceManager::singleton()->createSurface(name(),
144 MirSurfaceItem::Normal,
145 m_application && m_application->fullscreen() ? MirSurfaceItem::Fullscreen : MirSurfaceItem::Maximized,
149void Session::addChildSession(Session* session)
151 insertChildSession(m_children->rowCount(), session);
154void Session::insertChildSession(uint index, Session* session)
156 qDebug() << "Session::insertChildSession - " << session->name() << " to " << name() << " @ " << index;
158 session->setParentSession(this);
159 m_children->insert(index, session);
162void Session::removeChildSession(Session* session)
164 qDebug() << "Session::removeChildSession - " << session->name() << " from " << name();
166 if (m_children->contains(session)) {
167 m_children->remove(session);
168 session->setParentSession(nullptr);
172SessionModel* Session::childSessions() const
177void Session::setManualSurfaceCreation(bool value)
179 if (value != m_manualSurfaceCreation) {
180 m_manualSurfaceCreation = value;
181 Q_EMIT manualSurfaceCreationChanged(value);
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list