File indexing completed on 2022-11-29 15:04:34

0001 /*
0002     SPDX-FileCopyrightText: 2016 Smith AR <audoban@openmailbox.org>
0003     SPDX-FileCopyrightText: 2016 Michail Vourlakos <mvourlakos@gmail.com>
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef QUICKWINDOWSYSTEM_H
0008 #define QUICKWINDOWSYSTEM_H
0009 
0010 // Qt
0011 #include <QObject>
0012 #include <QQmlEngine>
0013 #include <QJSEngine>
0014 
0015 namespace Latte {
0016 
0017 /**
0018  * @brief The QuickWindowSystem class,
0019  * is a tiny class that provide basic information of WindowSystem
0020  */
0021 class QuickWindowSystem final : public QObject
0022 {
0023     Q_OBJECT
0024 
0025     Q_PROPERTY(bool compositingActive READ compositingActive NOTIFY compositingChanged FINAL)
0026     Q_PROPERTY(bool isPlatformWayland READ isPlatformWayland NOTIFY isPlatformWaylandChanged FINAL)
0027     Q_PROPERTY(bool isPlatformX11 READ isPlatformX11 NOTIFY isPlatformX11Changed FINAL)
0028 
0029 public:
0030     explicit QuickWindowSystem(QObject *parent = nullptr);
0031     virtual ~QuickWindowSystem();
0032 
0033     bool compositingActive() const;
0034     bool isPlatformWayland() const;
0035     bool isPlatformX11() const;
0036 
0037 signals:
0038     void compositingChanged();
0039     void isPlatformWaylandChanged();
0040     void isPlatformX11Changed();
0041 
0042 private:
0043     bool m_compositing{true};
0044 };
0045 
0046 static QObject *windowsystem_qobject_singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
0047 {
0048     Q_UNUSED(engine)
0049     Q_UNUSED(scriptEngine)
0050 
0051 // NOTE: QML engine is the owner of this resource
0052     return new QuickWindowSystem;
0053 }
0054 
0055 }
0056 
0057 #endif // QUICKWINDOWSYSTEM_H