From 563b23a33726289387193b85d90fb569631ee05f Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Tue, 13 Oct 2026 23:52:22 +0300 Subject: Reconnect to a restarted Wayland compositor Windows now outlive the compositor. On connection loss YASL sends DISPLAY_LOST instead of closing every window, retries the connection on a loop timer, rebuilds each toplevel with its title, size, state and GL context, and sends DISPLAY_RESTORED. CPU windows keep their pixels; GPU renderers drop Vulkan surfaces and GL objects on loss and rebuild them on restore. - Free the dead connection's objects on the next wait, after the application has released GPU objects built on them. - Report a lost connection as an event rather than a failed wait. - Refuse window and Vulkan surface creation while offline with the new YASL_ERROR_DISCONNECTED. - Close popups, cancel drags and fail pending clipboard requests on loss. - Print only protocol errors, not ordinary disconnects. - Examples survive a restart; game.c rebinds its GL context. - Add an end-to-end test that kills Weston under CPU, GL and Vulkan windows and requires them to recover. Co-Authored-By: Claude Opus 5.5 --- src/common/surface.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/common/surface.c') diff --git a/src/common/surface.c b/src/common/surface.c index 897b95a..9b4a8ad 100644 --- a/src/common/surface.c +++ b/src/common/surface.c @@ -32,13 +32,14 @@ bool yasl_public_fail(int error) else if (error==ENOMEM) code=YASL_ERROR_NO_MEMORY; else if (error==EBUSY) code=YASL_ERROR_BUSY; else if (error==EPERM) code=YASL_ERROR_WRONG_THREAD; + else if (error==ENOTCONN) code=YASL_ERROR_DISCONNECTED; yasl_public_set_error(code,error); errno=error; return false; } enum yasl_error yasl_get_error(const char **description) { static const char *const messages[]={"No error","Invalid argument","Unsupported operation", "Out of memory","Library not initialized","Operation is busy","Wrong thread", - "Input context expired","Native operation failed"}; + "Input context expired","Native operation failed","Display disconnected"}; if(description) *description=messages[last_error]; return last_error; } @@ -254,6 +255,7 @@ static bool convert_event(const struct yasl_private_event *p,yasl_event *e) case YASL_PRIVATE_EVENT_DISPLAY_QUIT:e->type=YASL_EVENT_QUIT;break; case YASL_PRIVATE_EVENT_DISPLAY_REOPEN:e->type=YASL_EVENT_REOPEN;break; case YASL_PRIVATE_EVENT_DISPLAY_LOST:e->type=YASL_EVENT_DISPLAY_LOST;break; + case YASL_PRIVATE_EVENT_DISPLAY_RESTORED:e->type=YASL_EVENT_DISPLAY_RESTORED;break; case YASL_PRIVATE_EVENT_REFRESH: if(!p->surface) return false; if(!refresh_ready(p->surface)) { p->surface->refresh_owed=true; return false; } -- cgit v1.2.3