Godot Engine – Multi-platform 2D and 3D game engine
[Windows] Implement support for desktop toast notifications.
bruvzg4f36d054cb93
diff --git a/doc/classes/DisplayServer.xml b/doc/classes/DisplayServer.xmlindex ab037aa890b..ba096540e6d 100644--- a/doc/classes/DisplayServer.xml+++ b/doc/classes/DisplayServer.xml@@ -1582,6 +1582,14 @@[b]Note:[/b] This method is implemented only on macOS.</description></method>+ <method name="hide_toast_notification">+ <return type="void" />+ <param index="0" name="id" type="int" />+ <description>+ Hides the toast notification with [param id] returned by [method send_toast_notification].+ [b]Note:[/b] This method is only implemented on Windows.+ </description>+ </method><method name="ime_get_selection" qualifiers="const"><return type="Vector2i" /><description>@@ -1897,6 +1905,17 @@[b]Note:[/b] On iOS, this method has no effect if [member ProjectSettings.display/window/handheld/orientation] is not set to [constant SCREEN_SENSOR].</description></method>+ <method name="send_toast_notification">+ <return type="int" />+ <param index="0" name="title" type="String" />+ <param index="1" name="text" type="String" />+ <param index="2" name="image" type="Texture2D" />+ <param index="3" name="callback" type="Callable" />+ <description>+ Displays a toast notification with [param title], [param text], and optionally [param image]. [param image] should be square, have a maximum edge length of 512 pixels, and should not exceed 4 MB when encoded as PNG. [param callback] should accept two arguments: [int] (notification ID) and [enum NotificationStatus]. Returns the notification ID or [constant INVALID_NOTIFICATION_ID] if it failed.+ [b]Note:[/b] This method is only implemented on Windows.+ </description>+ </method><method name="set_hardware_keyboard_connection_change_callback"><return type="void" /><param index="0" name="callable" type="Callable" />@@ -3147,6 +3166,9 @@<constant name="INVALID_INDICATOR_ID" value="-1">The ID that refers to a nonexistent application status indicator.</constant>+ <constant name="INVALID_NOTIFICATION_ID" value="-1">+ The ID that refers to a nonexistent toast notification.+ </constant><constant name="SCREEN_LANDSCAPE" value="0" enum="ScreenOrientation">Default landscape orientation.</constant>@@ -3429,6 +3451,15 @@<constant name="WINDOW_EDGE_MAX" value="8" enum="WindowResizeEdge">Represents the size of the [enum WindowResizeEdge] enum.</constant>+ <constant name="NOTIFICATION_ACTIVATED" value="0" enum="NotificationStatus">+ User activates a toast notification through a click or touch.+ </constant>+ <constant name="NOTIFICATION_DISMISSED" value="1" enum="NotificationStatus">+ A toast notification expires or is explicitly dismissed by the user.+ </constant>+ <constant name="NOTIFICATION_FAILED" value="2" enum="NotificationStatus">+ Attempts to raise a toast notification failed.+ </constant><constant name="VSYNC_DISABLED" value="0" enum="VSyncMode">No vertical synchronization, which means the engine will display frames as fast as possible (tearing may be visible). Framerate is unlimited (regardless of [member Engine.max_fps]).</constant>diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cppindex a242a417094..dcea6be7296 100644--- a/platform/windows/display_server_windows.cpp+++ b/platform/windows/display_server_windows.cpp@@ -76,6 +76,7 @@#include <dwmapi.h>#include <propkey.h>#include <propvarutil.h>+#include <psapi.h>#include <shellapi.h>#include <shellscalingapi.h>#include <shlwapi.h>@@ -872,30 +873,110 @@ void DisplayServerWindows::_thread_fd_monitor(void *p_ud) {}}-Error DisplayServerWindows::_file_dialog_with_options_show(const String &p_title, const String &p_current_directory, const String &p_root, const String &p_filename, bool p_show_hidden, DisplayServerEnums::FileDialogMode p_mode, const Vector<String> &p_filters, const TypedArray<Dictionary> &p_options, const Callable &p_callback, bool p_options_in_cb, DisplayServerEnums::WindowID p_window_id) {- _THREAD_SAFE_METHOD_+String DisplayServerWindows::_get_app_id() const {+ static String appname;+ if (appname.is_empty()) {+ if (Engine::get_singleton()->is_editor_hint()) {+ appname = "Godot.GodotEditor." + String(GODOT_VERSION_FULL_CONFIG);+ } else {+ String name = GLOBAL_GET("application/config/name");+ String version = GLOBAL_GET("application/config/version");+ if (version.is_empty()) {+ version = "0";+ }+ String clean_app_name = name.to_pascal_case();+ for (int i = 0; i < clean_app_name.length(); i++) {+ if (!is_ascii_alphanumeric_char(clean_app_name[i]) && clean_app_name[i] != '_' && clean_app_name[i] != '.') {+ clean_app_name[i] = '_';+ }+ }+ clean_app_name = clean_app_name.substr(0, 120 - version.length()).trim_suffix(".");+ appname = "Godot." + clean_app_name + "." + version;+ }+ }+ return appname;+}- ERR_FAIL_INDEX_V(int(p_mode), DisplayServerEnums::FILE_DIALOG_MODE_SAVE_MAX, FAILED);+String DisplayServerWindows::_get_app_name() const {+ static String appname;+ if (appname.is_empty()) {+ if (Engine::get_singleton()->is_editor_hint()) {+ appname = "Godot";+ } else {+ appname = GLOBAL_GET("application/config/name");+ }+ }+ return appname;+}- String appname;- if (Engine::get_singleton()->is_editor_hint()) {- appname = "Godot.GodotEditor." + String(GODOT_VERSION_BRANCH);+bool DisplayServerWindows::_try_create_shortcut() {+ String path = vformat("%s\\Microsoft\\Windows\\Start Menu\\Programs\\%s.lnk", OS::get_singleton()->get_environment("APPDATA"), _get_app_name());+ Char16String cs_path = path.utf16();+ DWORD attributes = GetFileAttributesW((PCWSTR)cs_path.get_data());++ if (attributes < 0xFFFFFFF) {+ return true;} else {- String name = GLOBAL_GET("application/config/name");- String version = GLOBAL_GET("application/config/version");- if (version.is_empty()) {- version = "0";+ wchar_t exe_path[MAX_PATH];+ DWORD sz = GetModuleFileNameExW(GetCurrentProcess(), nullptr, exe_path, ARRAYSIZE(exe_path));+ if (sz == 0) {+ return false;}- String clean_app_name = name.to_pascal_case();- for (int i = 0; i < clean_app_name.length(); i++) {- if (!is_ascii_alphanumeric_char(clean_app_name[i]) && clean_app_name[i] != '_' && clean_app_name[i] != '.') {- clean_app_name[i] = '_';++ bool done = false;+ IShellLinkW *shell_link = nullptr;+ HRESULT hr = CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&shell_link));+ if (SUCCEEDED(hr)) {+ shell_link->SetPath(exe_path);+ shell_link->SetArguments(L"");++ IPropertyStore *prop_store = nullptr;+ hr = shell_link->QueryInterface(IID_PPV_ARGS(&prop_store));+ if (SUCCEEDED(hr)) {+ PROPVARIANT val;+ String appid = _get_app_id();+ InitPropVariantFromString((PCWSTR)appid.utf16().get_data(), &val);+ prop_store->SetValue(PKEY_AppUserModel_ID, val);+ prop_store->Commit();++ IPersistFile *persist_file = nullptr;+ hr = shell_link->QueryInterface(IID_PPV_ARGS(&persist_file));+ if (SUCCEEDED(hr)) {+ hr = persist_file->Save((PCWSTR)cs_path.get_data(), true);+ if (SUCCEEDED(hr)) {+ done = true;+ }+ persist_file->Release();+ }+ PropVariantClear(&val);+ prop_store->Release();}+ shell_link->Release();}- clean_app_name = clean_app_name.substr(0, 120 - version.length()).trim_suffix(".");- appname = "Godot." + clean_app_name + "." + version;+ return done;+ }+}++DisplayServerEnums::NotificationID DisplayServerWindows::send_toast_notification(const String &p_title, const String &p_text, const Ref<Texture2D> &p_image, const Callable &p_callback) {+ if (!has_winrt_queue) {+ return DisplayServerEnums::INVALID_NOTIFICATION_ID;+ }+ if (!_try_create_shortcut()) {+ return DisplayServerEnums::INVALID_NOTIFICATION_ID;}+ return WinRTUtils::send_toast_notification(p_title, p_text, p_image, p_callback);+}++void DisplayServerWindows::hide_toast_notification(DisplayServerEnums::NotificationID p_id) {+ if (has_winrt_queue) {+ WinRTUtils::hide_toast_notification(p_id);+ }+}++Error DisplayServerWindows::_file_dialog_with_options_show(const String &p_title, const String &p_current_directory, const String &p_root, const String &p_filename, bool p_show_hidden, DisplayServerEnums::FileDialogMode p_mode, const Vector<String> &p_filters, const TypedArray<Dictionary> &p_options, const Callable &p_callback, bool p_options_in_cb, DisplayServerEnums::WindowID p_window_id) {+ _THREAD_SAFE_METHOD_+ ERR_FAIL_INDEX_V(int(p_mode), DisplayServerEnums::FILE_DIALOG_MODE_SAVE_MAX, FAILED);FileDialogData *fd = memnew(FileDialogData);if (windows.has(p_window_id) && !windows[p_window_id].is_popup) {fd->hwnd_owner = windows[p_window_id].hWnd;@@ -906,7 +987,7 @@ Error DisplayServerWindows::_file_dialog_with_options_show(const String &p_titlefd->hwnd_owner = nullptr;fd->wrect = Rect2i(CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT);}- fd->appid = appname;+ fd->appid = _get_app_id();fd->title = p_title;fd->current_directory = p_current_directory;fd->root = p_root;@@ -7383,25 +7464,8 @@ Error DisplayServerWindows::_create_window(DisplayServerEnums::WindowID p_windowHRESULT hr = SHGetPropertyStoreForWindow(wd.hWnd, IID_IPropertyStore, (void **)&prop_store);if (hr == S_OK) {PROPVARIANT val;- String appname;- if (Engine::get_singleton()->is_editor_hint()) {- appname = "Godot.GodotEditor." + String(GODOT_VERSION_FULL_CONFIG);- } else {- String name = GLOBAL_GET("application/config/name");- String version = GLOBAL_GET("application/config/version");- if (version.is_empty()) {- version = "0";- }- String clean_app_name = name.to_pascal_case();- for (int i = 0; i < clean_app_name.length(); i++) {- if (!is_ascii_alphanumeric_char(clean_app_name[i]) && clean_app_name[i] != '_' && clean_app_name[i] != '.') {- clean_app_name[i] = '_';- }- }- clean_app_name = clean_app_name.substr(0, 120 - version.length()).trim_suffix(".");- appname = "Godot." + clean_app_name + "." + version;- }- InitPropVariantFromString((PCWSTR)appname.utf16().get_data(), &val);+ String appid = _get_app_id();+ InitPropVariantFromString((PCWSTR)appid.utf16().get_data(), &val);prop_store->SetValue(PKEY_AppUserModel_ID, val);prop_store->Release();}@@ -7809,7 +7873,7 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Disnative_menu = memnew(NativeMenuWindows);// Init WinRT API and create dispatch queue.- has_winrt_queue = WinRTUtils::create_queue();+ has_winrt_queue = WinRTUtils::create_queue(_get_app_id());// Init TTS (note: should be called after WinRT init).bool tts_enabled = GLOBAL_GET("audio/general/text_to_speech");diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.hindex ce9e987cb46..ec961d4d8ea 100644--- a/platform/windows/display_server_windows.h+++ b/platform/windows/display_server_windows.h@@ -569,6 +569,10 @@ class DisplayServerWindows : public DisplayServer {void _update_hdr_output_for_window(DisplayServerEnums::WindowID p_window, const WindowData &p_window_data, ScreenHdrData p_screen_data);void _legacy_update_hdr_output_for_tracked_windows(bool p_include_sdr_white_level);+ String _get_app_id() const;+ String _get_app_name() const;+ bool _try_create_shortcut();+public:LRESULT WndProcFileDialog(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);LRESULT WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);@@ -742,6 +746,9 @@ public:virtual DisplayServerEnums::CursorShape cursor_get_shape() const override;virtual void cursor_set_custom_image(const Ref<Resource> &p_cursor, DisplayServerEnums::CursorShape p_shape = DisplayServerEnums::CURSOR_ARROW, const Vector2 &p_hotspot = Vector2()) override;+ virtual DisplayServerEnums::NotificationID send_toast_notification(const String &p_title, const String &p_text, const Ref<Texture2D> &p_image, const Callable &p_callback) override;+ virtual void hide_toast_notification(DisplayServerEnums::NotificationID p_id) override;+virtual bool get_swap_cancel_ok() override;virtual void enable_for_stealing_focus(ProcessID pid) override;diff --git a/platform/windows/winrt_defines.h b/platform/windows/winrt_defines.hindex 67592126887..4f9f778d19e 100644--- a/platform/windows/winrt_defines.h+++ b/platform/windows/winrt_defines.h@@ -119,6 +119,7 @@ struct ROEventToken {value = 0;}};+enum class ROAdvancedColorKind : int32_t {StandardDynamicRange = 0,WideColorGamut = 1,@@ -161,6 +162,17 @@ enum class RoTimedMetadataTrackPresentationMode : int32_t {PlatformPresented = 3,};+enum class ROToastTemplateType : int32_t {+ ToastImageAndText01 = 0,+ ToastImageAndText02 = 1,+ ToastImageAndText03 = 2,+ ToastImageAndText04 = 3,+ ToastText01 = 4,+ ToastText02 = 5,+ ToastText03 = 6,+ ToastText04 = 7,+};+GODOT_GCC_WARNING_PUSHGODOT_GCC_WARNING_IGNORE("-Wnon-virtual-dtor")GODOT_GCC_WARNING_IGNORE("-Wctor-dtor-privacy")@@ -583,6 +595,149 @@ public:virtual HRESULT STDMETHODCALLTYPE get_ContentType(void **) = 0;};+MIDL_INTERFACE("50AC103F-D235-4598-BBEF-98FE4D1A3AD4")+ROToastNotificationManagerStatics : public IInspectable {+ virtual HRESULT STDMETHODCALLTYPE CreateToastNotifier(void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE CreateToastNotifierWithId(void *, void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE GetTemplateContent(int32_t, void **) = 0;+};++MIDL_INTERFACE("75927B93-03F3-41EC-91D3-6E5BAC1B38E7")+ROToastNotifier : public IInspectable {+ virtual HRESULT STDMETHODCALLTYPE Show(void *) = 0;+ virtual HRESULT STDMETHODCALLTYPE Hide(void *) = 0;+ virtual HRESULT STDMETHODCALLTYPE get_Setting(int32_t *) = 0;+ virtual HRESULT STDMETHODCALLTYPE AddToSchedule(void *) = 0;+ virtual HRESULT STDMETHODCALLTYPE RemoveFromSchedule(void *) = 0;+ virtual HRESULT STDMETHODCALLTYPE GetScheduledToastNotifications(void **) = 0;+};++MIDL_INTERFACE("04124B20-82C6-4229-B109-FD9ED4662B53")+ROToastNotificationFactory : public IInspectable {+ virtual HRESULT STDMETHODCALLTYPE CreateToastNotification(void *, void **) = 0;+};++MIDL_INTERFACE("997E2675-059E-4E60-8B06-1760917C8B80")+ROToastNotification : public IInspectable {+ virtual HRESULT STDMETHODCALLTYPE get_Content(void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE put_ExpirationTime(void *) = 0;+ virtual HRESULT STDMETHODCALLTYPE get_ExpirationTime(void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE add_Dismissed(void *, ROEventToken *) = 0;+ virtual HRESULT STDMETHODCALLTYPE remove_Dismissed(ROEventToken) = 0;+ virtual HRESULT STDMETHODCALLTYPE add_Activated(void *, ROEventToken *) = 0;+ virtual HRESULT STDMETHODCALLTYPE remove_Activated(ROEventToken) = 0;+ virtual HRESULT STDMETHODCALLTYPE add_Failed(void *, ROEventToken *) = 0;+ virtual HRESULT STDMETHODCALLTYPE remove_Failed(ROEventToken) = 0;+};++MIDL_INTERFACE("F7F3A506-1E87-42D6-BCFB-B8C809FA5494")+ROXmlDocument : public IInspectable {+ virtual HRESULT STDMETHODCALLTYPE get_Doctype(void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE get_Implementation(void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE get_DocumentElement(void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE CreateElement(void *, void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE CreateDocumentFragment(void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE CreateTextNode(void *, void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE CreateComment(void *, void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE CreateProcessingInstruction(void *, void *, void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE CreateAttribute(void *, void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE CreateEntityReference(void *, void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE GetElementsByTagName(void *, void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE CreateCDataSection(void *, void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE get_DocumentUri(void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE CreateAttributeNS(void *, void *, void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE CreateElementNS(void *, void *, void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE GetElementById(void *, void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE ImportNode(void *, bool, void **) = 0;+};++MIDL_INTERFACE("63DBBA8B-D0DB-4FE1-B745-F9433AFDC25B")+ROXmlNodeSelector : public IInspectable {+ virtual HRESULT STDMETHODCALLTYPE SelectSingleNode(void *, void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE SelectNodes(void *, void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE SelectSingleNodeNS(void *, void *, void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE SelectNodesNS(void *, void *, void **) = 0;+};++MIDL_INTERFACE("1C741D59-2122-47D5-A856-83F3D4214875")+ROXmlNode : public IInspectable {+ virtual HRESULT STDMETHODCALLTYPE get_NodeValue(void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE put_NodeValue(void *) = 0;+ virtual HRESULT STDMETHODCALLTYPE get_NodeType(int32_t*) = 0;+ virtual HRESULT STDMETHODCALLTYPE get_NodeName(void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE get_ParentNode(void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE get_ChildNodes(void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE get_FirstChild(void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE get_LastChild(void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE get_PreviousSibling(void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE get_NextSibling(void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE get_Attributes(void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE HasChildNodes(bool*) = 0;+ virtual HRESULT STDMETHODCALLTYPE get_OwnerDocument(void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE InsertBefore(void *, void *, void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE ReplaceChild(void *, void *, void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE RemoveChild(void *, void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE AppendChild(void *, void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE CloneNode(bool, void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE get_NamespaceUri(void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE get_LocalName(void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE get_Prefix(void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE Normalize() = 0;+ virtual HRESULT STDMETHODCALLTYPE put_Prefix(void *) = 0;+};++MIDL_INTERFACE("5CC5B382-E6DD-4991-ABEF-06D8D2E7BD0C")+ROXmlNodeSerializer : public IInspectable {+ virtual HRESULT STDMETHODCALLTYPE GetXml(void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE get_InnerText(void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE put_InnerText(void *) = 0;+};++MIDL_INTERFACE("2DFB8A1F-6B10-4EF8-9F83-EFCCE8FAEC37")+ROXmlElement : public IInspectable {+ virtual HRESULT STDMETHODCALLTYPE get_TagName(void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE GetAttribute(void *, void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE SetAttribute(void *, void *) = 0;+ virtual HRESULT STDMETHODCALLTYPE RemoveAttribute(void *) = 0;+ virtual HRESULT STDMETHODCALLTYPE GetAttributeNode(void *, void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE SetAttributeNode(void *, void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE RemoveAttributeNode(void *, void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE GetElementsByTagName(void *, void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE SetAttributeNS(void *, void *, void *) = 0;+ virtual HRESULT STDMETHODCALLTYPE GetAttributeNS(void *, void *, void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE RemoveAttributeNS(void *, void *) = 0;+ virtual HRESULT STDMETHODCALLTYPE SetAttributeNodeNS(void *, void **) = 0;+ virtual HRESULT STDMETHODCALLTYPE GetAttributeNodeNS(void *, void *, void **) = 0;+};++MIDL_INTERFACE("3F89D935-D9CB-4538-A0F0-FFE7659938F8")+ROToastDismissedEventArgs : public IInspectable {+ virtual HRESULT STDMETHODCALLTYPE get_Reason(int32_t *) = 0;+};++MIDL_INTERFACE("35176862-CFD4-44F8-AD64-F500FD896C3B")+ROToastFailedEventArgs : public IInspectable {+ virtual HRESULT STDMETHODCALLTYPE get_ErrorCode(HRESULT *) = 0;+};++MIDL_INTERFACE("61C2402F-0ED0-5A18-AB69-59F4AA99A368")+ROTypedEventHandler_ToastNotification_ToastDismissedEventArgs : public IUnknown {+public:+ virtual HRESULT STDMETHODCALLTYPE Invoke(ROToastNotification *, ROToastDismissedEventArgs *) = 0;+};++MIDL_INTERFACE("AB54DE2D-97D9-5528-B6AD-105AFE156530")+ROTypedEventHandler_ToastNotification_IInspectable : public IUnknown {+public:+ virtual HRESULT STDMETHODCALLTYPE Invoke(ROToastNotification *, IInspectable *) = 0;+};++MIDL_INTERFACE("95E3E803-C969-5E3A-9753-EA2AD22A9A33")+ROTypedEventHandler_ToastNotification_ToastFailedEventArgs : public IUnknown {+public:+ virtual HRESULT STDMETHODCALLTYPE Invoke(ROToastNotification *, ROToastFailedEventArgs *) = 0;+};+// clang-format on#ifdef __CRT_UUID_DECL@@ -629,6 +784,21 @@ __CRT_UUID_DECL(ROMediaCue, 0xC7D15E5D, 0x59DC, 0x431F, 0xA0, 0xEE, 0x27, 0x74,__CRT_UUID_DECL(ROSpeechCue, 0xAEE254DC, 0x1725, 0x4BAD, 0x80, 0x43, 0xA9, 0x84, 0x99, 0xB0, 0x17, 0xA2)__CRT_UUID_DECL(ROMediaPlayerFailedEventArgs, 0x2744E9B9, 0xA7E3, 0x4F16, 0xBA, 0xC4, 0x79, 0x14, 0xEB, 0xC0, 0x83, 0x01)__CRT_UUID_DECL(ROContentTypeProvider, 0x97D098A5, 0x3B99, 0x4DE9, 0x88, 0xA5, 0xE1, 0x1D, 0x2F, 0x50, 0xC7, 0x95)+__CRT_UUID_DECL(ROToastNotificationManagerStatics, 0x50AC103F, 0xD235, 0x4598, 0xBB, 0xEF, 0x98, 0xFE, 0x4D, 0x1A, 0x3A, 0xD4)+__CRT_UUID_DECL(ROToastNotifier, 0x75927B93, 0x03F3, 0x41EC, 0x91, 0xD3, 0x6E, 0x5B, 0xAC, 0x1B, 0x38, 0xE7)+__CRT_UUID_DECL(ROToastNotificationFactory, 0x04124B20, 0x82C6, 0x4229, 0xB1, 0x09, 0xFD, 0x9E, 0xD4, 0x66, 0x2B, 0x53)+__CRT_UUID_DECL(ROToastNotification, 0x997E2675, 0x059E, 0x4E60, 0x8B, 0x06, 0x17, 0x60, 0x91, 0x7C, 0x8B, 0x80)+__CRT_UUID_DECL(ROXmlDocument, 0xF7F3A506, 0x1E87, 0x42D6, 0xBC, 0xFB, 0xB8, 0xC8, 0x09, 0xFA, 0x54, 0x94)+__CRT_UUID_DECL(ROXmlNodeSelector, 0x63DBBA8B, 0xD0DB, 0x4FE1, 0xB7, 0x45, 0xF9, 0x43, 0x3A, 0xFD, 0xC2, 0x5B)+__CRT_UUID_DECL(ROXmlNode, 0x1C741D59, 0x2122, 0x47D5, 0xA8, 0x56, 0x83, 0xF3, 0xD4, 0x21, 0x48, 0x75)+__CRT_UUID_DECL(ROXmlNodeSerializer, 0x5CC5B382, 0xE6DD, 0x4991, 0xAB, 0xEF, 0x06, 0xD8, 0xD2, 0xE7, 0xBD, 0x0C)+__CRT_UUID_DECL(ROXmlElement, 0x2DFB8A1F, 0x6B10, 0x4EF8, 0x9F, 0x83, 0xEF, 0xCC, 0xE8, 0xFA, 0xEC, 0x37)+__CRT_UUID_DECL(ROToastDismissedEventArgs, 0x3F89D935, 0xD9CB, 0x4538, 0xA0, 0xF0, 0xFF, 0xE7, 0x65, 0x99, 0x38, 0xF8)+__CRT_UUID_DECL(ROToastFailedEventArgs, 0x35176862, 0xCFD4, 0x44F8, 0xAD, 0x64, 0xF5, 0x00, 0xFD, 0x89, 0x6C, 0x3B)+__CRT_UUID_DECL(ROTypedEventHandler_ToastNotification_ToastDismissedEventArgs, 0x61C2402F, 0x0ED0, 0x5A18, 0xAB, 0x69, 0x59, 0xF4, 0xAA, 0x99, 0xA3, 0x68)+__CRT_UUID_DECL(ROTypedEventHandler_ToastNotification_IInspectable, 0xAB54DE2D, 0x97D9, 0x5528, 0xB6, 0xAD, 0x10, 0x5A, 0xFE, 0x15, 0x65, 0x30)+__CRT_UUID_DECL(ROTypedEventHandler_ToastNotification_ToastFailedEventArgs, 0x95E3E803, 0xC969, 0x5E3A, 0x97, 0x53, 0xEA, 0x2A, 0xD2, 0x2A, 0x9A, 0x33)+#endif // __CRT_UUID_DECLGODOT_GCC_WARNING_POPdiff --git a/platform/windows/winrt_utils.cpp b/platform/windows/winrt_utils.cppindex 4ccce17c09d..76787903c88 100644--- a/platform/windows/winrt_utils.cpp+++ b/platform/windows/winrt_utils.cpp@@ -30,6 +30,13 @@#include "winrt_utils.h"+#include "core/crypto/crypto_core.h"+#include "core/io/dir_access.h"+#include "core/os/mutex.h"+#include "core/os/os.h"+#include "core/os/time.h"+#include "scene/resources/texture.h"+enum DISPATCHERQUEUE_THREAD_APARTMENTTYPE {DQTAT_COM_NONE = 0,DQTAT_COM_ASTA = 1,@@ -63,6 +70,52 @@ static const WCHAR *RODisplayInformationName = L"Windows.Graphics.Display.Displastatic const WCHAR *ROGlobalizationPreferencesStaticsName = L"Windows.System.UserProfile.GlobalizationPreferences";static const WCHAR *ROCoreInputViewName = L"Windows.UI.ViewManagement.Core.CoreInputView";static const WCHAR *ROApiInformationName = L"Windows.Foundation.Metadata.ApiInformation";+static const WCHAR *ROToastNotificationManagerName = L"Windows.UI.Notifications.ToastNotificationManager";+static const WCHAR *ROToastNotificationName = L"Windows.UI.Notifications.ToastNotification";++class WinRTWindowData {+ friend class WinRTUtils;++ bool has_disp_info = false;+ ComPtr<RODisplayInformation5> disp_info;+ ComPtr<ROTypedEventHandler> handler;+ ROEventToken token;+};++class WinRTNotificationData : public RefCounted {+ friend class WinRTUtils;+ friend class GodotToastActivatedEventHandler;+ friend class GodotToastDismissedEventHandler;+ friend class GodotToastFailedEventHandler;++ ComPtr<ROToastNotification> nt;++ String temp_file;++ DisplayServerEnums::NotificationID nid = DisplayServerEnums::INVALID_NOTIFICATION_ID;+ Callable cb;+ ROEventToken act_token;+ ROEventToken fail_token;+ ROEventToken dis_token;++public:+ ~WinRTNotificationData() {+ if (nt) {+ nt->remove_Activated(act_token);+ nt->remove_Dismissed(dis_token);+ nt->remove_Failed(fail_token);+ nt.Reset();+ }+ if (!temp_file.is_empty()) {+ DirAccess::remove_absolute(temp_file);+ }+ }+};++DisplayServerEnums::NotificationID notification_id = 0;+HashMap<DisplayServerEnums::NotificationID, Ref<WinRTNotificationData>> notifications;+ComPtr<ROToastNotifier> notifier;+Mutex noti_mutex;GODOT_GCC_WARNING_PUSHGODOT_GCC_WARNING_IGNORE("-Wnon-virtual-dtor")@@ -95,6 +148,85 @@ public:}};+/**************************************************************************/+/* ToastNotification events */+/**************************************************************************/++class GodotToastActivatedEventHandler : public ROTypedEventHandler_ToastNotification_IInspectable {+ TYPED_EVENT_HANDLER_CLASS(GodotToastActivatedEventHandler, ROTypedEventHandler_ToastNotification_IInspectable)++private:+ DisplayServerEnums::NotificationID nid = 0;++public:+ HRESULT STDMETHODCALLTYPE Invoke(ROToastNotification *, IInspectable *) {+ MutexLock lock(noti_mutex);+ if (!notifications.has(nid)) {+ return S_OK;+ }+ Ref<WinRTNotificationData> cur_nd = notifications[nid];+ if (cur_nd->cb.is_valid()) {+ cur_nd->cb.call_deferred(nid, DisplayServerEnums::NOTIFICATION_ACTIVATED);+ }+ notifications.erase(nid);+ return S_OK;+ }++ GodotToastActivatedEventHandler(DisplayServerEnums::NotificationID p_nid) {+ nid = p_nid;+ }+};++class GodotToastDismissedEventHandler : public ROTypedEventHandler_ToastNotification_ToastDismissedEventArgs {+ TYPED_EVENT_HANDLER_CLASS(GodotToastDismissedEventHandler, ROTypedEventHandler_ToastNotification_ToastDismissedEventArgs)++private:+ DisplayServerEnums::NotificationID nid = 0;++public:+ HRESULT STDMETHODCALLTYPE Invoke(ROToastNotification *, ROToastDismissedEventArgs *) {+ MutexLock lock(noti_mutex);+ if (!notifications.has(nid)) {+ return S_OK;+ }+ Ref<WinRTNotificationData> cur_nd = notifications[nid];+ if (cur_nd->cb.is_valid()) {+ cur_nd->cb.call_deferred(nid, DisplayServerEnums::NOTIFICATION_DISMISSED);+ }+ notifications.erase(nid);+ return S_OK;+ }++ GodotToastDismissedEventHandler(DisplayServerEnums::NotificationID p_nid) {+ nid = p_nid;+ }+};++class GodotToastFailedEventHandler : public ROTypedEventHandler_ToastNotification_ToastFailedEventArgs {+ TYPED_EVENT_HANDLER_CLASS(GodotToastFailedEventHandler, ROTypedEventHandler_ToastNotification_ToastFailedEventArgs)++private:+ DisplayServerEnums::NotificationID nid = 0;++public:+ HRESULT STDMETHODCALLTYPE Invoke(ROToastNotification *, ROToastFailedEventArgs *) {+ MutexLock lock(noti_mutex);+ if (!notifications.has(nid)) {+ return S_OK;+ }+ Ref<WinRTNotificationData> cur_nd = notifications[nid];+ if (cur_nd->cb.is_valid()) {+ cur_nd->cb.call_deferred(nid, DisplayServerEnums::NOTIFICATION_FAILED);+ }+ notifications.erase(nid);+ return S_OK;+ }++ GodotToastFailedEventHandler(DisplayServerEnums::NotificationID p_nid) {+ nid = p_nid;+ }+};+GODOT_GCC_WARNING_POPGODOT_CLANG_WARNING_POP@@ -155,15 +287,6 @@ HRESULT WinRTUtils::activation_factory(const String &p_class_name, REFIID p_iid,return res;}-class WinRTWindowData {- friend class WinRTUtils;-- bool has_disp_info = false;- ComPtr<RODisplayInformation5> disp_info;- ComPtr<ROTypedEventHandler> handler;- ROEventToken token;-};-bool WinRTUtils::is_initialized() {return api_initialized;}@@ -188,7 +311,7 @@ void WinRTUtils::init() {api_initialized = true;}-bool WinRTUtils::create_queue() {+bool WinRTUtils::create_queue(const String &p_appid) {ERR_FAIL_COND_V(!api_initialized, false);HMODULE coremessaging = LoadLibraryW(L"coremessaging.dll");@@ -204,12 +327,29 @@ bool WinRTUtils::create_queue() {HRESULT res = GD_CreateDispatcherQueueController(options, queue_ctrl.GetAddressOf());ERR_FAIL_COND_V_MSG(FAILED(res), false, "CreateDispatcherQueueController failed with error " + vformat("0x%08ux", (uint64_t)res) + ".");+ Ref<HStringWrapper> appid;+ appid.instantiate();+ appid->set_string(p_appid);++ ComPtr<ROToastNotificationManagerStatics> toastman_fact;+ if (SUCCEEDED(activation_factory(ROToastNotificationManagerName, IID_PPV_ARGS(&toastman_fact)))) {+ res = toastman_fact->CreateToastNotifierWithId(appid->get_ptr(), (void **)notifier.GetAddressOf());+ print_verbose(vformat("Windows.UI.Notifications.ToastNotificationManager initialized for AppID '%s'.", p_appid));+ }+return true;}void WinRTUtils::destroy_queue() {ERR_FAIL_COND(!api_initialized);+ // Remove pending notifications.+ if (notifier) {+ notifier.Reset();+ }+ notifications.clear();++ // Shutdown queue.ComPtr<ROAsyncAction> action;ERR_FAIL_COND(FAILED(queue_ctrl->ShutdownQueueAsync((void **)action.GetAddressOf())));@@ -347,3 +487,141 @@ void WinRTUtils::destroy_wd(WinRTWindowData *p_data) {memdelete(p_data);}}++DisplayServerEnums::NotificationID WinRTUtils::send_toast_notification(const String &p_title, const String &p_text, const Ref<Texture2D> &p_image, const Callable &p_callback) {+ if (!notifier) {+ return DisplayServerEnums::INVALID_NOTIFICATION_ID;+ }++ Ref<HStringWrapper> text;+ text.instantiate();+ text->set_string(p_text);++ Ref<HStringWrapper> title;+ title.instantiate();+ title->set_string(p_title);++ Ref<WinRTNotificationData> nd;+ nd.instantiate();+ DisplayServerEnums::NotificationID nid = notification_id++;++ ComPtr<ROToastNotificationManagerStatics> toastman_fact;+ ERR_FAIL_COND_V(FAILED(activation_factory(ROToastNotificationManagerName, IID_PPV_ARGS(&toastman_fact))), DisplayServerEnums::INVALID_NOTIFICATION_ID);++ ComPtr<IInspectable> xml_ii;+ ERR_FAIL_COND_V(FAILED(toastman_fact->GetTemplateContent((int32_t)ROToastTemplateType::ToastImageAndText02, (void **)xml_ii.GetAddressOf())), DisplayServerEnums::INVALID_NOTIFICATION_ID);+ ComPtr<ROXmlDocument> xml;+ ERR_FAIL_COND_V(FAILED(xml_ii.As(&xml)), DisplayServerEnums::INVALID_NOTIFICATION_ID);+ ComPtr<ROXmlNodeSelector> xml_sel;+ ERR_FAIL_COND_V(FAILED(xml_ii.As(&xml_sel)), DisplayServerEnums::INVALID_NOTIFICATION_ID);++ if (p_image.is_valid()) {+ Ref<Image> img = p_image->get_image();+ if (img->is_compressed()) {+ img->decompress();+ }+ img->convert(Image::FORMAT_RGBA8);++ const String TEMP_DIR = OS::get_singleton()->get_temp_path();+ uint32_t suffix_i = 0;+ String img_path;+ int pid = OS::get_singleton()->get_process_id();+ while (true) {+ String datetime = Time::get_singleton()->get_datetime_string_from_system().remove_chars("-T:");+ datetime += itos(Time::get_singleton()->get_ticks_usec());+ String suffix = datetime + (suffix_i > 0 ? itos(suffix_i) : "");+ img_path = TEMP_DIR.path_join(vformat("_noti_%x_%s.png", pid, suffix));+ if (!DirAccess::exists(img_path)) {+ break;+ }+ suffix_i += 1;+ }+ img->save_png(img_path);++ nd->temp_file = img_path;+ Ref<HStringWrapper> himage;+ himage.instantiate();+ himage->set_string(img_path);++ Ref<HStringWrapper> hxpath;+ hxpath.instantiate();+ hxpath->set_string(L"//image[@id=\"1\"]");++ Ref<HStringWrapper> hxattr;+ hxattr.instantiate();+ hxattr->set_string(L"src");++ ComPtr<ROXmlNode> xml_node;+ ERR_FAIL_COND_V(FAILED(xml_sel->SelectSingleNode(hxpath->get_ptr(), (void **)xml_node.GetAddressOf())), DisplayServerEnums::INVALID_NOTIFICATION_ID);+ ComPtr<ROXmlElement> xml_element;+ ERR_FAIL_COND_V(FAILED(xml_node.As(&xml_element)), DisplayServerEnums::INVALID_NOTIFICATION_ID);+ ERR_FAIL_COND_V(FAILED(xml_element->SetAttribute(hxattr->get_ptr(), himage->get_ptr())), DisplayServerEnums::INVALID_NOTIFICATION_ID);+ }+ {+ Ref<HStringWrapper> hxpath;+ hxpath.instantiate();+ hxpath->set_string(L"//text[@id=\"1\"]");++ ComPtr<ROXmlNode> xml_node;+ ERR_FAIL_COND_V(FAILED(xml_sel->SelectSingleNode(hxpath->get_ptr(), (void **)xml_node.GetAddressOf())), DisplayServerEnums::INVALID_NOTIFICATION_ID);+ ComPtr<ROXmlNodeSerializer> xml_node_sr;+ ERR_FAIL_COND_V(FAILED(xml_node.As(&xml_node_sr)), DisplayServerEnums::INVALID_NOTIFICATION_ID);+ ERR_FAIL_COND_V(FAILED(xml_node_sr->put_InnerText(title->get_ptr())), DisplayServerEnums::INVALID_NOTIFICATION_ID);+ }+ {+ Ref<HStringWrapper> hxpath;+ hxpath.instantiate();+ hxpath->set_string(L"//text[@id=\"2\"]");++ ComPtr<ROXmlNode> xml_node;+ ERR_FAIL_COND_V(FAILED(xml_sel->SelectSingleNode(hxpath->get_ptr(), (void **)xml_node.GetAddressOf())), DisplayServerEnums::INVALID_NOTIFICATION_ID);+ ComPtr<ROXmlNodeSerializer> xml_node_sr;+ ERR_FAIL_COND_V(FAILED(xml_node.As(&xml_node_sr)), DisplayServerEnums::INVALID_NOTIFICATION_ID);+ ERR_FAIL_COND_V(FAILED(xml_node_sr->put_InnerText(text->get_ptr())), DisplayServerEnums::INVALID_NOTIFICATION_ID);+ }++ ComPtr<ROToastNotificationFactory> toast_fact;+ ERR_FAIL_COND_V(FAILED(WinRTUtils::activation_factory(ROToastNotificationName, IID_PPV_ARGS(&toast_fact))), DisplayServerEnums::INVALID_NOTIFICATION_ID);+ ERR_FAIL_COND_V(FAILED(toast_fact->CreateToastNotification(xml.Get(), (void **)nd->nt.GetAddressOf())), DisplayServerEnums::INVALID_NOTIFICATION_ID);++ nd->nid = nid;+ nd->cb = p_callback;++ ComPtr<ROTypedEventHandler_ToastNotification_IInspectable> handler_a;+ GodotToastActivatedEventHandler *handler_act = new GodotToastActivatedEventHandler(nid);+ ERR_FAIL_COND_V(FAILED(handler_act->QueryInterface(IID_PPV_ARGS(&handler_a))), DisplayServerEnums::INVALID_NOTIFICATION_ID);+ ERR_FAIL_COND_V(FAILED(nd->nt->add_Activated(handler_a.Get(), &nd->act_token)), DisplayServerEnums::INVALID_NOTIFICATION_ID);++ ComPtr<ROTypedEventHandler_ToastNotification_ToastDismissedEventArgs> handler_d;+ GodotToastDismissedEventHandler *handler_dis = new GodotToastDismissedEventHandler(nid);+ ERR_FAIL_COND_V(FAILED(handler_dis->QueryInterface(IID_PPV_ARGS(&handler_d))), DisplayServerEnums::INVALID_NOTIFICATION_ID);+ ERR_FAIL_COND_V(FAILED(nd->nt->add_Dismissed(handler_d.Get(), &nd->dis_token)), DisplayServerEnums::INVALID_NOTIFICATION_ID);++ ComPtr<ROTypedEventHandler_ToastNotification_ToastFailedEventArgs> handler_f;+ GodotToastFailedEventHandler *handler_fail = new GodotToastFailedEventHandler(nid);+ ERR_FAIL_COND_V(FAILED(handler_fail->QueryInterface(IID_PPV_ARGS(&handler_f))), DisplayServerEnums::INVALID_NOTIFICATION_ID);+ ERR_FAIL_COND_V(FAILED(nd->nt->add_Failed(handler_f.Get(), &nd->fail_token)), DisplayServerEnums::INVALID_NOTIFICATION_ID);++ {+ MutexLock lock(noti_mutex);+ notifications[nid] = nd;+ }++ ERR_FAIL_COND_V(FAILED(notifier->Show(nd->nt.Get())), DisplayServerEnums::INVALID_NOTIFICATION_ID);+ return nid;+}++void WinRTUtils::hide_toast_notification(DisplayServerEnums::NotificationID p_id) {+ if (!notifier) {+ return;+ }++ MutexLock lock(noti_mutex);+ if (!notifications.has(p_id)) {+ return;+ }+ Ref<WinRTNotificationData> nd = notifications[p_id];+ notifications.erase(p_id);++ notifier->Hide(nd->nt.Get());+}diff --git a/platform/windows/winrt_utils.h b/platform/windows/winrt_utils.hindex 6d08f5d0e76..f2e713f4255 100644--- a/platform/windows/winrt_utils.h+++ b/platform/windows/winrt_utils.h@@ -35,10 +35,12 @@#include "core/typedefs.h"#include "core/variant/callable.h"#include "core/variant/variant.h"+#include "servers/display/display_server_enums.h"#include <windows.h>class WinRTWindowData;+class Texture2D;class WinRTUtils {public:@@ -49,7 +51,7 @@ public:static bool is_initialized();static void init();- static bool create_queue();+ static bool create_queue(const String &p_appid);static void destroy_queue();static void cleanup();@@ -60,4 +62,7 @@ public:static bool window_has_display_info(const WinRTWindowData *p_data);static void window_get_advanced_color_info(const WinRTWindowData *p_data, bool &r_hdr_supported, float &r_min_luminance, float &r_max_luminance, float &r_max_average_luminance, float &r_sdr_white_level);static void destroy_wd(WinRTWindowData *p_data);++ static DisplayServerEnums::NotificationID send_toast_notification(const String &p_title, const String &p_text, const Ref<Texture2D> &p_image, const Callable &p_callback);+ static void hide_toast_notification(DisplayServerEnums::NotificationID p_id);};diff --git a/servers/display/display_server.cpp b/servers/display/display_server.cppindex 81249efcac1..7ec0727615e 100644--- a/servers/display/display_server.cpp+++ b/servers/display/display_server.cpp@@ -1151,6 +1151,12 @@ void DisplayServer::cursor_set_custom_image(const Ref<Resource> &p_cursor, DisplWARN_PRINT("Custom cursor shape not supported by this display server.");}+DisplayServerEnums::NotificationID DisplayServer::send_toast_notification(const String &p_title, const String &p_text, const Ref<Texture2D> &p_image, const Callable &p_callback) {+ return DisplayServerEnums::INVALID_NOTIFICATION_ID;+}++void DisplayServer::hide_toast_notification(DisplayServerEnums::NotificationID p_id) {}+bool DisplayServer::get_swap_cancel_ok() {return false;}@@ -1676,6 +1682,9 @@ void DisplayServer::_bind_methods() {ClassDB::bind_method(D_METHOD("cursor_get_shape"), &DisplayServer::cursor_get_shape);ClassDB::bind_method(D_METHOD("cursor_set_custom_image", "cursor", "shape", "hotspot"), &DisplayServer::cursor_set_custom_image, DEFVAL(DisplayServerEnums::CURSOR_ARROW), DEFVAL(Vector2()));+ ClassDB::bind_method(D_METHOD("send_toast_notification", "title", "text", "image", "callback"), &DisplayServer::send_toast_notification);+ ClassDB::bind_method(D_METHOD("hide_toast_notification", "id"), &DisplayServer::hide_toast_notification);+ClassDB::bind_method(D_METHOD("get_swap_cancel_ok"), &DisplayServer::get_swap_cancel_ok);ClassDB::bind_method(D_METHOD("enable_for_stealing_focus", "process_id"), &DisplayServer::enable_for_stealing_focus);@@ -1889,6 +1898,7 @@ void DisplayServer::_bind_methods() {BIND_CONSTANT(DisplayServerEnums::MAIN_WINDOW_ID);BIND_CONSTANT(DisplayServerEnums::INVALID_WINDOW_ID);BIND_CONSTANT(DisplayServerEnums::INVALID_INDICATOR_ID);+ BIND_CONSTANT(DisplayServerEnums::INVALID_NOTIFICATION_ID);BIND_ENUM_CONSTANT(DisplayServerEnums::SCREEN_LANDSCAPE);BIND_ENUM_CONSTANT(DisplayServerEnums::SCREEN_PORTRAIT);@@ -1980,6 +1990,10 @@ void DisplayServer::_bind_methods() {BIND_ENUM_CONSTANT(DisplayServerEnums::WINDOW_EDGE_BOTTOM_RIGHT);BIND_ENUM_CONSTANT(DisplayServerEnums::WINDOW_EDGE_MAX);+ BIND_ENUM_CONSTANT(DisplayServerEnums::NOTIFICATION_ACTIVATED);+ BIND_ENUM_CONSTANT(DisplayServerEnums::NOTIFICATION_DISMISSED);+ BIND_ENUM_CONSTANT(DisplayServerEnums::NOTIFICATION_FAILED);+BIND_ENUM_CONSTANT(DisplayServerEnums::VSYNC_DISABLED);BIND_ENUM_CONSTANT(DisplayServerEnums::VSYNC_ENABLED);BIND_ENUM_CONSTANT(DisplayServerEnums::VSYNC_ADAPTIVE);diff --git a/servers/display/display_server.h b/servers/display/display_server.hindex b49f986f711..1349ef791b9 100644--- a/servers/display/display_server.h+++ b/servers/display/display_server.h@@ -496,6 +496,11 @@ public:virtual Error remove_embedded_process(ProcessID p_pid);virtual ProcessID get_focused_process_id();+ /* NOTIFICATIONS */++ virtual DisplayServerEnums::NotificationID send_toast_notification(const String &p_title, const String &p_text, const Ref<Texture2D> &p_image, const Callable &p_callback);+ virtual void hide_toast_notification(DisplayServerEnums::NotificationID p_id);+/* DIALOGS */virtual bool get_swap_cancel_ok();@@ -654,6 +659,7 @@ VARIANT_ENUM_CAST_EXT(DisplayServerEnums::WindowResizeEdge, DisplayServer::WindoVARIANT_ENUM_CAST_EXT(DisplayServerEnums::VSyncMode, DisplayServer::VSyncMode)VARIANT_ENUM_CAST_EXT(DisplayServerEnums::ProgressState, DisplayServer::ProgressState)VARIANT_ENUM_CAST_EXT(DisplayServerEnums::FileDialogMode, DisplayServer::FileDialogMode)+VARIANT_ENUM_CAST_EXT(DisplayServerEnums::NotificationStatus, DisplayServer::NotificationStatus)#ifndef DISABLE_DEPRECATEDVARIANT_ENUM_CAST_EXT(DisplayServerEnums::AccessibilityRole, DisplayServer::AccessibilityRole)diff --git a/servers/display/display_server_enums.h b/servers/display/display_server_enums.hindex 5c8b7e997ce..f21695799fe 100644--- a/servers/display/display_server_enums.h+++ b/servers/display/display_server_enums.h@@ -179,7 +179,8 @@ typedef int WindowID;enum {MAIN_WINDOW_ID = 0,INVALID_WINDOW_ID = -1,- INVALID_INDICATOR_ID = -1+ INVALID_INDICATOR_ID = -1,+ INVALID_NOTIFICATION_ID = -1,};enum HandleType {@@ -288,6 +289,16 @@ enum FileDialogMode {FILE_DIALOG_MODE_SAVE_MAX};+/* NOTIFICATIONS */++typedef int NotificationID;++enum NotificationStatus {+ NOTIFICATION_ACTIVATED,+ NOTIFICATION_DISMISSED,+ NOTIFICATION_FAILED,+};+/* STATUS INDICATOR */typedef int IndicatorID;