diff options
| author | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2023-09-04 17:30:44 +0200 |
|---|---|---|
| committer | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2023-09-04 17:30:48 +0200 |
| commit | e3c83ab2e000e2d4fd01f5ada5e9eae91237bb41 (patch) | |
| tree | 352c98fb006fd22b9afbf4b6fb07b63c86c5425c /src | |
| parent | b4c832a1f2d1d85815a28990c7337a1ffc34fc9b (diff) | |
xwaylandmgr: find closest output in xwayland coord translation
partially off-screen windows would be snapped to 0,0 otherwise
Diffstat (limited to 'src')
| -rw-r--r-- | src/managers/XWaylandManager.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/managers/XWaylandManager.cpp b/src/managers/XWaylandManager.cpp index 76f979da..1ac4416d 100644 --- a/src/managers/XWaylandManager.cpp +++ b/src/managers/XWaylandManager.cpp @@ -314,12 +314,17 @@ Vector2D CHyprXWaylandManager::xwaylandToWaylandCoords(const Vector2D& coord) { static auto* const PXWLFORCESCALEZERO = &g_pConfigManager->getConfigValuePtr("xwayland:force_zero_scaling")->intValue; - CMonitor* pMonitor = nullptr; + CMonitor* pMonitor = nullptr; + double bestDistance = __FLT_MAX__; for (auto& m : g_pCompositor->m_vMonitors) { const auto SIZ = *PXWLFORCESCALEZERO ? m->vecTransformedSize : m->vecSize; - if (VECINRECT(coord, m->vecXWaylandPosition.x, m->vecXWaylandPosition.y, m->vecXWaylandPosition.x + SIZ.x, m->vecXWaylandPosition.y + SIZ.y)) { - pMonitor = m.get(); - break; + + double distance = + vecToRectDistanceSquared(coord, {m->vecXWaylandPosition.x, m->vecXWaylandPosition.y}, {m->vecXWaylandPosition.x + SIZ.x, m->vecXWaylandPosition.y + SIZ.y}); + + if (distance < bestDistance) { + bestDistance = distance; + pMonitor = m.get(); } } |
