Yuhang Zhao
2023-12-06 0287f19b3eabf6b6632d51c0288e6cf0be2c5e69
src/core/corewindowagent.cpp
@@ -1,42 +1,58 @@
#include "corewindowagent.h"
#include "corewindowagent_p.h"
#include "qwkcoreglobal_p.h"
#ifdef Q_OS_WINDOWS
#  include "handler/win32windowcontext_p.h"
#  include "win32windowcontext_p.h"
#else
#  include "handler/qtwindowcontext_p.h"
#  include "qtwindowcontext_p.h"
#endif
Q_LOGGING_CATEGORY(qWindowKitLog, "qwindowkit")
namespace QWK {
    CoreWindowAgentPrivate::CoreWindowAgentPrivate() {
    CoreWindowAgentPrivate::CoreWindowAgentPrivate() : q_ptr(nullptr), context(nullptr) {
    }
    CoreWindowAgentPrivate::~CoreWindowAgentPrivate() {
        if (context) {
            delete context;
            context = nullptr;
        }
    }
    void CoreWindowAgentPrivate::init() {
    }
    void CoreWindowAgentPrivate::setup(QWindow *window, WindowItemDelegate *delegate) {
    bool CoreWindowAgentPrivate::setup(const QObject *host, const WindowItemDelegate *delegate) {
        auto ctx =
#ifdef Q_OS_WINDOWS
        m_eventHandler = new Win32WindowContext(window, delegate);
            new Win32WindowContext(host, delegate)
#else
        m_eventHandler = new QtWindowContext(window, delegate);
            new QtWindowContext(host, window, delegate)
#endif
            ;
        if (!ctx->setup()) {
            delete ctx;
            ctx = nullptr;
            return false;
        }
        context = ctx;
        return true;
    }
    CoreWindowAgent::~CoreWindowAgent() {
    }
    CoreWindowAgent::~CoreWindowAgent() = default;
    void CoreWindowAgent::showSystemMenu(const QPoint &pos) {
        Q_D(CoreWindowAgent);
        d->m_eventHandler->showSystemMenu(pos);
        d->context->showSystemMenu(pos);
    }
    void CoreWindowAgent::startSystemMove(const QPoint &pos) {
        Q_D(CoreWindowAgent);
        auto win = d->m_eventHandler->window();
        auto win = d->context->window();
        if (!win) {
            return;
        }
@@ -47,7 +63,7 @@
    void CoreWindowAgent::startSystemResize(Qt::Edges edges, const QPoint &pos) {
        Q_D(CoreWindowAgent);
        auto win = d->m_eventHandler->window();
        auto win = d->context->window();
        if (!win) {
            return;
        }