File indexing completed on 2024-05-12 17:07:23

0001 /*
0002     SPDX-FileCopyrightText: 1999 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
0003     SPDX-FileCopyrightText: 2005 Lubos Lunak <l.lunak@kde.org>
0004     SPDX-FileCopyrightText: 2017 Xuetian Weng <wengxt@gmail.com>
0005     SPDX-FileCopyrightText: 2018 Roman Gilg <subdiff@gmail.com>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #include "backends/x11/x11_backend.h"
0011 
0012 #include <KWindowSystem>
0013 
0014 #include <QFile>
0015 #include <QGuiApplication>
0016 
0017 #include <QDebug>
0018 
0019 int main(int argc, char *argv[])
0020 {
0021     int ret = 0;
0022     QGuiApplication::setDesktopSettingsAware(false);
0023     QGuiApplication app(argc, argv);
0024     if (argc != 3)
0025         return 1;
0026     QString theme = QFile::decodeName(argv[1]);
0027     QString size = QFile::decodeName(argv[2]);
0028 
0029     if (!KWindowSystem::isPlatformX11()) {
0030         qDebug() << "X11 backend not detected. Exit.";
0031         return 2;
0032     }
0033 
0034     X11Backend *backend = X11Backend::implementation();
0035 
0036     if (!backend->isValid()) {
0037         return 2;
0038     }
0039 
0040     // Note: If you update this code, update main.cpp as well.
0041 
0042     // use a default value for theme only if it's not configured at all, not even in X resources
0043     if (theme.isEmpty() && backend->currentCursorTheme().isEmpty()) {
0044         theme = "breeze_cursors";
0045         ret = 10; // means to switch to default
0046     }
0047 
0048     backend->applyCursorTheme(theme, size.toInt());
0049 
0050     delete backend;
0051     return ret;
0052 }