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))
39// qDebug() << "Session::Session() " << this->name();
41 QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
46// qDebug() << "Session::~Session() " << name();
48 QList<Session*> children(m_children->list());
49 for (Session* child : children) {
52 if (m_parentSession) {
53 m_parentSession->removeChildSession(this);
56 m_application->setSession(nullptr);
61 if (m_surface->viewCount() == 0) {
64 m_surface->setLive(false);
69void Session::release()
71// qDebug() << "Session::release " << name();
75void Session::updateFullscreenProperty()
77 if (m_surfaces.rowCount() > 0) {
78 // TODO: Figure out something better
79 setFullscreen(lastSurface()->state() == Mir::FullscreenState);
81 // Keep the current value of the fullscreen property until we get a new
86void Session::setFullscreen(bool fullscreen)
88 if (m_fullscreen != fullscreen) {
89 m_fullscreen = fullscreen;
90 Q_EMIT fullscreenChanged(m_fullscreen);
94void Session::setApplication(ApplicationInfo* application)
96 if (m_application == application)
99 m_application = application;
100 Q_EMIT applicationChanged(application);
103void Session::appendSurface(MirSurface* surface)
105 qDebug() << "Session::appendSurface - session=" << name() << "surface=" << surface;
107 m_surfaces.insert(m_surfaces.rowCount(), surface);
109 connect(surface, &MirSurfaceInterface::stateChanged, this, &Session::updateFullscreenProperty);
110 connect(surface, &QObject::destroyed,
111 this, [this, surface]() { this->removeSurface(surface); });
113 Q_EMIT lastSurfaceChanged(surface);
114 Q_EMIT surfaceAdded(surface);
116 updateFullscreenProperty();
119void Session::removeSurface(MirSurface* surface)
121 disconnect(surface, nullptr, this, nullptr);
122 if (m_surfaces.contains(surface)) {
123 m_surfaces.remove(surface);
126 updateFullscreenProperty();
129void Session::setScreenshot(const QUrl& screenshot)
131 if (screenshot != m_screenshot) {
132 m_screenshot = screenshot;
134 m_surface->setScreenshotUrl(m_screenshot);
139void Session::setLive(bool live)
141 if (m_live != live) {
143 Q_EMIT liveChanged(m_live);
147void Session::setParentSession(Session* session)
149 if (m_parentSession == session || session == this)
152 m_parentSession = session;
153 Q_EMIT parentSessionChanged(session);
156void Session::createSurface()
158 if (m_surface) return;
160 appendSurface(SurfaceManager::singleton()->createSurface(name(),
162 m_application && m_application->fullscreen() ? Mir::FullscreenState :
167void Session::addChildSession(Session* session)
169 insertChildSession(m_children->rowCount(), session);
172void Session::insertChildSession(uint index, Session* session)
174 qDebug() << "Session::insertChildSession - " << session->name() << " to " << name() << " @ " << index;
176 session->setParentSession(this);
177 m_children->insert(index, session);
178 SessionManager::singleton()->registerSession(session);
181void Session::removeChildSession(Session* session)
183 qDebug() << "Session::removeChildSession - " << session->name() << " from " << name();
185 if (m_children->contains(session)) {
186 m_children->remove(session);
187 session->setParentSession(nullptr);
188 Q_EMIT session->deregister();
192SessionModel* Session::childSessions() const
197ObjectListModel<MirSurface>* Session::surfaces() const
199 return const_cast<ObjectListModel<MirSurface>*>(&m_surfaces);
202MirSurface *Session::lastSurface() const
204 if (m_surfaces.rowCount() > 0) {
205 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