aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/managers/XWaylandManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/managers/XWaylandManager.cpp')
-rw-r--r--src/managers/XWaylandManager.cpp30
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");