comparison mac/dw.m @ 2081:24875681eec5

Added htmlEngine to DWEnv
author mhessling@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 31 May 2020 05:25:18 +0000
parents a42267bf4208
children 94ea915bd917
comparison
equal deleted inserted replaced
2080:8f08d4c9d3fc 2081:24875681eec5
790 case 18: 790 case 18:
791 { 791 {
792 int (* API htmlresultfunc)(HWND, int, char *, void *, void *) = handler->signalfunction; 792 int (* API htmlresultfunc)(HWND, int, char *, void *, void *) = handler->signalfunction;
793 void **params = (void **)event; 793 void **params = (void **)event;
794 NSString *result = params[0]; 794 NSString *result = params[0];
795 795
796 return htmlresultfunc(handler->window, [result length] ? DW_ERROR_NONE : DW_ERROR_UNKNOWN, [result length] ? (char *)[result UTF8String] : NULL, params[1], handler->data); 796 return htmlresultfunc(handler->window, [result length] ? DW_ERROR_NONE : DW_ERROR_UNKNOWN, [result length] ? (char *)[result UTF8String] : NULL, params[1], handler->data);
797 } 797 }
798 /* HTML changed event */ 798 /* HTML changed event */
799 case 19: 799 case 19:
800 { 800 {
801 int (* API htmlchangedfunc)(HWND, int, char *, void *) = handler->signalfunction; 801 int (* API htmlchangedfunc)(HWND, int, char *, void *) = handler->signalfunction;
802 void **params = (void **)event; 802 void **params = (void **)event;
803 NSString *uri = params[1]; 803 NSString *uri = params[1];
804 804
805 return htmlchangedfunc(handler->window, DW_POINTER_TO_INT(params[0]), (char *)[uri UTF8String], handler->data); 805 return htmlchangedfunc(handler->window, DW_POINTER_TO_INT(params[0]), (char *)[uri UTF8String], handler->data);
806 } 806 }
807 } 807 }
808 } 808 }
809 return -1; 809 return -1;
8878 */ 8878 */
8879 int dw_html_javascript_run(HWND handle, const char *script, void *scriptdata) 8879 int dw_html_javascript_run(HWND handle, const char *script, void *scriptdata)
8880 { 8880 {
8881 DWWebView *html = handle; 8881 DWWebView *html = handle;
8882 DW_LOCAL_POOL_IN; 8882 DW_LOCAL_POOL_IN;
8883 8883
8884 #if WK_API_ENABLED 8884 #if WK_API_ENABLED
8885 [html evaluateJavaScript:[NSString stringWithUTF8String:script] completionHandler:^(NSString *result, NSError *error) 8885 [html evaluateJavaScript:[NSString stringWithUTF8String:script] completionHandler:^(NSString *result, NSError *error)
8886 { 8886 {
8887 void *params[2] = { result, scriptdata }; 8887 void *params[2] = { result, scriptdata };
8888 _event_handler(html, (NSEvent *)params, 18); 8888 _event_handler(html, (NSEvent *)params, 18);
10760 HWND dw_notification_new(const char *title, HPIXMAP pixmap, const char *description, ...) 10760 HWND dw_notification_new(const char *title, HPIXMAP pixmap, const char *description, ...)
10761 { 10761 {
10762 #ifdef BUILDING_FOR_MOUNTAIN_LION 10762 #ifdef BUILDING_FOR_MOUNTAIN_LION
10763 char outbuf[1025] = {0}; 10763 char outbuf[1025] = {0};
10764 HWND retval = NULL; 10764 HWND retval = NULL;
10765 10765
10766 if(description) 10766 if(description)
10767 { 10767 {
10768 va_list args; 10768 va_list args;
10769 10769
10770 va_start(args, description); 10770 va_start(args, description);
10777 if (@available(macOS 10.14, *)) 10777 if (@available(macOS 10.14, *))
10778 { 10778 {
10779 if([[NSBundle mainBundle] bundleIdentifier] != nil) 10779 if([[NSBundle mainBundle] bundleIdentifier] != nil)
10780 { 10780 {
10781 UNMutableNotificationContent* notification = [[UNMutableNotificationContent alloc] init]; 10781 UNMutableNotificationContent* notification = [[UNMutableNotificationContent alloc] init];
10782 10782
10783 if(notification) 10783 if(notification)
10784 { 10784 {
10785 notification.title = [NSString stringWithUTF8String:title]; 10785 notification.title = [NSString stringWithUTF8String:title];
10786 if(description) 10786 if(description)
10787 notification.body = [NSString stringWithUTF8String:outbuf]; 10787 notification.body = [NSString stringWithUTF8String:outbuf];
10792 else 10792 else
10793 #endif 10793 #endif
10794 { 10794 {
10795 // Fallback on earlier versions 10795 // Fallback on earlier versions
10796 NSUserNotification *notification = [[NSUserNotification alloc] init]; 10796 NSUserNotification *notification = [[NSUserNotification alloc] init];
10797 10797
10798 if(notification) 10798 if(notification)
10799 { 10799 {
10800 notification.title = [NSString stringWithUTF8String:title]; 10800 notification.title = [NSString stringWithUTF8String:title];
10801 notification.informativeText = [NSString stringWithUTF8String:outbuf]; 10801 notification.informativeText = [NSString stringWithUTF8String:outbuf];
10802 if(pixmap && pixmap->image) 10802 if(pixmap && pixmap->image)
10830 { 10830 {
10831 UNMutableNotificationContent *content = (UNMutableNotificationContent *)notification; 10831 UNMutableNotificationContent *content = (UNMutableNotificationContent *)notification;
10832 NSString *notid = [NSString stringWithFormat:@"dw-notification-%llu", (unsigned long long)notification]; 10832 NSString *notid = [NSString stringWithFormat:@"dw-notification-%llu", (unsigned long long)notification];
10833 UNNotificationRequest* request = [UNNotificationRequest requestWithIdentifier:notid 10833 UNNotificationRequest* request = [UNNotificationRequest requestWithIdentifier:notid
10834 content:content trigger:nil]; 10834 content:content trigger:nil];
10835 10835
10836 UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter]; 10836 UNUserNotificationCenter* center = [UNUserNotificationCenter currentNotificationCenter];
10837 [center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) { 10837 [center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
10838 _event_handler(notification, nil, 8); 10838 _event_handler(notification, nil, 8);
10839 }]; 10839 }];
10840 } 10840 }
10862 memset(env, '\0', sizeof(DWEnv)); 10862 memset(env, '\0', sizeof(DWEnv));
10863 strcpy(env->osName, "MacOS"); 10863 strcpy(env->osName, "MacOS");
10864 10864
10865 strncpy(env->buildDate, __DATE__, sizeof(env->buildDate)-1); 10865 strncpy(env->buildDate, __DATE__, sizeof(env->buildDate)-1);
10866 strncpy(env->buildTime, __TIME__, sizeof(env->buildTime)-1); 10866 strncpy(env->buildTime, __TIME__, sizeof(env->buildTime)-1);
10867 #ifdef WK_API_ENABLED
10868 strncpy(env->htmlEngine, "WEBKIT", sizeof(env->htmlEngine)-1);
10869 #else
10870 strncpy(env->htmlEngine, "WEBVIEW", sizeof(env->htmlEngine)-1);
10871 #endif
10867 env->DWMajorVersion = DW_MAJOR_VERSION; 10872 env->DWMajorVersion = DW_MAJOR_VERSION;
10868 env->DWMinorVersion = DW_MINOR_VERSION; 10873 env->DWMinorVersion = DW_MINOR_VERSION;
10869 #ifdef VER_REV 10874 #ifdef VER_REV
10870 env->DWSubVersion = VER_REV; 10875 env->DWSubVersion = VER_REV;
10871 #else 10876 #else
12047 if(argc > 0 && argv[0]) 12052 if(argc > 0 && argv[0])
12048 { 12053 {
12049 char *pathcopy = strdup(argv[0]); 12054 char *pathcopy = strdup(argv[0]);
12050 char *app = strstr(pathcopy, ".app/"); 12055 char *app = strstr(pathcopy, ".app/");
12051 char *binname = strrchr(pathcopy, '/'); 12056 char *binname = strrchr(pathcopy, '/');
12052 12057
12053 if(binname && (binname++) && !_dw_app_id[0]) 12058 if(binname && (binname++) && !_dw_app_id[0])
12054 { 12059 {
12055 /* If we have a binary name, use that for the Application ID instead. */ 12060 /* If we have a binary name, use that for the Application ID instead. */
12056 snprintf(_dw_app_id, 100, "%s.%s", DW_APP_DOMAIN_DEFAULT, binname); 12061 snprintf(_dw_app_id, 100, "%s.%s", DW_APP_DOMAIN_DEFAULT, binname);
12057 } 12062 }