on 747a319 help sign in
140 lines 4.0 kB history raw
1/*
2 * Copyright (C) 2017 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 */
17#include "Screen.h"
18#include "WorkspaceModel.h"
19#include "WorkspaceManager.h"
20#include "Workspace.h"
22Screen::Screen(qtmir::Screen* screen)
23 : m_wrapped(screen)
24 , m_workspaces(new WorkspaceModel)
26 connect(m_wrapped, &qtmir::Screen::usedChanged, this, &Screen::usedChanged);
27 connect(m_wrapped, &qtmir::Screen::nameChanged, this, &Screen::nameChanged);
28 connect(m_wrapped, &qtmir::Screen::outputTypeChanged, this, &Screen::outputTypeChanged);
29 connect(m_wrapped, &qtmir::Screen::scaleChanged, this, &Screen::scaleChanged);
30 connect(m_wrapped, &qtmir::Screen::formFactorChanged, this, &Screen::formFactorChanged);
31 connect(m_wrapped, &qtmir::Screen::physicalSizeChanged, this, &Screen::physicalSizeChanged);
32 connect(m_wrapped, &qtmir::Screen::positionChanged, this, &Screen::positionChanged);
33 connect(m_wrapped, &qtmir::Screen::activeChanged, this, &Screen::activeChanged);
34 connect(m_wrapped, &qtmir::Screen::currentModeIndexChanged, this, &Screen::currentModeIndexChanged);
35 connect(m_wrapped, &qtmir::Screen::availableModesChanged, this, &Screen::availableModesChanged);
37 // Connect the active workspace to activate the screen.
38 connect(m_workspaces.data(), &WorkspaceModel::workspaceAdded, this, [this](Workspace* workspace) {
39 connect(workspace, &Workspace::activeChanged, this, [this](bool active) {
40 if (active) activate();
41 });
42 if (workspace->isActive()) activate();
43 });
44 connect(m_workspaces.data(), &WorkspaceModel::workspaceRemoved, this, [this](Workspace* workspace) {
45 disconnect(workspace, &Workspace::activeChanged, this, 0);
46 });
48 WorkspaceManager::instance()->createWorkspace()->assign(m_workspaces.data());
49 WorkspaceManager::instance()->createWorkspace()->assign(m_workspaces.data());
52qtmir::OutputId Screen::outputId() const
54 return m_wrapped->outputId();
57bool Screen::used() const
59 return m_wrapped->used();
62QString Screen::name() const
64 return m_wrapped->name();
67float Screen::scale() const
69 return m_wrapped->scale();
72QSizeF Screen::physicalSize() const
74 return m_wrapped->physicalSize();
77qtmir::FormFactor Screen::formFactor() const
79 return m_wrapped->formFactor();
82qtmir::OutputTypes Screen::outputType() const
84 return m_wrapped->outputType();
87MirPowerMode Screen::powerMode() const
89 return m_wrapped->powerMode();
92Qt::ScreenOrientation Screen::orientation() const
94 return m_wrapped->orientation();
97QPoint Screen::position() const
99 return m_wrapped->position();
102QQmlListProperty<qtmir::ScreenMode> Screen::availableModes()
104 return m_wrapped->availableModes();
107uint Screen::currentModeIndex() const
109 return m_wrapped->currentModeIndex();
112bool Screen::isActive() const
114 return m_wrapped->isActive();
117qtmir::ScreenConfiguration *Screen::beginConfiguration() const
119 return m_wrapped->beginConfiguration();
122bool Screen::applyConfiguration(qtmir::ScreenConfiguration *configuration)
124 return m_wrapped->applyConfiguration(configuration);
127void Screen::activate()
129 setActive(true);
132void Screen::setActive(bool active)
134 m_wrapped->setActive(active);
137QScreen *Screen::qscreen() const
139 return m_wrapped->qscreen();