Changeset View
Changeset View
Standalone View
Standalone View
kcms/input/inputbackend.cpp
- This file was moved from kcms/input/mousebackend.cpp.
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | * Copyright 2017 Xuetian Weng <wengxt@gmail.com> | 2 | * Copyright 2017 Xuetian Weng <wengxt@gmail.com> | ||
3 | * Copyright 2018 Roman Gilg <subdiff@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 | */ | ||
19 | #include "inputbackend.h" | ||||
18 | 20 | | |||
19 | #include "mousebackend.h" | 21 | #include "backends/x11/x11_backend.h" | ||
20 | 22 | #include "backends/kwin_wl/kwin_wl_backend.h" | |||
21 | #include "backends/x11/x11mousebackend.h" | | |||
22 | #include "logging.h" | 23 | #include "logging.h" | ||
23 | 24 | | |||
24 | #include <QThreadStorage> | 25 | #include <KWindowSystem/kwindowsystem.h> | ||
25 | #include <QSharedPointer> | | |||
26 | | ||||
27 | #include <QGuiApplication> | | |||
28 | 26 | | |||
29 | MouseBackend *MouseBackend::implementation() | 27 | InputBackend *InputBackend::implementation(QObject *parent) | ||
30 | { | 28 | { | ||
31 | //There are multiple possible backends, always use X11 backend for now. | 29 | //There are multiple possible backends | ||
32 | static QThreadStorage<QSharedPointer<X11MouseBackend>> backend; | 30 | if (KWindowSystem::isPlatformX11()) { | ||
33 | if (!backend.hasLocalData()) { | | |||
34 | qCDebug(KCM_INPUT) << "Using X11 backend"; | 31 | qCDebug(KCM_INPUT) << "Using X11 backend"; | ||
35 | backend.setLocalData(QSharedPointer<X11MouseBackend>(new X11MouseBackend)); | 32 | return new X11Backend(parent); | ||
36 | } | 33 | } | ||
37 | return backend.localData().data(); | 34 | else if (KWindowSystem::isPlatformWayland()) { | ||
38 | 35 | qCDebug(KCM_INPUT) << "Using KWin+Wayland backend"; | |||
39 | #if 0 | 36 | return new KWinWaylandBackend(parent); | ||
37 | } | ||||
38 | else { | ||||
40 | qCCritical(KCM_INPUT) << "Not able to select appropriate backend."; | 39 | qCCritical(KCM_INPUT) << "Not able to select appropriate backend."; | ||
41 | return nullptr; | 40 | return nullptr; | ||
42 | #endif | 41 | } | ||
43 | } | 42 | } |