~alan-griffiths/miral/an-alternative-touch-resize-algorithm

« back to all changes in this revision

Viewing changes to miral-qt/src/platforms/mirserver/sessionlistener.cpp

  • Committer: Alan Griffiths
  • Author(s): Gerry Boland
  • Date: 2016-06-02 10:40:16 UTC
  • mfrom: (177.1.1 miral-qt)
  • Revision ID: alan@octopull.co.uk-20160602104016-ti051tbupu1ab2d0
Import QtMir code into miral-qt subdirectory. Disabled by default, use -DMIRAL_ENABLE_QT=1 to build.

QtMir code largely untouched, only the build scripts changed to reflect the new directory and deal with cflags

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2013-2015 Canonical, Ltd.
 
3
 *
 
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.
 
7
 *
 
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.
 
12
 *
 
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/>.
 
15
 */
 
16
 
 
17
#include "sessionlistener.h"
 
18
#include "surfaceobserver.h"
 
19
#include "logging.h"
 
20
#include "tracepoints.h" // generated from tracepoints.tp
 
21
 
 
22
#include <mir/scene/surface.h>
 
23
 
 
24
namespace ms = mir::scene;
 
25
 
 
26
Q_DECLARE_METATYPE(std::shared_ptr<ms::Session>)
 
27
Q_DECLARE_METATYPE(std::shared_ptr<ms::Surface>)
 
28
 
 
29
SessionListener::SessionListener(QObject *parent) :
 
30
    QObject(parent)
 
31
{
 
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>();
 
38
}
 
39
 
 
40
SessionListener::~SessionListener()
 
41
{
 
42
    qCDebug(QTMIR_MIR_MESSAGES) << "SessionListener::~SessionListener - this=" << this;
 
43
}
 
44
 
 
45
void SessionListener::starting(std::shared_ptr<ms::Session> const& session)
 
46
{
 
47
    tracepoint(qtmirserver, starting);
 
48
    qCDebug(QTMIR_MIR_MESSAGES) << "SessionListener::starting - this=" << this << "session=" << session.get();
 
49
    Q_EMIT sessionStarting(session);
 
50
}
 
51
 
 
52
void SessionListener::stopping(std::shared_ptr<ms::Session> const& session)
 
53
{
 
54
    tracepoint(qtmirserver, stopping);
 
55
    qCDebug(QTMIR_MIR_MESSAGES) << "SessionListener::stopping - this=" << this << "session=" << session.get();
 
56
    Q_EMIT sessionStopping(session);
 
57
}
 
58
 
 
59
void SessionListener::focused(std::shared_ptr<ms::Session> const& session)
 
60
{
 
61
    qCDebug(QTMIR_MIR_MESSAGES) << "SessionListener::focused - this=" << this << "session=" << session.get();
 
62
    Q_EMIT sessionFocused(session);
 
63
}
 
64
 
 
65
void SessionListener::unfocused()
 
66
{
 
67
    qCDebug(QTMIR_MIR_MESSAGES) << "SessionListener::unfocused - this=" << this;
 
68
    Q_EMIT sessionUnfocused();
 
69
}
 
70
 
 
71
void SessionListener::surface_created(ms::Session& session, std::shared_ptr<ms::Surface> const& surface)
 
72
{
 
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);
 
79
 
 
80
    qtmir::CreationHints creationHints = m_creationHintsForNewSurface.take(&session);
 
81
 
 
82
    Q_EMIT sessionCreatedSurface(&session, surface, surfaceObserver, creationHints);
 
83
}
 
84
 
 
85
void SessionListener::destroying_surface(ms::Session& session, std::shared_ptr<ms::Surface> const& surface)
 
86
{
 
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);
 
91
}
 
92
 
 
93
void SessionListener::surfaceAboutToBeCreated(mir::scene::Session& session, qtmir::CreationHints creationHints)
 
94
{
 
95
    m_creationHintsForNewSurface[&session] = creationHints;
 
96
}