summaryrefslogtreecommitdiff
path: root/src/desktop/Popup.cpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2024-05-09 21:47:21 +0100
committerVaxry <vaxry@vaxry.net>2024-05-09 22:02:18 +0100
commit635a02d83fe9d598cf5f6aba47e672647608fb76 (patch)
tree71f5e2ad0991af3086602c5b30b1411ee4c04562 /src/desktop/Popup.cpp
parent85f7f69046c07c61f59b0ef7cccd01e88b316413 (diff)
layer-shell: move to new impl
Also bumps the hw-s dep
Diffstat (limited to 'src/desktop/Popup.cpp')
-rw-r--r--src/desktop/Popup.cpp47
1 files changed, 46 insertions, 1 deletions
diff --git a/src/desktop/Popup.cpp b/src/desktop/Popup.cpp
index 73a29560..f1517083 100644
--- a/src/desktop/Popup.cpp
+++ b/src/desktop/Popup.cpp
@@ -1,6 +1,8 @@
#include "Popup.hpp"
#include "../config/ConfigValue.hpp"
#include "../Compositor.hpp"
+#include "../protocols/LayerShell.hpp"
+#include <ranges>
CPopup::CPopup(PHLWINDOW pOwner) : m_pWindowOwner(pOwner) {
initAllSignals();
@@ -72,7 +74,7 @@ void CPopup::initAllSignals() {
if (!m_pWindowOwner.expired())
hyprListener_newPopup.initCallback(&m_pWindowOwner->m_uSurface.xdg->events.new_popup, ::onNewPopup, this, "CPopup Head");
else if (!m_pLayerOwner.expired())
- hyprListener_newPopup.initCallback(&m_pLayerOwner->layerSurface->events.new_popup, ::onNewPopup, this, "CPopup Head");
+ listeners.newPopup = m_pLayerOwner->layerSurface->events.newPopup.registerListener([this](std::any d) { this->onNewPopup(std::any_cast<wlr_xdg_popup*>(d)); });
else
ASSERT(false);
@@ -278,3 +280,46 @@ bool CPopup::visible() {
return false;
}
+
+void CPopup::bfHelper(std::vector<CPopup*> nodes, std::function<void(CPopup*, void*)> fn, void* data) {
+ for (auto& n : nodes) {
+ fn(n, data);
+ }
+
+ std::vector<CPopup*> nodes2;
+
+ for (auto& n : nodes) {
+ for (auto& c : n->m_vChildren) {
+ nodes2.push_back(c.get());
+ }
+ }
+
+ bfHelper(nodes2, fn, data);
+}
+
+void CPopup::breadthfirst(std::function<void(CPopup*, void*)> fn, void* data) {
+ std::vector<CPopup*> popups;
+ popups.push_back(this);
+}
+
+CPopup* CPopup::at(const Vector2D& globalCoords, bool allowsInput) {
+ std::vector<CPopup*> popups;
+ breadthfirst([](CPopup* popup, void* data) { ((std::vector<CPopup*>*)data)->push_back(popup); }, &popups);
+
+ for (auto& p : popups | std::views::reverse) {
+ if (!p->m_pWLR)
+ continue;
+
+ if (!allowsInput) {
+ const auto BOX = CBox{p->coordsGlobal(), p->size()};
+ if (BOX.containsPoint(globalCoords))
+ return p;
+ } else {
+ const auto REGION = CRegion{&m_sWLSurface.wlr()->current.input}.translate(p->coordsGlobal());
+ if (REGION.containsPoint(globalCoords))
+ return p;
+ }
+ }
+
+ return nullptr;
+}