on 3caee59 help sign in
unity8/tests/mocks/Unity/Application/SurfaceManager.cpp
119 lines 3.8 kB history raw
1/*
2 * Copyright (C) 2014-2015 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17#include "SurfaceManager.h"
19#include "VirtualKeyboard.h"
21#include <paths.h>
23SurfaceManager *SurfaceManager::the_surface_manager = nullptr;
25SurfaceManager *SurfaceManager::singleton()
27 if (!the_surface_manager) {
28 the_surface_manager = new SurfaceManager();
29 }
30 return the_surface_manager;
33SurfaceManager::SurfaceManager(QObject *parent) :
34 QObject(parent)
35 , m_virtualKeyboard(nullptr)
37 m_virtualKeyboard = new VirtualKeyboard(this);
38 connect(m_virtualKeyboard, &QObject::destroyed, this, [this](QObject *obj) {
39 MirSurface* surface = qobject_cast<MirSurface*>(obj);
40 m_virtualKeyboard = nullptr;
41 Q_EMIT inputMethodSurfaceChanged();
42 Q_EMIT surfaceDestroyed(surface);
43 });
46MirSurface *SurfaceManager::createSurface(const QString& name,
47 Mir::Type type,
48 Mir::State state,
49 const QUrl& screenshot)
51 MirSurface* surface = new MirSurface(name, type, state, screenshot);
52 connect(surface, &QObject::destroyed, this, [this](QObject *obj) {
53 MirSurface* surface = qobject_cast<MirSurface*>(obj);
54 Q_EMIT surfaceDestroyed(surface);
55 });
57 surface->setMinimumWidth(m_newSurfaceMinimumWidth);
58 surface->setMaximumWidth(m_newSurfaceMaximumWidth);
59 surface->setMinimumHeight(m_newSurfaceMinimumHeight);
60 surface->setMaximumHeight(m_newSurfaceMaximumHeight);
61 surface->setWidthIncrement(m_newSurfaceWidthIncrement);
62 surface->setHeightIncrement(m_newSurfaceHeightIncrement);
64 Q_EMIT surfaceCreated(surface);
65 return surface;
68MirSurface *SurfaceManager::inputMethodSurface() const
70 return m_virtualKeyboard;
73void SurfaceManager::setNewSurfaceMinimumWidth(int value)
75 if (m_newSurfaceMinimumWidth != value) {
76 m_newSurfaceMinimumWidth = value;
77 Q_EMIT newSurfaceMinimumWidthChanged(m_newSurfaceMinimumWidth);
78 }
81void SurfaceManager::setNewSurfaceMaximumWidth(int value)
83 if (m_newSurfaceMaximumWidth != value) {
84 m_newSurfaceMaximumWidth = value;
85 Q_EMIT newSurfaceMaximumWidthChanged(m_newSurfaceMaximumWidth);
86 }
89void SurfaceManager::setNewSurfaceMinimumHeight(int value)
91 if (m_newSurfaceMinimumHeight != value) {
92 m_newSurfaceMinimumHeight = value;
93 Q_EMIT newSurfaceMinimumHeightChanged(m_newSurfaceMinimumHeight);
94 }
97void SurfaceManager::setNewSurfaceMaximumHeight(int value)
99 if (m_newSurfaceMaximumHeight != value) {
100 m_newSurfaceMaximumHeight = value;
101 Q_EMIT newSurfaceMaximumHeightChanged(m_newSurfaceMaximumHeight);
102 }
105void SurfaceManager::setNewSurfaceWidthIncrement(int value)
107 if (m_newSurfaceWidthIncrement != value) {
108 m_newSurfaceWidthIncrement = value;
109 Q_EMIT newSurfaceWidthIncrementChanged(m_newSurfaceWidthIncrement);
110 }
113void SurfaceManager::setNewSurfaceHeightIncrement(int value)
115 if (m_newSurfaceHeightIncrement != value) {
116 m_newSurfaceHeightIncrement = value;
117 Q_EMIT newSurfaceHeightIncrementChanged(m_newSurfaceHeightIncrement);
118 }