mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-30 04:45:59 +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) {
|
void CCompositor::setPreferredScaleForSurface(wlr_surface* pSurface, double scale) {
|
||||||
g_pProtocolManager->m_pFractionalScaleProtocolManager->setPreferredScaleForSurface(pSurface, scale);
|
g_pProtocolManager->m_pFractionalScaleProtocolManager->setPreferredScaleForSurface(pSurface, scale);
|
||||||
wlr_surface_set_preferred_buffer_scale(pSurface, static_cast<int32_t>(std::ceil(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) {
|
void CCompositor::setPreferredTransformForSurface(wlr_surface* pSurface, wl_output_transform transform) {
|
||||||
wlr_surface_set_preferred_buffer_transform(pSurface, 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() {
|
void CCompositor::updateSuspendedStates() {
|
||||||
|
|
|
@ -366,7 +366,12 @@ void CWindow::updateSurfaceScaleTransformDetails() {
|
||||||
m_pWLSurface.wlr(),
|
m_pWLSurface.wlr(),
|
||||||
[](wlr_surface* surf, int x, int y, void* data) {
|
[](wlr_surface* surf, int x, int y, void* data) {
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(((CWindow*)data)->m_iMonitorID);
|
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);
|
g_pCompositor->setPreferredTransformForSurface(surf, PMONITOR->transform);
|
||||||
},
|
},
|
||||||
this);
|
this);
|
||||||
|
|
|
@ -803,8 +803,6 @@ void Events::listener_commitWindow(void* owner, void* data) {
|
||||||
PWINDOW->m_pPendingSizeAck.reset();
|
PWINDOW->m_pPendingSizeAck.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
PWINDOW->updateSurfaceScaleTransformDetails();
|
|
||||||
|
|
||||||
g_pHyprRenderer->damageSurface(PWINDOW->m_pWLSurface.wlr(), PWINDOW->m_vRealPosition.goalv().x, PWINDOW->m_vRealPosition.goalv().y,
|
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);
|
PWINDOW->m_bIsX11 ? 1.0 / PWINDOW->m_fX11SurfaceScaledBy : 1.0);
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,12 @@ class CWLSurface {
|
||||||
// if present, means this is a base surface of a window. Cleaned on unassign()
|
// 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) {
|
CWLSurface& operator=(wlr_surface* pSurface) {
|
||||||
destroy();
|
destroy();
|
||||||
m_pWLRSurface = pSurface;
|
m_pWLRSurface = pSurface;
|
||||||
|
|
|
@ -2019,8 +2019,10 @@ void CHyprOpenGLImpl::clearWithTex() {
|
||||||
TEXIT = m_mMonitorBGTextures.find(m_RenderData.pMonitor);
|
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())
|
if (TEXIT != m_mMonitorBGTextures.end())
|
||||||
renderTexturePrimitive(TEXIT->second, &m_mMonitorRenderResources[m_RenderData.pMonitor].backgroundTexBox);
|
renderTexture(TEXIT->second, &box, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprOpenGLImpl::destroyMonitorResources(CMonitor* pMonitor) {
|
void CHyprOpenGLImpl::destroyMonitorResources(CMonitor* pMonitor) {
|
||||||
|
|
|
@ -1997,6 +1997,7 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
||||||
Vector2D logicalZero = pMonitor->vecPixelSize / scaleZero;
|
Vector2D logicalZero = pMonitor->vecPixelSize / scaleZero;
|
||||||
if (logicalZero == logicalZero.round()) {
|
if (logicalZero == logicalZero.round()) {
|
||||||
pMonitor->scale = scaleZero;
|
pMonitor->scale = scaleZero;
|
||||||
|
wlr_output_set_scale(pMonitor->output, pMonitor->scale);
|
||||||
} else {
|
} else {
|
||||||
for (size_t i = 1; i < 90; ++i) {
|
for (size_t i = 1; i < 90; ++i) {
|
||||||
double scaleUp = (searchScale + i) / 120.0;
|
double scaleUp = (searchScale + i) / 120.0;
|
||||||
|
@ -2034,10 +2035,14 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
||||||
} else
|
} else
|
||||||
pMonitor->scale = searchScale;
|
pMonitor->scale = searchScale;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
wlr_output_set_scale(pMonitor->output, pMonitor->scale);
|
// 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const std::array<std::vector<std::pair<std::string, uint32_t>>, 2> formats{
|
static const std::array<std::vector<std::pair<std::string, uint32_t>>, 2> formats{
|
||||||
|
|
Loading…
Reference in a new issue