@@ -435,7 +435,7 @@ index 7636325..e7c6113 100644
435435 WINDOW_RULE_EFFECT_LAST_STATIC,
436436 };
437437diff --git a/src/desktop/view/Window.cpp b/src/desktop/view/Window.cpp
438- index 8836f73..4088113 100644
438+ index 8836f73..926df06 100644
439439--- a/src/desktop/view/Window.cpp
440440+++ b/src/desktop/view/Window.cpp
441441@@ -44,6 +44,7 @@
@@ -464,7 +464,7 @@ index 8836f73..4088113 100644
464464
465465 return REPORTSIZE;
466466 }
467- @@ -1706,27 +1704,80 @@ Vector2D CWindow::realToReportPosition() {
467+ @@ -1706,27 +1704,81 @@ Vector2D CWindow::realToReportPosition() {
468468 }
469469
470470 Vector2D CWindow::xwaylandSizeToReal(Vector2D size) {
@@ -481,7 +481,8 @@ index 8836f73..4088113 100644
481481
482482 Vector2D CWindow::xwaylandPositionToReal(Vector2D pos) {
483483+ // a menu or tooltip of an app that draws unscaled lies in its window's pixels, enlarged with them
484- + if (isX11OverrideRedirect()) {
484+ + static auto PUNSCALED = CConfigValue<Config::BOOL>("xwayland:unscaled_windows");
485+ + if (isX11OverrideRedirect() && *PUNSCALED) {
485486+ if (const auto OWNER = x11UnscaledOwner(); OWNER && OWNER->m_xwaylandSurface)
486487+ return OWNER->m_realPosition->goal() + (pos - OWNER->m_xwaylandSurface->m_geometry.pos());
487488+ }
@@ -557,7 +558,7 @@ index 8836f73..4088113 100644
557558 }
558559
559560 void CWindow::sendWindowSize(bool force) {
560- @@ -1859,8 +1910 ,10 @@ SP<CWLSurfaceResource> CWindow::getSolitaryResource() {
561+ @@ -1859,8 +1911 ,10 @@ SP<CWLSurfaceResource> CWindow::getSolitaryResource() {
561562 }
562563
563564 Vector2D CWindow::getReportedSize() {
@@ -569,7 +570,7 @@ index 8836f73..4088113 100644
569570 if (m_wlSurface && m_wlSurface->resource())
570571 return m_wlSurface->resource()->m_current.ackedSize;
571572 return m_reportedSize;
572- @@ -2546,11 +2599 ,8 @@ void CWindow::mapWindow() {
573+ @@ -2546,11 +2600 ,8 @@ void CWindow::mapWindow() {
573574 if (m_workspace)
574575 m_workspace->updateWindows();
575576
@@ -583,7 +584,7 @@ index 8836f73..4088113 100644
583584
584585 Event::bus()->m_events.window.openLate.emit(m_self.lock());
585586 }
586- @@ -2854,12 +2904 ,9 @@ void CWindow::unmanagedSetGeometry() {
587+ @@ -2854,12 +2905 ,9 @@ void CWindow::unmanagedSetGeometry() {
587588 return;
588589 }
589590
@@ -599,7 +600,7 @@ index 8836f73..4088113 100644
599600
600601 if (abs(std::floor(POS.x) - LOGICALPOS.x) > 2 || abs(std::floor(POS.y) - LOGICALPOS.y) > 2 || abs(std::floor(SIZ.x) - LOGICALGEOSIZE.x) > 2 ||
601602 abs(std::floor(SIZ.y) - LOGICALGEOSIZE.y) > 2) {
602- @@ -2893,7 +2940 ,10 @@ std::optional<Vector2D> CWindow::minSize() {
603+ @@ -2893,7 +2941 ,10 @@ std::optional<Vector2D> CWindow::minSize() {
603604 if ((m_isX11 && !hasSizeHints) || (!m_isX11 && !hasTopLevel))
604605 return std::nullopt;
605606
@@ -611,7 +612,7 @@ index 8836f73..4088113 100644
611612
612613 minSize = minSize.clamp({1, 1});
613614
614- @@ -2913,10 +2963 ,11 @@ std::optional<Vector2D> CWindow::maxSize() {
615+ @@ -2913,10 +2964 ,11 @@ std::optional<Vector2D> CWindow::maxSize() {
615616
616617 Vector2D maxSize = m_isX11 ? Vector2D(m_xwaylandSurface->m_sizeHints->max_width, m_xwaylandSurface->m_sizeHints->max_height) : m_xdgSurface->m_toplevel->layoutMaxSize();
617618
@@ -1090,7 +1091,7 @@ index 346bfe8..48e5d36 100644
10901091 friend class CXWaylandShellResource;
10911092 };
10921093diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
1093- index 249f084..dbd4050 100644
1094+ index 249f084..e3249aa 100644
10941095--- a/src/render/Renderer.cpp
10951096+++ b/src/render/Renderer.cpp
10961097@@ -20,6 +20,7 @@
@@ -1101,18 +1102,20 @@ index 249f084..dbd4050 100644
11011102 #include "../protocols/PresentationTime.hpp"
11021103 #include "../protocols/core/DataDevice.hpp"
11031104 #include "../protocols/core/Compositor.hpp"
1104- @@ -671,7 +672,14 @@ void IHyprRenderer::renderWindow(PHLWINDOW pWindow, PHLMONITOR pMonitor, const T
1105+ @@ -671,7 +672,16 @@ void IHyprRenderer::renderWindow(PHLWINDOW pWindow, PHLMONITOR pMonitor, const T
11051106 }
11061107
11071108 static auto PXWLUSENN = CConfigValue<Config::INTEGER>("xwayland:use_nearest_neighbor");
11081109- if ((pWindow->m_isX11 && *PXWLUSENN) || pWindow->m_ruleApplicator->nearestNeighbor().valueOrDefault())
1109- + // an X11 window drawn at another scale than the monitor's is filtered linearly unless each
1110- + // of its pixels becomes a whole number of the monitor's: nearest neighbour would drop whole
1111- + // rows of a window drawn at a higher scale (the one X11 scale for every monitor), and
1112- + // double some rows and not others of one enlarged by 1.6 (an unscaled window)
1110+ + static auto PXWLSCALE = CConfigValue<Config::FLOAT>("xwayland:scale");
1111+ + // with xwayland:scale, an X11 window drawn at another scale than the monitor's is filtered
1112+ + // linearly unless each of its pixels becomes a whole number of the monitor's: nearest
1113+ + // neighbour would drop whole rows of a window drawn at a higher scale (the one X11 scale for
1114+ + // every monitor), and double some rows and not others of one enlarged by 1.6 (an unscaled
1115+ + // window). Without it, X11 is filtered as it always was.
11131116+ const float XWLBUFFERSCALE = pWindow->m_isX11 ? pWindow->x11PixelScale() : 1.F;
11141117+ const float XWLRATIO = pMonitor->m_scale / XWLBUFFERSCALE;
1115- + const bool XWLRESAMPLED = pWindow->m_isX11 && (XWLRATIO < 0.999F || std::abs(XWLRATIO - std::round(XWLRATIO)) > 0.001F);
1118+ + const bool XWLRESAMPLED = pWindow->m_isX11 && *PXWLSCALE != 0.F && (XWLRATIO < 0.999F || std::abs(XWLRATIO - std::round(XWLRATIO)) > 0.001F);
11161119+ if ((pWindow->m_isX11 && *PXWLUSENN && !XWLRESAMPLED) || pWindow->m_ruleApplicator->nearestNeighbor().valueOrDefault())
11171120 renderdata.useNearestNeighbor = true;
11181121
0 commit comments