system: keep error dialogs open until dismissed

This commit is contained in:
nmzik
2026-09-06 08:34:58 +04:00
parent 44f982bca7
commit 997ad60c50
12 changed files with 466 additions and 156 deletions
+62 -8
View File
@@ -8,6 +8,7 @@
#include <cstdio>
#include <cstring>
#include <mutex>
// NOLINTNEXTLINE(modernize-concat-nested-namespaces)
namespace Libs::Dialog {
@@ -643,11 +644,61 @@ struct ErrorDialogParam {
int32_t reserved;
};
static int g_error_status = STATUS_NONE;
static_assert(sizeof(ErrorDialogParam) == 16);
static std::mutex g_error_mutex;
static int g_error_status = STATUS_NONE;
static uint64_t g_error_generation = 0;
static uint64_t g_error_revision = 0;
static int32_t g_error_code = 0;
static void (*g_error_visibility_callback)() = nullptr;
static void SetStatus(int status, std::unique_lock<std::mutex>& lock) {
const bool visibility_changed =
(g_error_status == STATUS_RUNNING) != (status == STATUS_RUNNING);
g_error_status = status;
if (visibility_changed) {
g_error_revision++;
}
const auto callback = visibility_changed ? g_error_visibility_callback : nullptr;
lock.unlock();
if (callback != nullptr) {
callback();
}
}
bool GetHostSnapshot(HostSnapshot* snapshot) {
std::scoped_lock lock(g_error_mutex);
if (g_error_status != STATUS_RUNNING) {
return false;
}
*snapshot = {g_error_generation, g_error_code};
return true;
}
VisualState GetVisualState() noexcept {
std::scoped_lock lock(g_error_mutex);
return {g_error_status == STATUS_RUNNING, g_error_revision};
}
void SetVisibilityCallback(void (*callback)()) {
std::scoped_lock lock(g_error_mutex);
g_error_visibility_callback = callback;
}
bool HostAccept(uint64_t generation) {
std::unique_lock lock(g_error_mutex);
if (g_error_status != STATUS_RUNNING || generation != g_error_generation) {
return false;
}
SetStatus(STATUS_FINISHED, lock);
return true;
}
int KYTY_SYSV_ABI ErrorDialogInitialize() {
PRINT_NAME();
std::scoped_lock lock(g_error_mutex);
if (g_error_status != STATUS_NONE) {
return ERROR_ALREADY_INITIALIZED;
}
@@ -660,6 +711,7 @@ int KYTY_SYSV_ABI ErrorDialogInitialize() {
int KYTY_SYSV_ABI ErrorDialogOpen(const void* param) {
PRINT_NAME();
std::unique_lock lock(g_error_mutex);
if (g_error_status != STATUS_INITIALIZED && g_error_status != STATUS_FINISHED) {
return ERROR_INVALID_STATE;
}
@@ -677,7 +729,9 @@ int KYTY_SYSV_ABI ErrorDialogOpen(const void* param) {
"\t user_id = %d\n",
p->size, static_cast<uint32_t>(p->error_code), p->user_id);
g_error_status = STATUS_RUNNING;
g_error_code = p->error_code;
g_error_generation++;
SetStatus(STATUS_RUNNING, lock);
return OK;
}
@@ -685,11 +739,12 @@ int KYTY_SYSV_ABI ErrorDialogOpen(const void* param) {
int KYTY_SYSV_ABI ErrorDialogClose() {
PRINT_NAME();
std::unique_lock lock(g_error_mutex);
if (g_error_status != STATUS_RUNNING) {
return ERROR_INVALID_STATE;
}
g_error_status = STATUS_FINISHED;
SetStatus(STATUS_FINISHED, lock);
return OK;
}
@@ -697,11 +752,12 @@ int KYTY_SYSV_ABI ErrorDialogClose() {
int KYTY_SYSV_ABI ErrorDialogTerminate() {
PRINT_NAME();
std::unique_lock lock(g_error_mutex);
if (g_error_status == STATUS_NONE) {
return ERROR_NOT_INITIALIZED;
}
g_error_status = STATUS_NONE;
SetStatus(STATUS_NONE, lock);
return OK;
}
@@ -709,16 +765,14 @@ int KYTY_SYSV_ABI ErrorDialogTerminate() {
int KYTY_SYSV_ABI ErrorDialogUpdateStatus() {
PRINT_NAME();
if (g_error_status == STATUS_RUNNING) {
g_error_status = STATUS_FINISHED;
}
std::scoped_lock lock(g_error_mutex);
return g_error_status;
}
int KYTY_SYSV_ABI ErrorDialogGetStatus() {
PRINT_NAME();
std::scoped_lock lock(g_error_mutex);
return g_error_status;
}
+15
View File
@@ -70,6 +70,21 @@ int KYTY_SYSV_ABI MsgDialogProgressBarSetMsg(int target, const char* msg);
namespace ErrorDialog {
struct HostSnapshot {
uint64_t generation;
int32_t error_code;
};
struct VisualState {
bool active;
uint64_t revision;
};
bool GetHostSnapshot(HostSnapshot* snapshot);
VisualState GetVisualState() noexcept;
void SetVisibilityCallback(void (*callback)());
bool HostAccept(uint64_t generation);
int KYTY_SYSV_ABI ErrorDialogInitialize();
int KYTY_SYSV_ABI ErrorDialogOpen(const void* param);
int KYTY_SYSV_ABI ErrorDialogClose();
+3 -1
View File
@@ -4,6 +4,7 @@
#include "common/emulatorConfig.h"
#include "common/logging/log.h"
#include "common/stringUtils.h"
#include "libs/dialog.h"
#include "libs/errno.h"
#include "libs/libs.h"
#include "loader/symbolDatabase.h"
@@ -160,7 +161,8 @@ static int KYTY_SYSV_ABI SystemServiceGetStatus(SystemServiceStatus* status) {
return SYSTEM_SERVICE_ERROR_PARAMETER;
}
*status = SystemServiceStatus();
*status = SystemServiceStatus();
status->is_system_ui_overlaid = Dialog::ErrorDialog::GetVisualState().active;
return OK;
}