diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2024-12-15 00:37:17 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-15 00:37:17 +0100 |
| commit | db249648776875ce3142141d0d3055e43ce606aa (patch) | |
| tree | 50cac68a73e0da6e8154bd4deef08a11e2784ad2 /src/managers/XWaylandManager.cpp | |
| parent | 9f7a96b997d90c4c188f3837e02859a25a05611e (diff) | |
xwayland: Support cross DnD from Wayland (#8708)
Adds support for drag-and-drop from Wayland clients to XWayland ones
Diffstat (limited to 'src/managers/XWaylandManager.cpp')
| -rw-r--r-- | src/managers/XWaylandManager.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/managers/XWaylandManager.cpp b/src/managers/XWaylandManager.cpp index 832173eb..5e5c6262 100644 --- a/src/managers/XWaylandManager.cpp +++ b/src/managers/XWaylandManager.cpp @@ -213,6 +213,36 @@ void CHyprXWaylandManager::setWindowFullscreen(PHLWINDOW pWindow, bool fullscree pWindow->m_pXDGSurface->toplevel->setFullscreen(fullscreen); } +Vector2D CHyprXWaylandManager::waylandToXWaylandCoords(const Vector2D& coord) { + static auto PXWLFORCESCALEZERO = CConfigValue<Hyprlang::INT>("xwayland:force_zero_scaling"); + + PHLMONITOR pMonitor = nullptr; + double bestDistance = __FLT_MAX__; + for (const auto& m : g_pCompositor->m_vMonitors) { + const auto SIZ = *PXWLFORCESCALEZERO ? m->vecTransformedSize : m->vecSize; + + double distance = vecToRectDistanceSquared(coord, {m->vecPosition.x, m->vecPosition.y}, {m->vecPosition.x + SIZ.x - 1, m->vecPosition.y + SIZ.y - 1}); + + if (distance < bestDistance) { + bestDistance = distance; + pMonitor = m; + } + } + + if (!pMonitor) + return Vector2D{}; + + // get local coords + Vector2D result = coord - pMonitor->vecPosition; + // if scaled, scale + if (*PXWLFORCESCALEZERO) + result *= pMonitor->scale; + // add pos + result += pMonitor->vecXWaylandPosition; + + return result; +} + Vector2D CHyprXWaylandManager::xwaylandToWaylandCoords(const Vector2D& coord) { static auto PXWLFORCESCALEZERO = CConfigValue<Hyprlang::INT>("xwayland:force_zero_scaling"); |
