// SPDX-FileCopyrightText: 2025 KylinSoft Co., Ltd.
//
// SPDX-License-Identifier: GPL-1.0-or-later

#pragma once

#include <QtWaylandClient/private/qwayland-ukui-output-v1.h>

#include <QRect>
#include <QList>

QT_BEGIN_NAMESPACE

namespace QtWaylandClient {

class QWaylandDisplay;
class QWaylandScreen;

class QWaylandUkuiOutputV1 : public QtWayland::ukui_output_v1
{
public:
    QWaylandUkuiOutputV1(struct ::ukui_output_v1 *output);
    ~QWaylandUkuiOutputV1() = default;

    QString name() const { return m_outputName; }
    QRect availableGeometry() const { return m_availableGeometry; }

    void setFinishedHandler(const std::function<void()> &handler);

protected:
    void ukui_output_v1_name(const QString &name) override;
    void ukui_output_v1_usable_area(int32_t x, int32_t y, int32_t width, int32_t height) override;
    void ukui_output_v1_finished() override;

private:
    std::function<void()> m_finishedHandler;
    QString m_outputName;
    QRect m_availableGeometry;
};

class QWaylandUkuiOutputManagementV1 : public QtWayland::ukui_output_management_v1
{
public:
    QWaylandUkuiOutputManagementV1(QWaylandDisplay *display, uint id, uint version);
    ~QWaylandUkuiOutputManagementV1() = default;

    QList<QWaylandUkuiOutputV1 *> ukuiOutputs() const;
    QWaylandUkuiOutputV1 *findUKuiOutput(const QString &name) const;

protected:
    void ukui_output_management_v1_output(struct ::ukui_output_v1 *output) override;
    void ukui_output_management_v1_done() override;

private:
    QWaylandDisplay *m_display = nullptr;
    QList<QWaylandUkuiOutputV1 *> m_ukuiOutputs;
};

} // namespace QtWaylandClient

QT_END_NAMESPACE
