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 "SessionManager.h"
20#include "SurfaceManager.h"
26Session::Session(const QString &name,
27 const QUrl& screenshot,
32 , m_screenshot(screenshot)
33 , m_application(nullptr)
35 , m_parentSession(nullptr)
36 , m_children(new SessionModel(this))
38 qDebug() << "Session::Session() " << this->name();
40 QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
45 qDebug() << "Session::~Session() " << name();
47 QList<Session*> children(m_children->list());
48 for (Session* child : children) {
51 if (m_parentSession) {
52 m_parentSession->removeChildSession(this);
55 m_application->setSession(nullptr);
61void Session::release()
63 qDebug() << "Session::release " << name();
65 if (m_parentSession) {
66 m_parentSession->removeChildSession(this);
69 m_application->setSession(nullptr);
76void Session::setApplication(ApplicationInfo* application)
78 if (m_application == application)
81 m_application = application;
82 Q_EMIT applicationChanged(application);
85void Session::setSurface(MirSurfaceItem* surface)
87 qDebug() << "Session::setSurface - session=" << name() << "surface=" << surface;
88 if (m_surface == surface)
92 m_surface->setSession(nullptr);
93 m_surface->setParent(nullptr);
94 Q_EMIT m_surface->deregister();
100 m_surface->setSession(this);
101 m_surface->setParent(this);
102 SurfaceManager::singleton()->registerSurface(m_surface);
105 Q_EMIT surfaceChanged(m_surface);
108void Session::setScreenshot(const QUrl& screenshot)
110 if (screenshot != m_screenshot) {
111 m_screenshot = screenshot;
113 m_surface->setScreenshot(m_screenshot);
118void Session::setLive(bool live)
120 if (m_live != live) {
122 Q_EMIT liveChanged(m_live);
126void Session::setParentSession(Session* session)
128 if (m_parentSession == session || session == this)
131 m_parentSession = session;
132 Q_EMIT parentSessionChanged(session);
135void Session::createSurface()
137 if (m_surface) return;
139 setSurface(SurfaceManager::singleton()->createSurface(name(),
140 MirSurfaceItem::Normal,
141 m_application && m_application->fullscreen() ? MirSurfaceItem::Fullscreen :
142 MirSurfaceItem::Maximized,
146void Session::addChildSession(Session* session)
148 insertChildSession(m_children->rowCount(), session);
151void Session::insertChildSession(uint index, Session* session)
153 qDebug() << "Session::insertChildSession - " << session->name() << " to " << name() << " @ " << index;
155 session->setParentSession(this);
156 m_children->insert(index, session);
157 SessionManager::singleton()->registerSession(session);
160void Session::removeChildSession(Session* session)
162 qDebug() << "Session::removeChildSession - " << session->name() << " from " << name();
164 if (m_children->contains(session)) {
165 m_children->remove(session);
166 session->setParentSession(nullptr);
167 Q_EMIT session->deregister();
171SessionModel* Session::childSessions() const
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