mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-23 05:09:49 +01:00
surface: avoid spam of window surfaces with scale and transform events
fixes #4408
This commit is contained in:
parent
8d31c84483
commit
6b92144f15
6 changed files with 40 additions and 7 deletions
|
@ -2797,10 +2797,27 @@ void CCompositor::leaveUnsafeState() {
|
|||
void CCompositor::setPreferredScaleForSurface(wlr_surface* pSurface, double scale) {
|
||||
g_pProtocolManager->m_pFractionalScaleProtocolManager->setPreferredScaleForSurface(pSurface, scale);
|
||||
wlr_surface_set_preferred_buffer_scale(pSurface, static_cast<int32_t>(std::ceil(scale)));
|
||||
|
||||
const auto PSURFACE = CWLSurface::surfaceFromWlr(pSurface);
|
||||
if (!PSURFACE) {
|
||||
Debug::log(WARN, "Orphaned wlr_surface {:x} in setPreferredScaleForSurface", (uintptr_t)pSurface);
|
||||
return;
|
||||
}
|
||||
|
||||
PSURFACE->m_fLastScale = scale;
|
||||
PSURFACE->m_iLastScale = static_cast<int32_t>(std::ceil(scale));
|
||||
}
|
||||
|
||||
void CCompositor::setPreferredTransformForSurface(wlr_surface* pSurface, wl_output_transform transform) {
|
||||
wlr_surface_set_preferred_buffer_transform(pSurface, transform);
|
||||
|
||||
const auto PSURFACE = CWLSurface::surfaceFromWlr(pSurface);
|
||||
if (!PSURFACE) {
|
||||
Debug::log(WARN, "Orphaned wlr_surface {:x} in setPreferredTransformForSurface", (uintptr_t)pSurface);
|
||||
return;
|
||||
}
|
||||
|
||||
PSURFACE->m_eLastTransform = transform;
|
||||
}
|
||||
|
||||
void CCompositor::updateSuspendedStates() {
|
||||
|
|
|
@ -366,7 +366,12 @@ void CWindow::updateSurfaceScaleTransformDetails() {
|
|||
m_pWLSurface.wlr(),
|
||||
[](wlr_surface* surf, int x, int y, void* data) {
|
||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(((CWindow*)data)->m_iMonitorID);
|
||||
g_pCompositor->setPreferredScaleForSurface(surf, PMONITOR ? PMONITOR->scale : 1.f);
|
||||
|
||||
const auto PSURFACE = CWLSurface::surfaceFromWlr(surf);
|
||||
if (PSURFACE && PSURFACE->m_fLastScale == PMONITOR->scale)
|
||||
return;
|
||||
|
||||
g_pCompositor->setPreferredScaleForSurface(surf, PMONITOR->scale);
|
||||
g_pCompositor->setPreferredTransformForSurface(surf, PMONITOR->transform);
|
||||
},
|
||||
this);
|
||||
|
|
|
@ -803,8 +803,6 @@ void Events::listener_commitWindow(void* owner, void* data) {
|
|||
PWINDOW->m_pPendingSizeAck.reset();
|
||||
}
|
||||
|
||||
PWINDOW->updateSurfaceScaleTransformDetails();
|
||||
|
||||
g_pHyprRenderer->damageSurface(PWINDOW->m_pWLSurface.wlr(), PWINDOW->m_vRealPosition.goalv().x, PWINDOW->m_vRealPosition.goalv().y,
|
||||
PWINDOW->m_bIsX11 ? 1.0 / PWINDOW->m_fX11SurfaceScaledBy : 1.0);
|
||||
|
||||
|
|
|
@ -28,8 +28,14 @@ class CWLSurface {
|
|||
bool m_bFillIgnoreSmall = false;
|
||||
|
||||
// if present, means this is a base surface of a window. Cleaned on unassign()
|
||||
CWindow* m_pOwner = nullptr;
|
||||
CWindow* m_pOwner = nullptr;
|
||||
|
||||
// track surface data and avoid dupes
|
||||
float m_fLastScale = 0;
|
||||
int m_iLastScale = 0;
|
||||
wl_output_transform m_eLastTransform = (wl_output_transform)-1;
|
||||
|
||||
//
|
||||
CWLSurface& operator=(wlr_surface* pSurface) {
|
||||
destroy();
|
||||
m_pWLRSurface = pSurface;
|
||||
|
|
|
@ -2019,8 +2019,10 @@ void CHyprOpenGLImpl::clearWithTex() {
|
|||
TEXIT = m_mMonitorBGTextures.find(m_RenderData.pMonitor);
|
||||
}
|
||||
|
||||
CBox box = {0, 0, m_RenderData.pMonitor->vecPixelSize.x, m_RenderData.pMonitor->vecPixelSize.y};
|
||||
|
||||
if (TEXIT != m_mMonitorBGTextures.end())
|
||||
renderTexturePrimitive(TEXIT->second, &m_mMonitorRenderResources[m_RenderData.pMonitor].backgroundTexBox);
|
||||
renderTexture(TEXIT->second, &box, 1);
|
||||
}
|
||||
|
||||
void CHyprOpenGLImpl::destroyMonitorResources(CMonitor* pMonitor) {
|
||||
|
|
|
@ -1997,6 +1997,7 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
|||
Vector2D logicalZero = pMonitor->vecPixelSize / scaleZero;
|
||||
if (logicalZero == logicalZero.round()) {
|
||||
pMonitor->scale = scaleZero;
|
||||
wlr_output_set_scale(pMonitor->output, pMonitor->scale);
|
||||
} else {
|
||||
for (size_t i = 1; i < 90; ++i) {
|
||||
double scaleUp = (searchScale + i) / 120.0;
|
||||
|
@ -2034,11 +2035,15 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
|||
} else
|
||||
pMonitor->scale = searchScale;
|
||||
}
|
||||
|
||||
// for wlroots, that likes flooring, we have to do this.
|
||||
double logicalX = std::round(pMonitor->vecPixelSize.x / pMonitor->scale);
|
||||
logicalX += 0.1;
|
||||
|
||||
wlr_output_set_scale(pMonitor->output, pMonitor->vecPixelSize.x / logicalX);
|
||||
}
|
||||
}
|
||||
|
||||
wlr_output_set_scale(pMonitor->output, pMonitor->scale);
|
||||
|
||||
// clang-format off
|
||||
static const std::array<std::vector<std::pair<std::string, uint32_t>>, 2> formats{
|
||||
std::vector<std::pair<std::string, uint32_t>>{ /* 10-bit */
|
||||
|
|
Loading…
Reference in a new issue