#pragma once #include #include class QWindow; namespace LayerShellQt { class Window; } // Places a keyboard window as a free-floating overlay that never takes focus. // On Wayland: a layer-shell surface anchored top-left, positioned via margins. // On X11: a frameless, non-focusable, always-on-top tool window. class FloatingWindow : public QObject { Q_OBJECT Q_PROPERTY(QPoint position READ position WRITE setPosition NOTIFY positionChanged) public: // Must be called before the window is shown for the first time. explicit FloatingWindow(QWindow *window, QObject *parent = nullptr); QPoint position() const { return m_position; } void setPosition(QPoint position); Q_INVOKABLE void moveBy(qreal dx, qreal dy); Q_INVOKABLE void show(); Q_INVOKABLE void hide(); Q_SIGNALS: void positionChanged(); private: QPoint clamped(QPoint position) const; QPoint defaultPosition() const; void apply(); QWindow *m_window; LayerShellQt::Window *m_layerSurface = nullptr; QPoint m_position; };