~alan-griffiths/miral/fix-1645284

« back to all changes in this revision

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

  • Committer: Alan Griffiths
  • Date: 2016-11-07 17:59:19 UTC
  • mfrom: (436.1.1 miral2)
  • Revision ID: alan@octopull.co.uk-20161107175919-stbb64i7j1htgog2
[miral-qt] delete all as qtmir work on MirAL has shifted to lp:~unity-team/qtmir/miral-qt-integration and this is a needless distration

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 SCREENCONTROLLER_H
18
 
#define SCREENCONTROLLER_H
19
 
 
20
 
#include <QObject>
21
 
#include <QPoint>
22
 
 
23
 
// Mir
24
 
#include <mir/graphics/display_configuration.h>
25
 
 
26
 
// std
27
 
#include <memory>
28
 
 
29
 
namespace mir {
30
 
    namespace graphics { class Display; }
31
 
    namespace compositor { class DisplayListener; }
32
 
}
33
 
class Screen;
34
 
class QWindow;
35
 
class QtCompositor;
36
 
 
37
 
/*
38
 
 * ScreensModel monitors the Mir display configuration and compositor status, and updates
39
 
 * the relevant QScreen and QWindow states accordingly.
40
 
 *
41
 
 * Primary purposes are:
42
 
 * 1. to update QScreen state on Mir display configuration changes
43
 
 * 2. to stop the Qt renderer by hiding its QWindow when Mir wants to stop all compositing,
44
 
 *    and resume Qt's renderer by showing its QWindow when Mir wants to resume compositing.
45
 
 *
46
 
 *
47
 
 * Threading Note:
48
 
 * This object must have affinity to the main Qt GUI thread, as it creates & destroys Platform
49
 
 * objects which Qt uses internally. However beware as the init() & terminate() methods need to
50
 
 * be called on the MirServerThread thread, as we need to monitor the screen state *after*
51
 
 * Mir has initialized but before Qt's event loop has started, and tear down before Mir terminates.
52
 
 * Also note the MirServerThread does not have an QEventLoop.
53
 
 *
54
 
 * All other methods must be called on the Qt GUI thread.
55
 
 */
56
 
 
57
 
class ScreensModel : public QObject
58
 
{
59
 
    Q_OBJECT
60
 
public:
61
 
    explicit ScreensModel(QObject *parent = 0);
62
 
 
63
 
    QList<Screen*> screens() const { return m_screenList; }
64
 
    bool compositing() const { return m_compositing; }
65
 
 
66
 
    QWindow* getWindowForPoint(QPoint point);
67
 
 
68
 
Q_SIGNALS:
69
 
    void screenAdded(Screen *screen);
70
 
    void screenRemoved(Screen *screen);
71
 
 
72
 
public Q_SLOTS:
73
 
    void update();
74
 
 
75
 
public:
76
 
    // called by MirServer
77
 
    void init(
78
 
        const std::shared_ptr<mir::graphics::Display>& display,
79
 
        const std::shared_ptr<QtCompositor>& compositor,
80
 
        const std::shared_ptr<mir::compositor::DisplayListener>& displayListener);
81
 
    void terminate();
82
 
 
83
 
    // override for testing purposes
84
 
    virtual Screen *createScreen(const mir::graphics::DisplayConfigurationOutput &output) const;
85
 
 
86
 
protected Q_SLOTS:
87
 
    void onCompositorStarting();
88
 
    void onCompositorStopping();
89
 
 
90
 
private:
91
 
    Screen* findScreenWithId(const QList<Screen*> &list, const mir::graphics::DisplayConfigurationOutputId id);
92
 
    bool canUpdateExistingScreen(const Screen *screen, const mir::graphics::DisplayConfigurationOutput &output);
93
 
    void allWindowsSetExposed(bool exposed);
94
 
 
95
 
    std::weak_ptr<mir::graphics::Display> m_display;
96
 
    std::shared_ptr<QtCompositor> m_compositor;
97
 
    std::shared_ptr<mir::compositor::DisplayListener> m_displayListener;
98
 
    QList<Screen*> m_screenList;
99
 
    bool m_compositing;
100
 
};
101
 
 
102
 
#endif // SCREENCONTROLLER_H