@@ -95,15 +95,15 @@ CWindow::CWindow(SP<CXDGSurfaceResource> resource) : m_pXDGSurface(resource) {
95
95
CWindow::CWindow (SP<CXWaylandSurface> surface) : m_pXWaylandSurface(surface) {
96
96
m_pWLSurface = CWLSurface::create ();
97
97
98
- listeners.map = m_pXWaylandSurface->events .map .registerListener ([this ](std::any d) { Events::listener_mapWindow (this , nullptr ); });
99
- listeners.unmap = m_pXWaylandSurface->events .unmap .registerListener ([this ](std::any d) { Events::listener_unmapWindow (this , nullptr ); });
100
- listeners.destroy = m_pXWaylandSurface->events .destroy .registerListener ([this ](std::any d) { Events::listener_destroyWindow (this , nullptr ); });
101
- listeners.commit = m_pXWaylandSurface->events .commit .registerListener ([this ](std::any d) { Events::listener_commitWindow (this , nullptr ); });
102
- listeners.configure = m_pXWaylandSurface->events .configure .registerListener ([this ](std::any d) { onX11Configure (std::any_cast<CBox>(d)); });
103
- listeners.updateState = m_pXWaylandSurface->events .stateChanged .registerListener ([this ](std::any d) { onUpdateState (); });
104
- listeners.updateMetadata = m_pXWaylandSurface->events .metadataChanged .registerListener ([this ](std::any d) { onUpdateMeta (); });
105
- listeners.resourceChange = m_pXWaylandSurface->events .resourceChange .registerListener ([this ](std::any d) { onResourceChangeX11 (); });
106
- listeners.activate = m_pXWaylandSurface->events .activate .registerListener ([this ](std::any d) { Events::listener_activateX11 (this , nullptr ); });
98
+ listeners.map = m_pXWaylandSurface->events .map .registerListener ([this ](std::any d) { Events::listener_mapWindow (this , nullptr ); });
99
+ listeners.unmap = m_pXWaylandSurface->events .unmap .registerListener ([this ](std::any d) { Events::listener_unmapWindow (this , nullptr ); });
100
+ listeners.destroy = m_pXWaylandSurface->events .destroy .registerListener ([this ](std::any d) { Events::listener_destroyWindow (this , nullptr ); });
101
+ listeners.commit = m_pXWaylandSurface->events .commit .registerListener ([this ](std::any d) { Events::listener_commitWindow (this , nullptr ); });
102
+ listeners.configureRequest = m_pXWaylandSurface->events .configureRequest .registerListener ([this ](std::any d) { onX11ConfigureRequest (std::any_cast<CBox>(d)); });
103
+ listeners.updateState = m_pXWaylandSurface->events .stateChanged .registerListener ([this ](std::any d) { onUpdateState (); });
104
+ listeners.updateMetadata = m_pXWaylandSurface->events .metadataChanged .registerListener ([this ](std::any d) { onUpdateMeta (); });
105
+ listeners.resourceChange = m_pXWaylandSurface->events .resourceChange .registerListener ([this ](std::any d) { onResourceChangeX11 (); });
106
+ listeners.activate = m_pXWaylandSurface->events .activate .registerListener ([this ](std::any d) { Events::listener_activateX11 (this , nullptr ); });
107
107
108
108
if (m_pXWaylandSurface->overrideRedirect )
109
109
listeners.setGeometry = m_pXWaylandSurface->events .setGeometry .registerListener ([this ](std::any d) { Events::listener_unmanagedSetGeometry (this , nullptr ); });
@@ -1530,14 +1530,14 @@ void CWindow::onResourceChangeX11() {
1530
1530
Debug::log (LOG, " xwayland window {:x} -> association to {:x}" , (uintptr_t )m_pXWaylandSurface.get (), (uintptr_t )m_pWLSurface->resource ().get ());
1531
1531
}
1532
1532
1533
- void CWindow::onX11Configure (CBox box) {
1533
+ void CWindow::onX11ConfigureRequest (CBox box) {
1534
1534
1535
1535
if (!m_pXWaylandSurface->surface || !m_pXWaylandSurface->mapped || !m_bIsMapped) {
1536
1536
m_pXWaylandSurface->configure (box);
1537
1537
m_vPendingReportedSize = box.size ();
1538
1538
m_vReportedSize = box.size ();
1539
- if ( const auto PMONITOR = m_pMonitor. lock (); PMONITOR)
1540
- m_fX11SurfaceScaledBy = PMONITOR-> scale ;
1539
+ m_vReportedPosition = box. pos ();
1540
+ updateX11SurfaceScale () ;
1541
1541
return ;
1542
1542
}
1543
1543
@@ -1555,25 +1555,20 @@ void CWindow::onX11Configure(CBox box) {
1555
1555
else
1556
1556
setHidden (true );
1557
1557
1558
- const auto LOGICALPOS = g_pXWaylandManager->xwaylandToWaylandCoords (box.pos ());
1559
-
1560
- m_vRealPosition->setValueAndWarp (LOGICALPOS);
1561
- m_vRealSize->setValueAndWarp (box.size ());
1562
-
1563
- static auto PXWLFORCESCALEZERO = CConfigValue<Hyprlang::INT>(" xwayland:force_zero_scaling" );
1564
- if (*PXWLFORCESCALEZERO) {
1565
- if (const auto PMONITOR = m_pMonitor.lock (); PMONITOR) {
1566
- m_vRealSize->setValueAndWarp (m_vRealSize->goal () / PMONITOR->scale );
1567
- m_fX11SurfaceScaledBy = PMONITOR->scale ;
1568
- }
1569
- }
1558
+ m_vRealPosition->setValueAndWarp (xwaylandPositionToReal (box.pos ()));
1559
+ m_vRealSize->setValueAndWarp (xwaylandSizeToReal (box.size ()));
1570
1560
1571
1561
m_vPosition = m_vRealPosition->goal ();
1572
1562
m_vSize = m_vRealSize->goal ();
1573
1563
1574
- m_vPendingReportedSize = box.size ();
1575
- m_vReportedSize = box.size ();
1564
+ if (m_vPendingReportedSize != box.size () || m_vReportedPosition != box.pos ()) {
1565
+ m_pXWaylandSurface->configure (box);
1566
+ m_vReportedSize = box.size ();
1567
+ m_vPendingReportedSize = box.size ();
1568
+ m_vReportedPosition = box.pos ();
1569
+ }
1576
1570
1571
+ updateX11SurfaceScale ();
1577
1572
updateWindowDecos ();
1578
1573
1579
1574
if (!m_pWorkspace || !m_pWorkspace->isVisible ())
@@ -1700,37 +1695,74 @@ Vector2D CWindow::requestedMaxSize() {
1700
1695
return maxSize;
1701
1696
}
1702
1697
1703
- void CWindow::sendWindowSize (bool force) {
1698
+ Vector2D CWindow::realToReportSize () {
1699
+ if (!m_bIsX11)
1700
+ return m_vRealSize->goal ().clamp (Vector2D{0 , 0 }, Vector2D{std::numeric_limits<double >::infinity (), std::numeric_limits<double >::infinity ()});
1701
+
1702
+ static auto PXWLFORCESCALEZERO = CConfigValue<Hyprlang::INT>(" xwayland:force_zero_scaling" );
1703
+
1704
+ const auto REPORTSIZE = m_vRealSize->goal ().clamp (Vector2D{1 , 1 }, Vector2D{std::numeric_limits<double >::infinity (), std::numeric_limits<double >::infinity ()});
1705
+ const auto PMONITOR = m_pMonitor.lock ();
1706
+
1707
+ if (*PXWLFORCESCALEZERO && PMONITOR)
1708
+ return REPORTSIZE * PMONITOR->scale ;
1709
+
1710
+ return REPORTSIZE;
1711
+ }
1712
+
1713
+ Vector2D CWindow::realToReportPosition () {
1714
+ if (!m_bIsX11)
1715
+ return m_vRealPosition->goal ();
1716
+
1717
+ return g_pXWaylandManager->waylandToXWaylandCoords (m_vRealPosition->goal ());
1718
+ }
1719
+
1720
+ Vector2D CWindow::xwaylandSizeToReal (Vector2D size) {
1721
+ static auto PXWLFORCESCALEZERO = CConfigValue<Hyprlang::INT>(" xwayland:force_zero_scaling" );
1722
+
1723
+ const auto PMONITOR = m_pMonitor.lock ();
1724
+ const auto SIZE = size.clamp (Vector2D{1 , 1 }, Vector2D{std::numeric_limits<double >::infinity (), std::numeric_limits<double >::infinity ()});
1725
+ const auto SCALE = *PXWLFORCESCALEZERO ? PMONITOR->scale : 1 .0f ;
1726
+
1727
+ return SIZE / SCALE;
1728
+ }
1729
+
1730
+ Vector2D CWindow::xwaylandPositionToReal (Vector2D pos) {
1731
+ return g_pXWaylandManager->xwaylandToWaylandCoords (pos);
1732
+ }
1733
+
1734
+ void CWindow::updateX11SurfaceScale () {
1704
1735
static auto PXWLFORCESCALEZERO = CConfigValue<Hyprlang::INT>(" xwayland:force_zero_scaling" );
1705
- const auto PMONITOR = m_pMonitor.lock ();
1736
+
1737
+ m_fX11SurfaceScaledBy = 1 .0f ;
1738
+ if (m_bIsX11 && *PXWLFORCESCALEZERO) {
1739
+ if (const auto PMONITOR = m_pMonitor.lock (); PMONITOR)
1740
+ m_fX11SurfaceScaledBy = PMONITOR->scale ;
1741
+ }
1742
+ }
1743
+
1744
+ void CWindow::sendWindowSize (bool force) {
1745
+ const auto PMONITOR = m_pMonitor.lock ();
1706
1746
1707
1747
Debug::log (TRACE, " sendWindowSize: window:{:x},title:{} with real pos {}, real size {} (force: {})" , (uintptr_t )this , this ->m_szTitle , m_vRealPosition->goal (),
1708
1748
m_vRealSize->goal (), force);
1709
1749
1710
1750
// TODO: this should be decoupled from setWindowSize IMO
1711
- Vector2D windowPos = m_vRealPosition->goal ();
1712
- Vector2D size = m_vRealSize->goal ().clamp (Vector2D{1 , 1 }, Vector2D{std::numeric_limits<double >::infinity (), std::numeric_limits<double >::infinity ()});
1751
+ const auto REPORTPOS = realToReportPosition ();
1713
1752
1714
- if (m_bIsX11 && PMONITOR) {
1715
- windowPos = g_pXWaylandManager->waylandToXWaylandCoords (windowPos);
1716
- if (*PXWLFORCESCALEZERO)
1717
- size *= PMONITOR->scale ;
1718
- }
1753
+ const auto REPORTSIZE = realToReportSize ();
1719
1754
1720
- if (!force && m_vPendingReportedSize == size && (windowPos == m_vReportedPosition || !m_bIsX11))
1755
+ if (!force && m_vPendingReportedSize == REPORTSIZE && (m_vReportedPosition == REPORTPOS || !m_bIsX11))
1721
1756
return ;
1722
1757
1723
- m_vReportedPosition = windowPos;
1724
- m_vPendingReportedSize = size;
1725
- m_fX11SurfaceScaledBy = 1 .0f ;
1726
-
1727
- if (*PXWLFORCESCALEZERO && m_bIsX11 && PMONITOR)
1728
- m_fX11SurfaceScaledBy = PMONITOR->scale ;
1758
+ m_vReportedPosition = REPORTPOS;
1759
+ m_vPendingReportedSize = REPORTSIZE;
1760
+ updateX11SurfaceScale ();
1729
1761
1730
1762
if (m_bIsX11 && m_pXWaylandSurface)
1731
- m_pXWaylandSurface->configure ({windowPos, size });
1763
+ m_pXWaylandSurface->configure ({REPORTPOS, REPORTSIZE });
1732
1764
else if (m_pXDGSurface && m_pXDGSurface->toplevel )
1733
- m_vPendingSizeAcks.emplace_back (m_pXDGSurface->toplevel ->setSize (size ), size .floor ());
1765
+ m_vPendingSizeAcks.emplace_back (m_pXDGSurface->toplevel ->setSize (REPORTSIZE ), REPORTPOS .floor ());
1734
1766
}
1735
1767
1736
1768
NContentType::eContentType CWindow::getContentType () {
0 commit comments