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);
60 if (m_surface->viewCount() == 0) {
63 m_surface->setLive(false);
68void Session::release()
70// qDebug() << "Session::release " << name();
74void Session::setApplication(ApplicationInfo* application)
76 if (m_application == application)
79 m_application = application;
80 Q_EMIT applicationChanged(application);
83void Session::appendSurface(MirSurface* surface)
85 // qDebug() << "Session::appendSurface - session=" << name() << "surface=" << surface;
87 m_surfaces.insert(m_surfaces.rowCount(), surface);
89 connect(surface, &QObject::destroyed,
90 this, [this, surface]() { this->removeSurface(surface); });
92 Q_EMIT lastSurfaceChanged(surface);
93 Q_EMIT surfaceAdded(surface);
96void Session::removeSurface(MirSurface* surface)
98 disconnect(surface, nullptr, this, nullptr);
99 if (m_surfaces.contains(surface)) {
100 m_surfaces.remove(surface);
104void Session::setScreenshot(const QUrl& screenshot)
106 if (screenshot != m_screenshot) {
107 m_screenshot = screenshot;
109 m_surface->setScreenshotUrl(m_screenshot);
114void Session::setLive(bool live)
116 if (m_live != live) {
118 Q_EMIT liveChanged(m_live);
122void Session::setParentSession(Session* session)
124 if (m_parentSession == session || session == this)
127 m_parentSession = session;
128 Q_EMIT parentSessionChanged(session);
131void Session::createSurface()
133 if (m_surface) return;
135 appendSurface(SurfaceManager::singleton()->createSurface(name(),
137 m_application && m_application->fullscreen() ? Mir::FullscreenState :
142void Session::addChildSession(Session* session)
144 insertChildSession(m_children->rowCount(), session);
147void Session::insertChildSession(uint index, Session* session)
149 qDebug() << "Session::insertChildSession - " << session->name() << " to " << name() << " @ " << index;
151 session->setParentSession(this);
152 m_children->insert(index, session);
153 SessionManager::singleton()->registerSession(session);
156void Session::removeChildSession(Session* session)
158 qDebug() << "Session::removeChildSession - " << session->name() << " from " << name();
160 if (m_children->contains(session)) {
161 m_children->remove(session);
162 session->setParentSession(nullptr);
163 Q_EMIT session->deregister();
167SessionModel* Session::childSessions() const
172ObjectListModel<MirSurface>* Session::surfaces() const
174 return const_cast<ObjectListModel<MirSurface>*>(&m_surfaces);
177MirSurface *Session::lastSurface() const
179 if (m_surfaces.rowCount() > 0) {
180 return m_surfaces.list().last();
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