diff options
| author | jmanc3 <jman12316@live.com> | 2025-10-29 06:24:34 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-29 11:24:34 +0000 |
| commit | ce9787b3f47ce550027274a1aa25e74b6fb1c74a (patch) | |
| tree | f26b1c1c071f01c9b5dd3a718fff1a9c85caaef8 /src/Compositor.cpp | |
| parent | 9eb82774e53dc02e4fa204a911cb4256cd21f429 (diff) | |
xwayland: set _NET_WORKAREA property (#12148)
Diffstat (limited to 'src/Compositor.cpp')
| -rw-r--r-- | src/Compositor.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 78b19c71..3c7ad6a2 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -1789,6 +1789,37 @@ bool CCompositor::isPointOnReservedArea(const Vector2D& point, const PHLMONITOR return VECNOTINRECT(point, XY1.x, XY1.y, XY2.x, XY2.y); } +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 + auto x = monitor->m_reservedTopLeft.x; + auto y = monitor->m_reservedTopLeft.y; + auto w = monitor->m_size.x - monitor->m_reservedBottomRight.x - x; + auto h = monitor->m_size.y - monitor->m_reservedBottomRight.y - y; + CBox box = {x, y, w, h}; + 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; + } + } + } + + // returning 0, 0 will remove the _NET_WORKAREA property + return workbox; +} + PHLMONITOR CCompositor::getMonitorInDirection(const char& dir) { return getMonitorInDirection(m_lastMonitor.lock(), dir); } @@ -2983,6 +3014,11 @@ void CCompositor::arrangeMonitors() { } PROTO::xdgOutput->updateAllOutputs(); + +#ifndef NO_XWAYLAND + CBox box = g_pCompositor->calculateX11WorkArea(); + g_pXWayland->m_wm->updateWorkArea(box.x, box.y, box.w, box.h); +#endif } void CCompositor::enterUnsafeState() { |
