minor toplevel sharing fixups

This commit is contained in:
vaxerski 2022-12-06 18:58:42 +00:00
parent dfa9277867
commit 6c8d993477

View file

@ -92,7 +92,7 @@ void CToplevelExportProtocolManager::removeClient(SToplevelClient* client, bool
void handleManagerResourceDestroy(wl_resource* resource) { void handleManagerResourceDestroy(wl_resource* resource) {
const auto PCLIENT = clientFromResource(resource); const auto PCLIENT = clientFromResource(resource);
g_pProtocolManager->m_pToplevelExportProtocolManager->removeClient(PCLIENT); g_pProtocolManager->m_pToplevelExportProtocolManager->removeClient(PCLIENT, true);
} }
void CToplevelExportProtocolManager::bindManager(wl_client* client, void* data, uint32_t version, uint32_t id) { void CToplevelExportProtocolManager::bindManager(wl_client* client, void* data, uint32_t version, uint32_t id) {
@ -215,22 +215,26 @@ void CToplevelExportProtocolManager::copyFrame(wl_client* client, wl_resource* r
if (!PFRAME->pWindow->m_bIsMapped || PFRAME->pWindow->isHidden()) { if (!PFRAME->pWindow->m_bIsMapped || PFRAME->pWindow->isHidden()) {
Debug::log(ERR, "Client requested sharing of window handle %x which is not shareable (2)!", PFRAME->pWindow); Debug::log(ERR, "Client requested sharing of window handle %x which is not shareable (2)!", PFRAME->pWindow);
hyprland_toplevel_export_frame_v1_send_failed(PFRAME->resource); hyprland_toplevel_export_frame_v1_send_failed(PFRAME->resource);
removeFrame(PFRAME);
return; return;
} }
const auto PBUFFER = wlr_buffer_from_resource(buffer); const auto PBUFFER = wlr_buffer_from_resource(buffer);
if (!PBUFFER) { if (!PBUFFER) {
wl_resource_post_error(PFRAME->resource, HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer"); wl_resource_post_error(PFRAME->resource, HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer");
removeFrame(PFRAME);
return; return;
} }
if (PBUFFER->width != PFRAME->box.width || PBUFFER->height != PFRAME->box.height) { if (PBUFFER->width != PFRAME->box.width || PBUFFER->height != PFRAME->box.height) {
wl_resource_post_error(PFRAME->resource, HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer dimensions"); wl_resource_post_error(PFRAME->resource, HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer dimensions");
removeFrame(PFRAME);
return; return;
} }
if (PFRAME->buffer) { if (PFRAME->buffer) {
wl_resource_post_error(PFRAME->resource, HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_ERROR_ALREADY_USED, "frame already used"); wl_resource_post_error(PFRAME->resource, HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_ERROR_ALREADY_USED, "frame already used");
removeFrame(PFRAME);
return; return;
} }
@ -243,6 +247,7 @@ void CToplevelExportProtocolManager::copyFrame(wl_client* client, wl_resource* r
if (dmabufAttrs.format != PFRAME->dmabufFormat) { if (dmabufAttrs.format != PFRAME->dmabufFormat) {
wl_resource_post_error(PFRAME->resource, HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer format"); wl_resource_post_error(PFRAME->resource, HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer format");
removeFrame(PFRAME);
return; return;
} }
} else if (wlr_buffer_begin_data_ptr_access(PBUFFER, WLR_BUFFER_DATA_PTR_ACCESS_WRITE, &wlrBufferAccessData, &wlrBufferAccessFormat, &wlrBufferAccessStride)) { } else if (wlr_buffer_begin_data_ptr_access(PBUFFER, WLR_BUFFER_DATA_PTR_ACCESS_WRITE, &wlrBufferAccessData, &wlrBufferAccessFormat, &wlrBufferAccessStride)) {
@ -250,13 +255,16 @@ void CToplevelExportProtocolManager::copyFrame(wl_client* client, wl_resource* r
if (wlrBufferAccessFormat != PFRAME->shmFormat) { if (wlrBufferAccessFormat != PFRAME->shmFormat) {
wl_resource_post_error(PFRAME->resource, HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer format"); wl_resource_post_error(PFRAME->resource, HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer format");
removeFrame(PFRAME);
return; return;
} else if ((int)wlrBufferAccessStride != PFRAME->shmStride) { } else if ((int)wlrBufferAccessStride != PFRAME->shmStride) {
wl_resource_post_error(PFRAME->resource, HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer stride"); wl_resource_post_error(PFRAME->resource, HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer stride");
removeFrame(PFRAME);
return; return;
} }
} else { } else {
wl_resource_post_error(PFRAME->resource, HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer type"); wl_resource_post_error(PFRAME->resource, HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_ERROR_INVALID_BUFFER, "invalid buffer type");
removeFrame(PFRAME);
return; return;
} }