# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1591375771 0 # Node ID bcc7877dcdaca447596a555e6bdee6a6bf8b735d # Parent 94ea915bd917aaba792523047b1622f94add5adb Win: Add the required wintoast.cpp glue and undo a test change that did not help with the flicker on embedded Edge widgets. diff -r 94ea915bd917 -r bcc7877dcdac win/dw.c --- a/win/dw.c Fri Jun 05 16:27:00 2020 +0000 +++ b/win/dw.c Fri Jun 05 16:49:31 2020 +0000 @@ -4425,7 +4425,7 @@ if (_DW_EDGE_DETECTED = _dw_edge_detect()) { wc.lpfnWndProc = (WNDPROC)_edgeWindowProc; - //wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); + wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); } else #endif diff -r 94ea915bd917 -r bcc7877dcdac win/wintoast.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/win/wintoast.cpp Fri Jun 05 16:49:31 2020 +0000 @@ -0,0 +1,91 @@ +/* Simple WinToast forwarder from Dynamic Windows APIs */ + +#include "wintoastlib.h" + +using namespace WinToastLib; + +class DWHandler : public IWinToastHandler { +public: + void toastActivated() const { + // The user clicked in this toast + } + + void toastActivated(int actionIndex) const { + // The user clicked on action + } + + void toastDismissed(WinToastDismissalReason state) const { + switch (state) { + case UserCanceled: + // The user dismissed this toast" + break; + case TimedOut: + // The toast has timed out + break; + case ApplicationHidden: + // The application hid the toast using ToastNotifier.hide() + break; + default: + // Toast not activated + break; + } + } + + void toastFailed() const { + // Error showing current toast + } +}; + + +enum Results { + ToastClicked, // user clicked on the toast + ToastDismissed, // user dismissed the toast + ToastTimeOut, // toast timed out + ToastHided, // application hid the toast + ToastNotActivated, // toast was not activated + ToastFailed, // toast failed + SystemNotSupported, // system does not support toasts + UnhandledOption, // unhandled option + MultipleTextNotSupported, // multiple texts were provided + InitializationFailure, // toast notification manager initialization failure + ToastNotLaunched // toast could not be launched +}; + +extern "C" { + + void _dw_toast_init(LPWSTR AppName, LPWSTR AppID) + { + if(WinToast::isCompatible()) + { + WinToast::instance()->setAppName(AppName); + WinToast::instance()->setAppUserModelId(AppID); + WinToast::instance()->initialize(); + } + } + + void *_dw_notification_new(LPWSTR title, LPWSTR image, LPWSTR description) + { + if(WinToast::isCompatible()) + { + WinToastTemplate *templ = new WinToastTemplate(image ? WinToastTemplate::ImageAndText02 : WinToastTemplate::Text02); + templ->setTextField(title, WinToastTemplate::FirstLine); + templ->setAttributionText(description); + if(image) + templ->setImagePath(image); + return (void *)templ; + } + return NULL; + } + + int _dw_notification_send(void *notification) + { + if(WinToast::isCompatible()) + { + WinToastTemplate *templ = (WinToastTemplate *)notification; + + if(templ && WinToast::instance()->showToast(*templ, new DWHandler()) >= 0) + return 0; // DW_ERROR_NONE + } + return -1; // DW_ERROR_UNKNOWN + } +}