UWP OnSuspending and save on quit fix (#14452)
* Update uwp_main.cpp * Update retroarch.c
This commit is contained in:
parent
5bfe70221c
commit
b93599c7e0
|
@ -6162,6 +6162,14 @@ bool retroarch_main_quit(void)
|
||||||
runloop_state_t *runloop_st = runloop_state_get_ptr();
|
runloop_state_t *runloop_st = runloop_state_get_ptr();
|
||||||
video_driver_state_t*video_st = video_state_get_ptr();
|
video_driver_state_t*video_st = video_state_get_ptr();
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
|
|
||||||
|
/*Save configs before quitting
|
||||||
|
*as for UWP depending on `OnSuspending` is not important as we can call it directly here
|
||||||
|
*specifically we need to get width,height which requires UI thread and it will not be available on exit
|
||||||
|
*/
|
||||||
|
bool config_save_on_exit = settings->bools.config_save_on_exit;
|
||||||
|
if (config_save_on_exit)
|
||||||
|
command_event(CMD_EVENT_MENU_SAVE_CURRENT_CONFIG, NULL);
|
||||||
|
|
||||||
#ifdef HAVE_PRESENCE
|
#ifdef HAVE_PRESENCE
|
||||||
{
|
{
|
||||||
|
|
|
@ -470,6 +470,11 @@ void App::OnActivated(CoreApplicationView^ applicationView, IActivatedEventArgs^
|
||||||
|
|
||||||
void App::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args)
|
void App::OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args)
|
||||||
{
|
{
|
||||||
|
//This function will ensure that configs saved in case the app sent to background or terminated
|
||||||
|
//for saving configs on quit now configs will be saved in `retroarch_main_quit` at `retroarch.c`
|
||||||
|
//if this function called because of app closed by quit the below code must be ignored
|
||||||
|
|
||||||
|
|
||||||
/* Save app state asynchronously after requesting a deferral. Holding a deferral
|
/* Save app state asynchronously after requesting a deferral. Holding a deferral
|
||||||
* indicates that the application is busy performing suspending operations. Be
|
* indicates that the application is busy performing suspending operations. Be
|
||||||
* aware that a deferral may not be held indefinitely. After about five seconds,
|
* aware that a deferral may not be held indefinitely. After about five seconds,
|
||||||
|
@ -871,28 +876,73 @@ extern "C" {
|
||||||
|
|
||||||
int uwp_get_height(void)
|
int uwp_get_height(void)
|
||||||
{
|
{
|
||||||
if (is_running_on_xbox())
|
//This function must be performed within UI thread otherwise it will cause crash in specific cases
|
||||||
|
//https://github.com/libretro/RetroArch/issues/13491
|
||||||
|
float surface_scale = 0;
|
||||||
|
int returnValue = -1;
|
||||||
|
volatile bool finished = false;
|
||||||
|
Windows::ApplicationModel::Core::CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(
|
||||||
|
CoreDispatcherPriority::Normal,
|
||||||
|
ref new Windows::UI::Core::DispatchedHandler([&surface_scale, &returnValue, &finished]()
|
||||||
|
{
|
||||||
|
if (is_running_on_xbox())
|
||||||
|
{
|
||||||
|
const Windows::Graphics::Display::Core::HdmiDisplayInformation^ hdi = Windows::Graphics::Display::Core::HdmiDisplayInformation::GetForCurrentView();
|
||||||
|
if (hdi)
|
||||||
|
returnValue = Windows::Graphics::Display::Core::HdmiDisplayInformation::GetForCurrentView()->GetCurrentDisplayMode()->ResolutionHeightInRawPixels;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (returnValue == -1) {
|
||||||
|
const LONG32 resolution_scale = static_cast<LONG32>(Windows::Graphics::Display::DisplayInformation::GetForCurrentView()->ResolutionScale);
|
||||||
|
surface_scale = static_cast<float>(resolution_scale) / 100.0f;
|
||||||
|
returnValue = static_cast<LONG32>(CoreWindow::GetForCurrentThread()->Bounds.Height * surface_scale);
|
||||||
|
}
|
||||||
|
finished = true;
|
||||||
|
}));
|
||||||
|
Windows::UI::Core::CoreWindow^ corewindow = Windows::UI::Core::CoreWindow::GetForCurrentThread();
|
||||||
|
while (!finished)
|
||||||
{
|
{
|
||||||
const Windows::Graphics::Display::Core::HdmiDisplayInformation^ hdi = Windows::Graphics::Display::Core::HdmiDisplayInformation::GetForCurrentView();
|
if (corewindow) {
|
||||||
if (hdi)
|
corewindow->Dispatcher->ProcessEvents(Windows::UI::Core::CoreProcessEventsOption::ProcessAllIfPresent);
|
||||||
return Windows::Graphics::Display::Core::HdmiDisplayInformation::GetForCurrentView()->GetCurrentDisplayMode()->ResolutionHeightInRawPixels;
|
}
|
||||||
}
|
}
|
||||||
const LONG32 resolution_scale = static_cast<LONG32>(Windows::Graphics::Display::DisplayInformation::GetForCurrentView()->ResolutionScale);
|
return returnValue;
|
||||||
auto surface_scale = static_cast<float>(resolution_scale) / 100.0f;
|
|
||||||
return static_cast<LONG32>(CoreWindow::GetForCurrentThread()->Bounds.Height * surface_scale);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int uwp_get_width(void)
|
int uwp_get_width(void)
|
||||||
{
|
{
|
||||||
if (is_running_on_xbox())
|
//This function must be performed within UI thread otherwise it will cause crash in specific cases
|
||||||
|
//https://github.com/libretro/RetroArch/issues/13491
|
||||||
|
float surface_scale = 0;
|
||||||
|
int returnValue = -1;
|
||||||
|
volatile bool finished = false;
|
||||||
|
Windows::ApplicationModel::Core::CoreApplication::MainView->CoreWindow->Dispatcher->RunAsync(
|
||||||
|
CoreDispatcherPriority::Normal,
|
||||||
|
ref new Windows::UI::Core::DispatchedHandler([&surface_scale, &returnValue, &finished]()
|
||||||
|
{
|
||||||
|
if (is_running_on_xbox())
|
||||||
|
{
|
||||||
|
const Windows::Graphics::Display::Core::HdmiDisplayInformation^ hdi = Windows::Graphics::Display::Core::HdmiDisplayInformation::GetForCurrentView();
|
||||||
|
if (hdi)
|
||||||
|
returnValue = Windows::Graphics::Display::Core::HdmiDisplayInformation::GetForCurrentView()->GetCurrentDisplayMode()->ResolutionWidthInRawPixels;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(returnValue == -1) {
|
||||||
|
const LONG32 resolution_scale = static_cast<LONG32>(Windows::Graphics::Display::DisplayInformation::GetForCurrentView()->ResolutionScale);
|
||||||
|
surface_scale = static_cast<float>(resolution_scale) / 100.0f;
|
||||||
|
returnValue = static_cast<LONG32>(CoreWindow::GetForCurrentThread()->Bounds.Width * surface_scale);
|
||||||
|
}
|
||||||
|
finished = true;
|
||||||
|
}));
|
||||||
|
Windows::UI::Core::CoreWindow^ corewindow = Windows::UI::Core::CoreWindow::GetForCurrentThread();
|
||||||
|
while (!finished)
|
||||||
{
|
{
|
||||||
const Windows::Graphics::Display::Core::HdmiDisplayInformation^ hdi = Windows::Graphics::Display::Core::HdmiDisplayInformation::GetForCurrentView();
|
if (corewindow) {
|
||||||
if (hdi)
|
corewindow->Dispatcher->ProcessEvents(Windows::UI::Core::CoreProcessEventsOption::ProcessAllIfPresent);
|
||||||
return Windows::Graphics::Display::Core::HdmiDisplayInformation::GetForCurrentView()->GetCurrentDisplayMode()->ResolutionWidthInRawPixels;
|
}
|
||||||
}
|
}
|
||||||
const LONG32 resolution_scale = static_cast<LONG32>(Windows::Graphics::Display::DisplayInformation::GetForCurrentView()->ResolutionScale);
|
|
||||||
auto surface_scale = static_cast<float>(resolution_scale) / 100.0f;
|
return returnValue;
|
||||||
return static_cast<LONG32>(CoreWindow::GetForCurrentThread()->Bounds.Width * surface_scale);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void uwp_fill_installed_core_packages(struct string_list *list)
|
void uwp_fill_installed_core_packages(struct string_list *list)
|
||||||
|
|
Loading…
Reference in New Issue