mirror of
https://github.com/hyprwm/hyprpicker.git
synced 2024-12-22 06:09:48 +01:00
core: minor transform fixes (#94)
This commit is contained in:
parent
89b9352d26
commit
4e8837ddab
4 changed files with 21 additions and 8 deletions
|
@ -21,6 +21,9 @@ CLayerSurface::CLayerSurface(SMonitor* pMonitor) {
|
|||
pFractionalScale = makeShared<CCWpFractionalScaleV1>(g_pHyprpicker->m_pFractionalMgr->sendGetFractionalScale(pSurface->resource()));
|
||||
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);
|
||||
fractionalScale = scale120 / 120.F;
|
||||
wantsReload = true;
|
||||
g_pHyprpicker->recheckACK();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -20,9 +20,11 @@ class CLayerSurface {
|
|||
SP<CCWpViewport> pViewport = nullptr;
|
||||
SP<CCWpFractionalScaleV1> pFractionalScale = nullptr;
|
||||
|
||||
bool wantsACK = false;
|
||||
uint32_t ACKSerial = 0;
|
||||
bool working = false;
|
||||
float fractionalScale = 1.F;
|
||||
bool wantsACK = false;
|
||||
bool wantsReload = false;
|
||||
uint32_t ACKSerial = 0;
|
||||
bool working = false;
|
||||
|
||||
int lastBuffer = 0;
|
||||
SP<SPoolBuffer> buffers[2];
|
||||
|
|
|
@ -39,6 +39,8 @@ void SMonitor::initSCFrame() {
|
|||
if (pLS->m_pMonitor->transform % 2 == 1)
|
||||
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);
|
||||
|
||||
int bytesPerPixel = pLS->screenBuffer->stride / (int)pLS->screenBuffer->pixelSize.x;
|
||||
|
@ -112,7 +114,7 @@ void SMonitor::initSCFrame() {
|
|||
|
||||
pSCFrame.reset();
|
||||
});
|
||||
pSCFrame->setFailed([this](CCZwlrScreencopyFrameV1* r) {
|
||||
pSCFrame->setFailed([](CCZwlrScreencopyFrameV1* r) {
|
||||
Debug::log(CRIT, "Failed to get a Screencopy!");
|
||||
g_pHyprpicker->finish(1);
|
||||
});
|
||||
|
|
|
@ -147,13 +147,17 @@ void CHyprpicker::finish(int code) {
|
|||
|
||||
void CHyprpicker::recheckACK() {
|
||||
for (auto& ls : m_vLayerSurfaces) {
|
||||
if (ls->wantsACK) {
|
||||
ls->wantsACK = false;
|
||||
ls->pLayerSurface->sendAckConfigure(ls->ACKSerial);
|
||||
if ((ls->wantsACK || ls->wantsReload) && ls->screenBuffer) {
|
||||
if (ls->wantsACK)
|
||||
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) {
|
||||
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[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 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);
|
||||
cairo_pattern_set_filter(PATTERNPRE, CAIRO_FILTER_BILINEAR);
|
||||
cairo_matrix_t matrixPre;
|
||||
|
|
Loading…
Reference in a new issue