/*
* Copyright (C) 2015 Canonical, Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "MirSurface.h"
#include
MirSurface::MirSurface(const QString& name,
Mir::Type type,
Mir::State state,
const QUrl& screenshot,
const QString &qmlFilePath)
: unity::shell::application::MirSurfaceInterface(nullptr)
, m_name(name)
, m_type(type)
, m_state(state)
, m_orientationAngle(Mir::Angle0)
, m_screenshotUrl(screenshot)
, m_qmlFilePath(qmlFilePath)
, m_live(true)
, m_viewCount(0)
, m_activeFocus(false)
, m_width(-1)
, m_height(-1)
{
qDebug() << "MirSurface::MirSurface() " << name;
}
MirSurface::~MirSurface()
{
qDebug() << "MirSurface::~MirSurface() " << name();
}
QString MirSurface::name() const
{
return m_name;
}
Mir::Type MirSurface::type() const
{
return m_type;
}
Mir::State MirSurface::state() const
{
return m_state;
}
void MirSurface::setState(Mir::State state)
{
if (state == m_state)
return;
m_state = state;
Q_EMIT stateChanged(state);
}
bool MirSurface::live() const
{
return m_live;
}
void MirSurface::setLive(bool live)
{
qDebug().nospace() << "MirSurface::setLive("<= 0);
if (!m_live && m_viewCount == 0) {
deleteLater();
}
}
int MirSurface::viewCount() const
{
return m_viewCount;
}
bool MirSurface::activeFocus() const
{
return m_activeFocus;
}
void MirSurface::setActiveFocus(bool value)
{
if (m_activeFocus == value)
return;
m_activeFocus = value;
Q_EMIT activeFocusChanged(value);
}
int MirSurface::width() const
{
return m_width;
}
int MirSurface::height() const
{
return m_height;
}
void MirSurface::resize(int width, int height)
{
if (width != m_width) {
m_width = width;
Q_EMIT widthChanged();
}
if (m_height != height) {
m_height = height;
Q_EMIT heightChanged();
}
}