diff options
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) { |
