# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1592365101 0 # Node ID 35abef6e33a94a5584ea2583028e4a2181831b39 # Parent b71f46cd58b9ba83e36a35c26e758583452b52d2 Win: Fixed the notification callback when clicking the toast. Currently, the toast isn't clickable once it moves into the action center. This is a known issue with WinToast, because once the toast moves into the action center, it requires a COM notificaiton object be registered. diff -r b71f46cd58b9 -r 35abef6e33a9 win/dw.c --- a/win/dw.c Tue Jun 16 05:46:22 2020 +0000 +++ b/win/dw.c Wed Jun 17 03:38:21 2020 +0000 @@ -2014,7 +2014,7 @@ /* Find any callbacks for this function */ while (tmp) { - if (tmp->message == msg || msg == WM_COMMAND || msg == WM_NOTIFY || tmp->message == WM_USER+1) + if (tmp->message == msg || msg == WM_COMMAND || msg == WM_NOTIFY || tmp->message == WM_USER+1 || msg == WM_USER+102) { switch (msg) { diff -r b71f46cd58b9 -r 35abef6e33a9 win/wintoast.cpp --- a/win/wintoast.cpp Tue Jun 16 05:46:22 2020 +0000 +++ b/win/wintoast.cpp Wed Jun 17 03:38:21 2020 +0000 @@ -7,9 +7,6 @@ extern "C" { LRESULT CALLBACK _wndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2); void dw_signal_disconnect_by_window(HWND window); -#ifdef DEBUG - void dw_debug(const char *format, ...); -#endif } class DWHandler : public IWinToastHandler { @@ -18,40 +15,30 @@ void toastActivated() const { // The user clicked in this toast -#ifdef DEBUG - dw_debug("Sending notification to DW eventhandler\n"); -#endif _wndproc((HWND)templ, WM_USER+102, 0, 0); + dw_signal_disconnect_by_window((HWND)templ); + delete templ; } void toastActivated(int actionIndex) const { // The user clicked on action -#ifdef DEBUG - dw_debug("Sending notification to DW eventhandler via action\n"); -#endif _wndproc((HWND)templ, WM_USER+102, 0, 0); + dw_signal_disconnect_by_window((HWND)templ); + delete templ; } void toastDismissed(WinToastDismissalReason state) const { switch (state) { case UserCanceled: // The user dismissed this toast -#ifdef DEBUG - dw_debug("The user dismissed this toast\n"); -#endif + dw_signal_disconnect_by_window((HWND)templ); delete templ; break; case TimedOut: // The toast has timed out -#ifdef DEBUG - dw_debug("The toast has timed out\n"); -#endif break; case ApplicationHidden: // The application hid the toast using ToastNotifier.hide() -#ifdef DEBUG - dw_debug("The application hid the toast using ToastNotifier.hide()\n"); -#endif break; default: // Toast not activated @@ -61,9 +48,6 @@ void toastFailed() const { // Error showing current toast -#ifdef DEBUG - dw_debug("Toast failed freeing template\n"); -#endif delete templ; } }; @@ -89,8 +73,19 @@ { if(WinToast::isCompatible()) { + // Generate a Microsoft compatible Application User Model ID + LPWSTR company = wcschr(AppID, '.'); + *company = 0; + LPWSTR product = wcschr(++company, '.'); + *product = 0; + LPWSTR subproduct = wcschr(++product, '.'); + if(subproduct) + *subproduct = 0; + LPWSTR version = subproduct ? wcschr(++subproduct, '.') : NULL; + WinToast::instance()->setAppName(AppName); - WinToast::instance()->setAppUserModelId(AppID); + WinToast::instance()->setAppUserModelId(WinToast::instance()->configureAUMI(company, product, + subproduct ? subproduct : L"", (version && version++ && _wtoi(version) > 0) ? version : L"")); WinToast::instance()->initialize(); } }