diff options
| author | vaxerski <vaxry@vaxry.net> | 2023-08-15 20:09:32 +0200 |
|---|---|---|
| committer | vaxerski <vaxry@vaxry.net> | 2023-08-15 20:10:43 +0200 |
| commit | 4986d74ef201171a930c312a8e3b72a22d9b84ee (patch) | |
| tree | 49a8a6db7178fe3cd7cfe063180d87fd4ada6005 /src/managers/XWaylandManager.cpp | |
| parent | 91e28bbe9df85e2e94fbcc0137106362aea14ab5 (diff) | |
xwayland: fix use of xwayland coords in native spaces
Diffstat (limited to 'src/managers/XWaylandManager.cpp')
| -rw-r--r-- | src/managers/XWaylandManager.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/managers/XWaylandManager.cpp b/src/managers/XWaylandManager.cpp index fcd64280..5820f9a3 100644 --- a/src/managers/XWaylandManager.cpp +++ b/src/managers/XWaylandManager.cpp @@ -308,4 +308,31 @@ Vector2D CHyprXWaylandManager::getMaxSizeForWindow(CWindow* pWindow) { MAXSIZE.y = 99999; return MAXSIZE; -}
\ No newline at end of file +} + +Vector2D CHyprXWaylandManager::xwaylandToWaylandCoords(const Vector2D& coord) { + + static auto* const PXWLFORCESCALEZERO = &g_pConfigManager->getConfigValuePtr("xwayland:force_zero_scaling")->intValue; + + CMonitor* pMonitor = nullptr; + for (auto& m : g_pCompositor->m_vMonitors) { + const auto SIZ = *PXWLFORCESCALEZERO ? m->vecTransformedSize : m->vecSize; + if (VECINRECT(coord, m->vecXWaylandPosition.x, m->vecXWaylandPosition.y, SIZ.x, SIZ.y)) { + pMonitor = m.get(); + break; + } + } + + if (!pMonitor) + return Vector2D{}; + + // get local coords + Vector2D result = coord - pMonitor->vecXWaylandPosition; + // if scaled, unscale + if (*PXWLFORCESCALEZERO) + result = result / pMonitor->scale; + // add pos + result = result + pMonitor->vecPosition; + + return result; +} |
