on 2066255 help sign in
unity8/tests/mocks/Unity/Application/SurfaceManager.cpp
118 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;
38 connect(m_virtualKeyboard, &QObject::destroyed, this, [this](QObject *obj) {
39 MirSurface* surface = qobject_cast<MirSurface*>(obj);
40 Q_EMIT inputMethodSurfaceChanged();
41 Q_EMIT surfaceDestroyed(surface);
42 });
45MirSurface *SurfaceManager::createSurface(const QString& name,
46 Mir::Type type,
47 Mir::State state,
48 const QUrl& screenshot)
50 MirSurface* surface = new MirSurface(name, type, state, screenshot);
51 connect(surface, &QObject::destroyed, this, [this](QObject *obj) {
52 MirSurface* surface = qobject_cast<MirSurface*>(obj);
53 Q_EMIT surfaceDestroyed(surface);
54 });
56 surface->setMinimumWidth(m_newSurfaceMinimumWidth);
57 surface->setMaximumWidth(m_newSurfaceMaximumWidth);
58 surface->setMinimumHeight(m_newSurfaceMinimumHeight);
59 surface->setMaximumHeight(m_newSurfaceMaximumHeight);
60 surface->setWidthIncrement(m_newSurfaceWidthIncrement);
61 surface->setHeightIncrement(m_newSurfaceHeightIncrement);
63 Q_EMIT surfaceCreated(surface);
64 return surface;
67MirSurface *SurfaceManager::inputMethodSurface() const
69 return m_virtualKeyboard;
72void SurfaceManager::setNewSurfaceMinimumWidth(int value)
74 if (m_newSurfaceMinimumWidth != value) {
75 m_newSurfaceMinimumWidth = value;
76 Q_EMIT newSurfaceMinimumWidthChanged(m_newSurfaceMinimumWidth);
77 }
80void SurfaceManager::setNewSurfaceMaximumWidth(int value)
82 if (m_newSurfaceMaximumWidth != value) {
83 m_newSurfaceMaximumWidth = value;
84 Q_EMIT newSurfaceMaximumWidthChanged(m_newSurfaceMaximumWidth);
85 }
88void SurfaceManager::setNewSurfaceMinimumHeight(int value)
90 if (m_newSurfaceMinimumHeight != value) {
91 m_newSurfaceMinimumHeight = value;
92 Q_EMIT newSurfaceMinimumHeightChanged(m_newSurfaceMinimumHeight);
93 }
96void SurfaceManager::setNewSurfaceMaximumHeight(int value)
98 if (m_newSurfaceMaximumHeight != value) {
99 m_newSurfaceMaximumHeight = value;
100 Q_EMIT newSurfaceMaximumHeightChanged(m_newSurfaceMaximumHeight);
101 }
104void SurfaceManager::setNewSurfaceWidthIncrement(int value)
106 if (m_newSurfaceWidthIncrement != value) {
107 m_newSurfaceWidthIncrement = value;
108 Q_EMIT newSurfaceWidthIncrementChanged(m_newSurfaceWidthIncrement);
109 }
112void SurfaceManager::setNewSurfaceHeightIncrement(int value)
114 if (m_newSurfaceHeightIncrement != value) {
115 m_newSurfaceHeightIncrement = value;
116 Q_EMIT newSurfaceHeightIncrementChanged(m_newSurfaceHeightIncrement);
117 }