2
* Copyright (C) 2015-2016 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
#ifndef SCREENCONTROLLER_H
18
#define SCREENCONTROLLER_H
24
#include <mir/graphics/display_configuration.h>
30
namespace graphics { class Display; }
31
namespace compositor { class DisplayListener; }
38
* ScreensModel monitors the Mir display configuration and compositor status, and updates
39
* the relevant QScreen and QWindow states accordingly.
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.
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.
54
* All other methods must be called on the Qt GUI thread.
57
class ScreensModel : public QObject
61
explicit ScreensModel(QObject *parent = 0);
63
QList<Screen*> screens() const { return m_screenList; }
64
bool compositing() const { return m_compositing; }
66
QWindow* getWindowForPoint(QPoint point);
69
void screenAdded(Screen *screen);
70
void screenRemoved(Screen *screen);
76
// called by MirServer
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);
83
// override for testing purposes
84
virtual Screen *createScreen(const mir::graphics::DisplayConfigurationOutput &output) const;
87
void onCompositorStarting();
88
void onCompositorStopping();
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);
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;
102
#endif // SCREENCONTROLLER_H