~alan-griffiths/miral/fix-1645284

« back to all changes in this revision

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

  • 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) 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
 
#include "screenscontroller.h"
18
 
#include "screen.h"
19
 
#include "screensmodel.h"
20
 
 
21
 
// Mir
22
 
#include <mir/graphics/display.h>
23
 
#include <mir/shell/display_configuration_controller.h>
24
 
#include <mir/geometry/point.h>
25
 
 
26
 
namespace mg = mir::graphics;
27
 
 
28
 
ScreensController::ScreensController(const QSharedPointer<ScreensModel> &model,
29
 
        const std::shared_ptr<mir::graphics::Display> &display,
30
 
        const std::shared_ptr<mir::shell::DisplayConfigurationController> &controller,
31
 
        QObject *parent)
32
 
    : QObject(parent)
33
 
    , m_screensModel(model)
34
 
    , m_display(display)
35
 
    , m_displayConfigurationController(controller)
36
 
{
37
 
}
38
 
 
39
 
CustomScreenConfigurationList ScreensController::configuration()
40
 
{
41
 
    CustomScreenConfigurationList list;
42
 
 
43
 
    Q_FOREACH(auto screen, m_screensModel->screens()) {
44
 
        list.append(
45
 
            CustomScreenConfiguration {
46
 
                        screen->outputId(),
47
 
                        screen->geometry().topLeft(),
48
 
                        screen->currentModeIndex(),
49
 
                        screen->powerMode(),
50
 
                        mir_orientation_normal, //screen->orientation(), disable for now
51
 
                        screen->scale(),
52
 
                        screen->formFactor()
53
 
            });
54
 
    }
55
 
    return list;
56
 
}
57
 
 
58
 
bool ScreensController::setConfiguration(const CustomScreenConfigurationList &newConfig)
59
 
{
60
 
    using namespace mir::geometry;
61
 
 
62
 
    auto displayConfiguration = m_display->configuration();
63
 
 
64
 
    Q_FOREACH (const auto &config, newConfig) {
65
 
        displayConfiguration->for_each_output(
66
 
            [&config](mg::UserDisplayConfigurationOutput &outputConfig)
67
 
            {
68
 
                if (config.id == outputConfig.id) {
69
 
                    outputConfig.current_mode_index = config.currentModeIndex;
70
 
                    outputConfig.top_left = Point{ X{config.topLeft.x()}, Y{config.topLeft.y()}};
71
 
                    outputConfig.power_mode = config.powerMode;
72
 
//                    outputConfig.orientation = config.orientation; // disabling for now
73
 
                    outputConfig.scale = config.scale;
74
 
                    outputConfig.form_factor = config.formFactor;
75
 
                }
76
 
            });
77
 
    }
78
 
 
79
 
    if (!displayConfiguration->valid()) {
80
 
        return false;
81
 
    }
82
 
 
83
 
    m_displayConfigurationController->set_base_configuration(std::move(displayConfiguration));
84
 
    return true;
85
 
}