kdeconnect-kde/plugins/mousepad/mousepadplugin.cpp
Albert Vaca Cintora 495e3019e4 Reduce number of optional dependencies
Change some optional dependencies from being optional to being mandatory
or being mandatory but behind on-by-default cmake flags. Eg: instead of
only compiling Wayland support if we find the appropriate libraries, we
always require the libraries unless the user specifies WITH_WAYLAND=OFF.

Optional libraries are hard to discover by packagers (since they don't
see an error once we add them) and create lots of possible build flavors
with a different features that can confuse users.
2023-07-19 17:08:03 +00:00

74 lines
1.8 KiB
C++

/**
* SPDX-FileCopyrightText: 2018 Albert Vaca Cintora <albertvaka@gmail.com>
* SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
* SPDX-FileCopyrightText: 2014 Ahmed I. Khalil <ahmedibrahimkhali@gmail.com>
*
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include "mousepadplugin.h"
#include <KLocalizedString>
#include <KPluginFactory>
#include <QGuiApplication>
#if defined(Q_OS_WIN)
#include "windowsremoteinput.h"
#elif defined(Q_OS_MACOS)
#include "macosremoteinput.h"
#else
#include "waylandremoteinput.h"
#if WITH_X11
#include "x11remoteinput.h"
#endif
#endif
K_PLUGIN_CLASS_WITH_JSON(MousepadPlugin, "kdeconnect_mousepad.json")
MousepadPlugin::MousepadPlugin(QObject *parent, const QVariantList &args)
: KdeConnectPlugin(parent, args)
, m_impl(nullptr)
{
#if defined(Q_OS_WIN)
m_impl = new WindowsRemoteInput(this);
#elif defined(Q_OS_APPLE)
m_impl = new MacOSRemoteInput(this);
#else
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) {
m_impl = new WaylandRemoteInput(this);
}
#if WITH_X11
if (QGuiApplication::platformName() == QLatin1String("xcb")) {
m_impl = new X11RemoteInput(this);
}
#endif
#endif
if (!m_impl) {
qDebug() << "KDE Connect was built without" << QGuiApplication::platformName() << "support";
}
}
MousepadPlugin::~MousepadPlugin()
{
delete m_impl;
}
bool MousepadPlugin::receivePacket(const NetworkPacket &np)
{
if (m_impl) {
return m_impl->handlePacket(np);
} else {
return false;
}
}
void MousepadPlugin::connected()
{
NetworkPacket np(PACKET_TYPE_MOUSEPAD_KEYBOARDSTATE);
if (m_impl) {
np.set<bool>(QStringLiteral("state"), m_impl->hasKeyboardSupport());
}
sendPacket(np);
}
#include "mousepadplugin.moc"