mirror of
https://invent.kde.org/plasma/plasma-desktop.git
synced 2026-11-03 22:59:45 -09:00
KDE prefers explicit CMake options over a conditional build that depends on which headers are installed on the user's system. Two new options are introduced to turn the build for the X11 and KWin+Wayland backends on or off separately. The touchpad KCM will now build both backends by default, as before, but won't silently exclude kcm_touchpad from the build if any of its required X11_XCB/X11_Xi/XORGSERVER dependencies are missing. Instead, it will loudly fail CMake configuration with an error and a hint about the existence of the CMake option. Plus, don't leak in TouchpadBackend::implementation(). If the X11 implementation keeps a backend singleton and returns that, the KWin+Wayland implementation shouldn't keep creating new backends that are never deleted.
67 lines
1.9 KiB
C++
67 lines
1.9 KiB
C++
/*
|
|
SPDX-FileCopyrightText: 2017 Roman Gilg <subdiff@gmail.com>
|
|
SPDX-FileCopyrightText: 2013 Alexander Mezin <mezin.alexander@gmail.com>
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
|
|
#include "touchpadbackend.h"
|
|
|
|
#if BUILD_KCM_TOUCHPAD_KWIN_WAYLAND
|
|
#include "backends/kwin_wayland/kwinwaylandbackend.h"
|
|
#endif
|
|
#if BUILD_KCM_TOUCHPAD_X11
|
|
#include "backends/x11/xlibbackend.h"
|
|
#endif
|
|
|
|
#include "logging.h"
|
|
#include "touchpadparameters.h"
|
|
|
|
#include <QThreadStorage>
|
|
|
|
#include <KWindowSystem>
|
|
|
|
void touchpadApplySavedConfig()
|
|
{
|
|
TouchpadBackend *backend = TouchpadBackend::implementation();
|
|
if (!backend) {
|
|
return;
|
|
}
|
|
|
|
TouchpadParameters config;
|
|
backend->applyConfig(config.values());
|
|
}
|
|
|
|
void TouchpadBackend::setMode(TouchpadInputBackendMode mode)
|
|
{
|
|
m_mode = mode;
|
|
}
|
|
|
|
TouchpadBackend *TouchpadBackend::implementation()
|
|
{
|
|
// There are multiple possible backends
|
|
#if BUILD_KCM_TOUCHPAD_X11
|
|
if (KWindowSystem::isPlatformX11()) {
|
|
static QThreadStorage<std::shared_ptr<XlibBackend>> backend;
|
|
if (!backend.hasLocalData()) {
|
|
qCDebug(KCM_TOUCHPAD) << "Using X11 backend";
|
|
backend.setLocalData(std::shared_ptr<XlibBackend>(XlibBackend::initialize()));
|
|
}
|
|
return backend.localData().get();
|
|
}
|
|
#endif
|
|
#if BUILD_KCM_TOUCHPAD_KWIN_WAYLAND
|
|
// TODO: test on kwin_wayland specifically? What about possibly other compositors under Wayland?
|
|
if (KWindowSystem::isPlatformWayland()) {
|
|
static QThreadStorage<std::shared_ptr<KWinWaylandBackend>> backend;
|
|
if (!backend.hasLocalData()) {
|
|
qCDebug(KCM_TOUCHPAD) << "Using KWin+Wayland backend";
|
|
backend.setLocalData(std::shared_ptr<KWinWaylandBackend>(new KWinWaylandBackend()));
|
|
}
|
|
return backend.localData().get();
|
|
}
|
|
#endif
|
|
|
|
qCCritical(KCM_TOUCHPAD) << "Not able to select appropriate backend.";
|
|
return nullptr;
|
|
}
|