diff --git a/src/Compositor.cpp b/src/Compositor.cpp index b57dd4bf..dd0e200a 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -335,6 +335,8 @@ wlr_surface* CCompositor::vectorWindowToSurface(const Vector2D& pos, CWindow* pW if (PFOUND) { sl.x = subx; sl.y = suby; + if (PFOUND != PSURFACE->surface) + Debug::log(LOG, "found non-base on window XDG %x", pWindow); return PFOUND; } diff --git a/src/events/Popups.cpp b/src/events/Popups.cpp index b265d6a7..9ccd63b6 100644 --- a/src/events/Popups.cpp +++ b/src/events/Popups.cpp @@ -18,8 +18,8 @@ void addPopupGlobalCoords(void* pPopup, int* x, int* y) { SXDGPopup *const PPOPUP = (SXDGPopup*)pPopup; - int px = 0; - int py = 0; + int px = PPOPUP->monitor->vecPosition.x; + int py = PPOPUP->monitor->vecPosition.y; auto curPopup = PPOPUP; while (true) { @@ -33,8 +33,8 @@ void addPopupGlobalCoords(void* pPopup, int* x, int* y) { } } - px += *PPOPUP->lx; - py += *PPOPUP->ly; + px += PPOPUP->lx; + py += PPOPUP->ly; *x += px; *y += py; @@ -53,6 +53,8 @@ void createNewPopup(wlr_xdg_popup* popup, SXDGPopup* pHyprPopup) { wlr_box box = {.x = PMONITOR->vecPosition.x, .y = PMONITOR->vecPosition.y, .width = PMONITOR->vecSize.x, .height = PMONITOR->vecSize.y}; wlr_xdg_popup_unconstrain_from_box(popup, &box); + + pHyprPopup->monitor = PMONITOR; } void Events::listener_newPopup(void* owner, void* data) { @@ -67,9 +69,12 @@ void Events::listener_newPopup(void* owner, void* data) { g_pCompositor->m_lXDGPopups.push_back(SXDGPopup()); const auto PNEWPOPUP = &g_pCompositor->m_lXDGPopups.back(); + const auto PMONITOR = g_pCompositor->getMonitorFromID(layersurface->monitorID); + PNEWPOPUP->popup = WLRPOPUP; - PNEWPOPUP->lx = &layersurface->position.x; - PNEWPOPUP->ly = &layersurface->position.y; + PNEWPOPUP->lx = layersurface->position.x; + PNEWPOPUP->ly = layersurface->position.y; + PNEWPOPUP->monitor = PMONITOR; createNewPopup(WLRPOPUP, PNEWPOPUP); } @@ -85,10 +90,13 @@ void Events::listener_newPopupXDG(void* owner, void* data) { g_pCompositor->m_lXDGPopups.push_back(SXDGPopup()); const auto PNEWPOPUP = &g_pCompositor->m_lXDGPopups.back(); + const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID); + PNEWPOPUP->popup = WLRPOPUP; - PNEWPOPUP->lx = &PWINDOW->m_vEffectivePosition.x; - PNEWPOPUP->ly = &PWINDOW->m_vEffectivePosition.y; + PNEWPOPUP->lx = PWINDOW->m_vEffectivePosition.x; + PNEWPOPUP->ly = PWINDOW->m_vEffectivePosition.y; PNEWPOPUP->parentWindow = PWINDOW; + PNEWPOPUP->monitor = PMONITOR; createNewPopup(WLRPOPUP, PNEWPOPUP); } @@ -112,6 +120,7 @@ void Events::listener_newPopupFromPopupXDG(void* owner, void* data) { PNEWPOPUP->lx = PPOPUP->lx; PNEWPOPUP->ly = PPOPUP->ly; PNEWPOPUP->parentWindow = PPOPUP->parentWindow; + PNEWPOPUP->monitor = PPOPUP->monitor; createNewPopup(WLRPOPUP, PNEWPOPUP); } @@ -121,7 +130,7 @@ void Events::listener_mapPopupXDG(void* owner, void* data) { ASSERT(PPOPUP); - Debug::log(LOG, "New XDG Popup mapped at %d %d", (int)*PPOPUP->lx, (int)*PPOPUP->ly); + Debug::log(LOG, "New XDG Popup mapped at %d %d", (int)PPOPUP->lx, (int)PPOPUP->ly); PPOPUP->pSurfaceTree = SubsurfaceTree::createTreeRoot(PPOPUP->popup->base->surface, addPopupGlobalCoords, PPOPUP); diff --git a/src/helpers/SubsurfaceTree.cpp b/src/helpers/SubsurfaceTree.cpp index c96228de..b0b62939 100644 --- a/src/helpers/SubsurfaceTree.cpp +++ b/src/helpers/SubsurfaceTree.cpp @@ -142,7 +142,11 @@ void Events::listener_unmapSubsurface(void* owner, void* data) { } void Events::listener_commitSubsurface(void* owner, void* data) { - // SSurfaceTreeNode* pNode = (SSurfaceTreeNode*)owner; + SSurfaceTreeNode* pNode = (SSurfaceTreeNode*)owner; + + int lx = 0, ly = 0; + + addSurfaceGlobalOffset(pNode, &lx, &ly); } void Events::listener_destroySubsurface(void* owner, void* data) { diff --git a/src/helpers/WLClasses.hpp b/src/helpers/WLClasses.hpp index a42b15dd..d8776af9 100644 --- a/src/helpers/WLClasses.hpp +++ b/src/helpers/WLClasses.hpp @@ -38,6 +38,7 @@ struct SRenderData { void* data = nullptr; wlr_surface* surface = nullptr; int w, h; + void* pMonitor = nullptr; }; struct SKeyboard { @@ -53,18 +54,21 @@ struct SKeyboard { } }; +struct SMonitor; + struct SXDGPopup { CWindow* parentWindow = nullptr; SXDGPopup* parentPopup = nullptr; wlr_xdg_popup* popup = nullptr; + SMonitor* monitor = nullptr; DYNLISTENER(newPopupFromPopupXDG); DYNLISTENER(destroyPopupXDG); DYNLISTENER(mapPopupXDG); DYNLISTENER(unmapPopupXDG); - double* lx; - double* ly; + double lx; + double ly; SSurfaceTreeNode* pSurfaceTree = nullptr; diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 7ca86bca..276b4556 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -18,6 +18,11 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) { double outputX = 0, outputY = 0; wlr_output_layout_output_coords(g_pCompositor->m_sWLROutputLayout, RDATA->output, &outputX, &outputY); + if (RDATA->pMonitor) { // BUG THIS TODO: this is just to show the popup on a monitor that isnt at 0,0 + // the popups are broken. + x -= ((SMonitor*)RDATA->pMonitor)->vecPosition.x; + y -= ((SMonitor*)RDATA->pMonitor)->vecPosition.y; + } wlr_box windowBox; if (RDATA->surface && surface == RDATA->surface) { @@ -101,6 +106,7 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec* } } else { + renderdata.pMonitor = pMonitor; wlr_xdg_surface_for_each_popup_surface(pWindow->m_uSurface.xdg, renderSurface, &renderdata); } }