From b6f2a4bc364b7e9d125d6dbe12632de15912b37a Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 28 Jul 2022 11:37:27 +0200 Subject: [PATCH] damage popups correctly --- src/events/Popups.cpp | 20 ++++++++++++++++++++ src/helpers/WLClasses.hpp | 1 + 2 files changed, 21 insertions(+) diff --git a/src/events/Popups.cpp b/src/events/Popups.cpp index 63f764315..53f8de8e6 100644 --- a/src/events/Popups.cpp +++ b/src/events/Popups.cpp @@ -55,6 +55,7 @@ void createNewPopup(wlr_xdg_popup* popup, SXDGPopup* pHyprPopup) { pHyprPopup->hyprListener_mapPopupXDG.initCallback(&popup->base->events.map, &Events::listener_mapPopupXDG, pHyprPopup, "HyprPopup"); pHyprPopup->hyprListener_unmapPopupXDG.initCallback(&popup->base->events.unmap, &Events::listener_unmapPopupXDG, pHyprPopup, "HyprPopup"); pHyprPopup->hyprListener_newPopupFromPopupXDG.initCallback(&popup->base->events.new_popup, &Events::listener_newPopupFromPopupXDG, pHyprPopup, "HyprPopup"); + pHyprPopup->hyprListener_commitPopupXDG.initCallback(&popup->base->surface->events.commit, &Events::listener_commitPopupXDG, pHyprPopup, "HyprPopup"); const auto PMONITOR = g_pCompositor->m_pLastMonitor; @@ -144,6 +145,11 @@ void Events::listener_mapPopupXDG(void* owner, void* data) { PPOPUP->pSurfaceTree = SubsurfaceTree::createTreeRoot(PPOPUP->popup->base->surface, addPopupGlobalCoords, PPOPUP, PPOPUP->parentWindow); + int lx = 0, ly = 0; + addPopupGlobalCoords(PPOPUP, &lx, &ly); + + g_pHyprRenderer->damageBox(lx, ly, PPOPUP->popup->current.geometry.width, PPOPUP->popup->current.geometry.width); + Debug::log(LOG, "XDG Popup got assigned a surfaceTreeNode %x", PPOPUP->pSurfaceTree); } @@ -155,9 +161,23 @@ void Events::listener_unmapPopupXDG(void* owner, void* data) { SubsurfaceTree::destroySurfaceTree(PPOPUP->pSurfaceTree); + int lx = 0, ly = 0; + addPopupGlobalCoords(PPOPUP, &lx, &ly); + + g_pHyprRenderer->damageBox(lx, ly, PPOPUP->popup->current.geometry.width, PPOPUP->popup->current.geometry.width); + PPOPUP->pSurfaceTree = nullptr; } +void Events::listener_commitPopupXDG(void* owner, void* data) { + SXDGPopup* PPOPUP = (SXDGPopup*)owner; + + int lx = 0, ly = 0; + addPopupGlobalCoords(PPOPUP, &lx, &ly); + + g_pHyprRenderer->damageSurface(PPOPUP->popup->base->surface, lx, ly); +} + void Events::listener_destroyPopupXDG(void* owner, void* data) { SXDGPopup* PPOPUP = (SXDGPopup*)owner; diff --git a/src/helpers/WLClasses.hpp b/src/helpers/WLClasses.hpp index d104f2ad8..6d2edfaa6 100644 --- a/src/helpers/WLClasses.hpp +++ b/src/helpers/WLClasses.hpp @@ -155,6 +155,7 @@ struct SXDGPopup { DYNLISTENER(destroyPopupXDG); DYNLISTENER(mapPopupXDG); DYNLISTENER(unmapPopupXDG); + DYNLISTENER(commitPopupXDG); double lx; double ly;