Sine Striker
2023-12-06 a0bede6ff6a700a6eea9702c49d378f07de22f63
src/core/corewindowagent.cpp
@@ -1,6 +1,8 @@
#include "corewindowagent.h"
#include "corewindowagent_p.h"
#include "qwkcoreglobal_p.h"
#ifdef Q_OS_WINDOWS
#  include "win32windowcontext_p.h"
#else
@@ -11,34 +13,26 @@
namespace QWK {
    CoreWindowAgentPrivate::CoreWindowAgentPrivate() : eventHandler(nullptr) {
    CoreWindowAgentPrivate::CoreWindowAgentPrivate() : q_ptr(nullptr), context(nullptr) {
    }
    CoreWindowAgentPrivate::~CoreWindowAgentPrivate() {
        delete eventHandler;
    }
    CoreWindowAgentPrivate::~CoreWindowAgentPrivate() = default;
    void CoreWindowAgentPrivate::init() {
    }
    bool CoreWindowAgentPrivate::setup(QWindow *window, WindowItemDelegate *delegate) {
        Q_ASSERT(window);
        if (!window) {
            return false;
        }
        auto handler =
    bool CoreWindowAgentPrivate::setup(QObject *host, WindowItemDelegate *delegate) {
        auto ctx =
#ifdef Q_OS_WINDOWS
            new Win32WindowContext(window, delegate)
            std::make_unique<Win32WindowContext>(host, delegate)
#else
            new QtWindowContext(window, delegate)
            std::make_unique<QtWindowContext>(host, window, delegate)
#endif
            ;
        if (!handler->setup()) {
            delete handler;
        if (!ctx->setup()) {
            return false;
        }
        eventHandler = handler;
        context = std::move(ctx);
        return true;
    }
@@ -46,12 +40,12 @@
    void CoreWindowAgent::showSystemMenu(const QPoint &pos) {
        Q_D(CoreWindowAgent);
        d->eventHandler->showSystemMenu(pos);
        d->context->showSystemMenu(pos);
    }
    void CoreWindowAgent::startSystemMove(const QPoint &pos) {
        Q_D(CoreWindowAgent);
        auto win = d->eventHandler->window();
        auto win = d->context->window();
        if (!win) {
            return;
        }
@@ -62,7 +56,7 @@
    void CoreWindowAgent::startSystemResize(Qt::Edges edges, const QPoint &pos) {
        Q_D(CoreWindowAgent);
        auto win = d->eventHandler->window();
        auto win = d->context->window();
        if (!win) {
            return;
        }