/*
 * Copyright (C) 2024, KylinSoft Co., Ltd.

 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Library General Public License as
 * published by the Free Software Foundation; either version 2, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#ifndef MULTITASKVIEWMODELBYCOMPOSITEHANDLER_H
#define MULTITASKVIEWMODELBYCOMPOSITEHANDLER_H
#include "../multitaskviewabstractmodelhandler.h"
#include "../windowmanagerinterface.h"
#include <QObject>
#include <QIcon>
#include <QList>
#include <QMap>
#include <QRect>
#include <QVariantList>
#include <QString>
#include <kwineffects.h>

class MultitaskViewModelByCompositeHandler : public MultitaskViewAbstractModelHandler
{
    Q_OBJECT

public:
    explicit MultitaskViewModelByCompositeHandler(QObject *parent = nullptr);
    ~MultitaskViewModelByCompositeHandler() = default;

    void removeAppWindow(QString windowId) override;
    void moveAppWindowToDesktop(QString windowId, int srcDesktopInex, int destDesktopInex) override;
    void activateAppWindow(QString windowId) override;
    QVariant getWindowIcon(QString windowId) override;
    void removeDesktop(int desktopIndex) override;
    void moveDesktop(int srcDesktopIndex, int destDesktopIndex) override;
    int getNumberOfDesktops() override;
    void appendDesktop() override;
    int getCurrentDesktop() override;
    bool isCurrentDesktopShowingDesktop() override;
    void setCurrentDesktop(int desktopIndex) override;
    QRect getFullScreenGeometry(int desktopIndex, int screenIndex) override;
    bool hasModalChildWindow(QString windowId) override;
    bool isExtensionMode() override;
    int logicalScreenCount() override;
    QList<Window> createWindowList(int desktopIndex, int screenIndex) override;
    QString getDesktopUuid(int desktopIndex) override;
    QString getOutputUuid(int outputIndex) override;
    void setDesktopName(const int desktopIndex, const QString name) override;
private:
    static WId getWindowId(KWin::EffectWindow* window);
    static QUuid getUuid(KWin::EffectWindow *window);
    bool shouldAcceptWindow(KWin::EffectWindow* window);
    void connectSignals();

private slots:
    void onWindowAdded(KWin::EffectWindow* window);
    void onWindowDeleted(KWin::EffectWindow* window);
    void onWindowActivated(KWin::EffectWindow* window);
    void onDesktopPresenceChanged(KWin::EffectWindow* window, int oldDesktopIndex, int newDesktopIndex);
    void onNumberScreensChanged();

};


#endif // MULTITASKVIEWMODELBYCOMPOSITEHANDLER_h
