Yuhang Zhao
2023-12-06 0287f19b3eabf6b6632d51c0288e6cf0be2c5e69
update pointer usage
6个文件已修改
48 ■■■■■ 已修改文件
src/core/contexts/abstractwindowcontext.cpp 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/contexts/abstractwindowcontext_p.h 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/contexts/win32windowcontext.cpp 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/contexts/win32windowcontext_p.h 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/corewindowagent.cpp 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/corewindowagent_p.h 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/core/contexts/abstractwindowcontext.cpp
@@ -2,7 +2,7 @@
namespace QWK {
    AbstractWindowContext::AbstractWindowContext(QObject *host, WindowItemDelegate *delegate)
    AbstractWindowContext::AbstractWindowContext(const QObject *host, const WindowItemDelegate *delegate)
        : m_host(host), m_delegate(delegate), m_windowHandle(delegate->hostWindow(host)) {
    }
src/core/contexts/abstractwindowcontext_p.h
@@ -16,13 +16,13 @@
    class QWK_CORE_EXPORT AbstractWindowContext : public QObject {
        Q_OBJECT
    public:
        AbstractWindowContext(QObject *host, WindowItemDelegate *delegate);
        AbstractWindowContext(const QObject *host, const WindowItemDelegate *delegate);
        ~AbstractWindowContext() override;
    public:
        virtual bool setup() = 0;
        inline QObject *host() const;
        inline const QObject *host() const;
        inline QWindow *window() const;
        inline bool isHitTestVisible(const QObject *obj) const;
@@ -42,8 +42,8 @@
        bool isInTitleBarDraggableArea(const QPoint &pos) const;
    protected:
        QObject *m_host;
        std::unique_ptr<WindowItemDelegate> m_delegate;
        const QObject *m_host;
        const WindowItemDelegate *m_delegate;
        QWindow *m_windowHandle;
        QSet<const QObject *> m_hitTestVisibleItems;
@@ -57,7 +57,7 @@
        mutable QRegion hitTestVisibleShape;
    };
    inline QObject *AbstractWindowContext::host() const {
    inline const QObject *AbstractWindowContext::host() const {
        return m_host;
    }
src/core/contexts/win32windowcontext.cpp
@@ -443,11 +443,17 @@
        static WindowsNativeEventFilter *instance;
        static inline void install() {
            if (instance) {
                return;
            }
            instance = new WindowsNativeEventFilter();
            installNativeEventFilter(instance);
        }
        static inline void uninstall() {
            if (!instance) {
                return;
            }
            removeNativeEventFilter(instance);
            delete instance;
            instance = nullptr;
@@ -539,7 +545,7 @@
        return ::CallWindowProcW(g_qtWindowProc, hWnd, message, wParam, lParam);
    }
    Win32WindowContext::Win32WindowContext(QObject *host, WindowItemDelegate *delegate)
    Win32WindowContext::Win32WindowContext(const QObject *host, const WindowItemDelegate *delegate)
        : AbstractWindowContext(host, delegate) {
    }
@@ -576,9 +582,7 @@
        ::SetWindowLongPtrW(hWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(QWKHookedWndProc));
        // Install global native event filter
        if (!WindowsNativeEventFilter::instance) {
            WindowsNativeEventFilter::install();
        }
        WindowsNativeEventFilter::install();
        // Cache window ID
        windowId = winId;
src/core/contexts/win32windowcontext_p.h
@@ -9,7 +9,7 @@
    class QWK_CORE_EXPORT Win32WindowContext : public AbstractWindowContext {
        Q_OBJECT
    public:
        Win32WindowContext(QObject *host, WindowItemDelegate *delegate);
        Win32WindowContext(const QObject *host, const WindowItemDelegate *delegate);
        ~Win32WindowContext() override;
        enum WindowPart {
src/core/corewindowagent.cpp
@@ -16,23 +16,30 @@
    CoreWindowAgentPrivate::CoreWindowAgentPrivate() : q_ptr(nullptr), context(nullptr) {
    }
    CoreWindowAgentPrivate::~CoreWindowAgentPrivate() = default;
    CoreWindowAgentPrivate::~CoreWindowAgentPrivate() {
        if (context) {
            delete context;
            context = nullptr;
        }
    }
    void CoreWindowAgentPrivate::init() {
    }
    bool CoreWindowAgentPrivate::setup(QObject *host, WindowItemDelegate *delegate) {
    bool CoreWindowAgentPrivate::setup(const QObject *host, const WindowItemDelegate *delegate) {
        auto ctx =
#ifdef Q_OS_WINDOWS
            std::make_unique<Win32WindowContext>(host, delegate)
            new Win32WindowContext(host, delegate)
#else
            std::make_unique<QtWindowContext>(host, window, delegate)
            new QtWindowContext(host, window, delegate)
#endif
            ;
        if (!ctx->setup()) {
            delete ctx;
            ctx = nullptr;
            return false;
        }
        context = std::move(ctx);
        context = ctx;
        return true;
    }
src/core/corewindowagent_p.h
@@ -16,10 +16,11 @@
        CoreWindowAgent *q_ptr; // no need to initialize
        bool setup(QObject *host, WindowItemDelegate *delegate);
        bool setup(const QObject *host, const WindowItemDelegate *delegate);
        std::unique_ptr<AbstractWindowContext> context;
        AbstractWindowContext *context;
    private:
        Q_DISABLE_COPY_MOVE(CoreWindowAgentPrivate)
    };