2 * Copyright (C) 2015 Canonical, Ltd.
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.
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.
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/>.
17#include "MirSurface.h"
21MirSurface::MirSurface(const QString& name,
24 const QUrl& screenshot,
25 const QUrl &qmlFilePath)
26 : unity::shell::application::MirSurfaceInterface(nullptr)
30 , m_orientationAngle(Mir::Angle0)
31 , m_screenshotUrl(screenshot)
32 , m_qmlFilePath(qmlFilePath)
35 , m_activeFocus(false)
38 , m_slowToResize(false)
39 , m_shellChrome(Mir::NormalChrome)
41// qDebug() << "MirSurface::MirSurface() " << name;
42 m_delayedResizeTimer.setInterval(600);
43 m_delayedResizeTimer.setSingleShot(true);
44 connect(&m_delayedResizeTimer, &QTimer::timeout, this, &MirSurface::applyDelayedResize);
47MirSurface::~MirSurface()
49// qDebug() << "MirSurface::~MirSurface() " << name();
52QString MirSurface::name() const
57Mir::Type MirSurface::type() const
62Mir::State MirSurface::state() const
67void MirSurface::setState(Mir::State state)
73 Q_EMIT stateChanged(state);
76bool MirSurface::live() const
81bool MirSurface::visible() const
86void MirSurface::setLive(bool live)
88// qDebug().nospace() << "MirSurface::setLive("<<live<<") " << name();
93 Q_EMIT liveChanged(live);
95 if (!m_live && m_views.count() == 0) {
100QUrl MirSurface::qmlFilePath() const
102 return m_qmlFilePath;
105QUrl MirSurface::screenshotUrl() const
107 return m_screenshotUrl;
110void MirSurface::setScreenshotUrl(QUrl screenshotUrl)
112 if (screenshotUrl == m_screenshotUrl)
115 m_screenshotUrl = screenshotUrl;
116 Q_EMIT screenshotUrlChanged(screenshotUrl);
119Mir::OrientationAngle MirSurface::orientationAngle() const
121 return m_orientationAngle;
124void MirSurface::setOrientationAngle(Mir::OrientationAngle angle)
126 if (angle == m_orientationAngle)
129 m_orientationAngle = angle;
130 Q_EMIT orientationAngleChanged(angle);
134Mir::ShellChrome MirSurface::shellChrome() const
136 return m_shellChrome;
139void MirSurface::setShellChrome(Mir::ShellChrome shellChrome)
141 if (shellChrome == m_shellChrome)
144 m_shellChrome = shellChrome;
145 Q_EMIT shellChromeChanged(shellChrome);
150void MirSurface::registerView(qintptr viewId)
152 m_views.insert(viewId, MirSurface::View{false});
153// qDebug().nospace() << "MirSurface[" << name() << "]::registerView(" << viewId << ")"
154// << " after=" << m_views.count();
157void MirSurface::unregisterView(qintptr viewId)
159// qDebug().nospace() << "MirSurface[" << name() << "]::unregisterView(" << viewId << ")"
160// << " after=" << m_views.count() << " live=" << m_live;
161 m_views.remove(viewId);
162 if (!m_live && m_views.count() == 0) {
168void MirSurface::setViewVisibility(qintptr viewId, bool visible)
170 if (!m_views.contains(viewId)) return;
172 m_views[viewId].visible = visible;
176void MirSurface::updateVisibility()
178 bool newVisible = false;
179 QHashIterator<qintptr, View> i(m_views);
180 while (i.hasNext()) {
182 newVisible |= i.value().visible;
185 if (newVisible != visible()) {
186// qDebug().nospace() << "MirSurface[" << name() << "]::updateVisibility(" << newVisible << ")";
188 m_visible = newVisible;
189 Q_EMIT visibleChanged(m_visible);
193bool MirSurface::activeFocus() const
195 return m_activeFocus;
198void MirSurface::setActiveFocus(bool value)
200 if (m_activeFocus == value)
203 m_activeFocus = value;
205 Q_EMIT activeFocusChanged(value);
208int MirSurface::width() const
213int MirSurface::height() const
218void MirSurface::resize(int width, int height)
220 if (m_slowToResize) {
221 if (!m_delayedResizeTimer.isActive()) {
222 m_delayedResize.setWidth(width);
223 m_delayedResize.setHeight(height);
224 m_delayedResizeTimer.start();
226 m_pendingResize.setWidth(width);
227 m_pendingResize.setHeight(height);
230 doResize(width, height);
234void MirSurface::applyDelayedResize()
236 doResize(m_delayedResize.width(), m_delayedResize.height());
237 m_delayedResize.setWidth(-1);
238 m_delayedResize.setHeight(-1);
240 if (m_pendingResize.isValid()) {
241 QSize size = m_pendingResize;
242 m_pendingResize.setWidth(-1);
243 m_pendingResize.setHeight(-1);
244 resize(size.width(), size.height());
248void MirSurface::doResize(int width, int height)
250 bool changed = false;
252 if (width != m_width) {
254 Q_EMIT widthChanged();
258 if (m_height != height) {
260 Q_EMIT heightChanged();
265 Q_EMIT sizeChanged(QSize(width, height));
269bool MirSurface::isSlowToResize() const
271 return m_slowToResize;
274void MirSurface::setSlowToResize(bool value)
276 if (m_slowToResize != value) {
277 m_slowToResize = value;
278 Q_EMIT slowToResizeChanged();
279 if (!m_slowToResize && m_delayedResizeTimer.isActive()) {
280 m_delayedResizeTimer.stop();
281 applyDelayedResize();
286void MirSurface::setMinimumWidth(int value)
288 if (value != m_minimumWidth) {
289 m_minimumWidth = value;
290 Q_EMIT minimumWidthChanged(m_minimumWidth);
294void MirSurface::setMaximumWidth(int value)
296 if (value != m_maximumWidth) {
297 m_maximumWidth = value;
298 Q_EMIT maximumWidthChanged(m_maximumWidth);
302void MirSurface::setMinimumHeight(int value)
304 if (value != m_minimumHeight) {
305 m_minimumHeight = value;
306 Q_EMIT minimumHeightChanged(m_minimumHeight);
310void MirSurface::setMaximumHeight(int value)
312 if (value != m_maximumHeight) {
313 m_maximumHeight = value;
314 Q_EMIT maximumHeightChanged(m_maximumHeight);
318void MirSurface::setWidthIncrement(int value)
320 if (value != m_widthIncrement) {
321 m_widthIncrement = value;
322 Q_EMIT widthIncrementChanged(m_widthIncrement);
326void MirSurface::setHeightIncrement(int value)
328 if (value != m_heightIncrement) {
329 m_heightIncrement = value;
330 Q_EMIT heightIncrementChanged(m_heightIncrement);
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list