transform fixes

This commit is contained in:
Vaxry 2024-11-04 01:42:27 +00:00
parent 89b9352d26
commit f1b300d137
4 changed files with 21 additions and 8 deletions

View file

@ -21,6 +21,9 @@ CLayerSurface::CLayerSurface(SMonitor* pMonitor) {
pFractionalScale = makeShared<CCWpFractionalScaleV1>(g_pHyprpicker->m_pFractionalMgr->sendGetFractionalScale(pSurface->resource())); pFractionalScale = makeShared<CCWpFractionalScaleV1>(g_pHyprpicker->m_pFractionalMgr->sendGetFractionalScale(pSurface->resource()));
pFractionalScale->setPreferredScale([this](CCWpFractionalScaleV1* r, uint32_t scale120) { // pFractionalScale->setPreferredScale([this](CCWpFractionalScaleV1* r, uint32_t scale120) { //
Debug::log(TRACE, "Received a preferredScale for %s: %.2f", m_pMonitor->name.c_str(), scale120 / 120.F); Debug::log(TRACE, "Received a preferredScale for %s: %.2f", m_pMonitor->name.c_str(), scale120 / 120.F);
fractionalScale = scale120 / 120.F;
wantsReload = true;
g_pHyprpicker->recheckACK();
}); });
} }

View file

@ -20,7 +20,9 @@ class CLayerSurface {
SP<CCWpViewport> pViewport = nullptr; SP<CCWpViewport> pViewport = nullptr;
SP<CCWpFractionalScaleV1> pFractionalScale = nullptr; SP<CCWpFractionalScaleV1> pFractionalScale = nullptr;
float fractionalScale = 1.F;
bool wantsACK = false; bool wantsACK = false;
bool wantsReload = false;
uint32_t ACKSerial = 0; uint32_t ACKSerial = 0;
bool working = false; bool working = false;

View file

@ -39,6 +39,8 @@ void SMonitor::initSCFrame() {
if (pLS->m_pMonitor->transform % 2 == 1) if (pLS->m_pMonitor->transform % 2 == 1)
std::swap(transformedSize.x, transformedSize.y); std::swap(transformedSize.x, transformedSize.y);
Debug::log(TRACE, "Frame ready: pixel %.0fx%.0f, xfmd: %.0fx%.0f", pLS->screenBuffer->pixelSize.x, pLS->screenBuffer->pixelSize.y, transformedSize.x, transformedSize.y);
SP<SPoolBuffer> newBuf = makeShared<SPoolBuffer>(transformedSize, pLS->screenBufferFormat, transformedSize.x * 4); SP<SPoolBuffer> newBuf = makeShared<SPoolBuffer>(transformedSize, pLS->screenBufferFormat, transformedSize.x * 4);
int bytesPerPixel = pLS->screenBuffer->stride / (int)pLS->screenBuffer->pixelSize.x; int bytesPerPixel = pLS->screenBuffer->stride / (int)pLS->screenBuffer->pixelSize.x;
@ -112,7 +114,7 @@ void SMonitor::initSCFrame() {
pSCFrame.reset(); pSCFrame.reset();
}); });
pSCFrame->setFailed([this](CCZwlrScreencopyFrameV1* r) { pSCFrame->setFailed([](CCZwlrScreencopyFrameV1* r) {
Debug::log(CRIT, "Failed to get a Screencopy!"); Debug::log(CRIT, "Failed to get a Screencopy!");
g_pHyprpicker->finish(1); g_pHyprpicker->finish(1);
}); });

View file

@ -147,13 +147,17 @@ void CHyprpicker::finish(int code) {
void CHyprpicker::recheckACK() { void CHyprpicker::recheckACK() {
for (auto& ls : m_vLayerSurfaces) { for (auto& ls : m_vLayerSurfaces) {
if (ls->wantsACK) { if ((ls->wantsACK || ls->wantsReload) && ls->screenBuffer) {
ls->wantsACK = false; if (ls->wantsACK)
ls->pLayerSurface->sendAckConfigure(ls->ACKSerial); ls->pLayerSurface->sendAckConfigure(ls->ACKSerial);
ls->wantsACK = false;
ls->wantsReload = false;
const auto MONITORSIZE = ls->screenBuffer && !g_pHyprpicker->m_bNoFractional ? ls->screenBuffer->pixelSize : ls->m_pMonitor->size * ls->m_pMonitor->scale; const auto MONITORSIZE =
(ls->screenBuffer && !g_pHyprpicker->m_bNoFractional ? ls->m_pMonitor->size * ls->fractionalScale : ls->m_pMonitor->size * ls->m_pMonitor->scale).round();
if (!ls->buffers[0] || ls->buffers[0]->pixelSize != MONITORSIZE) { if (!ls->buffers[0] || ls->buffers[0]->pixelSize != MONITORSIZE) {
Debug::log(TRACE, "making new buffers: size changed to %.0fx%.0f", MONITORSIZE.x, MONITORSIZE.y);
ls->buffers[0] = makeShared<SPoolBuffer>(MONITORSIZE, WL_SHM_FORMAT_ARGB8888, MONITORSIZE.x * 4); ls->buffers[0] = makeShared<SPoolBuffer>(MONITORSIZE, WL_SHM_FORMAT_ARGB8888, MONITORSIZE.x * 4);
ls->buffers[1] = makeShared<SPoolBuffer>(MONITORSIZE, WL_SHM_FORMAT_ARGB8888, MONITORSIZE.x * 4); ls->buffers[1] = makeShared<SPoolBuffer>(MONITORSIZE, WL_SHM_FORMAT_ARGB8888, MONITORSIZE.x * 4);
} }
@ -360,6 +364,8 @@ void CHyprpicker::renderSurface(CLayerSurface* pSurface, bool forceInactive) {
const auto MOUSECOORDSABS = m_vLastCoords.floor() / pSurface->m_pMonitor->size; const auto MOUSECOORDSABS = m_vLastCoords.floor() / pSurface->m_pMonitor->size;
const auto CLICKPOS = MOUSECOORDSABS * PBUFFER->pixelSize; const auto CLICKPOS = MOUSECOORDSABS * PBUFFER->pixelSize;
Debug::log(TRACE, "renderSurface: scalebufs %.2fx%.2f", SCALEBUFS.x, SCALEBUFS.y);
const auto PATTERNPRE = cairo_pattern_create_for_surface(pSurface->screenBuffer->surface); const auto PATTERNPRE = cairo_pattern_create_for_surface(pSurface->screenBuffer->surface);
cairo_pattern_set_filter(PATTERNPRE, CAIRO_FILTER_BILINEAR); cairo_pattern_set_filter(PATTERNPRE, CAIRO_FILTER_BILINEAR);
cairo_matrix_t matrixPre; cairo_matrix_t matrixPre;