Fix desktop designer click handling and add goHome API

Designer click handling:
- Fix DPI scaling in MouseButtonCallback and CursorPosCallback
- Scale coordinates from window space to framebuffer/RmlUi context
- Remove window resizing in ResizeToPhone (caused DPI mismatches)

Test framework:
- Fix SendMouseDown to use MOUSEEVENTF_MOVE before button down
- Remove double-scaling in ScaleToPhysical (WindowController handles it)
- All 5 UI navigation tests now pass

Kernel API:
- Add goHome() Lua function to return to home screen
- Stops any running third-party apps before navigating

Test app:
- Update sandbox-test to use goHome() instead of goBack()

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-19 14:52:15 +01:00
parent d6b7504408
commit 984e8715d7
5 changed files with 160 additions and 76 deletions

View File

@@ -257,13 +257,65 @@ static int LuaLoadScreen(lua_State* L)
return 1;
}
// Lua function to go back to home screen
static int LuaGoHome(lua_State* L)
{
if (!g_context)
{
lua_pushboolean(L, false);
return 1;
}
Logger::Log("goHome called - returning to home screen");
// Stop any running third-party app
if (g_sandbox_manager) {
auto running_apps = g_sandbox_manager->GetRunningApps();
for (const auto& app_id : running_apps) {
// Don't stop system apps
if (app_id.find("com.mosis.") == 0 && app_id != "com.mosis.home") {
Logger::Log(std::format("Stopping app: {}", app_id));
g_sandbox_manager->StopApp(app_id);
}
}
}
// Load home screen
const char* home_path = "apps/home/home.rml";
// Unload current document
if (g_document)
{
g_context->UnloadDocument(g_document);
g_document = nullptr;
}
// Load home document
g_document = g_context->LoadDocument(home_path);
if (g_document)
{
g_document->Show();
Logger::Log("Returned to home screen");
lua_pushboolean(L, true);
}
else
{
Logger::Log("Failed to load home screen");
lua_pushboolean(L, false);
}
return 1;
}
// Register Lua functions for navigation
static void RegisterLuaFunctions(const std::string& current_app_id, bool is_system_app)
{
lua_State* L = Rml::Lua::Interpreter::GetLuaState();
lua_pushcfunction(L, LuaLoadScreen);
lua_setglobal(L, "loadScreen");
Logger::Log("Registered Lua loadScreen function");
lua_pushcfunction(L, LuaGoHome);
lua_setglobal(L, "goHome");
Logger::Log("Registered Lua loadScreen and goHome functions");
// Register app management APIs
if (g_app_manager && g_update_service) {