diff options
| author | Andreas Backx <AndreasBackx@users.noreply.github.com> | 2026-04-05 16:54:38 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-04-05 16:54:38 +0100 |
| commit | 8edb7c5663c9aea552074c5d9e36e6f688baf4b7 (patch) | |
| tree | abad473e2ebf0480b50f88af4174eedfcc8de7be /src/managers/XWaylandManager.cpp | |
| parent | 6983b1906caf31e89d9c92cd04d3b6dc69218bff (diff) | |
xwayland: pipe through monitor in coordinate mapping (#13700)
* xwayland: prefer monitor-aware hover coords
Introduce monitor-aware XWayland coordinate helpers and keep the X11 hover path anchored to the main surface box while preserving detailed debug logging, reducing dependence on nearest-monitor guesses in layout-sensitive input paths.
* xwayland: use window monitor for reported coords
Report X11 window positions through the window's known monitor instead of the generic nearest-monitor heuristic so boundary-aligned outputs keep stable XWayland coordinates.
* xwayland: use window monitor for real position restore
Convert XWayland geometry back into compositor space using the window's current monitor when available so vertically offset layouts do not round-trip through the wrong output.
* xwayland: use window monitor for unmanaged geometry
Restore override-redirect X11 geometry through the window's known monitor so helper windows and popups avoid nearest-monitor misclassification on offset layouts.
* xwayland: remove monitor conversion debug logging
Drop the temporary XWayland hover and coordinate conversion diagnostics now that the monitor-selection bug is confirmed and the window-monitor based conversions fix the issue.
* xwayland: drop unrelated focused-motion change
Remove the exploratory X11-specific pointer focus scaling from InputManager so the monitor mapping fix stays narrowly scoped to the XWayland coordinate conversion changes that actually resolve the bug.
* clang-format XWaylandManager
Diffstat (limited to 'src/managers/XWaylandManager.cpp')
| -rw-r--r-- | src/managers/XWaylandManager.cpp | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/src/managers/XWaylandManager.cpp b/src/managers/XWaylandManager.cpp index 1fca293a..95fa085b 100644 --- a/src/managers/XWaylandManager.cpp +++ b/src/managers/XWaylandManager.cpp @@ -174,18 +174,24 @@ void CHyprXWaylandManager::setWindowFullscreen(PHLWINDOW pWindow, bool fullscree } Vector2D CHyprXWaylandManager::waylandToXWaylandCoords(const Vector2D& coord) { + return waylandToXWaylandCoords(coord, nullptr); +} + +Vector2D CHyprXWaylandManager::waylandToXWaylandCoords(const Vector2D& coord, PHLMONITOR preferredMonitor) { static auto PXWLFORCESCALEZERO = CConfigValue<Hyprlang::INT>("xwayland:force_zero_scaling"); - PHLMONITOR pMonitor = nullptr; - double bestDistance = __FLT_MAX__; - for (const auto& m : g_pCompositor->m_monitors) { - const auto SIZ = *PXWLFORCESCALEZERO ? m->m_transformedSize : m->m_size; + PHLMONITOR pMonitor = preferredMonitor; + if (!pMonitor) { + double bestDistance = __FLT_MAX__; + for (const auto& m : g_pCompositor->m_monitors) { + const auto SIZ = *PXWLFORCESCALEZERO ? m->m_transformedSize : m->m_size; - double distance = vecToRectDistanceSquared(coord, {m->m_position.x, m->m_position.y}, {m->m_position.x + SIZ.x - 1, m->m_position.y + SIZ.y - 1}); + double distance = vecToRectDistanceSquared(coord, {m->m_position.x, m->m_position.y}, {m->m_position.x + SIZ.x - 1, m->m_position.y + SIZ.y - 1}); - if (distance < bestDistance) { - bestDistance = distance; - pMonitor = m; + if (distance < bestDistance) { + bestDistance = distance; + pMonitor = m; + } } } @@ -204,20 +210,26 @@ Vector2D CHyprXWaylandManager::waylandToXWaylandCoords(const Vector2D& coord) { } Vector2D CHyprXWaylandManager::xwaylandToWaylandCoords(const Vector2D& coord) { + return xwaylandToWaylandCoords(coord, nullptr); +} + +Vector2D CHyprXWaylandManager::xwaylandToWaylandCoords(const Vector2D& coord, PHLMONITOR preferredMonitor) { static auto PXWLFORCESCALEZERO = CConfigValue<Hyprlang::INT>("xwayland:force_zero_scaling"); - PHLMONITOR pMonitor = nullptr; - double bestDistance = __FLT_MAX__; - for (const auto& m : g_pCompositor->m_monitors) { - const auto SIZ = *PXWLFORCESCALEZERO ? m->m_transformedSize : m->m_size; + PHLMONITOR pMonitor = preferredMonitor; + if (!pMonitor) { + double bestDistance = __FLT_MAX__; + for (const auto& m : g_pCompositor->m_monitors) { + const auto SIZ = *PXWLFORCESCALEZERO ? m->m_transformedSize : m->m_size; - double distance = - vecToRectDistanceSquared(coord, {m->m_xwaylandPosition.x, m->m_xwaylandPosition.y}, {m->m_xwaylandPosition.x + SIZ.x - 1, m->m_xwaylandPosition.y + SIZ.y - 1}); + double distance = + vecToRectDistanceSquared(coord, {m->m_xwaylandPosition.x, m->m_xwaylandPosition.y}, {m->m_xwaylandPosition.x + SIZ.x - 1, m->m_xwaylandPosition.y + SIZ.y - 1}); - if (distance < bestDistance) { - bestDistance = distance; - pMonitor = m; + if (distance < bestDistance) { + bestDistance = distance; + pMonitor = m; + } } } |
