#ifndef UKUISHELL_H
#define UKUISHELL_H


#include <QObject>
#include <QSize>
#include <QPointer>
#include <KWayland/Client/surface.h>
#include <KWayland/Client/event_queue.h>
#include "ukui-shell-client-protocol.h"

struct wl_surface;
struct ukui_surface;

class UkuiShellSurface;

using namespace KWayland::Client;

class  UkuiShell : public QObject
{
    Q_OBJECT
public:
    explicit UkuiShell(QObject *parent = nullptr);
    ~UkuiShell() override;


    bool isValid() const;

    void release();

    void destroy();

    void setup(ukui_shell *shell);


    void setEventQueue(EventQueue *queue);

    EventQueue *eventQueue();


    UkuiShellSurface *createSurface(wl_surface *surface, QObject *parent = nullptr);

    UkuiShellSurface *createSurface(Surface *surface, QObject *parent = nullptr);

    operator ukui_shell *();
    operator ukui_shell *() const;

Q_SIGNALS:

    void interfaceAboutToBeReleased();

    void interfaceAboutToBeDestroyed();

    void removed();

private:
    class Private;
    QScopedPointer<Private> d;
};


class  UkuiShellSurface : public QObject
{
    Q_OBJECT
public:
    explicit UkuiShellSurface(QObject *parent);
    ~UkuiShellSurface() override;

    void release();

    void destroy();

    void setup(ukui_surface *surface);

    static UkuiShellSurface *get(Surface *surf);

    bool isValid() const;

    operator ukui_surface *();
    operator ukui_surface *() const;

    enum class Role {
        Normal,
        Desktop,
        Panel,
        OnScreenDisplay,
        Notification,
        ToolTip,
        CriticalNotification,
        AppletPop,
        ScreenLock,
        Watermark,
        SystemWindow,
        InputPanel,
        Logout,
        ScreenLockNotification
    };

    enum class SurfaceProperty {
        NoTitleBar,
        Theme,
        WindowRadius,
        BorderWidth,
        BorderColor,
        ShadowRadius,
        ShadowOffset,
        ShadowColor
    };


    void setRole(Role role);

    Role role() const;

    void setSurfaceProperty(SurfaceProperty property, uint32_t value);

    SurfaceProperty surfaceProperty() const;

    void setPosition(const QPoint &point);

    void setSkipTaskbar(bool skip);

    void setSkipSwitcher(bool skip);

    void setPanelTakesFocus(bool takesFocus);

    void setPanelAutoHide(bool autoHide);


Q_SIGNALS:

    void autoHidePanelHidden();

    void autoHidePanelShown();

private:
    friend class UkuiShell;
    class Private;
    QScopedPointer<Private> d;
};


#endif // UKUISHELL_H
