File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ ConfigJson LoadConfigJson(const std::string& path)
1212 ret.startUrl = " https://github.com/WebView-CG/CanIWebView2" ;
1313 ret.preferUnstableChannel = false ;
1414 ret.additionalBrowserArguments = " " ;
15+ ret.hostingMode = " " ;
1516
1617 // If file does not exist, just use defaults
1718 if (!FileExists (path))
@@ -39,5 +40,8 @@ ConfigJson LoadConfigJson(const std::string& path)
3940 if (parsedJson.contains (" additionalBrowserArguments" ))
4041 ret.additionalBrowserArguments = parsedJson[" additionalBrowserArguments" ].get <std::string>();
4142
43+ if (parsedJson.contains (" hostingMode" ))
44+ ret.hostingMode = parsedJson[" hostingMode" ].get <std::string>();
45+
4246 return ret;
4347}
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ struct ConfigJson {
66 std::string startUrl;
77 bool preferUnstableChannel;
88 std::string additionalBrowserArguments;
9+ std::string hostingMode;
910};
1011
1112ConfigJson LoadConfigJson (const std::string& path);
Original file line number Diff line number Diff line change @@ -37,6 +37,14 @@ int CALLBACK WinMain(
3737 std::string configJsonPath = FolderFromPath (GetModulePath ()) + " config.json" ;
3838 ConfigJson configJson = LoadConfigJson (configJsonPath);
3939
40+ // If config.json specifies the hosting mode as "window-to-visual", force this hosting mode by setting the
41+ // environment variable COREWEBVIEW2_FORCED_HOSTING_MODE to COREWEBVIEW2_HOSTING_MODE_WINDOW_TO_VISUAL.
42+ // See: https://learn.microsoft.com/en-us/microsoft-edge/webview2/concepts/windowed-vs-visual-hosting
43+ if (configJson.hostingMode == " window-to-visual" )
44+ {
45+ SetEnvironmentVariable (L" COREWEBVIEW2_FORCED_HOSTING_MODE" , L" COREWEBVIEW2_HOSTING_MODE_WINDOW_TO_VISUAL" );
46+ }
47+
4048 // ///////////////////////////////////////////////////
4149 // Register window class
4250 WNDCLASSEX wcex;
You can’t perform that action at this time.
0 commit comments