~lukas-kde/miral/shellchrome-windowinfo

« back to all changes in this revision

Viewing changes to miral-qt/src/platforms/mirserver/qmirserver_p.h

  • Committer: Larry Price
  • Date: 2016-09-13 16:19:29 UTC
  • mto: (330.4.1 miral)
  • mto: This revision was merged to the branch mainline in revision 352.
  • Revision ID: larry.price@canonical.com-20160913161929-vs9ka1capmljq1es
Removing miral-qt from release branch, updating copyright file, and adding GPL3 license to root dir

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2015-2016 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
 
#ifndef QMIRSERVER_P_H
18
 
#define QMIRSERVER_P_H
19
 
 
20
 
// Qt
21
 
#include <QThread>
22
 
#include <QSharedPointer>
23
 
 
24
 
// std
25
 
#include <condition_variable>
26
 
#include <mutex>
27
 
 
28
 
// local
29
 
#include "openglcontextfactory.h"
30
 
#include "screensmodel.h"
31
 
#include "windowcontroller.h"
32
 
#include "windowmodelnotifier.h"
33
 
#include "sessionauthorizer.h"
34
 
#include "mirserverhooks.h"
35
 
 
36
 
//miral
37
 
#include <miral/application_authorizer.h>
38
 
#include <miral/runner.h>
39
 
 
40
 
class MirServerThread;
41
 
class QOpenGLContext;
42
 
 
43
 
namespace qtmir
44
 
{
45
 
using SetSessionAuthorizer = miral::SetApplicationAuthorizer<SessionAuthorizer>;
46
 
}
47
 
 
48
 
class QMirServerPrivate
49
 
{
50
 
public:
51
 
    QMirServerPrivate(int argc, char* argv[]);
52
 
    const QSharedPointer<ScreensModel> screensModel{new ScreensModel()};
53
 
    QSharedPointer<ScreensController> screensController;
54
 
    MirServerThread *serverThread;
55
 
 
56
 
    QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const;
57
 
 
58
 
    void run(const std::function<void()> &startCallback);
59
 
    void stop();
60
 
 
61
 
    SessionListener *sessionListener() const;
62
 
    PromptSessionListener *promptSessionListener() const;
63
 
    std::shared_ptr<mir::scene::PromptSessionManager> promptSessionManager() const;
64
 
 
65
 
    std::shared_ptr<SessionAuthorizer> theApplicationAuthorizer() const
66
 
        { return m_sessionAuthorizer.the_custom_application_authorizer(); }
67
 
 
68
 
    qtmir::WindowModelNotifierInterface *windowModelNotifier() const
69
 
        { return &m_windowModelNotifier; }
70
 
 
71
 
    qtmir::WindowControllerInterface *windowController() const
72
 
        { return &m_windowController; }
73
 
 
74
 
private:
75
 
    qtmir::SetSessionAuthorizer m_sessionAuthorizer;
76
 
    qtmir::OpenGLContextFactory m_openGLContextFactory;
77
 
    qtmir::MirServerHooks       m_mirServerHooks;
78
 
 
79
 
    miral::MirRunner runner;
80
 
 
81
 
    mutable qtmir::WindowModelNotifier m_windowModelNotifier;
82
 
    mutable qtmir::WindowController m_windowController;
83
 
    int &argc;
84
 
    char **argv;
85
 
};
86
 
 
87
 
class MirServerThread : public QThread
88
 
{
89
 
    Q_OBJECT
90
 
 
91
 
public:
92
 
    MirServerThread(QMirServerPrivate* server)
93
 
        : server(server)
94
 
    {}
95
 
 
96
 
    bool waitForMirStartup();
97
 
 
98
 
Q_SIGNALS:
99
 
    void stopped();
100
 
 
101
 
public Q_SLOTS:
102
 
    void run() override;
103
 
 
104
 
private:
105
 
    std::mutex mutex;
106
 
    std::condition_variable started_cv;
107
 
    bool mir_running{false};
108
 
 
109
 
    QMirServerPrivate* const server;
110
 
};
111
 
 
112
 
#endif // QMIRSERVER_P_H