From 71166ef40b5f7640fcddb1951d84f0f086e198d2 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Tue, 9 Jan 2024 18:14:08 +0100 Subject: [PATCH] subsurfaceTree: update surface tree protocol feedback on map --- src/Window.cpp | 14 ++++++++------ src/Window.hpp | 2 +- src/events/Monitors.cpp | 2 +- src/events/Windows.cpp | 2 +- src/helpers/Monitor.cpp | 2 +- src/helpers/SubsurfaceTree.cpp | 3 +++ 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/Window.cpp b/src/Window.cpp index 01b58253..73835ccd 100644 --- a/src/Window.cpp +++ b/src/Window.cpp @@ -318,7 +318,7 @@ void CWindow::destroyToplevelHandle() { } void CWindow::updateToplevel() { - updateSurfaceOutputs(); + updateSurfaceScaleTransformDetails(); if (!m_phForeignToplevel) return; @@ -345,8 +345,8 @@ void sendLeaveIter(wlr_surface* pSurface, int x, int y, void* data) { wlr_surface_send_leave(pSurface, OUTPUT); } -void CWindow::updateSurfaceOutputs() { - if (m_iLastSurfaceMonitorID == m_iMonitorID || !m_bIsMapped || m_bHidden) +void CWindow::updateSurfaceScaleTransformDetails() { + if (!m_bIsMapped || m_bHidden) return; const auto PLASTMONITOR = g_pCompositor->getMonitorFromID(m_iLastSurfaceMonitorID); @@ -355,10 +355,12 @@ void CWindow::updateSurfaceOutputs() { const auto PNEWMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID); - if (PLASTMONITOR && PLASTMONITOR->m_bEnabled) - wlr_surface_for_each_surface(m_pWLSurface.wlr(), sendLeaveIter, PLASTMONITOR->output); + if (PNEWMONITOR != PLASTMONITOR) { + if (PLASTMONITOR && PLASTMONITOR->m_bEnabled) + wlr_surface_for_each_surface(m_pWLSurface.wlr(), sendLeaveIter, PLASTMONITOR->output); - wlr_surface_for_each_surface(m_pWLSurface.wlr(), sendEnterIter, PNEWMONITOR->output); + wlr_surface_for_each_surface(m_pWLSurface.wlr(), sendEnterIter, PNEWMONITOR->output); + } wlr_surface_for_each_surface( m_pWLSurface.wlr(), diff --git a/src/Window.hpp b/src/Window.hpp index 559e4c90..d700af7e 100644 --- a/src/Window.hpp +++ b/src/Window.hpp @@ -356,7 +356,7 @@ class CWindow { void createToplevelHandle(); void destroyToplevelHandle(); void updateToplevel(); - void updateSurfaceOutputs(); + void updateSurfaceScaleTransformDetails(); void moveToWorkspace(int); CWindow* X11TransientFor(); void onUnmap(); diff --git a/src/events/Monitors.cpp b/src/events/Monitors.cpp index 13f3f829..56f1d757 100644 --- a/src/events/Monitors.cpp +++ b/src/events/Monitors.cpp @@ -109,7 +109,7 @@ void Events::listener_newOutput(wl_listener* listener, void* data) { for (auto& w : g_pCompositor->m_vWindows) { if (w->m_iMonitorID == PNEWMONITOR->ID) { w->m_iLastSurfaceMonitorID = -1; - w->updateSurfaceOutputs(); + w->updateSurfaceScaleTransformDetails(); } } } diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index ce5103ee..b3c811c1 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -803,7 +803,7 @@ void Events::listener_commitWindow(void* owner, void* data) { PWINDOW->m_pPendingSizeAck.reset(); } - PWINDOW->updateSurfaceOutputs(); + 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); diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index 3b4f4016..2f23c0d7 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -621,7 +621,7 @@ void CMonitor::setSpecialWorkspace(CWorkspace* const pWorkspace) { for (auto& w : g_pCompositor->m_vWindows) { if (w->m_iWorkspaceID == pWorkspace->m_iID) { w->m_iMonitorID = ID; - w->updateSurfaceOutputs(); + w->updateSurfaceScaleTransformDetails(); const auto MIDDLE = w->middle(); if (w->m_bIsFloating && !VECINRECT(MIDDLE, vecPosition.x, vecPosition.y, vecPosition.x + vecSize.x, vecPosition.y + vecSize.y) && w->m_iX11Type != 2) { diff --git a/src/helpers/SubsurfaceTree.cpp b/src/helpers/SubsurfaceTree.cpp index 5891411b..41b968e4 100644 --- a/src/helpers/SubsurfaceTree.cpp +++ b/src/helpers/SubsurfaceTree.cpp @@ -178,6 +178,9 @@ void Events::listener_mapSubsurface(void* owner, void* data) { Debug::log(LOG, "Subsurface {:x} mapped", (uintptr_t)subsurface->pSubsurface); subsurface->pChild = createSubsurfaceNode(subsurface->pParent, subsurface, subsurface->pSubsurface->surface, subsurface->pWindowOwner); + + if (subsurface->pWindowOwner) + subsurface->pWindowOwner->updateSurfaceScaleTransformDetails(); } void Events::listener_unmapSubsurface(void* owner, void* data) {