diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 23:52:22 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 23:52:22 +0300 |
| commit | 563b23a33726289387193b85d90fb569631ee05f (patch) | |
| tree | ddf438338034b5ab2690b531684906999e56df44 /src/common | |
| parent | 76073fe5fad8799e5850805f2f090af2cb62c741 (diff) | |
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 <noreply@anthropic.com>
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/backend.h | 1 | ||||
| -rw-r--r-- | src/common/surface.c | 4 | ||||
| -rw-r--r-- | src/common/types.h | 3 | ||||
| -rw-r--r-- | src/common/vulkan.c | 1 |
4 files changed, 7 insertions, 2 deletions
diff --git a/src/common/backend.h b/src/common/backend.h index e3dc6de..bf6815a 100644 --- a/src/common/backend.h +++ b/src/common/backend.h @@ -16,6 +16,7 @@ struct yasl_private_event_state; struct yasl_private_display { const struct yasl_private_backend_ops *ops; void *native_handle; + bool offline; /* Connection lost; native handles are unusable until it is restored. */ struct yasl_private_display_cbs callbacks; struct yasl_private_loop *loop; /* Backend's copy of yasl_private_display_spec.app_id, or NULL; for desktop services. */ 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; } diff --git a/src/common/types.h b/src/common/types.h index 91f8a47..40c502f 100644 --- a/src/common/types.h +++ b/src/common/types.h @@ -355,7 +355,8 @@ enum yasl_private_event_type { YASL_PRIVATE_EVENT_DISPLAY_LOST, YASL_PRIVATE_EVENT_PEN, YASL_PRIVATE_EVENT_TEXT_EDIT, - YASL_PRIVATE_EVENT_REFRESH, /**< No payload; display connection failed. */ + YASL_PRIVATE_EVENT_REFRESH, /**< No payload; surface contents are needed. */ + YASL_PRIVATE_EVENT_DISPLAY_RESTORED, /**< No payload; display reconnected after DISPLAY_LOST. */ }; /** Physical keyboard transition with optional layout labels. diff --git a/src/common/vulkan.c b/src/common/vulkan.c index 1bca415..62bc3a0 100644 --- a/src/common/vulkan.c +++ b/src/common/vulkan.c @@ -55,6 +55,7 @@ VkResult yasl_vulkan_create_surface(yasl_surface *s,VkInstance instance,const Vk { if(out)*out=VK_NULL_HANDLE; if(!yasl_public_surface(s,false)||!instance||!out||!get_proc){yasl_public_fail(EINVAL);return VK_ERROR_INITIALIZATION_FAILED;} + if(s->display->offline){yasl_public_fail(ENOTCONN);return VK_ERROR_SURFACE_LOST_KHR;} if(s->presenter!=YASL_PRIVATE_PRESENTER_NONE){yasl_public_fail(EBUSY);return VK_ERROR_NATIVE_WINDOW_IN_USE_KHR;} VkResult result=VK_ERROR_EXTENSION_NOT_PRESENT; switch(s->display->ops->type) { |
