Yuhang Zhao
2023-12-05 9b1599d82e86d2d0463b60fe6fa61f94be50f983
src/core/corewindowagent.cpp
@@ -1,42 +1,57 @@
#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(QWindow *window, WindowItemDelegate *delegate) {
        Q_ASSERT(window);
        if (!window) {
            return false;
        }
        auto handler =
#ifdef Q_OS_WINDOWS
        m_eventHandler = new Win32WindowContext(window, delegate);
            new Win32WindowContext(window, delegate)
#else
        m_eventHandler = new QtWindowContext(window, delegate);
            new QtWindowContext(window, delegate)
#endif
            ;
        if (!handler->setup()) {
            delete handler;
            return false;
        }
        context.reset(handler);
        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 +62,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;
        }