[UI] Loop thread to main thread WindowedAppContext

This commit is contained in:
Triang3l
2021-08-28 19:38:24 +03:00
parent f540c188bf
commit 6ce5330f5f
95 changed files with 2343 additions and 1235 deletions

View File

@@ -15,6 +15,7 @@
#include "xenia/kernel/xam/xam_private.h"
#include "xenia/ui/imgui_dialog.h"
#include "xenia/ui/window.h"
#include "xenia/ui/windowed_app_context.h"
#include "xenia/xbox.h"
namespace xe {
@@ -50,15 +51,16 @@ dword_result_t XamShowNuiTroubleshooterUI(unknown_t unk1, unknown_t unk2,
auto display_window = kernel_state()->emulator()->display_window();
xe::threading::Fence fence;
display_window->loop()->PostSynchronous([&]() {
xe::ui::ImGuiDialog::ShowMessageBox(
display_window, "NUI Troubleshooter",
"The game has indicated there is a problem with NUI (Kinect).")
->Then(&fence);
});
++xam_dialogs_shown_;
fence.Wait();
--xam_dialogs_shown_;
if (display_window->app_context().CallInUIThreadSynchronous([&]() {
xe::ui::ImGuiDialog::ShowMessageBox(
display_window, "NUI Troubleshooter",
"The game has indicated there is a problem with NUI (Kinect).")
->Then(&fence);
})) {
++xam_dialogs_shown_;
fence.Wait();
--xam_dialogs_shown_;
}
return 0;
}

View File

@@ -17,6 +17,7 @@
#include "xenia/kernel/xam/xam_private.h"
#include "xenia/ui/imgui_dialog.h"
#include "xenia/ui/window.h"
#include "xenia/ui/windowed_app_context.h"
#include "xenia/xbox.h"
namespace xe {
@@ -76,11 +77,16 @@ X_RESULT xeXamDispatchDialog(T* dialog,
result = close_callback(dialog);
});
xe::threading::Fence fence;
kernel_state()->emulator()->display_window()->loop()->PostSynchronous(
[&dialog, &fence]() { dialog->Then(&fence); });
++xam_dialogs_shown_;
fence.Wait();
--xam_dialogs_shown_;
xe::ui::WindowedAppContext& app_context =
kernel_state()->emulator()->display_window()->app_context();
if (app_context.CallInUIThreadSynchronous(
[&dialog, &fence]() { dialog->Then(&fence); })) {
++xam_dialogs_shown_;
fence.Wait();
--xam_dialogs_shown_;
} else {
delete dialog;
}
// dialog should be deleted at this point!
return result;
};
@@ -117,11 +123,14 @@ X_RESULT xeXamDispatchDialogEx(
result = close_callback(dialog, extended_error, length);
});
xe::threading::Fence fence;
display_window->loop()->PostSynchronous(
[&dialog, &fence]() { dialog->Then(&fence); });
++xam_dialogs_shown_;
fence.Wait();
--xam_dialogs_shown_;
if (display_window->app_context().CallInUIThreadSynchronous(
[&dialog, &fence]() { dialog->Then(&fence); })) {
++xam_dialogs_shown_;
fence.Wait();
--xam_dialogs_shown_;
} else {
delete dialog;
}
// dialog should be deleted at this point!
return result;
};