~alan-griffiths/miral/debug

« back to all changes in this revision

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

  • Committer: Gerry Boland
  • Date: 2016-06-01 22:06:51 UTC
  • mto: This revision was merged to the branch mainline in revision 178.
  • Revision ID: gerry.boland@canonical.com-20160601220651-ge508tffql4e7u7c
Import QtMir code into miral-qt subdirectory. Disabled by default, use -DMIRAL_ENABLE_QT=1 to build.

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 <mir/scene/surface_creation_parameters.h>
 
18
 
 
19
#include "creationhints.h"
 
20
 
 
21
using namespace qtmir;
 
22
 
 
23
inline const char* shellChromeToString(Mir::ShellChrome chrome) {
 
24
    switch (chrome) {
 
25
        case Mir::ShellChrome::NormalChrome:
 
26
            return "normal";
 
27
        case Mir::ShellChrome::LowChrome:
 
28
            return "low";
 
29
    }
 
30
    return "unknown";
 
31
}
 
32
 
 
33
CreationHints::CreationHints(const mir::scene::SurfaceCreationParameters &params)
 
34
{
 
35
    minWidth = params.min_width.is_set() ? params.min_width.value().as_int() : 0;
 
36
    maxWidth = params.max_width.is_set() ? params.max_width.value().as_int() : 0;
 
37
 
 
38
    minHeight = params.min_height.is_set() ? params.min_height.value().as_int() : 0;
 
39
    maxHeight = params.max_height.is_set() ? params.max_height.value().as_int() : 0;
 
40
 
 
41
    widthIncrement = params.width_inc.is_set() ? params.width_inc.value().as_int() : 0;
 
42
    heightIncrement = params.height_inc.is_set() ? params.height_inc.value().as_int() : 0;
 
43
 
 
44
    if (params.shell_chrome.is_set()) {
 
45
        switch (params.shell_chrome.value()) {
 
46
            case mir_shell_chrome_normal:
 
47
            default:
 
48
                shellChrome = Mir::ShellChrome::NormalChrome;
 
49
                break;
 
50
            case mir_shell_chrome_low:
 
51
                shellChrome = Mir::ShellChrome::LowChrome;
 
52
                break;
 
53
        }
 
54
    }
 
55
}
 
56
 
 
57
QString CreationHints::toString() const
 
58
{
 
59
    return QString("CreationHints(minW=%1,minH=%2,maxW=%3,maxH=%4,wIncr=%5,hInc=%6,shellChrome=%7)")
 
60
        .arg(minWidth)
 
61
        .arg(minHeight)
 
62
        .arg(maxWidth)
 
63
        .arg(maxHeight)
 
64
        .arg(widthIncrement)
 
65
        .arg(heightIncrement)
 
66
        .arg(shellChromeToString(shellChrome));
 
67
}