mirror of
https://github.com/hyprwm/Hyprland.git
synced 2026-09-26 17:10:38 -04:00
layersurface: inform layer surfaces of scale changes (#14771)
* layersurface: inform layer surfaces of scale changes * monitor: move surface scale and transform updates into their own method * layersurface: ensure layer subsurfaces have scales set on map/commit
This commit is contained in:
+2
-1
@@ -3063,10 +3063,11 @@ void CCompositor::onNewMonitor(SP<Aquamarine::IOutput> output) {
|
||||
for (auto const& w : g_pCompositor->m_windows) {
|
||||
if (w->m_monitor == PNEWMONITOR) {
|
||||
w->m_lastSurfaceMonitorID = MONITOR_INVALID;
|
||||
w->updateSurfaceScaleTransformDetails();
|
||||
}
|
||||
}
|
||||
|
||||
PNEWMONITOR->updateSurfaceScaleTransformDetails();
|
||||
|
||||
g_pHyprRenderer->damageMonitor(PNEWMONITOR);
|
||||
PNEWMONITOR->m_frameScheduler->onFrame();
|
||||
|
||||
|
||||
@@ -219,8 +219,7 @@ void CLayerSurface::onMap() {
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{.event = "openlayer", .data = m_namespace});
|
||||
Event::bus()->m_events.layer.opened.emit(m_self.lock());
|
||||
|
||||
g_pCompositor->setPreferredScaleForSurface(m_wlSurface->resource(), PMONITOR->m_scale);
|
||||
g_pCompositor->setPreferredTransformForSurface(m_wlSurface->resource(), PMONITOR->m_transform);
|
||||
updateSurfaceScaleTransformDetails();
|
||||
}
|
||||
|
||||
void CLayerSurface::onUnmap() {
|
||||
@@ -414,8 +413,7 @@ void CLayerSurface::onCommit() {
|
||||
|
||||
g_pHyprRenderer->damageSurface(m_wlSurface->resource(), m_position.x, m_position.y);
|
||||
|
||||
g_pCompositor->setPreferredScaleForSurface(m_wlSurface->resource(), PMONITOR->m_scale);
|
||||
g_pCompositor->setPreferredTransformForSurface(m_wlSurface->resource(), PMONITOR->m_transform);
|
||||
updateSurfaceScaleTransformDetails();
|
||||
}
|
||||
|
||||
bool CLayerSurface::isFadedOut() {
|
||||
@@ -447,3 +445,29 @@ pid_t CLayerSurface::getPID() {
|
||||
|
||||
return PID;
|
||||
}
|
||||
|
||||
void CLayerSurface::updateSurfaceScaleTransformDetails() {
|
||||
if (!aliveAndVisible() || g_pCompositor->m_unsafeState)
|
||||
return;
|
||||
|
||||
const auto PMONITOR = m_monitor.lock();
|
||||
|
||||
if (!PMONITOR)
|
||||
return;
|
||||
|
||||
auto surf = m_layerSurface->m_surface.lock();
|
||||
|
||||
if (!surf)
|
||||
return;
|
||||
|
||||
surf->breadthfirst(
|
||||
[PMONITOR](SP<CWLSurfaceResource> s, const Vector2D& offset, void* d) {
|
||||
const auto PSURFACE = CWLSurface::fromResource(s);
|
||||
if (PSURFACE && PSURFACE->m_lastScaleFloat == PMONITOR->m_scale)
|
||||
return;
|
||||
|
||||
g_pCompositor->setPreferredScaleForSurface(s, PMONITOR->m_scale);
|
||||
g_pCompositor->setPreferredTransformForSurface(s, PMONITOR->m_transform);
|
||||
},
|
||||
nullptr);
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ namespace Desktop::View {
|
||||
SP<Render::IFramebuffer> m_snapshotFB;
|
||||
|
||||
pid_t getPID();
|
||||
void updateSurfaceScaleTransformDetails();
|
||||
|
||||
void onDestroy();
|
||||
void onMap();
|
||||
|
||||
+19
-7
@@ -58,6 +58,7 @@ using namespace Hyprutils::Utils;
|
||||
using namespace Hyprutils::OS;
|
||||
using enum NContentType::eContentType;
|
||||
using namespace NColorManagement;
|
||||
using namespace Desktop::View;
|
||||
using namespace Render::GL;
|
||||
using namespace Monitor;
|
||||
|
||||
@@ -1108,13 +1109,8 @@ bool CMonitor::applyMonitorRule(Config::CMonitorRule&& pMonitorRule, bool force)
|
||||
|
||||
updateVCGTRamps();
|
||||
|
||||
// Set scale for all surfaces on this monitor, needed for some clients
|
||||
// but not on unsafe state to avoid crashes
|
||||
if (!g_pCompositor->m_unsafeState) {
|
||||
for (auto const& w : g_pCompositor->m_windows) {
|
||||
w->updateSurfaceScaleTransformDetails();
|
||||
}
|
||||
}
|
||||
updateSurfaceScaleTransformDetails();
|
||||
|
||||
// updato us
|
||||
g_pHyprRenderer->arrangeLayersForMonitor(m_id);
|
||||
|
||||
@@ -1868,6 +1864,22 @@ uint8_t CMonitor::isTearingBlocked(bool full) {
|
||||
return reasons;
|
||||
}
|
||||
|
||||
void CMonitor::updateSurfaceScaleTransformDetails() {
|
||||
if (g_pCompositor->m_unsafeState)
|
||||
return;
|
||||
|
||||
for (auto const& w : g_pCompositor->m_windows) {
|
||||
if (w->m_monitor == m_self)
|
||||
w->updateSurfaceScaleTransformDetails();
|
||||
}
|
||||
|
||||
for (auto const& lsl : m_layerSurfaceLayers) {
|
||||
for (auto const& ls : lsl) {
|
||||
ls->updateSurfaceScaleTransformDetails();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool CMonitor::updateTearing() {
|
||||
m_tearingState.activelyTearing = !isTearingBlocked();
|
||||
m_tearingState.nextRenderTorn = false;
|
||||
|
||||
@@ -323,6 +323,7 @@ class CMonitor {
|
||||
uint32_t isSolitaryBlocked(bool full = false);
|
||||
void recheckSolitary();
|
||||
uint8_t isTearingBlocked(bool full = false);
|
||||
void updateSurfaceScaleTransformDetails();
|
||||
bool updateTearing();
|
||||
uint16_t isDSBlocked(bool full = false);
|
||||
bool attemptDirectScanout();
|
||||
|
||||
Reference in New Issue
Block a user