summaryrefslogtreecommitdiff
path: root/src/Compositor.cpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2026-02-25 22:44:35 +0000
committerGitHub <noreply@github.com>2026-02-25 22:44:35 +0000
commitd0583e176151bd037015ae48e3c0c582d94c59da (patch)
tree49f9f3c46e511759390822c96b5684d98792e615 /src/Compositor.cpp
parent5b2efe54b135a5142bdd2266bbb3f26bca0b29e2 (diff)
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
Diffstat (limited to 'src/Compositor.cpp')
-rw-r--r--src/Compositor.cpp48
1 files changed, 21 insertions, 27 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp
index 9e409ef4..e027b563 100644
--- a/src/Compositor.cpp
+++ b/src/Compositor.cpp
@@ -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);
}
-CBox CCompositor::calculateX11WorkArea() {
+std::optional<CBox> CCompositor::calculateX11WorkArea() {
static auto PXWLFORCESCALEZERO = CConfigValue<Hyprlang::INT>("xwayland:force_zero_scaling");
- CBox workbox = {0, 0, 0, 0};
- bool firstMonitor = true;
-
- for (const auto& monitor : m_monitors) {
- // we ignore monitor->m_position on purpose
- CBox box = monitor->logicalBoxMinusReserved().translate(-monitor->m_position);
- if ((*PXWLFORCESCALEZERO))
- box.scale(monitor->m_scale);
-
- if (firstMonitor) {
- firstMonitor = false;
- workbox = box;
- } else {
- // 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;
- }
- }
- }
+ // We more than likely won't be able to calculate one
+ // and even if we could this is minor
+ if (m_monitors.size() > 1 || m_monitors.empty())
+ return std::nullopt;
- // returning 0, 0 will remove the _NET_WORKAREA property
- return workbox;
+ const auto M = m_monitors.front();
+
+ // we ignore monitor->m_position on purpose
+ CBox box = M->logicalBoxMinusReserved().translate(-M->m_position);
+ if ((*PXWLFORCESCALEZERO))
+ box.scale(M->m_scale);
+
+ return box.translate(M->m_xwaylandPosition);
}
PHLMONITOR CCompositor::getMonitorInDirection(Math::eDirection dir) {
@@ -2759,10 +2749,14 @@ void CCompositor::arrangeMonitors() {
PROTO::xdgOutput->updateAllOutputs();
#ifndef NO_XWAYLAND
- CBox box = g_pCompositor->calculateX11WorkArea();
- if (!g_pXWayland || !g_pXWayland->m_wm)
- return;
- g_pXWayland->m_wm->updateWorkArea(box.x, box.y, box.w, box.h);
+ const auto box = g_pCompositor->calculateX11WorkArea();
+ if (g_pXWayland && g_pXWayland->m_wm) {
+ if (box)
+ g_pXWayland->m_wm->updateWorkArea(box->x, box->y, box->w, box->h);
+ else
+ g_pXWayland->m_wm->updateWorkArea(0, 0, 0, 0);
+ }
+
#endif
}