2
* Copyright (C) 2013-2015 Canonical, Ltd.
4
* This program is free software: you can redistribute it and/or modify it under
5
* the terms of the GNU Lesser General Public License version 3, as published by
6
* the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but WITHOUT
9
* ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10
* SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
* Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
#include "sessionlistener.h"
18
#include "surfaceobserver.h"
20
#include "tracepoints.h" // generated from tracepoints.tp
22
#include <mir/scene/surface.h>
24
namespace ms = mir::scene;
26
Q_DECLARE_METATYPE(std::shared_ptr<ms::Session>)
27
Q_DECLARE_METATYPE(std::shared_ptr<ms::Surface>)
29
SessionListener::SessionListener(QObject *parent) :
32
qCDebug(QTMIR_MIR_MESSAGES) << "SessionListener::SessionListener - this=" << this;
33
// need to register type to send over threads with signal/slot
34
qRegisterMetaType<std::shared_ptr<ms::Session>>("std::shared_ptr<mir::scene::Session>");
35
qRegisterMetaType<std::shared_ptr<ms::Surface>>("std::shared_ptr<mir::scene::Surface>");
36
qRegisterMetaType<std::shared_ptr<SurfaceObserver>>("std::shared_ptr<SurfaceObserver>");
37
qRegisterMetaType<qtmir::CreationHints>();
40
SessionListener::~SessionListener()
42
qCDebug(QTMIR_MIR_MESSAGES) << "SessionListener::~SessionListener - this=" << this;
45
void SessionListener::starting(std::shared_ptr<ms::Session> const& session)
47
tracepoint(qtmirserver, starting);
48
qCDebug(QTMIR_MIR_MESSAGES) << "SessionListener::starting - this=" << this << "session=" << session.get();
49
Q_EMIT sessionStarting(session);
52
void SessionListener::stopping(std::shared_ptr<ms::Session> const& session)
54
tracepoint(qtmirserver, stopping);
55
qCDebug(QTMIR_MIR_MESSAGES) << "SessionListener::stopping - this=" << this << "session=" << session.get();
56
Q_EMIT sessionStopping(session);
59
void SessionListener::focused(std::shared_ptr<ms::Session> const& session)
61
qCDebug(QTMIR_MIR_MESSAGES) << "SessionListener::focused - this=" << this << "session=" << session.get();
62
Q_EMIT sessionFocused(session);
65
void SessionListener::unfocused()
67
qCDebug(QTMIR_MIR_MESSAGES) << "SessionListener::unfocused - this=" << this;
68
Q_EMIT sessionUnfocused();
71
void SessionListener::surface_created(ms::Session& session, std::shared_ptr<ms::Surface> const& surface)
73
tracepoint(qtmirserver, surfaceCreated);
74
qCDebug(QTMIR_MIR_MESSAGES) << "SessionListener::surface_created - this=" << this << "session=" << &session
75
<< "surface=" << surface.get();
76
std::shared_ptr<SurfaceObserver> surfaceObserver = std::make_shared<SurfaceObserver>();
77
SurfaceObserver::registerObserverForSurface(surfaceObserver.get(), surface.get());
78
surface->add_observer(surfaceObserver);
80
qtmir::CreationHints creationHints = m_creationHintsForNewSurface.take(&session);
82
Q_EMIT sessionCreatedSurface(&session, surface, surfaceObserver, creationHints);
85
void SessionListener::destroying_surface(ms::Session& session, std::shared_ptr<ms::Surface> const& surface)
87
tracepoint(qtmirserver, surfaceDestroyed);
88
qCDebug(QTMIR_MIR_MESSAGES) << "SessionListener::destroying_surface - this=" << this << "session=" << &session
89
<< "surface=" << surface.get();
90
Q_EMIT sessionDestroyingSurface(&session, surface);
93
void SessionListener::surfaceAboutToBeCreated(mir::scene::Session& session, qtmir::CreationHints creationHints)
95
m_creationHintsForNewSurface[&session] = creationHints;