Yuhang Zhao
2023-12-07 3d50f3133ddbbd7136dca8173cf9164b78121823
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include "corewindowagent.h"
#include "corewindowagent_p.h"
 
#include "qwkcoreglobal_p.h"
 
#ifdef Q_OS_WINDOWS
#  include "win32windowcontext_p.h"
#else
#  include "qtwindowcontext_p.h"
#endif
 
Q_LOGGING_CATEGORY(qWindowKitLog, "qwindowkit")
 
namespace QWK {
 
    CoreWindowAgentPrivate::CoreWindowAgentPrivate() : q_ptr(nullptr), context(nullptr) {
    }
 
    CoreWindowAgentPrivate::~CoreWindowAgentPrivate() = default;
 
    void CoreWindowAgentPrivate::init() {
    }
 
    AbstractWindowContext *CoreWindowAgentPrivate::createContext() const {
        return
#ifdef Q_OS_WINDOWS
            new Win32WindowContext()
#else
            new QtWindowContext()
#endif
                ;
    }
 
 
    bool CoreWindowAgentPrivate::setup(QObject *host, WindowItemDelegate *delegate) {
        std::unique_ptr<AbstractWindowContext> ctx(createContext());
        if (!ctx->setup(host, delegate)) {
            return false;
        }
        context = std::move(ctx);
        return true;
    }
 
    CoreWindowAgent::~CoreWindowAgent() = default;
 
    void CoreWindowAgent::showSystemMenu(const QPoint &pos) {
        Q_D(CoreWindowAgent);
        d->context->showSystemMenu(pos);
    }
 
    void CoreWindowAgent::startSystemMove(const QPoint &pos) {
        Q_D(CoreWindowAgent);
        auto win = d->context->window();
        if (!win) {
            return;
        }
 
        Q_UNUSED(pos)
        win->startSystemMove();
    }
 
    void CoreWindowAgent::startSystemResize(Qt::Edges edges, const QPoint &pos) {
        Q_D(CoreWindowAgent);
        auto win = d->context->window();
        if (!win) {
            return;
        }
 
        Q_UNUSED(pos)
        win->startSystemResize(edges);
    }
 
    void CoreWindowAgent::centralize() {
    }
 
    void CoreWindowAgent::raise() {
    }
 
    CoreWindowAgent::CoreWindowAgent(CoreWindowAgentPrivate &d, QObject *parent)
        : QObject(parent), d_ptr(&d) {
        d.q_ptr = this;
 
        d.init();
    }
 
}