aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorVaxry <[email protected]>2023-11-10 00:13:22 +0000
committerVaxry <[email protected]>2023-11-10 00:13:22 +0000
commitb8a615ffb892aaa35a15dc732208bb7ad2a60209 (patch)
tree28dfd657e44968e654bc2d64ccb4ebfe48921580
parent8dd02eb5f3d47ce67a33c836ea6d648bd6967962 (diff)
downloadHyprland-b8a615ffb892aaa35a15dc732208bb7ad2a60209.tar.gz
Hyprland-b8a615ffb892aaa35a15dc732208bb7ad2a60209.zip
xdg-shell: improve ack-configure handling
fixes #3807
-rw-r--r--src/Window.hpp10
-rw-r--r--src/events/Windows.cpp16
-rw-r--r--src/managers/XWaylandManager.cpp4
3 files changed, 18 insertions, 12 deletions
diff --git a/src/Window.hpp b/src/Window.hpp
index 915cf018..580b0a2a 100644
--- a/src/Window.hpp
+++ b/src/Window.hpp
@@ -205,11 +205,11 @@ class CWindow {
CAnimatedVariable m_vRealSize;
// for not spamming the protocols
- Vector2D m_vReportedPosition;
- Vector2D m_vReportedSize;
- Vector2D m_vPendingReportedSize;
- bool m_bPendingSizeAcked = false;
- std::optional<uint32_t> m_iPendingSizeAck;
+ Vector2D m_vReportedPosition;
+ Vector2D m_vReportedSize;
+ Vector2D m_vPendingReportedSize;
+ std::optional<std::pair<uint32_t, Vector2D>> m_pPendingSizeAck;
+ std::vector<std::pair<uint32_t, Vector2D>> m_vPendingSizeAcks;
// for restoring floating statuses
Vector2D m_vLastFloatingSize;
diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp
index 1fbc9070..e44fa0a9 100644
--- a/src/events/Windows.cpp
+++ b/src/events/Windows.cpp
@@ -794,11 +794,14 @@ void Events::listener_ackConfigure(void* owner, void* data) {
CWindow* PWINDOW = (CWindow*)owner;
const auto E = (wlr_xdg_surface_configure*)data;
- if (!PWINDOW->m_iPendingSizeAck.has_value() || E->serial != PWINDOW->m_iPendingSizeAck)
+ // find last matching serial
+ const auto SERIAL = std::find_if(PWINDOW->m_vPendingSizeAcks.rbegin(), PWINDOW->m_vPendingSizeAcks.rend(), [&](const auto& e) { return e.first == E->serial; });
+
+ if (SERIAL == PWINDOW->m_vPendingSizeAcks.rend())
return;
- PWINDOW->m_bPendingSizeAcked = true;
- PWINDOW->m_iPendingSizeAck.reset();
+ PWINDOW->m_pPendingSizeAck = *SERIAL;
+ std::erase_if(PWINDOW->m_vPendingSizeAcks, [&](const auto& el) { return el.first == SERIAL->first; });
}
void Events::listener_commitWindow(void* owner, void* data) {
@@ -807,9 +810,12 @@ void Events::listener_commitWindow(void* owner, void* data) {
if (!PWINDOW->m_bMappedX11 || PWINDOW->isHidden() || (PWINDOW->m_bIsX11 && !PWINDOW->m_bMappedX11))
return;
- if (PWINDOW->m_bIsX11 || PWINDOW->m_bPendingSizeAcked)
+ if (PWINDOW->m_bIsX11)
PWINDOW->m_vReportedSize = PWINDOW->m_vPendingReportedSize; // apply pending size. We pinged, the window ponged.
- PWINDOW->m_bPendingSizeAcked = false;
+ else if (PWINDOW->m_pPendingSizeAck.has_value()) {
+ PWINDOW->m_vReportedSize = PWINDOW->m_pPendingSizeAck->second;
+ PWINDOW->m_pPendingSizeAck.reset();
+ }
PWINDOW->updateSurfaceOutputs();
diff --git a/src/managers/XWaylandManager.cpp b/src/managers/XWaylandManager.cpp
index f9d57a3f..04fcf967 100644
--- a/src/managers/XWaylandManager.cpp
+++ b/src/managers/XWaylandManager.cpp
@@ -162,7 +162,7 @@ void CHyprXWaylandManager::setWindowSize(CWindow* pWindow, Vector2D size, bool f
windowPos = windowPos + PMONITOR->vecXWaylandPosition; // move to correct position for xwayland
}
- if (!force && ((pWindow->m_vReportedSize == size && windowPos == pWindow->m_vReportedPosition) || (pWindow->m_vReportedSize == size && !pWindow->m_bIsX11)))
+ if (!force && ((pWindow->m_vPendingReportedSize == size && windowPos == pWindow->m_vReportedPosition) || (pWindow->m_vPendingReportedSize == size && !pWindow->m_bIsX11)))
return;
pWindow->m_vReportedPosition = windowPos;
@@ -180,7 +180,7 @@ void CHyprXWaylandManager::setWindowSize(CWindow* pWindow, Vector2D size, bool f
if (pWindow->m_bIsX11)
wlr_xwayland_surface_configure(pWindow->m_uSurface.xwayland, windowPos.x, windowPos.y, size.x, size.y);
else
- pWindow->m_iPendingSizeAck = wlr_xdg_toplevel_set_size(pWindow->m_uSurface.xdg->toplevel, size.x, size.y);
+ pWindow->m_vPendingSizeAcks.push_back(std::make_pair<>(wlr_xdg_toplevel_set_size(pWindow->m_uSurface.xdg->toplevel, size.x, size.y), size.floor()));
}
void CHyprXWaylandManager::setWindowStyleTiled(CWindow* pWindow, uint32_t edgez) {