diff options
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; +} |
