2
* Copyright (C) 2016 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 "mirfocuscontroller.h"
19
#include "mirsurfaceinterface.h"
24
namespace unityapp = unity::shell::application;
25
using namespace qtmir;
27
#define DEBUG_MSG qCDebug(QTMIR_SURFACES).nospace() << "MirFocusController::" << __func__
29
MirFocusController *MirFocusController::m_instance = nullptr;
31
void MirFocusController::setFocusedSurface(unityapp::MirSurfaceInterface *unityAppSurface)
33
auto surface = static_cast<qtmir::MirSurfaceInterface*>(unityAppSurface);
35
if (m_focusedSurface == surface) {
39
DEBUG_MSG << "(" << surface << ")";
41
m_previouslyFocusedSurface = m_focusedSurface;
42
m_focusedSurface = surface;
44
if (m_previouslyFocusedSurface) {
45
m_previouslyFocusedSurface->setFocused(false);
48
if (m_focusedSurface) {
49
m_focusedSurface->setFocused(true);
50
m_focusedSurface->raise();
53
if (m_previouslyFocusedSurface != m_focusedSurface) {
54
Q_EMIT focusedSurfaceChanged();
58
unity::shell::application::MirSurfaceInterface* MirFocusController::focusedSurface() const
60
return m_focusedSurface;
63
MirFocusController* MirFocusController::instance()
66
m_instance = new MirFocusController;