Skip to content

Commit bdbfa93

Browse files
committed
popup: take xdg geometry into account in input calcs
fixes #9023
1 parent f827690 commit bdbfa93

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/desktop/Popup.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -339,22 +339,24 @@ void CPopup::breadthfirst(std::function<void(WP<CPopup>, void*)> fn, void* data)
339339

340340
WP<CPopup> CPopup::at(const Vector2D& globalCoords, bool allowsInput) {
341341
std::vector<WP<CPopup>> popups;
342-
breadthfirst([](WP<CPopup> popup, void* data) { ((std::vector<WP<CPopup>>*)data)->push_back(popup); }, &popups);
342+
breadthfirst([&popups](WP<CPopup> popup, void* data) { popups.push_back(popup); }, &popups);
343343

344344
for (auto const& p : popups | std::views::reverse) {
345345
if (!p->m_pResource || !p->m_bMapped)
346346
continue;
347347

348348
if (!allowsInput) {
349-
const Vector2D offset = p->m_pResource ? (p->size() - p->m_pResource->geometry.size()) / 2.F : Vector2D{};
350-
const Vector2D size = p->m_pResource ? p->m_pResource->geometry.size() : p->size();
349+
const Vector2D offset =
350+
p->m_pResource && p->m_pResource->surface ? (p->size() - p->m_pResource->geometry.size()) / 2.F - p->m_pResource->surface->current.geometry.pos() : Vector2D{};
351+
const Vector2D size = p->m_pResource ? p->m_pResource->geometry.size() : p->size();
351352

352353
const auto BOX = CBox{p->coordsGlobal() + offset, size};
353354
if (BOX.containsPoint(globalCoords))
354355
return p;
355356
} else {
356-
const Vector2D offset = p->m_pResource ? (p->size() - p->m_pResource->geometry.size()) / 2.F : Vector2D{};
357-
const auto REGION =
357+
const Vector2D offset =
358+
p->m_pResource && p->m_pResource->surface ? (p->size() - p->m_pResource->geometry.size()) / 2.F - p->m_pResource->surface->current.geometry.pos() : Vector2D{};
359+
const auto REGION =
358360
CRegion{p->m_pWLSurface->resource()->current.input}.intersect(CBox{{}, p->m_pWLSurface->resource()->current.size}).translate(p->coordsGlobal() + offset);
359361
if (REGION.containsPoint(globalCoords))
360362
return p;

src/protocols/core/Compositor.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,7 @@ void CWLSurfaceResource::breadthfirst(std::function<void(SP<CWLSurfaceResource>,
308308

309309
std::pair<SP<CWLSurfaceResource>, Vector2D> CWLSurfaceResource::at(const Vector2D& localCoords, bool allowsInput) {
310310
std::vector<std::pair<SP<CWLSurfaceResource>, Vector2D>> surfs;
311-
breadthfirst([](SP<CWLSurfaceResource> surf, const Vector2D& offset,
312-
void* data) { ((std::vector<std::pair<SP<CWLSurfaceResource>, Vector2D>>*)data)->emplace_back(std::make_pair<>(surf, offset)); },
313-
&surfs);
311+
breadthfirst([&surfs](SP<CWLSurfaceResource> surf, const Vector2D& offset, void* data) { surfs.emplace_back(std::make_pair<>(surf, offset)); }, &surfs);
314312

315313
for (auto const& [surf, pos] : surfs | std::views::reverse) {
316314
if (!allowsInput) {

0 commit comments

Comments
 (0)