#pragma once #include #include #include #include #include // Small facts about the host that QML needs in order to pick window flags, // plus the input-region call that makes an overlay window click-through. class PlatformInfo : public QObject { Q_OBJECT QML_NAMED_ELEMENT(Platform) QML_SINGLETON Q_PROPERTY(QString name READ name CONSTANT) Q_PROPERTY(bool isX11 READ isX11 CONSTANT) Q_PROPERTY(bool isWayland READ isWayland CONSTANT) Q_PROPERTY(bool overlayMode READ overlayMode CONSTANT) Q_PROPERTY(bool bypassWindowManager READ bypassWindowManager CONSTANT) Q_PROPERTY(bool opaqueBackground READ opaqueBackground CONSTANT) public: explicit PlatformInfo(QObject *parent = nullptr); QString name() const { return m_name; } bool isX11() const { return m_name == QLatin1String("xcb"); } bool isWayland() const { return m_name.startsWith(QLatin1String("wayland")); } // Wayland forbids a client from placing its own window, so there the cat // lives inside one screen-filling overlay and only moves within it. // TNCAT_OVERLAY=1 forces the same mode elsewhere. bool overlayMode() const { return m_overlay || isWayland(); } // TNCAT_X11_BYPASS=1 turns the cat into an override-redirect window. // Useful on window managers that refuse to keep a Qt::Tool window on top. bool bypassWindowManager() const { return m_bypass; } // TNCAT_OPAQUE=1 paints a solid background instead of relying on a // compositor. Without compositing X11 renders transparency as black. bool opaqueBackground() const { return m_opaque; } // Restricts the window's input region to one rectangle so clicks land on // whatever is behind the rest of the overlay. Implemented by the X11 and // Wayland plugins; a no-op on platforms that ignore the mask. Q_INVOKABLE void setInputRegion(QQuickWindow *window, const QRectF ®ion); private: QString m_name; bool m_overlay = false; bool m_bypass = false; bool m_opaque = false; };