From bbd0f1932fcf7a730d8ab9410e158f2b1035bc23 Mon Sep 17 00:00:00 2001 From: Sine Striker <trueful@163.com> Date: 周三, 13 12月 2023 18:53:02 +0800 Subject: [PATCH] Add cocoa --- src/core/contexts/cocoawindowcontext.mm | 22 +++++++++++ src/core/CMakeLists.txt | 37 ++++++++++-------- src/core/contexts/cocoawindowcontext_p.h | 24 ++++++++++++ src/core/windowagentbase.cpp | 5 ++ 4 files changed, 71 insertions(+), 17 deletions(-) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 71c0e72..9cc3744 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -27,30 +27,33 @@ qwindowkit_windows.h qwindowkit_windows.cpp ) +elseif(NOT APPLE) + list(APPEND _src + qwindowkit_linux.h + ) +endif() - if(QWINDOWKIT_FORCE_QT_WINDOW_CONTEXT) - list(APPEND _src - contexts/qtwindowcontext_p.h - contexts/qtwindowcontext.cpp - ) - list(APPEND _defines_private QWINDOWKIT_FORCE_QT_WINDOW_CONTEXT) - else() - list(APPEND _src - contexts/win32windowcontext_p.h - contexts/win32windowcontext.cpp - ) - endif() -else() +if(QWINDOWKIT_FORCE_QT_WINDOW_CONTEXT) list(APPEND _src contexts/qtwindowcontext_p.h contexts/qtwindowcontext.cpp ) - - if(APPLE) - # add files + list(APPEND _defines_private QWINDOWKIT_FORCE_QT_WINDOW_CONTEXT) +else() + if(WIN32) + list(APPEND _src + contexts/win32windowcontext_p.h + contexts/win32windowcontext.cpp + ) + elseif(APPLE) + list(APPEND _src + contexts/cocoawindowcontext_p.h + contexts/cocoawindowcontext.cpp + ) else() list(APPEND _src - qwindowkit_linux.h + contexts/qtwindowcontext_p.h + contexts/qtwindowcontext.cpp ) endif() endif() diff --git a/src/core/contexts/cocoawindowcontext.mm b/src/core/contexts/cocoawindowcontext.mm new file mode 100644 index 0000000..e55488c --- /dev/null +++ b/src/core/contexts/cocoawindowcontext.mm @@ -0,0 +1,22 @@ +#include "cocoawindowcontext_p.h" + +namespace QWK { + + CocoaWindowContext::CocoaWindowContext() { + } + + CocoaWindowContext::~CocoaWindowContext() { + } + + QString CocoaWindowContext::key() const { + return "cocoa"; + } + + void CocoaWindowContext::virtual_hook(int id, void *data) { + } + + bool CocoaWindowContext::setupHost() { + return false; + } + +} \ No newline at end of file diff --git a/src/core/contexts/cocoawindowcontext_p.h b/src/core/contexts/cocoawindowcontext_p.h new file mode 100644 index 0000000..180d4bb --- /dev/null +++ b/src/core/contexts/cocoawindowcontext_p.h @@ -0,0 +1,24 @@ +#ifndef COCOAWINDOWCONTEXT_P_H +#define COCOAWINDOWCONTEXT_P_H + + +#include <QWKCore/private/abstractwindowcontext_p.h> + +namespace QWK { + + class CocoaWindowContext : public AbstractWindowContext { + Q_OBJECT + public: + CocoaWindowContext(); + ~CocoaWindowContext() override; + + QString key() const override; + void virtual_hook(int id, void *data) override; + + protected: + bool setupHost() override; + }; + +} + +#endif // COCOAWINDOWCONTEXT_P_H diff --git a/src/core/windowagentbase.cpp b/src/core/windowagentbase.cpp index b179042..a796b3e 100644 --- a/src/core/windowagentbase.cpp +++ b/src/core/windowagentbase.cpp @@ -5,6 +5,8 @@ #if defined(Q_OS_WINDOWS) && !defined(QWINDOWKIT_FORCE_QT_WINDOW_CONTEXT) # include "win32windowcontext_p.h" +#elif defined(Q_OS_MAC) && !defined(QWINDOWKIT_FORCE_QT_WINDOW_CONTEXT) +# include "cocoawindowcontext_p.h" #else # include "qtwindowcontext_p.h" #endif @@ -28,8 +30,11 @@ if (windowContextFactoryMethod) { return windowContextFactoryMethod(); } + #if defined(Q_OS_WINDOWS) && !defined(QWINDOWKIT_FORCE_QT_WINDOW_CONTEXT) return new Win32WindowContext(); +#elif defined(Q_OS_MAC) && !defined(QWINDOWKIT_FORCE_QT_WINDOW_CONTEXT) + return new CocoaWindowContext(); #else return new QtWindowContext(); #endif -- Gitblit v1.9.1