From 59f27e7f570170783ac01fb46a0ff90e14de53e6 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Sun, 22 Oct 2023 16:58:06 +0100 Subject: [PATCH] compositor: send preferred scale and transform events to surfaces fixes #3635 --- src/Compositor.cpp | 9 +++++++++ src/Compositor.hpp | 2 ++ src/Window.cpp | 3 ++- src/events/Layers.cpp | 6 ++++-- src/events/Popups.cpp | 6 ++++-- src/events/Windows.cpp | 3 ++- 6 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 704ac64a..cc9d4244 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -2677,3 +2677,12 @@ void CCompositor::leaveUnsafeState() { m_pUnsafeOutput = nullptr; } + +void CCompositor::setPreferredScaleForSurface(wlr_surface* pSurface, double scale) { + g_pProtocolManager->m_pFractionalScaleProtocolManager->setPreferredScaleForSurface(pSurface, scale); + wlr_surface_set_preferred_buffer_scale(pSurface, scale); +} + +void CCompositor::setPreferredTransformForSurface(wlr_surface* pSurface, wl_output_transform transform) { + wlr_surface_set_preferred_buffer_transform(pSurface, transform); +} \ No newline at end of file diff --git a/src/Compositor.hpp b/src/Compositor.hpp index 86460211..fdbac136 100644 --- a/src/Compositor.hpp +++ b/src/Compositor.hpp @@ -207,6 +207,8 @@ class CCompositor { void arrangeMonitors(); void enterUnsafeState(); void leaveUnsafeState(); + void setPreferredScaleForSurface(wlr_surface* pSurface, double scale); + void setPreferredTransformForSurface(wlr_surface* pSurface, wl_output_transform transform); std::string explicitConfigPath; diff --git a/src/Window.cpp b/src/Window.cpp index af5015d4..65619585 100644 --- a/src/Window.cpp +++ b/src/Window.cpp @@ -325,7 +325,8 @@ void CWindow::updateSurfaceOutputs() { m_pWLSurface.wlr(), [](wlr_surface* surf, int x, int y, void* data) { const auto PMONITOR = g_pCompositor->getMonitorFromID(((CWindow*)data)->m_iMonitorID); - g_pProtocolManager->m_pFractionalScaleProtocolManager->setPreferredScaleForSurface(surf, PMONITOR ? PMONITOR->scale : 1.f); + g_pCompositor->setPreferredScaleForSurface(surf, PMONITOR ? PMONITOR->scale : 1.f); + g_pCompositor->setPreferredTransformForSurface(surf, PMONITOR->transform); }, this); } diff --git a/src/events/Layers.cpp b/src/events/Layers.cpp index cb99d0b3..a14ae3f9 100644 --- a/src/events/Layers.cpp +++ b/src/events/Layers.cpp @@ -171,7 +171,8 @@ void Events::listener_mapLayerSurface(void* owner, void* data) { g_pEventManager->postEvent(SHyprIPCEvent{"openlayer", std::string(layersurface->layerSurface->_namespace ? layersurface->layerSurface->_namespace : "")}); EMIT_HOOK_EVENT("openLayer", layersurface); - g_pProtocolManager->m_pFractionalScaleProtocolManager->setPreferredScaleForSurface(layersurface->layerSurface->surface, PMONITOR->scale); + g_pCompositor->setPreferredScaleForSurface(layersurface->layerSurface->surface, PMONITOR->scale); + g_pCompositor->setPreferredTransformForSurface(layersurface->layerSurface->surface, PMONITOR->transform); } void Events::listener_unmapLayerSurface(void* owner, void* data) { @@ -342,5 +343,6 @@ void Events::listener_commitLayerSurface(void* owner, void* data) { g_pHyprRenderer->damageSurface(layersurface->layerSurface->surface, layersurface->position.x, layersurface->position.y); - g_pProtocolManager->m_pFractionalScaleProtocolManager->setPreferredScaleForSurface(layersurface->layerSurface->surface, PMONITOR->scale); + g_pCompositor->setPreferredScaleForSurface(layersurface->layerSurface->surface, PMONITOR->scale); + g_pCompositor->setPreferredTransformForSurface(layersurface->layerSurface->surface, PMONITOR->transform); } diff --git a/src/events/Popups.cpp b/src/events/Popups.cpp index b8d1dffa..570963d9 100644 --- a/src/events/Popups.cpp +++ b/src/events/Popups.cpp @@ -164,8 +164,10 @@ void Events::listener_mapPopupXDG(void* owner, void* data) { g_pHyprRenderer->damageBox(lx - extents.x, ly - extents.y, extents.width + 2, extents.height + 2); - if (PPOPUP->monitor) - g_pProtocolManager->m_pFractionalScaleProtocolManager->setPreferredScaleForSurface(PPOPUP->popup->base->surface, PPOPUP->monitor->scale); + if (PPOPUP->monitor) { + g_pCompositor->setPreferredScaleForSurface(PPOPUP->popup->base->surface, PPOPUP->monitor->scale); + g_pCompositor->setPreferredTransformForSurface(PPOPUP->popup->base->surface, PPOPUP->monitor->transform); + } Debug::log(LOG, "XDG Popup got assigned a surfaceTreeNode {:x}", (uintptr_t)PPOPUP->pSurfaceTree); } diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index df8475d2..89b327b0 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -646,7 +646,8 @@ void Events::listener_mapWindow(void* owner, void* data) { if (PWORKSPACE->m_bHasFullscreenWindow && !PWINDOW->m_bIsFullscreen && !PWINDOW->m_bIsFloating) PWINDOW->m_fAlpha.setValueAndWarp(0.f); - g_pProtocolManager->m_pFractionalScaleProtocolManager->setPreferredScaleForSurface(PWINDOW->m_pWLSurface.wlr(), PMONITOR->scale); + g_pCompositor->setPreferredScaleForSurface(PWINDOW->m_pWLSurface.wlr(), PMONITOR->scale); + g_pCompositor->setPreferredTransformForSurface(PWINDOW->m_pWLSurface.wlr(), PMONITOR->transform); } void Events::listener_unmapWindow(void* owner, void* data) {