[UI] Loop thread to main thread WindowedAppContext
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -11,10 +11,6 @@
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#ifdef XE_PLATFORM_WIN32
|
||||
#include <objbase.h>
|
||||
#endif
|
||||
|
||||
#include "third_party/fmt/include/fmt/format.h"
|
||||
#include "xenia/base/byte_stream.h"
|
||||
#include "xenia/base/clock.h"
|
||||
@@ -383,20 +379,6 @@ X_STATUS XThread::Create() {
|
||||
// Set name immediately, if we have one.
|
||||
thread_->set_name(thread_name_);
|
||||
|
||||
#ifdef XE_PLATFORM_WIN32
|
||||
// Setup COM on this thread.
|
||||
//
|
||||
// https://devblogs.microsoft.com/oldnewthing/?p=4613
|
||||
//
|
||||
// "If any thread in the process calls CoInitialize[Ex] with the
|
||||
// COINIT_MULTITHREADED flag, then that not only initializes the current
|
||||
// thread as a member of the multi-threaded apartment, but it also says,
|
||||
// "Any thread which has never called CoInitialize[Ex] is also part of the
|
||||
// multi-threaded apartment."
|
||||
#pragma warning(suppress : 6031)
|
||||
CoInitializeEx(nullptr, COINIT_MULTITHREADED);
|
||||
#endif
|
||||
|
||||
// Profiler needs to know about the thread.
|
||||
xe::Profiler::ThreadEnter(thread_name_.c_str());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user