Changeset View
Changeset View
Standalone View
Standalone View
kcms/touchpad/src/touchpadbackend.cpp
- This file was copied to kcms/touchpad/src/kcm/libinput/components/ToolTip.qml.
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | * Copyright (C) 2013 Alexander Mezin <mezin.alexander@gmail.com> | 2 | * Copyright 2017 Roman Gilg <subdiff@gmail.com> | ||
3 | * Copyright 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 | ||
5 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | 7 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | 8 | * (at your option) any later version. | ||
8 | * | 9 | * | ||
9 | * This program is distributed in the hope that it will be useful, | 10 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. | ||
13 | * | 14 | * | ||
14 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | */ | 18 | */ | ||
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 | 28 | | |||
25 | #include "backends/x11/xlibbackend.h" | 29 | #include <KWindowSystem/kwindowsystem.h> | ||
26 | | ||||
27 | TouchpadBackend::TouchpadBackend(QObject *parent) : QObject(parent) | | |||
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 | if (KWindowSystem::isPlatformX11()) { | ||||
34 | static QThreadStorage<QSharedPointer<XlibBackend> > backend; | 35 | static QThreadStorage<QSharedPointer<XlibBackend> > backend; | ||
35 | if (!backend.hasLocalData()) { | 36 | if (!backend.hasLocalData()) { | ||
36 | if (QX11Info::isPlatformX11()) { | 37 | qCDebug(KCM_TOUCHPAD) << "Using X11 backend"; | ||
37 | backend.setLocalData(QSharedPointer<XlibBackend>(XlibBackend::initialize())); | 38 | backend.setLocalData(QSharedPointer<XlibBackend>(XlibBackend::initialize())); | ||
38 | } | 39 | } | ||
39 | } | | |||
40 | return backend.localData().data(); | 40 | return backend.localData().data(); | ||
41 | } | 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; | ||||
50 | } | ||||
51 | } |