File indexing completed on 2024-12-29 05:17:37

0001 /*
0002  * App to render feeds coming from xdg-desktop-portal
0003  *
0004  * SPDX-License-Identifier: LicenseRef-KDE-Accepted-GPL
0005  * SPDX-FileCopyrightText: 2023 David Edmundson <kde@davidedmundson.co.uk>
0006  * SPDX-FileCopyrightText: 2023 Aleix Pol <aleixpol@kde.org>
0007  */
0008 
0009 #include "xwaylandvideobridge.h"
0010 #include "version.h"
0011 
0012 #include <QApplication>
0013 #include <QCommandLineParser>
0014 #include <QSessionManager>
0015 #include <QIcon>
0016 #include <KLocalizedString>
0017 #include <KAboutData>
0018 
0019 int main(int argc, char **argv)
0020 {
0021     if (qgetenv("XDG_SESSION_TYPE") == "x11") {
0022         return 0;
0023     }
0024     qputenv("QT_QPA_PLATFORM", "xcb");
0025     qputenv("QT_XCB_GL_INTEGRATION", "xcb_egl");
0026 
0027     qputenv("QT_QPA_UPDATE_IDLE_TIME", "0");
0028     qputenv("QSG_RENDER_LOOP", "basic");
0029     QApplication app(argc, argv); // widgets are needed just for the SNI.
0030     app.setAttribute(Qt::AA_UseHighDpiPixmaps);
0031 
0032      auto disableSessionManagement = [](QSessionManager &sm) {
0033         sm.setRestartHint(QSessionManager::RestartNever);
0034     };
0035     QObject::connect(&app, &QGuiApplication::commitDataRequest, disableSessionManagement);
0036     QObject::connect(&app, &QGuiApplication::saveStateRequest, disableSessionManagement);
0037 
0038     KLocalizedString::setApplicationDomain("xwaylandvideobridge");
0039     {
0040         KAboutData about("xwaylandvideobridge", i18n("Xwayland Video Bridge"), version, i18n("Offer XDG Desktop Portals screencast streams to X11 apps"),
0041                          KAboutLicense::GPL, i18n("(C) 2022 Aleix Pol Gonzalez"));
0042 
0043         about.addAuthor("Aleix Pol Gonzalez", i18n("Author"), "aleixpol@kde.org" );
0044         about.addAuthor("David Edmundson", i18n("Author"), "davidedmundson@kde.org" );
0045 
0046         KAboutData::setApplicationData(about);
0047         QGuiApplication::setWindowIcon(QIcon::fromTheme(QStringLiteral("xwaylandvideobridge"), app.windowIcon()));
0048 
0049         QCommandLineParser parser;
0050         about.setupCommandLine(&parser);
0051         parser.process(app);
0052         about.processCommandLine(&parser);
0053 
0054         new XwaylandVideoBridge(&app);
0055     }
0056     return app.exec();
0057 }