From d3d7430ec9afb94abaf78fa2c9edd9d9f946881c Mon Sep 17 00:00:00 2001
From: Sine Striker <trueful@163.com>
Date: 周一, 18 12月 2023 01:29:07 +0800
Subject: [PATCH] Add QtContext WinIdChange workaround

---
 src/core/CMakeLists.txt |   64 ++++++++++++++++++++++++-------
 1 files changed, 49 insertions(+), 15 deletions(-)

diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 03fa2dd..88d350b 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -4,44 +4,78 @@
 )
 
 set(_src
-    qwkcoreglobal.h
-    corewindowagent.h
-    corewindowagent_p.h
-    corewindowagent.cpp
-    windowitemdelegate.h
-    handler/abstractwindowcontext_p.h
-    handler/abstractwindowcontext.cpp
+    qwkglobal.h
+    qwkglobal_p.h
+    windowagentbase.h
+    windowagentbase_p.h
+    windowagentbase.cpp
+    windowitemdelegate_p.h
+    windowitemdelegate.cpp
+    kernel/nativeeventfilter_p.h
+    kernel/nativeeventfilter.cpp
+    contexts/abstractwindowcontext_p.h
+    contexts/abstractwindowcontext.cpp
 )
+
+set(_defines_private)
+set(_links_private)
 
 if(WIN32)
     list(APPEND _src
         qwindowkit_windows.h
-        handler/win32windowcontext_p.h
-        handler/win32windowcontext.cpp
+        qwindowkit_windows.cpp
+    )
+elseif(APPLE)
+    list(APPEND _links_private
+        "-framework Foundation"
+        "-framework Cocoa"
+        "-framework AppKit"
     )
 else()
     list(APPEND _src
-        handler/qtwindowcontext_p.h
-        handler/qtwindowcontext.cpp
+        qwindowkit_linux.h
     )
-    if(APPLE)
-        # add files
+endif()
+
+if(QWINDOWKIT_FORCE_QT_WINDOW_CONTEXT)
+    list(APPEND _src
+        contexts/qtwindowcontext_p.h
+        contexts/qtwindowcontext.cpp
+    )
+else()
+    if(WIN32)
+        list(APPEND _src
+            contexts/win32windowcontext_p.h
+            contexts/win32windowcontext.cpp
+        )
+    elseif(APPLE)
+        list(APPEND _src
+            contexts/cocoawindowcontext_p.h
+            contexts/cocoawindowcontext.mm
+        )
     else()
         list(APPEND _src
-            qwindowkit_linux.h
+            contexts/qtwindowcontext_p.h
+            contexts/qtwindowcontext.cpp
         )
     endif()
 endif()
 
 qwk_add_library(${PROJECT_NAME} AUTOGEN
     SOURCES ${_src}
+    DEFINES_PRIVATE ${_defines_private}
     LINKS
+    LINKS_PRIVATE ${_links_private}
     QT_LINKS Core Gui
     QT_INCLUDE_PRIVATE Core Gui
+    INCLUDE_PRIVATE kernel contexts platforms
     PREFIX QWK_CORE
 )
 
 set_target_properties(${PROJECT_NAME} PROPERTIES
     CXX_STANDARD 17
     CXX_STANDARD_REQUIRED TRUE
-)
\ No newline at end of file
+)
+
+set(QWINDOWKIT_ENABLED_TARGETS ${QWINDOWKIT_ENABLED_TARGETS} ${PROJECT_NAME} PARENT_SCOPE)
+set(QWINDOWKIT_ENABLED_SUBDIRECTORIES ${QWINDOWKIT_ENABLED_SUBDIRECTORIES} core PARENT_SCOPE)
\ No newline at end of file

--
Gitblit v1.9.1