Yuhang Zhao
2023-12-06 d5cc7b515e8897c94815ebb2d8fe6da675846149
src/core/corewindowagent.cpp
@@ -1,42 +1,51 @@
#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() {
    }
    CoreWindowAgentPrivate::~CoreWindowAgentPrivate() = default;
    void CoreWindowAgentPrivate::init() {
    }
    void CoreWindowAgentPrivate::setup(QWindow *window, WindowItemDelegate *delegate) {
    bool CoreWindowAgentPrivate::setup(QObject *host, WindowItemDelegate *delegate) {
        auto ctx =
#ifdef Q_OS_WINDOWS
        m_eventHandler = new Win32WindowContext(window, delegate);
            std::make_unique<Win32WindowContext>(host, delegate)
#else
        m_eventHandler = new QtWindowContext(window, delegate);
            std::make_unique<QtWindowContext>(host, window, delegate)
#endif
            ;
        if (!ctx->setup()) {
            return false;
        }
        context = std::move(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 +56,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;
        }