Skip to content

基于自定义规则的番剧采集APP,支持流媒体在线观看,支持弹幕,支持实时超分辨率。

fix(windows): keep flutter accessibility bridge disabled (#2668)

Predidit27c4efe70e24
diff --git a/windows/runner/CMakeLists.txt b/windows/runner/CMakeLists.txt
index eec604b8..804c89dd 100644
--- a/windows/runner/CMakeLists.txt
+++ b/windows/runner/CMakeLists.txt
@@ -36,7 +36,7 @@ target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
# Add dependency libraries and include directories. Add any application-specific
# dependencies here.
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
-target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib")
+target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib" "comctl32.lib")
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
# Run the Flutter tool portions of the build. This must not be removed.
diff --git a/windows/runner/flutter_window.cpp b/windows/runner/flutter_window.cpp
index f16880f9..598b44d4 100644
--- a/windows/runner/flutter_window.cpp
+++ b/windows/runner/flutter_window.cpp
@@ -8,9 +8,32 @@
#include <flutter/standard_method_codec.h>
#include <flutter/plugin_registrar_windows.h>
#include <windows.h>
+#include <commctrl.h>
#include "flutter/generated_plugin_registrant.h"
+namespace {
+
+// The engine turns on semantics the first time any UIA/MSAA client sends
+// WM_GETOBJECT to the Flutter view, and never turns them off again. Answering
+// with the system default keeps the accessibility bridge from ever being
+// created, which avoids the engine's AXTree crashes
+// (flutter/flutter#175041).
+LRESULT CALLBACK FlutterViewSubclassProc(HWND hwnd, UINT message,
+ WPARAM wparam, LPARAM lparam,
+ UINT_PTR subclass_id, DWORD_PTR) {
+ switch (message) {
+ case WM_GETOBJECT:
+ return DefWindowProc(hwnd, message, wparam, lparam);
+ case WM_NCDESTROY:
+ RemoveWindowSubclass(hwnd, FlutterViewSubclassProc, subclass_id);
+ break;
+ }
+ return DefSubclassProc(hwnd, message, wparam, lparam);
+}
+
+} // namespace
+
FlutterWindow::FlutterWindow(const flutter::DartProject& project)
: project_(project) {}
@@ -32,7 +55,9 @@ bool FlutterWindow::OnCreate() {
return false;
}
RegisterPlugins(flutter_controller_->engine());
- SetChildContent(flutter_controller_->view()->GetNativeWindow());
+ HWND flutter_view = flutter_controller_->view()->GetNativeWindow();
+ SetWindowSubclass(flutter_view, FlutterViewSubclassProc, 0, 0);
+ SetChildContent(flutter_view);
// Removed automatic window show to let window_manager plugin control visibility
// This prevents window flashing during startup