# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1593045517 0 # Node ID f9a2fc59611cc427f70af49b07c12dc346d59aa2 # Parent 589896c07c91c9535a72be9a13b6c2ac3de939f1 Win: That last fix wasn't tested enough. Create a subfolder with the AppID. The previous fix only allowed one dwindows application instance access to Edge. Create a subdirectory under TEMP with the specified or auto-detected ID. This change made me pull the application ID code out of #ifdef BUILD_TOAST. diff -r 589896c07c91 -r f9a2fc59611c win/dw.c --- a/win/dw.c Thu Jun 25 00:00:48 2020 +0000 +++ b/win/dw.c Thu Jun 25 00:38:37 2020 +0000 @@ -278,10 +278,8 @@ */ static char _dw_alternate_temp_dir[MAX_PATH+1] = {0}; static char _dw_exec_dir[MAX_PATH+1] = {0}; -#ifdef BUILD_TOAST static char _dw_app_id[101]= {0}; static char _dw_app_name[101]= {0}; -#endif int main(int argc, char *argv[]); @@ -315,7 +313,7 @@ #if (defined(BUILD_DLL) || defined(BUILD_HTML)) LRESULT CALLBACK _browserWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); #ifdef BUILD_EDGE -BOOL _dw_edge_detect(VOID); +BOOL _dw_edge_detect(LPWSTR AppID); BOOL _DW_EDGE_DETECTED = FALSE; LRESULT CALLBACK _edgeWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); #endif @@ -4275,14 +4273,12 @@ if(pos) { strncpy(_dw_exec_dir, argv[0], (size_t)(pos - argv[0])); -#ifdef BUILD_TOAST if((pos++) && !_dw_app_id[0]) { /* If we have a binary name, use that for the Application ID instead. */ snprintf(_dw_app_id, 100, "%s.%s", DW_APP_DOMAIN_DEFAULT, pos); strncpy(_dw_app_name, pos, 100); } -#endif } } /* If that failed... just get the current directory */ @@ -4442,7 +4438,7 @@ wc.style = CS_HREDRAW | CS_VREDRAW; #ifdef BUILD_EDGE /* Check if Microsoft Edge (Chromium) is installed */ - if (_DW_EDGE_DETECTED = _dw_edge_detect()) + if (_DW_EDGE_DETECTED = _dw_edge_detect(UTF8toWide(_dw_app_id))) { wc.lpfnWndProc = (WNDPROC)_edgeWindowProc; wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); @@ -4502,7 +4498,6 @@ hrichedit = LoadLibrary(TEXT("riched32")); } #endif -#ifdef BUILD_TOAST if(!_dw_app_id[0]) { /* Generate an Application ID based on the PID if all else fails. */ @@ -4518,6 +4513,7 @@ pos++; strncpy(_dw_app_name, pos ? pos : fullpath, 100); } +#ifdef BUILD_TOAST _dw_toast_init(UTF8toWide(_dw_app_name), UTF8toWide(_dw_app_id)); #endif return 0; @@ -12917,14 +12913,10 @@ */ int API dw_app_id_set(const char *appid, const char *appname) { -#ifdef BUILD_TOAST strncpy(_dw_app_id, appid, 100); if(appname) strncpy(_dw_app_name, appname, 100); return DW_ERROR_NONE; -#else - return DW_ERROR_UNKNOWN; -#endif } /* diff -r 589896c07c91 -r f9a2fc59611c win/edge.cpp --- a/win/edge.cpp Thu Jun 25 00:00:48 2020 +0000 +++ b/win/edge.cpp Thu Jun 25 00:38:37 2020 +0000 @@ -30,7 +30,7 @@ { public: LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); - BOOL Detect(VOID); + BOOL Detect(LPWSTR AppID); protected: Microsoft::WRL::ComPtr Env; }; @@ -224,11 +224,14 @@ WebHost->put_IsVisible(TRUE); } -BOOL EdgeBrowser::Detect(VOID) +BOOL EdgeBrowser::Detect(LPWSTR AppID) { - WCHAR tempdir[MAX_PATH+1]; + WCHAR tempdir[MAX_PATH+1] = {0}; GetTempPathW(MAX_PATH, tempdir); + wcscat(tempdir, AppID); + wcscat(tempdir, L"\\"); + CreateDirectoryW(tempdir, NULL); CreateCoreWebView2EnvironmentWithOptions(nullptr, tempdir, nullptr, Callback( @@ -359,12 +362,12 @@ * If we succeed return TRUE and use Edge for HTML windows. * If it fails return FALSE and fall back to using embedded IE. */ - BOOL _dw_edge_detect(VOID) + BOOL _dw_edge_detect(LPWSTR AppID) { DW_EDGE = new EdgeBrowser; if (DW_EDGE) { - BOOL result = DW_EDGE->Detect(); + BOOL result = DW_EDGE->Detect(AppID); if (!result) { delete DW_EDGE;