summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2023-08-21 01:15:00 +0200
committervaxerski <43317083+vaxerski@users.noreply.github.com>2023-08-21 01:15:00 +0200
commit63b2189ce81f08ca77894f50e3d484902283189a (patch)
tree930d87b3be70d7e798e8f1655ae1a016f9473fc6 /src
parent025c023e4bbe22fc61a9dc39a33c0c14495230be (diff)
xdgshell: damage old popup coords after a reposition
fixes #3038. I updated the shell ver without properly supporting .reposition
Diffstat (limited to 'src')
-rw-r--r--src/events/Events.hpp1
-rw-r--r--src/events/Popups.cpp26
-rw-r--r--src/helpers/WLClasses.hpp9
3 files changed, 33 insertions, 3 deletions
diff --git a/src/events/Events.hpp b/src/events/Events.hpp
index e7d6e2ad..f89032ea 100644
--- a/src/events/Events.hpp
+++ b/src/events/Events.hpp
@@ -39,6 +39,7 @@ namespace Events {
DYNLISTENFUNC(destroyPopupXDG);
DYNLISTENFUNC(commitPopupXDG);
DYNLISTENFUNC(newPopupFromPopupXDG);
+ DYNLISTENFUNC(repositionPopupXDG);
// Surface XDG (window)
LISTENER(newXDGSurface);
diff --git a/src/events/Popups.cpp b/src/events/Popups.cpp
index b76c70af..0c1594a5 100644
--- a/src/events/Popups.cpp
+++ b/src/events/Popups.cpp
@@ -60,6 +60,7 @@ void createNewPopup(wlr_xdg_popup* popup, SXDGPopup* pHyprPopup) {
pHyprPopup->hyprListener_unmapPopupXDG.initCallback(&popup->base->surface->events.unmap, &Events::listener_unmapPopupXDG, pHyprPopup, "HyprPopup");
pHyprPopup->hyprListener_newPopupFromPopupXDG.initCallback(&popup->base->events.new_popup, &Events::listener_newPopupFromPopupXDG, pHyprPopup, "HyprPopup");
pHyprPopup->hyprListener_commitPopupXDG.initCallback(&popup->base->surface->events.commit, &Events::listener_commitPopupXDG, pHyprPopup, "HyprPopup");
+ pHyprPopup->hyprListener_repositionPopupXDG.initCallback(&popup->events.reposition, &Events::listener_repositionPopupXDG, pHyprPopup, "HyprPopup");
const auto PMONITOR = g_pCompositor->m_pLastMonitor;
@@ -170,6 +171,21 @@ void Events::listener_mapPopupXDG(void* owner, void* data) {
Debug::log(LOG, "XDG Popup got assigned a surfaceTreeNode %lx", PPOPUP->pSurfaceTree);
}
+void Events::listener_repositionPopupXDG(void* owner, void* data) {
+ SXDGPopup* PPOPUP = (SXDGPopup*)owner;
+
+ Debug::log(LOG, "XDG Popup %lx asks for a reposition", PPOPUP);
+
+ int lx = 0, ly = 0;
+ addPopupGlobalCoords(PPOPUP, &lx, &ly);
+
+ wlr_box extents;
+ wlr_surface_get_extends(PPOPUP->popup->base->surface, &extents);
+
+ PPOPUP->lastPos = {lx - extents.x, ly - extents.y};
+ PPOPUP->repositionRequested = true;
+}
+
void Events::listener_unmapPopupXDG(void* owner, void* data) {
SXDGPopup* PPOPUP = (SXDGPopup*)owner;
Debug::log(LOG, "XDG Popup unmapped");
@@ -207,9 +223,17 @@ void Events::listener_commitPopupXDG(void* owner, void* data) {
PPOPUP->ly = PPOPUP->parentWindow->m_vRealPosition.vec().y;
}
- int lx = 0, ly = 0;
+ int lx = 0, ly = 0;
addPopupGlobalCoords(PPOPUP, &lx, &ly);
+ wlr_box extents;
+ wlr_surface_get_extends(PPOPUP->popup->base->surface, &extents);
+
+ if (PPOPUP->repositionRequested)
+ g_pHyprRenderer->damageBox(PPOPUP->lastPos.x, PPOPUP->lastPos.y, extents.width + 2, extents.height + 2);
+
+ PPOPUP->repositionRequested = false;
+
g_pHyprRenderer->damageSurface(PPOPUP->popup->base->surface, lx, ly);
}
diff --git a/src/helpers/WLClasses.hpp b/src/helpers/WLClasses.hpp
index e43a00ff..b84c9657 100644
--- a/src/helpers/WLClasses.hpp
+++ b/src/helpers/WLClasses.hpp
@@ -191,10 +191,14 @@ struct SXDGPopup {
DYNLISTENER(mapPopupXDG);
DYNLISTENER(unmapPopupXDG);
DYNLISTENER(commitPopupXDG);
+ DYNLISTENER(repositionPopupXDG);
double lx;
double ly;
+ Vector2D lastPos = {};
+ bool repositionRequested = false;
+
SSurfaceTreeNode* pSurfaceTree = nullptr;
// For the list lookup
@@ -242,8 +246,9 @@ struct STablet {
std::string name = "";
- bool operator==(const STablet& b) const {
- return wlrDevice == b.wlrDevice;
+ //
+ bool operator==(const STablet& b) const {
+ return wlrDevice == b.wlrDevice;
}
};