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

#pragma once

#include "qwayland-ukui-shell.h"
#include "qwayland-ukui-shell-v1.h"
#include "qwayland-xdg-shell.h"

#include "xdgdecorationv1.h"

#include <QRegion>

#include <memory>

namespace QtWaylandClient
{

class QWaylandDisplay;
class QWaylandWindow;
class Popup;
class Toplevel;
class UkuiBlurManager;
class QWaylandShellSurface;
class UkuiShellSurface;
class UkuiShellSurfaceV1;
class XdgDialogWmV1;
class XdgActivationV1;
class KdeSlideManager;

class UkuiShell : public QtWayland::xdg_wm_base
{
public:
    UkuiShell(QWaylandDisplay *display, uint32_t id, uint32_t availableVersion);
    ~UkuiShell() override;

    XdgDecorationManagerV1 *decorationManager();
    XdgDialogWmV1 *xdgDialogWm();
    XdgActivationV1 *xdgActivation();
    UkuiBlurManager *blurManager();
    KdeSlideManager *slideManager();
    QtWayland::ukui_shell *QtwaylandUkuiShell();
    QtWayland::ukui_shell_v1 *QtwaylandUkuiShellV1();

    QWaylandShellSurface *getUkuiShellSurface(QWaylandWindow *window);

protected:
    void xdg_wm_base_ping(uint32_t serial) override;

private:
    static void handleRegistryGlobal(void *data, ::wl_registry *registry, uint id,
                                     const QString &interface, uint version);

    QWaylandDisplay *m_display = nullptr;

    std::unique_ptr<QtWayland::ukui_shell> m_ukuiShell;
    std::unique_ptr<QtWayland::ukui_shell_v1> m_ukuiShellV1;
    std::unique_ptr<XdgDecorationManagerV1> m_xdgDecorationManager;
    std::unique_ptr<XdgDialogWmV1> m_xdgDialogWm;
    std::unique_ptr<XdgActivationV1> m_xdgActivation;
    std::unique_ptr<UkuiBlurManager> m_blurManager;
    std::unique_ptr<KdeSlideManager> m_slideManager;
};
}