Changeset View
Changeset View
Standalone View
Standalone View
kcms/touchpad/src/touchpadbackend.cpp
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | * Copyright (C) 2016 Roman Gilg <subdiff@gmail.com> | ||||
2 | * Copyright (C) 2013 Alexander Mezin <mezin.alexander@gmail.com> | 3 | * Copyright (C) 2013 Alexander Mezin <mezin.alexander@gmail.com> | ||
3 | * | 4 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | 5 | * This program is free software; you can redistribute it and/or modify | ||
Context not available. | |||||
18 | 19 | | |||
19 | #include "touchpadbackend.h" | 20 | #include "touchpadbackend.h" | ||
20 | 21 | | |||
22 | #include "backends/x11/xlibbackend.h" | ||||
23 | #include "backends/kwin_wayland/kwinwaylandbackend.h" | ||||
24 | #include "logging.h" | ||||
25 | | ||||
21 | #include <QThreadStorage> | 26 | #include <QThreadStorage> | ||
22 | #include <QSharedPointer> | 27 | #include <QSharedPointer> | ||
23 | #include <QX11Info> | | |||
24 | | ||||
25 | #include "backends/x11/xlibbackend.h" | | |||
26 | 28 | | |||
27 | TouchpadBackend::TouchpadBackend(QObject *parent) : QObject(parent) | 29 | #include <KWindowSystem/kwindowsystem.h> | ||
28 | { | | |||
29 | } | | |||
30 | 30 | | |||
31 | TouchpadBackend *TouchpadBackend::implementation() | 31 | TouchpadBackend *TouchpadBackend::implementation() | ||
32 | { | 32 | { | ||
33 | //There will be multiple backends later | 33 | //There are multiple possible backends | ||
34 | static QThreadStorage<QSharedPointer<XlibBackend> > backend; | 34 | if (KWindowSystem::isPlatformX11()) { | ||
35 | if (!backend.hasLocalData()) { | 35 | static QThreadStorage<QSharedPointer<XlibBackend> > backend; | ||
36 | if (QX11Info::isPlatformX11()) { | 36 | if (!backend.hasLocalData()) { | ||
37 | backend.setLocalData(QSharedPointer<XlibBackend>(XlibBackend::initialize())); | 37 | qCDebug(KCM_TOUCHPAD) << "Using X11 backend"; | ||
38 | } | 38 | backend.setLocalData(QSharedPointer<XlibBackend>(XlibBackend::initialize())); | ||
39 | } | ||||
40 | return backend.localData().data(); | ||||
41 | } | ||||
42 | // TODO: test on kwin_wayland specifically? What about possibly other compositors under Wayland? | ||||
43 | else if (KWindowSystem::isPlatformWayland()) { | ||||
44 | qCDebug(KCM_TOUCHPAD) << "Using KWin+Wayland backend"; | ||||
45 | return (new KWinWaylandBackend()); | ||||
46 | } | ||||
47 | else { | ||||
48 | qCCritical(KCM_TOUCHPAD) << "Not able to select appropriate backend."; | ||||
49 | return nullptr; | ||||
39 | } | 50 | } | ||
40 | return backend.localData().data(); | | |||
41 | } | 51 | } | ||
Context not available. |