fix hw cursors with new aq stuff

This commit is contained in:
Vaxry 2024-06-26 19:26:55 +02:00
parent e1adef12f5
commit 817c2a56c9

View file

@ -375,25 +375,21 @@ bool CPointerManager::setHWCursorBuffer(SP<SMonitorPointerState> state, SP<Aquam
SP<Aquamarine::IBuffer> CPointerManager::renderHWCursorBuffer(SP<CPointerManager::SMonitorPointerState> state, SP<CTexture> texture) { SP<Aquamarine::IBuffer> CPointerManager::renderHWCursorBuffer(SP<CPointerManager::SMonitorPointerState> state, SP<CTexture> texture) {
auto output = state->monitor->output; auto output = state->monitor->output;
auto maxSize = output->maxCursorSize(); auto maxSize = output->cursorPlaneSize();
auto cursorSize = currentCursorImage.size; auto cursorSize = currentCursorImage.size;
if (cursorSize == Vector2D{})
return nullptr;
// error
if (maxSize == Vector2D{}) if (maxSize == Vector2D{})
return nullptr; return nullptr;
if (maxSize != Vector2D{-1, -1}) { if (maxSize != Vector2D{-1, -1}) {
if (cursorSize.x < maxSize.x || cursorSize.y < maxSize.y) { if (cursorSize.x > maxSize.x || cursorSize.y > maxSize.y) {
Debug::log(TRACE, "hardware cursor too big! {} > {}", currentCursorImage.size, maxSize); Debug::log(TRACE, "hardware cursor too big! {} > {}", currentCursorImage.size, maxSize);
return nullptr; return nullptr;
} }
} } else
maxSize = cursorSize;
if (!state->monitor->cursorSwapchain || cursorSize != state->monitor->cursorSwapchain->currentOptions().size) { if (!state->monitor->cursorSwapchain || maxSize != state->monitor->cursorSwapchain->currentOptions().size) {
auto format = pickCursorFormat(output); auto format = pickCursorFormat(output);
if (format.drmFormat == DRM_FORMAT_INVALID) { if (format.drmFormat == DRM_FORMAT_INVALID) {
@ -402,12 +398,14 @@ SP<Aquamarine::IBuffer> CPointerManager::renderHWCursorBuffer(SP<CPointerManager
} }
if (!state->monitor->cursorSwapchain) if (!state->monitor->cursorSwapchain)
state->monitor->cursorSwapchain = makeShared<Aquamarine::CSwapchain>(g_pCompositor->m_pAqBackend->allocator); state->monitor->cursorSwapchain = Aquamarine::CSwapchain::create(g_pCompositor->m_pAqBackend->allocator, state->monitor->output->getBackend());
auto options = state->monitor->cursorSwapchain->currentOptions(); auto options = state->monitor->cursorSwapchain->currentOptions();
options.size = cursorSize; options.size = maxSize;
options.length = 2; options.length = 2;
options.format = format.drmFormat; options.format = format.drmFormat;
options.scanout = true;
options.cursor = true;
if (!state->monitor->cursorSwapchain->reconfigure(options)) { if (!state->monitor->cursorSwapchain->reconfigure(options)) {
Debug::log(TRACE, "Failed to reconfigure cursor swapchain"); Debug::log(TRACE, "Failed to reconfigure cursor swapchain");