Lomiri
Loading...
Searching...
No Matches
InputMethodManager.cpp
1/*
2 * Copyright (C) 2019 UBports Foundation
3 * Author(s) Marius Gripsgard <marius@ubports.com>
4 *
5 * This program is free software: you can redistribute it and/or modify it under
6 * the terms of the GNU Lesser General Public License version 3, as published by
7 * the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
11 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "InputMethodManager.h"
19#include <QDebug>
20
21#include <lomiri/shell/application/MirSurfaceInterface.h>
22
23// local
24#include "Window.h"
25
26Q_LOGGING_CATEGORY(INPUTMETHODMANAGER, "InputMethodManager", QtInfoMsg)
27#define DEBUG_MSG qCDebug(INPUTMETHODMANAGER).nospace().noquote() << __func__
28
29namespace lomiriapi = lomiri::shell::application;
30
31InputMethodManager *InputMethodManager::instance()
32{
33 static InputMethodManager* inputMethod(new InputMethodManager());
34 return inputMethod;
35}
36
37InputMethodManager::InputMethodManager()
38{
39}
40
41void InputMethodManager::setWindow(Window* window)
42{
43 if (window == m_inputMethodWindow) {
44 return;
45 }
46
47 DEBUG_MSG << "(" << window << ")";
48
49 m_inputMethodWindow = window;
50 Q_EMIT surfaceChanged(surface());
51}
52
53lomiriapi::MirSurfaceInterface* InputMethodManager::surface() const
54{
55 return m_inputMethodWindow ? m_inputMethodWindow->surface() : nullptr;
56}
A slightly higher concept than MirSurface.
Definition Window.h:48