diff options
| author | Vaxry <vaxry@vaxry.net> | 2025-02-01 15:49:10 +0000 |
|---|---|---|
| committer | Vaxry <vaxry@vaxry.net> | 2025-02-01 15:49:10 +0000 |
| commit | e380b6ed66aceeae8fde84b4baed0d91550e9f4c (patch) | |
| tree | c13145da5041b9f6eb809562f902b5ee59b8419b /src | |
| parent | 88adae73ba3b57490fdef1041f58fcc6a15a54c8 (diff) | |
popup: take xdg geometry into account in input calcs
fixes #9023
Diffstat (limited to 'src')
| -rw-r--r-- | src/desktop/Popup.cpp | 12 | ||||
| -rw-r--r-- | src/protocols/core/Compositor.cpp | 4 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/desktop/Popup.cpp b/src/desktop/Popup.cpp index 20ff49d7..e66cebcd 100644 --- a/src/desktop/Popup.cpp +++ b/src/desktop/Popup.cpp @@ -339,22 +339,24 @@ void CPopup::breadthfirst(std::function<void(WP<CPopup>, void*)> fn, void* data) WP<CPopup> CPopup::at(const Vector2D& globalCoords, bool allowsInput) { std::vector<WP<CPopup>> popups; - breadthfirst([](WP<CPopup> popup, void* data) { ((std::vector<WP<CPopup>>*)data)->push_back(popup); }, &popups); + breadthfirst([&popups](WP<CPopup> popup, void* data) { popups.push_back(popup); }, &popups); for (auto const& p : popups | std::views::reverse) { if (!p->m_pResource || !p->m_bMapped) continue; if (!allowsInput) { - const Vector2D offset = p->m_pResource ? (p->size() - p->m_pResource->geometry.size()) / 2.F : Vector2D{}; - const Vector2D size = p->m_pResource ? p->m_pResource->geometry.size() : p->size(); + const Vector2D offset = + p->m_pResource && p->m_pResource->surface ? (p->size() - p->m_pResource->geometry.size()) / 2.F - p->m_pResource->surface->current.geometry.pos() : Vector2D{}; + const Vector2D size = p->m_pResource ? p->m_pResource->geometry.size() : p->size(); const auto BOX = CBox{p->coordsGlobal() + offset, size}; if (BOX.containsPoint(globalCoords)) return p; } else { - const Vector2D offset = p->m_pResource ? (p->size() - p->m_pResource->geometry.size()) / 2.F : Vector2D{}; - const auto REGION = + const Vector2D offset = + p->m_pResource && p->m_pResource->surface ? (p->size() - p->m_pResource->geometry.size()) / 2.F - p->m_pResource->surface->current.geometry.pos() : Vector2D{}; + const auto REGION = CRegion{p->m_pWLSurface->resource()->current.input}.intersect(CBox{{}, p->m_pWLSurface->resource()->current.size}).translate(p->coordsGlobal() + offset); if (REGION.containsPoint(globalCoords)) return p; diff --git a/src/protocols/core/Compositor.cpp b/src/protocols/core/Compositor.cpp index 93683993..92c3c425 100644 --- a/src/protocols/core/Compositor.cpp +++ b/src/protocols/core/Compositor.cpp @@ -308,9 +308,7 @@ void CWLSurfaceResource::breadthfirst(std::function<void(SP<CWLSurfaceResource>, std::pair<SP<CWLSurfaceResource>, Vector2D> CWLSurfaceResource::at(const Vector2D& localCoords, bool allowsInput) { std::vector<std::pair<SP<CWLSurfaceResource>, Vector2D>> surfs; - breadthfirst([](SP<CWLSurfaceResource> surf, const Vector2D& offset, - void* data) { ((std::vector<std::pair<SP<CWLSurfaceResource>, Vector2D>>*)data)->emplace_back(std::make_pair<>(surf, offset)); }, - &surfs); + breadthfirst([&surfs](SP<CWLSurfaceResource> surf, const Vector2D& offset, void* data) { surfs.emplace_back(std::make_pair<>(surf, offset)); }, &surfs); for (auto const& [surf, pos] : surfs | std::views::reverse) { if (!allowsInput) { |
