toplevelexport: fix transformed origin for shm buffers (#9343)

* toplevelexport: fix transformed origin for shm buffers

* toplevelexport: fix style nits
This commit is contained in:
WhySoBad
2025-02-06 13:42:20 +01:00
committed by GitHub
parent 30b49c75bf
commit acbcf0cf11

View File

@@ -11,6 +11,7 @@
#include "../render/Renderer.hpp"
#include <algorithm>
#include <hyprutils/math/Vector2D.hpp>
CToplevelExportClient::CToplevelExportClient(SP<CHyprlandToplevelExportManagerV1> resource_) : resource(resource_) {
if UNLIKELY (!good())
@@ -289,7 +290,29 @@ bool CToplevelExportFrame::copyShm(timespec* now) {
glPixelStorei(GL_PACK_ALIGNMENT, 1);
auto glFormat = PFORMAT->flipRB ? GL_BGRA_EXT : GL_RGBA;
glReadPixels(0, 0, box.width, box.height, glFormat, PFORMAT->glType, pixelData);
auto origin = Vector2D(0, 0);
switch (PMONITOR->transform) {
case WL_OUTPUT_TRANSFORM_FLIPPED_180:
case WL_OUTPUT_TRANSFORM_90: {
origin.y = PMONITOR->vecPixelSize.y - box.height;
break;
}
case WL_OUTPUT_TRANSFORM_FLIPPED_270:
case WL_OUTPUT_TRANSFORM_180: {
origin.x = PMONITOR->vecPixelSize.x - box.width;
origin.y = PMONITOR->vecPixelSize.y - box.height;
break;
}
case WL_OUTPUT_TRANSFORM_FLIPPED:
case WL_OUTPUT_TRANSFORM_270: {
origin.x = PMONITOR->vecPixelSize.x - box.width;
break;
}
default: break;
}
glReadPixels(origin.x, origin.y, box.width, box.height, glFormat, PFORMAT->glType, pixelData);
if (overlayCursor) {
g_pPointerManager->unlockSoftwareForMonitor(PMONITOR->self.lock());