comparison win/dw.c @ 2127:663467f6eee4

Code cleanup: Add constants to header for dark mode, buffer sizes and Unicode support. Windows and OS/2 can both be built without Unicode support for legacy platforms and apps. Some new Windows features require Unicode (notifications, edge) and Unicode is buggy on OS/2. Can now check if Unicode is supported with the DW_FEATURE_UTF8_UNICODE feature test. Dark mode constants added DW_DARK_MODE_DISABLED/BASIC/FULL/FORCED. Win: Include dw.h in the WinToast glue for the constants, and improve safety in Edge glue.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 28 Jun 2020 20:34:25 +0000
parents 97839ff3c985
children 9e6e4ebd5e96
comparison
equal deleted inserted replaced
2126:97839ff3c985 2127:663467f6eee4
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 static char _dw_app_id[101]= {0}; 281 static char _dw_app_id[_DW_APP_ID_SIZE+1]= {0};
282 static char _dw_app_name[101]= {0}; 282 static char _dw_app_name[_DW_APP_ID_SIZE+1]= {0};
283 283
284 int main(int argc, char *argv[]); 284 int main(int argc, char *argv[]);
285 285
286 #define ICON_INDEX_LIMIT 200 286 #define ICON_INDEX_LIMIT 200
287 HICON lookup[200]; 287 HICON lookup[200];
4274 { 4274 {
4275 strncpy(_dw_exec_dir, argv[0], (size_t)(pos - argv[0])); 4275 strncpy(_dw_exec_dir, argv[0], (size_t)(pos - argv[0]));
4276 if((pos++) && !_dw_app_id[0]) 4276 if((pos++) && !_dw_app_id[0])
4277 { 4277 {
4278 /* 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. */
4279 _snprintf(_dw_app_id, 100, "%s.%s", DW_APP_DOMAIN_DEFAULT, pos); 4279 _snprintf(_dw_app_id, _DW_APP_ID_SIZE, "%s.%s", DW_APP_DOMAIN_DEFAULT, pos);
4280 strncpy(_dw_app_name, pos, 100); 4280 strncpy(_dw_app_name, pos, _DW_APP_ID_SIZE);
4281 } 4281 }
4282 } 4282 }
4283 } 4283 }
4284 /* If that failed... just get the current directory */ 4284 /* If that failed... just get the current directory */
4285 if(!_dw_exec_dir[0]) 4285 if(!_dw_exec_dir[0])
4432 } 4432 }
4433 4433
4434 if(!_dw_app_id[0]) 4434 if(!_dw_app_id[0])
4435 { 4435 {
4436 /* Generate an Application ID based on the PID if all else fails. */ 4436 /* Generate an Application ID based on the PID if all else fails. */
4437 _snprintf(_dw_app_id, 100, "%s.pid.%d", DW_APP_DOMAIN_DEFAULT, getpid()); 4437 _snprintf(_dw_app_id, _DW_APP_ID_SIZE, "%s.pid.%d", DW_APP_DOMAIN_DEFAULT, getpid());
4438 } 4438 }
4439 if(!_dw_app_name[0]) 4439 if(!_dw_app_name[0])
4440 { 4440 {
4441 /* If we still don't have an app name, get the executable name */ 4441 /* If we still don't have an app name, get the executable name */
4442 char fullpath[261] = {0}, *pos; 4442 char fullpath[MAX_PATH+1] = {0}, *pos;
4443 GetModuleFileNameA(DWInstance, fullpath, 260); 4443 GetModuleFileNameA(DWInstance, fullpath, MAX_PATH);
4444 pos = strrchr(fullpath, '\\'); 4444 pos = strrchr(fullpath, '\\');
4445 if(pos) 4445 if(pos)
4446 pos++; 4446 pos++;
4447 strncpy(_dw_app_name, pos ? pos : fullpath, 100); 4447 strncpy(_dw_app_name, pos ? pos : fullpath, _DW_APP_ID_SIZE);
4448 } 4448 }
4449 4449
4450 #if (defined(BUILD_DLL) || defined(BUILD_HTML)) 4450 #if (defined(BUILD_DLL) || defined(BUILD_HTML))
4451 /* Register HTML renderer class */ 4451 /* Register HTML renderer class */
4452 memset(&wc, 0, sizeof(WNDCLASS)); 4452 memset(&wc, 0, sizeof(WNDCLASS));
12912 * The appname is only required on Windows. If NULL is passed the detected 12912 * The appname is only required on Windows. If NULL is passed the detected
12913 * application name will be used, but a prettier name may be desired. 12913 * application name will be used, but a prettier name may be desired.
12914 */ 12914 */
12915 int API dw_app_id_set(const char *appid, const char *appname) 12915 int API dw_app_id_set(const char *appid, const char *appname)
12916 { 12916 {
12917 strncpy(_dw_app_id, appid, 100); 12917 strncpy(_dw_app_id, appid, _DW_APP_ID_SIZE);
12918 if(appname) 12918 if(appname)
12919 strncpy(_dw_app_name, appname, 100); 12919 strncpy(_dw_app_name, appname, _DW_APP_ID_SIZE);
12920 return DW_ERROR_NONE; 12920 return DW_ERROR_NONE;
12921 } 12921 }
12922 12922
12923 /* 12923 /*
12924 * Call a function from the window (widget)'s context. 12924 * Call a function from the window (widget)'s context.
13376 */ 13376 */
13377 int API dw_feature_get(DWFEATURE feature) 13377 int API dw_feature_get(DWFEATURE feature)
13378 { 13378 {
13379 switch(feature) 13379 switch(feature)
13380 { 13380 {
13381 #ifdef UNICODE
13382 case DW_FEATURE_UTF8_UNICODE:
13383 #endif
13381 #if (defined(BUILD_DLL) || defined(BUILD_HTML)) 13384 #if (defined(BUILD_DLL) || defined(BUILD_HTML))
13382 case DW_FEATURE_HTML: 13385 case DW_FEATURE_HTML:
13383 case DW_FEATURE_HTML_RESULT: 13386 case DW_FEATURE_HTML_RESULT:
13384 #endif 13387 #endif
13385 case DW_FEATURE_CONTAINER_STRIPE: 13388 case DW_FEATURE_CONTAINER_STRIPE:
13428 int API dw_feature_set(DWFEATURE feature, int state) 13431 int API dw_feature_set(DWFEATURE feature, int state)
13429 { 13432 {
13430 switch(feature) 13433 switch(feature)
13431 { 13434 {
13432 /* These features are supported but not configurable */ 13435 /* These features are supported but not configurable */
13436 #ifdef UNICODE
13437 case DW_FEATURE_UTF8_UNICODE:
13438 #endif
13433 #if (defined(BUILD_DLL) || defined(BUILD_HTML)) 13439 #if (defined(BUILD_DLL) || defined(BUILD_HTML))
13434 case DW_FEATURE_HTML: 13440 case DW_FEATURE_HTML:
13435 case DW_FEATURE_HTML_RESULT: 13441 case DW_FEATURE_HTML_RESULT:
13436 #endif 13442 #endif
13437 #ifdef AEROGLASS 13443 #ifdef AEROGLASS