[XAM] Extend UI delay on close. Added delay to headless after notification sent.

Created thread to do async notification broadcast on close for headless.

This fixes game freeze in 534407FC
This commit is contained in:
Gliniak
2026-07-15 20:05:41 +02:00
committed by Radosław Gliński
parent c2650c6e58
commit 44e1a64f35

View File

@@ -34,6 +34,8 @@ DEFINE_bool(storage_selection_dialog, false,
DECLARE_int32(license_mask);
constexpr std::chrono::milliseconds kUIDelayMillis(200);
namespace xe {
namespace kernel {
namespace xam {
@@ -81,8 +83,11 @@ X_RESULT xeXamDispatchDialog(T* dialog,
return result;
};
auto post = []() {
xe::threading::Sleep(std::chrono::milliseconds(100));
kernel_state()->BroadcastNotification(kXNotificationSystemUI, false);
std::jthread t([] {
xe::threading::Sleep(kUIDelayMillis);
kernel_state()->BroadcastNotification(kXNotificationSystemUI, false);
});
t.detach();
};
if (!overlapped) {
pre();
@@ -123,7 +128,7 @@ X_RESULT xeXamDispatchDialogEx(
return result;
};
auto post = []() {
xe::threading::Sleep(std::chrono::milliseconds(100));
xe::threading::Sleep(kUIDelayMillis);
kernel_state()->BroadcastNotification(kXNotificationSystemUI, false);
};
if (!overlapped) {
@@ -143,10 +148,15 @@ X_RESULT xeXamDispatchHeadless(std::function<X_RESULT()> run_callback,
uint32_t overlapped) {
auto pre = []() {
kernel_state()->BroadcastNotification(kXNotificationSystemUI, true);
xe::threading::Sleep(std::chrono::milliseconds(25));
};
auto post = []() {
xe::threading::Sleep(std::chrono::milliseconds(100));
kernel_state()->BroadcastNotification(kXNotificationSystemUI, false);
std::jthread t([]() {
xe::threading::Sleep(kUIDelayMillis);
kernel_state()->BroadcastNotification(kXNotificationSystemUI, false);
});
t.detach();
};
if (!overlapped) {
pre();
@@ -167,7 +177,7 @@ X_RESULT xeXamDispatchHeadlessEx(
kernel_state()->BroadcastNotification(kXNotificationSystemUI, true);
};
auto post = []() {
xe::threading::Sleep(std::chrono::milliseconds(100));
xe::threading::Sleep(kUIDelayMillis);
kernel_state()->BroadcastNotification(kXNotificationSystemUI, false);
};
if (!overlapped) {
@@ -198,7 +208,7 @@ X_RESULT xeXamDispatchDialogAsync(T* dialog,
kernel_state()->xam_state()->xam_dialogs_shown_--;
auto run = []() -> void {
xe::threading::Sleep(std::chrono::milliseconds(100));
xe::threading::Sleep(kUIDelayMillis);
kernel_state()->BroadcastNotification(kXNotificationSystemUI, false);
};
@@ -220,7 +230,7 @@ X_RESULT xeXamDispatchHeadlessAsync(std::function<void()> run_callback) {
kernel_state()->xam_state()->xam_dialogs_shown_--;
auto run = []() -> void {
xe::threading::Sleep(std::chrono::milliseconds(100));
xe::threading::Sleep(kUIDelayMillis);
kernel_state()->BroadcastNotification(kXNotificationSystemUI, false);
};