diff --git a/PowerToys.sln b/PowerToys.sln index a1fb9fc4cf..b9cbb148e4 100644 --- a/PowerToys.sln +++ b/PowerToys.sln @@ -88,6 +88,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PowerRenameUWPUI", "src\mod {0E072714-D127-460B-AFAD-B4C40B412798} = {0E072714-D127-460B-AFAD-B4C40B412798} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "notifications", "src\common\notifications_winrt\notifications.vcxproj", "{0B593A6C-4143-4337-860E-DB5710FB87DB}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "notifications_dll", "src\common\notifications\notifications_dll.vcxproj", "{031AC72E-FA28-4AB7-B690-6F7B9C28AA73}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "windowwalker", "windowwalker", "{8DC78AF7-DC3E-4C57-A8FB-7E347DE74A03}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Window Walker", "src\modules\windowwalker\app\Window Walker\Window Walker.csproj", "{B9BDF8BE-FED7-49B5-A7AE-DD4D1CA2D9EB}" @@ -168,6 +172,14 @@ Global {0485F45C-EA7A-4BB5-804B-3E8D14699387}.Debug|x64.Build.0 = Debug|x64 {0485F45C-EA7A-4BB5-804B-3E8D14699387}.Release|x64.ActiveCfg = Release|x64 {0485F45C-EA7A-4BB5-804B-3E8D14699387}.Release|x64.Build.0 = Release|x64 + {0B593A6C-4143-4337-860E-DB5710FB87DB}.Debug|x64.ActiveCfg = Debug|x64 + {0B593A6C-4143-4337-860E-DB5710FB87DB}.Debug|x64.Build.0 = Debug|x64 + {0B593A6C-4143-4337-860E-DB5710FB87DB}.Release|x64.ActiveCfg = Release|x64 + {0B593A6C-4143-4337-860E-DB5710FB87DB}.Release|x64.Build.0 = Release|x64 + {031AC72E-FA28-4AB7-B690-6F7B9C28AA73}.Debug|x64.ActiveCfg = Debug|x64 + {031AC72E-FA28-4AB7-B690-6F7B9C28AA73}.Debug|x64.Build.0 = Debug|x64 + {031AC72E-FA28-4AB7-B690-6F7B9C28AA73}.Release|x64.ActiveCfg = Release|x64 + {031AC72E-FA28-4AB7-B690-6F7B9C28AA73}.Release|x64.Build.0 = Release|x64 {B9BDF8BE-FED7-49B5-A7AE-DD4D1CA2D9EB}.Debug|x64.ActiveCfg = Debug|x64 {B9BDF8BE-FED7-49B5-A7AE-DD4D1CA2D9EB}.Debug|x64.Build.0 = Debug|x64 {B9BDF8BE-FED7-49B5-A7AE-DD4D1CA2D9EB}.Release|x64.ActiveCfg = Release|x64 @@ -199,6 +211,8 @@ Global {2151F984-E006-4A9F-92EF-C6DDE3DC8413} = {89E20BCE-EB9C-46C8-8B50-E01A82E6FDC3} {64A80062-4D8B-4229-8A38-DFA1D7497749} = {BEEAB7F2-FFF6-45AB-9CDB-B04CC0734B88} {0485F45C-EA7A-4BB5-804B-3E8D14699387} = {89E20BCE-EB9C-46C8-8B50-E01A82E6FDC3} + {0B593A6C-4143-4337-860E-DB5710FB87DB} = {1AFB6476-670D-4E80-A464-657E01DFF482} + {031AC72E-FA28-4AB7-B690-6F7B9C28AA73} = {1AFB6476-670D-4E80-A464-657E01DFF482} {8DC78AF7-DC3E-4C57-A8FB-7E347DE74A03} = {4574FDD0-F61D-4376-98BF-E5A1262C11EC} {B9BDF8BE-FED7-49B5-A7AE-DD4D1CA2D9EB} = {8DC78AF7-DC3E-4C57-A8FB-7E347DE74A03} {51D3BD1F-07A8-48EB-B2A0-0A249CD4E1A6} = {8DC78AF7-DC3E-4C57-A8FB-7E347DE74A03} diff --git a/doc/devdocs/common.md b/doc/devdocs/common.md index 2c89bc7517..8b4cdf84ad 100644 --- a/doc/devdocs/common.md +++ b/doc/devdocs/common.md @@ -43,3 +43,67 @@ Helper methods for the settings. #### Start visible helper: [header](/src/common/start_visible.h) [source](/src/common/start_visible.cpp) Contains function to test if the Start menu is visible. + +# Toast Notifications + +#### Notifications API [header](/src/common/notifications.h) [source](/src/common/notifications.cpp) +To use UWP-style toast notifications, simply include the header and call one of these functions: + +```cpp + void show_toast(std::wstring_view message); // #1 + + void show_toast_background_activated( // #2 + std::wstring_view message, + std::wstring_view background_handler_id, + std::vector button_labels); +``` +We might add more functions in the future if the need arises, e.g. `show_toast_xml` which will accept raw XML for rich customization. + +Description: +- `#1` is for sending simple notifications without any callbacks or buttons +- `#2` is capable of showing a toast with multiple buttons and background activation +- `message` is a plain-text argument + +Implement a toast activation handler/callback as a function in [handler_functions.cpp](/src/common/notifications_winrt/handler_functions.cpp) and register its `background_handler_id` via `handlers_map`, e.g.: + +```cpp +// Your .cpp where you'd like to show a toast + +#include + +void some_func() { +// ... + notifications::show_toast_background_activated( + L"Toast message!", // text displayed in a toast + L"awesome_toast", // activation handler id + {L"Press me!", L"Also could press me!", L"I'm here to be pressed!"} // buttons in a toast + ); +``` + +```cpp +// handler_functions.cpp +void awesome_toast_handler(IBackgroundTaskInstance, const size_t button_id) +{ + switch(button_id) + { + case 0: + // handle "Press me!" button click + case 1: + // handle "Also could press me!" button click + case 2: + // handle "I'm here to be pressed!" button click + } +} + +namespace +{ + const std::unordered_map handlers_map = { + // ...other handlers... + {L"awesome_toast", awesome_toast_handler} + };} + +``` + +Note: since _background activation_ implies that your toast handler will be invoked in a separate process, you can't share data directly from within a handler and your PT process. Also, since PT is currently a Desktop Bridge app, _foreground activation_ is [handled the same as background](https://docs.microsoft.com/en-US/windows/uwp/design/shell/tiles-and-notifications/send-local-toast-desktop-cpp-wrl#foreground-vs-background-activation), therefore we don't make a dedicated API for it. You can read more on the rationale of the current design [here](https://github.com/microsoft/PowerToys/pull/1178#issue-368768337). + + diff --git a/installer/MSIX/PackagingLayout.xml b/installer/MSIX/PackagingLayout.xml index ef63b83964..6ba5034252 100644 --- a/installer/MSIX/PackagingLayout.xml +++ b/installer/MSIX/PackagingLayout.xml @@ -16,6 +16,7 @@ + diff --git a/installer/MSIX/appxmanifest.xml b/installer/MSIX/appxmanifest.xml index d15bbeca33..27f03b6188 100644 --- a/installer/MSIX/appxmanifest.xml +++ b/installer/MSIX/appxmanifest.xml @@ -48,7 +48,20 @@ + + + + + + + + + Notifications.dll + + + + diff --git a/src/common/common.vcxproj b/src/common/common.vcxproj index 666adf1382..21cf2fa1bb 100644 --- a/src/common/common.vcxproj +++ b/src/common/common.vcxproj @@ -99,6 +99,7 @@ + @@ -127,6 +128,7 @@ + Create diff --git a/src/common/common.vcxproj.filters b/src/common/common.vcxproj.filters index 197085eedf..87b34e6bff 100644 --- a/src/common/common.vcxproj.filters +++ b/src/common/common.vcxproj.filters @@ -87,6 +87,9 @@ Header Files + + Header Files + @@ -144,5 +147,8 @@ Source Files + + Source Files + \ No newline at end of file diff --git a/src/common/notifications.cpp b/src/common/notifications.cpp new file mode 100644 index 0000000000..96c64df79c --- /dev/null +++ b/src/common/notifications.cpp @@ -0,0 +1,89 @@ +#include "pch.h" +#include "notifications.h" + +#include +#include +#include +#include +#include +#include +#include + +using namespace winrt::Windows::ApplicationModel::Background; +using winrt::Windows::Data::Xml::Dom::XmlDocument; +using winrt::Windows::UI::Notifications::ToastNotification; +using winrt::Windows::UI::Notifications::ToastNotificationManager; + +namespace +{ + constexpr std::wstring_view TASK_NAME = L"PowerToysBackgroundNotificationsHandler"; + constexpr std::wstring_view TASK_ENTRYPOINT = L"PowerToysNotifications.BackgroundHandler"; + constexpr std::wstring_view APPLICATION_ID = L"PowerToys"; +} + +void notifications::register_background_toast_handler() +{ + try + { + // Re-request access to clean up from previous PowerToys installations + BackgroundExecutionManager::RemoveAccess(); + BackgroundExecutionManager::RequestAccessAsync().get(); + + BackgroundTaskBuilder builder; + ToastNotificationActionTrigger trigger{ APPLICATION_ID }; + builder.SetTrigger(trigger); + builder.TaskEntryPoint(TASK_ENTRYPOINT); + builder.Name(TASK_NAME); + + const auto tasks = BackgroundTaskRegistration::AllTasks(); + const bool already_registered = std::any_of(begin(tasks), end(tasks), [=](const auto& task) { + return task.Value().Name() == TASK_NAME; + }); + if (already_registered) + { + return; + } + (void)builder.Register(); + } + catch (...) + { + // Couldn't register the background task, nothing we can do + } +} + +void notifications::show_toast(std::wstring_view message) +{ + // The toast won't be actually activated in the background, since it doesn't have any buttons + show_toast_background_activated(message, {}, {}); +} + +void notifications::show_toast_background_activated(std::wstring_view message, std::wstring_view background_handler_id, std::vector button_labels) +{ + // DO NOT LOCALIZE any string in this function, because they're XML tags and a subject to + // https://docs.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/toast-xml-schema + + std::wstring toast_xml; + toast_xml.reserve(1024); + toast_xml += LR"(PowerToys)"; + toast_xml += message; + toast_xml += L""; + + for (size_t i = 0; i < size(button_labels); ++i) + { + toast_xml += LR"()"; + } + toast_xml += L""; + + XmlDocument toast_xml_doc; + toast_xml_doc.LoadXml(toast_xml); + ToastNotification notification{ toast_xml_doc }; + + const auto notifier = ToastNotificationManager::ToastNotificationManager::CreateToastNotifier(); + notifier.Show(notification); +} diff --git a/src/common/notifications.h b/src/common/notifications.h new file mode 100644 index 0000000000..f0b525f7a8 --- /dev/null +++ b/src/common/notifications.h @@ -0,0 +1,13 @@ +#pragma once + +#include +#include + +namespace notifications +{ + void register_background_toast_handler(); + + // Make sure your plaintext_message argument is properly XML-escaped + void show_toast(std::wstring_view plaintext_message); + void show_toast_background_activated(std::wstring_view plaintext_message, std::wstring_view background_handler_id, std::vector plaintext_button_labels); +} diff --git a/src/common/notifications/cpp.hint b/src/common/notifications/cpp.hint new file mode 100644 index 0000000000..a6c9ed6025 --- /dev/null +++ b/src/common/notifications/cpp.hint @@ -0,0 +1,2 @@ +#define NOTIFICATIONSDLL_API __declspec(dllexport) +#define NOTIFICATIONSDLL_API __declspec(dllimport) diff --git a/src/common/notifications/dllmain.cpp b/src/common/notifications/dllmain.cpp new file mode 100644 index 0000000000..9ec9aac887 --- /dev/null +++ b/src/common/notifications/dllmain.cpp @@ -0,0 +1,26 @@ +#include "pch.h" + +STDAPI DllRegisterServer() +{ + return S_OK; +} + +STDAPI DllUnregisterServer() +{ + return S_OK; +} + +BOOL APIENTRY DllMain(HMODULE, + DWORD ul_reason_for_call, + LPVOID) +{ + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} diff --git a/src/common/notifications/framework.h b/src/common/notifications/framework.h new file mode 100644 index 0000000000..bb8d8ee3a2 --- /dev/null +++ b/src/common/notifications/framework.h @@ -0,0 +1,8 @@ +#pragma once + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include + +#include +#include +#include diff --git a/src/common/notifications/notifications.def b/src/common/notifications/notifications.def new file mode 100644 index 0000000000..6f14af44a9 --- /dev/null +++ b/src/common/notifications/notifications.def @@ -0,0 +1,5 @@ +EXPORTS +DllCanUnloadNow = WINRT_CanUnloadNow PRIVATE +DllGetActivationFactory = WINRT_GetActivationFactory PRIVATE +DllRegisterServer PRIVATE +DllUnregisterServer PRIVATE diff --git a/src/common/notifications/notifications_dll.vcxproj b/src/common/notifications/notifications_dll.vcxproj new file mode 100644 index 0000000000..e2c31f1883 --- /dev/null +++ b/src/common/notifications/notifications_dll.vcxproj @@ -0,0 +1,194 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + {031AC72E-FA28-4AB7-B690-6F7B9C28AA73} + Win32Proj + notificationsdll + 10.0 + + + + DynamicLibrary + true + v142 + Unicode + + + DynamicLibrary + false + v142 + true + Unicode + + + DynamicLibrary + true + v142 + Unicode + + + DynamicLibrary + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + Notifications + false + + + NOTIFICATIONSDLL + true + + + Notifications + true + + + NOTIFICATIONSDLL + false + + + + Use + Level4 + true + true + true + NDEBUG;NOTIFICATIONSDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + pch.h + stdcpplatest + /await %(AdditionalOptions) + true + + + Windows + true + true + true + false + notifications.def + WindowsApp.lib;%(AdditionalDependencies) + /ignore:4099 %(AdditionalOptions) + + + + + Use + Level3 + true + WIN32;_DEBUG;NOTIFICATIONSDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + pch.h + + + Windows + true + false + + + + + Use + Level4 + true + _DEBUG;NOTIFICATIONSDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + pch.h + stdcpplatest + /await %(AdditionalOptions) + true + + + Windows + true + false + notifications.def + WindowsApp.lib;%(AdditionalDependencies) + /ignore:4099 %(AdditionalOptions) + + + + + Use + Level3 + true + true + true + WIN32;NDEBUG;NOTIFICATIONSDLL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + true + pch.h + + + Windows + true + true + true + false + + + + + + + + + + + + + + Create + Create + Create + Create + + + + + + + + {031AC72E-FA28-4AB7-B690-6F7B9C28AA73} + + + \ No newline at end of file diff --git a/src/common/notifications/notifications_dll.vcxproj.filters b/src/common/notifications/notifications_dll.vcxproj.filters new file mode 100644 index 0000000000..daaa21a60d --- /dev/null +++ b/src/common/notifications/notifications_dll.vcxproj.filters @@ -0,0 +1,39 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + + Resource Files + + + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + \ No newline at end of file diff --git a/src/common/notifications/pch.cpp b/src/common/notifications/pch.cpp new file mode 100644 index 0000000000..64b7eef6d6 --- /dev/null +++ b/src/common/notifications/pch.cpp @@ -0,0 +1,5 @@ +// pch.cpp: source file corresponding to the pre-compiled header + +#include "pch.h" + +// When you are using pre-compiled headers, this source file is necessary for compilation to succeed. diff --git a/src/common/notifications/pch.h b/src/common/notifications/pch.h new file mode 100644 index 0000000000..20fe3b3766 --- /dev/null +++ b/src/common/notifications/pch.h @@ -0,0 +1,8 @@ +#pragma once + +#ifndef PCH_H +#define PCH_H + +#include "framework.h" + +#endif //PCH_H diff --git a/src/common/notifications_winrt/BackgroundHandler.cpp b/src/common/notifications_winrt/BackgroundHandler.cpp new file mode 100644 index 0000000000..6a73ff6c72 --- /dev/null +++ b/src/common/notifications_winrt/BackgroundHandler.cpp @@ -0,0 +1,27 @@ +#include "pch.h" +#include "BackgroundHandler.h" +#include "BackgroundHandler.g.cpp" + +#include "handler_functions.h" + +namespace winrt::PowerToysNotifications::implementation +{ + using Windows::ApplicationModel::Background::IBackgroundTaskInstance; + using Windows::UI::Notifications::ToastNotificationActionTriggerDetail; + using Windows::Foundation::WwwFormUrlDecoder; + + void BackgroundHandler::Run(IBackgroundTaskInstance bti) + { + const auto details = bti.TriggerDetails().try_as(); + if (!details) + { + return; + } + + WwwFormUrlDecoder decoder{details.Argument()}; + + const size_t button_id = std::stoi(decoder.GetFirstValueByName(L"button_id").c_str()); + auto handler = decoder.GetFirstValueByName(L"handler"); + dispatch_to_backround_handler(std::move(handler), std::move(bti), button_id); + } +} diff --git a/src/common/notifications_winrt/BackgroundHandler.h b/src/common/notifications_winrt/BackgroundHandler.h new file mode 100644 index 0000000000..73cff3dfa8 --- /dev/null +++ b/src/common/notifications_winrt/BackgroundHandler.h @@ -0,0 +1,20 @@ +#pragma once + +#include "BackgroundHandler.g.h" + +namespace winrt::PowerToysNotifications::implementation +{ + struct BackgroundHandler : BackgroundHandlerT + { + BackgroundHandler() = default; + + void Run(winrt::Windows::ApplicationModel::Background::IBackgroundTaskInstance); + }; +} + +namespace winrt::PowerToysNotifications::factory_implementation +{ + struct BackgroundHandler : BackgroundHandlerT + { + }; +} diff --git a/src/common/notifications_winrt/BackgroundHandler.idl b/src/common/notifications_winrt/BackgroundHandler.idl new file mode 100644 index 0000000000..9a85cb8c0d --- /dev/null +++ b/src/common/notifications_winrt/BackgroundHandler.idl @@ -0,0 +1,11 @@ +namespace PowerToysNotifications +{ + [version(1)] + [default_interface] + runtimeclass BackgroundHandler : Windows.ApplicationModel.Background.IBackgroundTask + { + BackgroundHandler(); + + void Run(Windows.ApplicationModel.Background.IBackgroundTaskInstance taskInstance); + } +} diff --git a/src/common/notifications_winrt/PropertySheet.props b/src/common/notifications_winrt/PropertySheet.props new file mode 100644 index 0000000000..e34141b019 --- /dev/null +++ b/src/common/notifications_winrt/PropertySheet.props @@ -0,0 +1,16 @@ + + + + + + + + \ No newline at end of file diff --git a/src/common/notifications_winrt/handler_functions.cpp b/src/common/notifications_winrt/handler_functions.cpp new file mode 100644 index 0000000000..39e04b2038 --- /dev/null +++ b/src/common/notifications_winrt/handler_functions.cpp @@ -0,0 +1,20 @@ +#include "pch.h" + +#include "handler_functions.h" + +using handler_function_t = void (*)(IBackgroundTaskInstance, const size_t button_id); + +namespace +{ + const std::unordered_map handlers_map; +} + +void dispatch_to_backround_handler(std::wstring_view background_handler_id, IBackgroundTaskInstance bti, const size_t button_id) +{ + const auto found_handler = handlers_map.find(background_handler_id); + if (found_handler == end(handlers_map)) + { + return; + } + found_handler->second(std::move(bti), button_id); +} diff --git a/src/common/notifications_winrt/handler_functions.h b/src/common/notifications_winrt/handler_functions.h new file mode 100644 index 0000000000..098a0c18e5 --- /dev/null +++ b/src/common/notifications_winrt/handler_functions.h @@ -0,0 +1,5 @@ +#pragma once + +using winrt::Windows::ApplicationModel::Background::IBackgroundTaskInstance; + +void dispatch_to_backround_handler(std::wstring_view background_handler_id, IBackgroundTaskInstance bti, const size_t button_id); diff --git a/src/common/notifications_winrt/notifications.vcxproj b/src/common/notifications_winrt/notifications.vcxproj new file mode 100644 index 0000000000..627e79f833 --- /dev/null +++ b/src/common/notifications_winrt/notifications.vcxproj @@ -0,0 +1,157 @@ + + + + + true + true + true + true + {0b593a6c-4143-4337-860e-db5710fb87db} + notifications + PowerToysNotifications + en-US + 14.0 + true + Windows Store + 10.0 + 10.0 + 10.0.17134.0 + + + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + Win32 + + + Release + x64 + + + + StaticLibrary + v140 + v141 + v142 + Unicode + false + + + true + true + + + false + true + false + + + + + + + + + + + + + + + notifications + + + notifications + + + + Use + pch.h + $(IntDir)pch.pch + Level4 + %(AdditionalOptions) /bigobj + + /DWINRT_NO_MAKE_DETECTION /await %(AdditionalOptions) + + + _WINRT_DLL;WIN32_LEAN_AND_MEAN;WINRT_LEAN_AND_MEAN;%(PreprocessorDefinitions) + $(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories) + + + Console + false + notifications.def + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + stdcpplatest + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + stdcpplatest + + + true + true + + + + + + + BackgroundHandler.idl + + + + + + Create + + + BackgroundHandler.idl + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file diff --git a/src/common/notifications_winrt/notifications.vcxproj.filters b/src/common/notifications_winrt/notifications.vcxproj.filters new file mode 100644 index 0000000000..097a6072f1 --- /dev/null +++ b/src/common/notifications_winrt/notifications.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + accd3aa8-1ba0-4223-9bbe-0c431709210b + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tga;tiff;tif;png;wav;mfcribbon-ms + + + {926ab91d-31b4-48c3-b9a4-e681349f27f0} + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/common/notifications_winrt/packages.config b/src/common/notifications_winrt/packages.config new file mode 100644 index 0000000000..c4867c30bf --- /dev/null +++ b/src/common/notifications_winrt/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/common/notifications_winrt/pch.cpp b/src/common/notifications_winrt/pch.cpp new file mode 100644 index 0000000000..bcb5590be1 --- /dev/null +++ b/src/common/notifications_winrt/pch.cpp @@ -0,0 +1 @@ +#include "pch.h" diff --git a/src/common/notifications_winrt/pch.h b/src/common/notifications_winrt/pch.h new file mode 100644 index 0000000000..0b82dcd2f1 --- /dev/null +++ b/src/common/notifications_winrt/pch.h @@ -0,0 +1,7 @@ +#pragma once +#include +#include "winrt/Windows.ApplicationModel.Background.h" +#include +#include +#include +#include diff --git a/src/runner/main.cpp b/src/runner/main.cpp index 05b4e6d3cc..2f562ccba6 100644 --- a/src/runner/main.cpp +++ b/src/runner/main.cpp @@ -13,6 +13,9 @@ #include #include +#include +#include + #if _DEBUG && _WIN64 #include "unhandled_exception_handler.h" #endif @@ -43,6 +46,10 @@ int runner() Trace::RegisterProvider(); winrt::init_apartment(); start_tray_icon(); + if (winstore::running_as_packaged()) + { + notifications::register_background_toast_handler(); + } int result; try {