add sandbox support to desktop designer, fix mouse coordinates and UI issues

- Add DesktopSandbox class that integrates timer, JSON, crypto, and VirtualFS APIs
- Fix mouse coordinate handling: GLFW reports window coordinates, not physical pixels
- Fix font path resolution to search multiple locations for test apps
- Fix screenshot capture timing (capture before buffer swap)
- Fix test app CSS: use border-width instead of border:none, add display:block
- Fix test app Lua: add document nil checks, use HTML entities for symbols
- Update hot_reload to reset sandbox state on reload

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-19 10:22:32 +01:00
parent d40ea1e537
commit 8432bbb986
8 changed files with 372 additions and 53 deletions

View File

@@ -22,14 +22,24 @@ void HotReload::Start() {
m_running = true;
#ifdef _WIN32
// Create a manual-reset event for signaling shutdown
m_stop_event = CreateEventW(nullptr, TRUE, FALSE, nullptr);
if (!m_stop_event) {
std::cerr << "Failed to create stop event" << std::endl;
m_running = false;
return;
}
m_notification_handle = FindFirstChangeNotificationW(
m_watch_path.c_str(),
TRUE, // Watch subtree
FILE_NOTIFY_CHANGE_LAST_WRITE
);
if (m_notification_handle == INVALID_HANDLE_VALUE) {
std::cerr << "Failed to set up file watching" << std::endl;
CloseHandle(m_stop_event);
m_stop_event = nullptr;
m_running = false;
return;
}
@@ -39,6 +49,12 @@ void HotReload::Start() {
void HotReload::Stop() {
m_running = false;
#ifdef _WIN32
// Signal the stop event to wake up the watch thread
if (m_stop_event) {
SetEvent(m_stop_event);
}
#endif
if (m_watch_thread.joinable()) {
m_watch_thread.join();
}
@@ -47,21 +63,33 @@ void HotReload::Stop() {
FindCloseChangeNotification(m_notification_handle);
m_notification_handle = nullptr;
}
if (m_stop_event) {
CloseHandle(m_stop_event);
m_stop_event = nullptr;
}
#endif
}
void HotReload::WatchThread() {
while (m_running) {
#ifdef _WIN32
DWORD result = WaitForSingleObject(m_notification_handle, 100); // 100ms timeout
// Wait on both the file change notification and the stop event
HANDLE handles[2] = { m_notification_handle, m_stop_event };
DWORD result = WaitForMultipleObjects(2, handles, FALSE, INFINITE);
if (result == WAIT_OBJECT_0) {
// File change notification
// Debounce - wait a bit for file writes to complete
std::this_thread::sleep_for(std::chrono::milliseconds(100));
if (m_callback) {
if (m_callback && m_running) {
m_callback();
}
FindNextChangeNotification(m_notification_handle);
} else if (result == WAIT_OBJECT_0 + 1) {
// Stop event signaled - exit the loop
break;
}
// WAIT_FAILED or other errors will just loop and check m_running
#else
// TODO: Linux inotify / macOS FSEvents implementation
std::this_thread::sleep_for(std::chrono::milliseconds(100));