Add support for prevent screen capture

This commit is contained in:
2023-09-22 17:28:33 +08:00
parent 50ff4b3fdd
commit 286e2fbb5b
7 changed files with 102 additions and 2 deletions

View File

@@ -224,6 +224,25 @@ bool FlutterWindow::OnCreate() {
result->NotImplemented();
}
});
flutter::MethodChannel<> display(flutter_controller_->engine()->messenger(), "lifegpc.eh_downloader_flutter/display",
&flutter::StandardMethodCodec::GetInstance());
display.SetMethodCallHandler([&](const flutter::MethodCall<>& call, std::unique_ptr<flutter::MethodResult<>> result) {
if (call.method_name() == "enableProtect") {
if (!SetWindowDisplayAffinity(Win32Window::GetHandle(), WDA_EXCLUDEFROMCAPTURE)) {
result->Error("ERROR", "Failed to enable protect.");
return;
}
result->Success();
} else if (call.method_name() == "disableProtect") {
if (!SetWindowDisplayAffinity(Win32Window::GetHandle(), WDA_NONE)) {
result->Error("ERROR", "Failed to disable protect.");
return;
}
result->Success();
} else {
result->NotImplemented();
}
});
SetChildContent(flutter_controller_->view()->GetNativeWindow());