summaryrefslogtreecommitdiff
path: root/src/desktop/Popup.cpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2024-05-11 01:02:57 +0100
committerVaxry <vaxry@vaxry.net>2024-05-14 23:13:33 +0100
commitfc72df8e58bc127442a245f2f29a3246acf77cce (patch)
treebe68c03888760af0c2a13bad4aed224fd6adfaa3 /src/desktop/Popup.cpp
parent0cfdde3d1acbfbf698af17f6986fbc4d644214da (diff)
seatmgr: Add a grab class
Diffstat (limited to 'src/desktop/Popup.cpp')
-rw-r--r--src/desktop/Popup.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/desktop/Popup.cpp b/src/desktop/Popup.cpp
index 605dfdfd..c652d298 100644
--- a/src/desktop/Popup.cpp
+++ b/src/desktop/Popup.cpp
@@ -45,6 +45,7 @@ void CPopup::initAllSignals() {
listeners.reposition = m_pResource->events.reposition.registerListener([this](std::any d) { this->onReposition(); });
listeners.map = m_pResource->surface->events.map.registerListener([this](std::any d) { this->onMap(); });
listeners.unmap = m_pResource->surface->events.unmap.registerListener([this](std::any d) { this->onUnmap(); });
+ listeners.dismissed = m_pResource->surface->events.unmap.registerListener([this](std::any d) { this->onUnmap(); });
listeners.destroy = m_pResource->surface->events.destroy.registerListener([this](std::any d) { this->onDestroy(); });
listeners.commit = m_pResource->surface->events.commit.registerListener([this](std::any d) { this->onCommit(); });
listeners.newPopup = m_pResource->surface->events.newPopup.registerListener([this](std::any d) { this->onNewPopup(std::any_cast<SP<CXDGPopupResource>>(d)); });
@@ -65,8 +66,9 @@ void CPopup::onDestroy() {
}
void CPopup::onMap() {
- m_vLastSize = {m_pResource->surface->surface->current.width, m_pResource->surface->surface->current.height};
- const auto COORDS = coordsGlobal();
+ m_vLastSize = {m_pResource->surface->surface->current.width, m_pResource->surface->surface->current.height};
+ const auto COORDS = coordsGlobal();
+ const auto PMONITOR = g_pCompositor->getMonitorFromVector(COORDS);
CBox box;
wlr_surface_get_extends(m_sWLSurface.wlr(), box.pWlr());
@@ -79,8 +81,9 @@ void CPopup::onMap() {
m_pSubsurfaceHead = std::make_unique<CSubsurface>(this);
- unconstrain();
+ //unconstrain();
sendScale();
+ wlr_surface_send_enter(m_pResource->surface->surface, PMONITOR->output);
if (!m_pLayerOwner.expired() && m_pLayerOwner->layer < ZWLR_LAYER_SHELL_V1_LAYER_TOP)
g_pHyprOpenGL->markBlurDirtyForMonitor(g_pCompositor->getMonitorFromID(m_pLayerOwner->layer));
@@ -178,7 +181,6 @@ void CPopup::unconstrain() {
CBox box = {PMONITOR->vecPosition.x - COORDS.x, PMONITOR->vecPosition.y - COORDS.y, PMONITOR->vecSize.x, PMONITOR->vecSize.y};
m_pResource->applyPositioning(box, COORDS - PMONITOR->vecPosition);
- wlr_surface_send_enter(m_pResource->surface->surface, PMONITOR->output);
}
Vector2D CPopup::coordsRelativeToParent() {
@@ -190,8 +192,6 @@ Vector2D CPopup::coordsRelativeToParent() {
CPopup* current = this;
offset -= current->m_pResource->surface->current.geometry.pos();
- offset -= m_pResource->surface->current.geometry.pos();
-
while (current->m_pParent && current->m_pResource) {
offset += {current->m_sWLSurface.wlr()->current.dx, current->m_sWLSurface.wlr()->current.dy};
@@ -293,11 +293,15 @@ CPopup* CPopup::at(const Vector2D& globalCoords, bool allowsInput) {
continue;
if (!allowsInput) {
- const auto BOX = CBox{p->coordsGlobal(), p->size()};
+ 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 auto BOX = CBox{p->coordsGlobal() + offset, size};
if (BOX.containsPoint(globalCoords))
return p;
} else {
- const auto REGION = CRegion{&p->m_sWLSurface.wlr()->current.input}.translate(p->coordsGlobal());
+ const Vector2D offset = p->m_pResource ? (p->size() - p->m_pResource->geometry.size()) / 2.F : Vector2D{};
+ const auto REGION = CRegion{&p->m_sWLSurface.wlr()->current.input}.translate(p->coordsGlobal() + offset);
if (REGION.containsPoint(globalCoords))
return p;
}