Mercurial > dwindows
comparison win/dw.c @ 2124:f9a2fc59611c
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.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 25 Jun 2020 00:38:37 +0000 |
parents | 251d050d306b |
children | 37758cfed67b |
comparison
equal
deleted
inserted
replaced
2123:589896c07c91 | 2124:f9a2fc59611c |
---|---|
276 * an alternate temporary directory if TMP is not set, so we get the value | 276 * an alternate temporary directory if TMP is not set, so we get the value |
277 * of TEMP and store it here. | 277 * of TEMP and store it here. |
278 */ | 278 */ |
279 static char _dw_alternate_temp_dir[MAX_PATH+1] = {0}; | 279 static char _dw_alternate_temp_dir[MAX_PATH+1] = {0}; |
280 static char _dw_exec_dir[MAX_PATH+1] = {0}; | 280 static char _dw_exec_dir[MAX_PATH+1] = {0}; |
281 #ifdef BUILD_TOAST | |
282 static char _dw_app_id[101]= {0}; | 281 static char _dw_app_id[101]= {0}; |
283 static char _dw_app_name[101]= {0}; | 282 static char _dw_app_name[101]= {0}; |
284 #endif | |
285 | 283 |
286 int main(int argc, char *argv[]); | 284 int main(int argc, char *argv[]); |
287 | 285 |
288 #define ICON_INDEX_LIMIT 200 | 286 #define ICON_INDEX_LIMIT 200 |
289 HICON lookup[200]; | 287 HICON lookup[200]; |
313 HFONT _DefaultFont = NULL; | 311 HFONT _DefaultFont = NULL; |
314 | 312 |
315 #if (defined(BUILD_DLL) || defined(BUILD_HTML)) | 313 #if (defined(BUILD_DLL) || defined(BUILD_HTML)) |
316 LRESULT CALLBACK _browserWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); | 314 LRESULT CALLBACK _browserWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); |
317 #ifdef BUILD_EDGE | 315 #ifdef BUILD_EDGE |
318 BOOL _dw_edge_detect(VOID); | 316 BOOL _dw_edge_detect(LPWSTR AppID); |
319 BOOL _DW_EDGE_DETECTED = FALSE; | 317 BOOL _DW_EDGE_DETECTED = FALSE; |
320 LRESULT CALLBACK _edgeWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); | 318 LRESULT CALLBACK _edgeWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); |
321 #endif | 319 #endif |
322 #endif | 320 #endif |
323 #ifdef BUILD_TOAST | 321 #ifdef BUILD_TOAST |
4273 pos = strrchr(argv[0], '/'); | 4271 pos = strrchr(argv[0], '/'); |
4274 | 4272 |
4275 if(pos) | 4273 if(pos) |
4276 { | 4274 { |
4277 strncpy(_dw_exec_dir, argv[0], (size_t)(pos - argv[0])); | 4275 strncpy(_dw_exec_dir, argv[0], (size_t)(pos - argv[0])); |
4278 #ifdef BUILD_TOAST | |
4279 if((pos++) && !_dw_app_id[0]) | 4276 if((pos++) && !_dw_app_id[0]) |
4280 { | 4277 { |
4281 /* If we have a binary name, use that for the Application ID instead. */ | 4278 /* If we have a binary name, use that for the Application ID instead. */ |
4282 snprintf(_dw_app_id, 100, "%s.%s", DW_APP_DOMAIN_DEFAULT, pos); | 4279 snprintf(_dw_app_id, 100, "%s.%s", DW_APP_DOMAIN_DEFAULT, pos); |
4283 strncpy(_dw_app_name, pos, 100); | 4280 strncpy(_dw_app_name, pos, 100); |
4284 } | 4281 } |
4285 #endif | |
4286 } | 4282 } |
4287 } | 4283 } |
4288 /* If that failed... just get the current directory */ | 4284 /* If that failed... just get the current directory */ |
4289 if(!_dw_exec_dir[0]) | 4285 if(!_dw_exec_dir[0]) |
4290 GetCurrentDirectoryA(MAX_PATH, _dw_exec_dir); | 4286 GetCurrentDirectoryA(MAX_PATH, _dw_exec_dir); |
4440 memset(&wc, 0, sizeof(WNDCLASS)); | 4436 memset(&wc, 0, sizeof(WNDCLASS)); |
4441 wc.lpszClassName = BrowserClassName; | 4437 wc.lpszClassName = BrowserClassName; |
4442 wc.style = CS_HREDRAW | CS_VREDRAW; | 4438 wc.style = CS_HREDRAW | CS_VREDRAW; |
4443 #ifdef BUILD_EDGE | 4439 #ifdef BUILD_EDGE |
4444 /* Check if Microsoft Edge (Chromium) is installed */ | 4440 /* Check if Microsoft Edge (Chromium) is installed */ |
4445 if (_DW_EDGE_DETECTED = _dw_edge_detect()) | 4441 if (_DW_EDGE_DETECTED = _dw_edge_detect(UTF8toWide(_dw_app_id))) |
4446 { | 4442 { |
4447 wc.lpfnWndProc = (WNDPROC)_edgeWindowProc; | 4443 wc.lpfnWndProc = (WNDPROC)_edgeWindowProc; |
4448 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); | 4444 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); |
4449 } | 4445 } |
4450 else | 4446 else |
4500 { | 4496 { |
4501 if(!(hrichedit = LoadLibrary(TEXT("riched20")))) | 4497 if(!(hrichedit = LoadLibrary(TEXT("riched20")))) |
4502 hrichedit = LoadLibrary(TEXT("riched32")); | 4498 hrichedit = LoadLibrary(TEXT("riched32")); |
4503 } | 4499 } |
4504 #endif | 4500 #endif |
4505 #ifdef BUILD_TOAST | |
4506 if(!_dw_app_id[0]) | 4501 if(!_dw_app_id[0]) |
4507 { | 4502 { |
4508 /* Generate an Application ID based on the PID if all else fails. */ | 4503 /* Generate an Application ID based on the PID if all else fails. */ |
4509 snprintf(_dw_app_id, 100, "%s.pid.%d", DW_APP_DOMAIN_DEFAULT, getpid()); | 4504 snprintf(_dw_app_id, 100, "%s.pid.%d", DW_APP_DOMAIN_DEFAULT, getpid()); |
4510 } | 4505 } |
4516 pos = strrchr(fullpath, '\\'); | 4511 pos = strrchr(fullpath, '\\'); |
4517 if(pos) | 4512 if(pos) |
4518 pos++; | 4513 pos++; |
4519 strncpy(_dw_app_name, pos ? pos : fullpath, 100); | 4514 strncpy(_dw_app_name, pos ? pos : fullpath, 100); |
4520 } | 4515 } |
4516 #ifdef BUILD_TOAST | |
4521 _dw_toast_init(UTF8toWide(_dw_app_name), UTF8toWide(_dw_app_id)); | 4517 _dw_toast_init(UTF8toWide(_dw_app_name), UTF8toWide(_dw_app_id)); |
4522 #endif | 4518 #endif |
4523 return 0; | 4519 return 0; |
4524 } | 4520 } |
4525 | 4521 |
12915 * The appname is only required on Windows. If NULL is passed the detected | 12911 * The appname is only required on Windows. If NULL is passed the detected |
12916 * application name will be used, but a prettier name may be desired. | 12912 * application name will be used, but a prettier name may be desired. |
12917 */ | 12913 */ |
12918 int API dw_app_id_set(const char *appid, const char *appname) | 12914 int API dw_app_id_set(const char *appid, const char *appname) |
12919 { | 12915 { |
12920 #ifdef BUILD_TOAST | |
12921 strncpy(_dw_app_id, appid, 100); | 12916 strncpy(_dw_app_id, appid, 100); |
12922 if(appname) | 12917 if(appname) |
12923 strncpy(_dw_app_name, appname, 100); | 12918 strncpy(_dw_app_name, appname, 100); |
12924 return DW_ERROR_NONE; | 12919 return DW_ERROR_NONE; |
12925 #else | |
12926 return DW_ERROR_UNKNOWN; | |
12927 #endif | |
12928 } | 12920 } |
12929 | 12921 |
12930 /* | 12922 /* |
12931 * Call a function from the window (widget)'s context. | 12923 * Call a function from the window (widget)'s context. |
12932 * Parameters: | 12924 * Parameters: |