compositor: fix calculating x11 work area (#13347)

in a multimon scenario, due to our positioning hacks, and due to the fact work area is a rect anyways, likely wont make sense
This commit is contained in:
Vaxry 2026-02-25 22:44:35 +00:00 committed by GitHub
parent 5b2efe54b1
commit d0583e1761
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 26 deletions

View file

@ -1627,31 +1627,21 @@ bool CCompositor::isPointOnReservedArea(const Vector2D& point, const PHLMONITOR
return VECNOTINRECT(point, box.x, box.y, box.x + box.w, box.y + box.h); return VECNOTINRECT(point, box.x, box.y, box.x + box.w, box.y + box.h);
} }
CBox CCompositor::calculateX11WorkArea() { std::optional<CBox> CCompositor::calculateX11WorkArea() {
static auto PXWLFORCESCALEZERO = CConfigValue<Hyprlang::INT>("xwayland:force_zero_scaling"); static auto PXWLFORCESCALEZERO = CConfigValue<Hyprlang::INT>("xwayland:force_zero_scaling");
CBox workbox = {0, 0, 0, 0}; // We more than likely won't be able to calculate one
bool firstMonitor = true; // and even if we could this is minor
if (m_monitors.size() > 1 || m_monitors.empty())
return std::nullopt;
for (const auto& monitor : m_monitors) { const auto M = m_monitors.front();
// we ignore monitor->m_position on purpose
CBox box = monitor->logicalBoxMinusReserved().translate(-monitor->m_position);
if ((*PXWLFORCESCALEZERO))
box.scale(monitor->m_scale);
if (firstMonitor) { // we ignore monitor->m_position on purpose
firstMonitor = false; CBox box = M->logicalBoxMinusReserved().translate(-M->m_position);
workbox = box; if ((*PXWLFORCESCALEZERO))
} else { box.scale(M->m_scale);
// if this monitor creates a different workbox than previous monitor, we remove the _NET_WORKAREA property all together
if ((std::abs(box.x - workbox.x) > 3) || (std::abs(box.y - workbox.y) > 3) || (std::abs(box.w - workbox.w) > 3) || (std::abs(box.h - workbox.h) > 3)) {
workbox = {0, 0, 0, 0};
break;
}
}
}
// returning 0, 0 will remove the _NET_WORKAREA property return box.translate(M->m_xwaylandPosition);
return workbox;
} }
PHLMONITOR CCompositor::getMonitorInDirection(Math::eDirection dir) { PHLMONITOR CCompositor::getMonitorInDirection(Math::eDirection dir) {
@ -2759,10 +2749,14 @@ void CCompositor::arrangeMonitors() {
PROTO::xdgOutput->updateAllOutputs(); PROTO::xdgOutput->updateAllOutputs();
#ifndef NO_XWAYLAND #ifndef NO_XWAYLAND
CBox box = g_pCompositor->calculateX11WorkArea(); const auto box = g_pCompositor->calculateX11WorkArea();
if (!g_pXWayland || !g_pXWayland->m_wm) if (g_pXWayland && g_pXWayland->m_wm) {
return; if (box)
g_pXWayland->m_wm->updateWorkArea(box.x, box.y, box.w, box.h); g_pXWayland->m_wm->updateWorkArea(box->x, box->y, box->w, box->h);
else
g_pXWayland->m_wm->updateWorkArea(0, 0, 0, 0);
}
#endif #endif
} }

View file

@ -121,7 +121,7 @@ class CCompositor {
WORKSPACEID getNextAvailableNamedWorkspace(); WORKSPACEID getNextAvailableNamedWorkspace();
bool isPointOnAnyMonitor(const Vector2D&); bool isPointOnAnyMonitor(const Vector2D&);
bool isPointOnReservedArea(const Vector2D& point, const PHLMONITOR monitor = nullptr); bool isPointOnReservedArea(const Vector2D& point, const PHLMONITOR monitor = nullptr);
CBox calculateX11WorkArea(); std::optional<CBox> calculateX11WorkArea();
PHLMONITOR getMonitorInDirection(Math::eDirection); PHLMONITOR getMonitorInDirection(Math::eDirection);
PHLMONITOR getMonitorInDirection(PHLMONITOR, Math::eDirection); PHLMONITOR getMonitorInDirection(PHLMONITOR, Math::eDirection);
void updateAllWindowsAnimatedDecorationValues(); void updateAllWindowsAnimatedDecorationValues();