File indexing completed on 2024-02-25 17:23:57

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2017 Martin Flöser <mgraesslin@kde.org>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 #include "virtualkeyboard_dbus.h"
0010 #include <QDBusConnection>
0011 
0012 namespace KWin
0013 {
0014 
0015 VirtualKeyboardDBus::VirtualKeyboardDBus(InputMethod *parent)
0016     : QObject(parent)
0017     , m_inputMethod(parent)
0018 {
0019     QDBusConnection::sessionBus().registerObject(QStringLiteral("/VirtualKeyboard"), this,
0020                                                  QDBusConnection::ExportAllProperties | QDBusConnection::ExportScriptableContents | // qdbuscpp2xml doesn't support yet properties with NOTIFY
0021                                                      QDBusConnection::ExportAllSlots);
0022     connect(parent, &InputMethod::activeChanged, this, &VirtualKeyboardDBus::activeChanged);
0023     connect(parent, &InputMethod::enabledChanged, this, &VirtualKeyboardDBus::enabledChanged);
0024     connect(parent, &InputMethod::visibleChanged, this, &VirtualKeyboardDBus::visibleChanged);
0025     connect(parent, &InputMethod::availableChanged, this, &VirtualKeyboardDBus::availableChanged);
0026     connect(parent, &InputMethod::activeClientSupportsTextInputChanged, this, &VirtualKeyboardDBus::activeClientSupportsTextInputChanged);
0027 }
0028 
0029 VirtualKeyboardDBus::~VirtualKeyboardDBus() = default;
0030 
0031 bool VirtualKeyboardDBus::isActive() const
0032 {
0033     return m_inputMethod->isActive();
0034 }
0035 
0036 void VirtualKeyboardDBus::setEnabled(bool enabled)
0037 {
0038     m_inputMethod->setEnabled(enabled);
0039 }
0040 
0041 void VirtualKeyboardDBus::setActive(bool active)
0042 {
0043     m_inputMethod->setActive(active);
0044 }
0045 
0046 bool VirtualKeyboardDBus::isEnabled() const
0047 {
0048     return m_inputMethod->isEnabled();
0049 }
0050 
0051 bool VirtualKeyboardDBus::isVisible() const
0052 {
0053     return m_inputMethod->isVisible();
0054 }
0055 
0056 bool VirtualKeyboardDBus::isAvailable() const
0057 {
0058     return m_inputMethod->isAvailable();
0059 }
0060 
0061 bool VirtualKeyboardDBus::activeClientSupportsTextInput() const
0062 {
0063     return m_inputMethod->activeClientSupportsTextInput();
0064 }
0065 
0066 bool VirtualKeyboardDBus::willShowOnActive() const
0067 {
0068     return isAvailable() && isEnabled() && m_inputMethod->shouldShowOnActive();
0069 }
0070 
0071 void VirtualKeyboardDBus::forceActivate()
0072 {
0073     m_inputMethod->forceActivate();
0074 }
0075 }