Merge branch 'hyprwm:main' into main

This commit is contained in:
Gilang ramadhan 2024-10-20 16:53:07 +07:00 committed by GitHub
commit ff036e265a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
73 changed files with 627 additions and 615 deletions

View file

@ -1,7 +1,7 @@
PREFIX = /usr/local PREFIX = /usr/local
legacyrenderer: legacyrenderer:
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:STRING=${PREFIX} -DLEGACY_RENDERER:BOOL=true -S . -B ./buildZ cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:STRING=${PREFIX} -DLEGACY_RENDERER:BOOL=true -S . -B ./build
cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF` cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
legacyrendererdebug: legacyrendererdebug:

View file

@ -119,10 +119,16 @@ animations {
# Ref https://wiki.hyprland.org/Configuring/Workspace-Rules/ # Ref https://wiki.hyprland.org/Configuring/Workspace-Rules/
# "Smart gaps" / "No gaps when only" # "Smart gaps" / "No gaps when only"
# uncomment all three if you wish to use that. # uncomment all if you wish to use that.
# workspace = w[t1], gapsout:0, gapsin:0, border: 0, rounding:0 # workspace = w[t1], gapsout:0, gapsin:0
# workspace = w[tg1], gapsout:0, gapsin:0, border: 0, rounding:0 # workspace = w[tg1], gapsout:0, gapsin:0
# workspace = f[1], gapsout:0, gapsin:0, border: 0, rounding:0 # workspace = f[1], gapsout:0, gapsin:0
# windowrulev2 = bordersize 0, floating:0, onworkspace:w[t1]
# windowrulev2 = rounding 0, floating:0, onworkspace:w[t1]
# windowrulev2 = bordersize 0, floating:0, onworkspace:w[tg1]
# windowrulev2 = rounding 0, floating:0, onworkspace:w[tg1]
# windowrulev2 = bordersize 0, floating:0, onworkspace:f[1]
# windowrulev2 = rounding 0, floating:0, onworkspace:f[1]
# See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more # See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more
dwindle { dwindle {

View file

@ -412,8 +412,8 @@ void CCompositor::initAllSignals() {
m_bSessionActive = true; m_bSessionActive = true;
for (auto const& m : m_vMonitors) { for (auto const& m : m_vMonitors) {
scheduleFrameForMonitor(m.get()); scheduleFrameForMonitor(m);
g_pHyprRenderer->applyMonitorRule(m.get(), &m->activeMonitorRule, true); g_pHyprRenderer->applyMonitorRule(m, &m->activeMonitorRule, true);
} }
g_pConfigManager->m_bWantsMonitorReload = true; g_pConfigManager->m_bWantsMonitorReload = true;
@ -498,7 +498,7 @@ void CCompositor::cleanup() {
m_vWindows.clear(); m_vWindows.clear();
for (auto const& m : m_vMonitors) { for (auto const& m : m_vMonitors) {
g_pHyprOpenGL->destroyMonitorResources(m.get()); g_pHyprOpenGL->destroyMonitorResources(m);
m->output->state->setEnabled(false); m->output->state->setEnabled(false);
m->state.commit(); m->state.commit();
@ -717,38 +717,38 @@ void CCompositor::startCompositor() {
g_pEventLoopManager->enterLoop(); g_pEventLoopManager->enterLoop();
} }
CMonitor* CCompositor::getMonitorFromID(const MONITORID& id) { PHLMONITOR CCompositor::getMonitorFromID(const MONITORID& id) {
for (auto const& m : m_vMonitors) { for (auto const& m : m_vMonitors) {
if (m->ID == id) { if (m->ID == id) {
return m.get(); return m;
} }
} }
return nullptr; return nullptr;
} }
CMonitor* CCompositor::getMonitorFromName(const std::string& name) { PHLMONITOR CCompositor::getMonitorFromName(const std::string& name) {
for (auto const& m : m_vMonitors) { for (auto const& m : m_vMonitors) {
if (m->szName == name) { if (m->szName == name) {
return m.get(); return m;
} }
} }
return nullptr; return nullptr;
} }
CMonitor* CCompositor::getMonitorFromDesc(const std::string& desc) { PHLMONITOR CCompositor::getMonitorFromDesc(const std::string& desc) {
for (auto const& m : m_vMonitors) { for (auto const& m : m_vMonitors) {
if (m->szDescription.starts_with(desc)) if (m->szDescription.starts_with(desc))
return m.get(); return m;
} }
return nullptr; return nullptr;
} }
CMonitor* CCompositor::getMonitorFromCursor() { PHLMONITOR CCompositor::getMonitorFromCursor() {
return getMonitorFromVector(g_pPointerManager->position()); return getMonitorFromVector(g_pPointerManager->position());
} }
CMonitor* CCompositor::getMonitorFromVector(const Vector2D& point) { PHLMONITOR CCompositor::getMonitorFromVector(const Vector2D& point) {
SP<CMonitor> mon; SP<CMonitor> mon;
for (auto const& m : m_vMonitors) { for (auto const& m : m_vMonitors) {
if (CBox{m->vecPosition, m->vecSize}.containsPoint(point)) { if (CBox{m->vecPosition, m->vecSize}.containsPoint(point)) {
@ -772,13 +772,13 @@ CMonitor* CCompositor::getMonitorFromVector(const Vector2D& point) {
if (!pBestMon) { // ????? if (!pBestMon) { // ?????
Debug::log(WARN, "getMonitorFromVector no close mon???"); Debug::log(WARN, "getMonitorFromVector no close mon???");
return m_vMonitors.front().get(); return m_vMonitors.front();
} }
return pBestMon.get(); return pBestMon;
} }
return mon.get(); return mon;
} }
void CCompositor::removeWindowFromVectorSafe(PHLWINDOW pWindow) { void CCompositor::removeWindowFromVectorSafe(PHLWINDOW pWindow) {
@ -790,9 +790,9 @@ void CCompositor::removeWindowFromVectorSafe(PHLWINDOW pWindow) {
} }
} }
bool CCompositor::monitorExists(CMonitor* pMonitor) { bool CCompositor::monitorExists(PHLMONITOR pMonitor) {
for (auto const& m : m_vRealMonitors) { for (auto const& m : m_vRealMonitors) {
if (m.get() == pMonitor) if (m == pMonitor)
return true; return true;
} }
@ -982,20 +982,20 @@ Vector2D CCompositor::vectorToSurfaceLocal(const Vector2D& vec, PHLWINDOW pWindo
return vec - pWindow->m_vRealPosition.goal() - std::get<1>(iterData) + Vector2D{geom.x, geom.y}; return vec - pWindow->m_vRealPosition.goal() - std::get<1>(iterData) + Vector2D{geom.x, geom.y};
} }
CMonitor* CCompositor::getMonitorFromOutput(SP<Aquamarine::IOutput> out) { PHLMONITOR CCompositor::getMonitorFromOutput(SP<Aquamarine::IOutput> out) {
for (auto const& m : m_vMonitors) { for (auto const& m : m_vMonitors) {
if (m->output == out) { if (m->output == out) {
return m.get(); return m;
} }
} }
return nullptr; return nullptr;
} }
CMonitor* CCompositor::getRealMonitorFromOutput(SP<Aquamarine::IOutput> out) { PHLMONITOR CCompositor::getRealMonitorFromOutput(SP<Aquamarine::IOutput> out) {
for (auto const& m : m_vRealMonitors) { for (auto const& m : m_vRealMonitors) {
if (m->output == out) { if (m->output == out) {
return m.get(); return m;
} }
} }
@ -1183,7 +1183,7 @@ void CCompositor::focusSurface(SP<CWLSurfaceResource> pSurface, PHLWINDOW pWindo
SURF->constraint()->activate(); SURF->constraint()->activate();
} }
SP<CWLSurfaceResource> CCompositor::vectorToLayerPopupSurface(const Vector2D& pos, CMonitor* monitor, Vector2D* sCoords, PHLLS* ppLayerSurfaceFound) { SP<CWLSurfaceResource> CCompositor::vectorToLayerPopupSurface(const Vector2D& pos, PHLMONITOR monitor, Vector2D* sCoords, PHLLS* ppLayerSurfaceFound) {
for (auto const& lsl : monitor->m_aLayerSurfaceLayers | std::views::reverse) { for (auto const& lsl : monitor->m_aLayerSurfaceLayers | std::views::reverse) {
for (auto const& ls : lsl | std::views::reverse) { for (auto const& ls : lsl | std::views::reverse) {
if (ls->fadingOut || !ls->layerSurface || (ls->layerSurface && !ls->layerSurface->mapped) || ls->alpha.value() == 0.f) if (ls->fadingOut || !ls->layerSurface || (ls->layerSurface && !ls->layerSurface->mapped) || ls->alpha.value() == 0.f)
@ -1779,7 +1779,7 @@ bool CCompositor::isPointOnAnyMonitor(const Vector2D& point) {
return false; return false;
} }
bool CCompositor::isPointOnReservedArea(const Vector2D& point, const CMonitor* pMonitor) { bool CCompositor::isPointOnReservedArea(const Vector2D& point, const PHLMONITOR pMonitor) {
const auto PMONITOR = pMonitor ? pMonitor : getMonitorFromVector(point); const auto PMONITOR = pMonitor ? pMonitor : getMonitorFromVector(point);
const auto XY1 = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft; const auto XY1 = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
@ -1788,11 +1788,11 @@ bool CCompositor::isPointOnReservedArea(const Vector2D& point, const CMonitor* p
return !VECINRECT(point, XY1.x, XY1.y, XY2.x, XY2.y); return !VECINRECT(point, XY1.x, XY1.y, XY2.x, XY2.y);
} }
CMonitor* CCompositor::getMonitorInDirection(const char& dir) { PHLMONITOR CCompositor::getMonitorInDirection(const char& dir) {
return this->getMonitorInDirection(m_pLastMonitor.get(), dir); return getMonitorInDirection(m_pLastMonitor.lock(), dir);
} }
CMonitor* CCompositor::getMonitorInDirection(CMonitor* pSourceMonitor, const char& dir) { PHLMONITOR CCompositor::getMonitorInDirection(PHLMONITOR pSourceMonitor, const char& dir) {
if (!pSourceMonitor) if (!pSourceMonitor)
return nullptr; return nullptr;
@ -1800,7 +1800,7 @@ CMonitor* CCompositor::getMonitorInDirection(CMonitor* pSourceMonitor, const cha
const auto SIZEA = pSourceMonitor->vecSize; const auto SIZEA = pSourceMonitor->vecSize;
auto longestIntersect = -1; auto longestIntersect = -1;
CMonitor* longestIntersectMonitor = nullptr; PHLMONITOR longestIntersectMonitor = nullptr;
for (auto const& m : m_vMonitors) { for (auto const& m : m_vMonitors) {
if (m == m_pLastMonitor) if (m == m_pLastMonitor)
@ -1814,7 +1814,7 @@ CMonitor* CCompositor::getMonitorInDirection(CMonitor* pSourceMonitor, const cha
const auto INTERSECTLEN = std::max(0.0, std::min(POSA.y + SIZEA.y, POSB.y + SIZEB.y) - std::max(POSA.y, POSB.y)); const auto INTERSECTLEN = std::max(0.0, std::min(POSA.y + SIZEA.y, POSB.y + SIZEB.y) - std::max(POSA.y, POSB.y));
if (INTERSECTLEN > longestIntersect) { if (INTERSECTLEN > longestIntersect) {
longestIntersect = INTERSECTLEN; longestIntersect = INTERSECTLEN;
longestIntersectMonitor = m.get(); longestIntersectMonitor = m;
} }
} }
break; break;
@ -1823,7 +1823,7 @@ CMonitor* CCompositor::getMonitorInDirection(CMonitor* pSourceMonitor, const cha
const auto INTERSECTLEN = std::max(0.0, std::min(POSA.y + SIZEA.y, POSB.y + SIZEB.y) - std::max(POSA.y, POSB.y)); const auto INTERSECTLEN = std::max(0.0, std::min(POSA.y + SIZEA.y, POSB.y + SIZEB.y) - std::max(POSA.y, POSB.y));
if (INTERSECTLEN > longestIntersect) { if (INTERSECTLEN > longestIntersect) {
longestIntersect = INTERSECTLEN; longestIntersect = INTERSECTLEN;
longestIntersectMonitor = m.get(); longestIntersectMonitor = m;
} }
} }
break; break;
@ -1833,7 +1833,7 @@ CMonitor* CCompositor::getMonitorInDirection(CMonitor* pSourceMonitor, const cha
const auto INTERSECTLEN = std::max(0.0, std::min(POSA.x + SIZEA.x, POSB.x + SIZEB.x) - std::max(POSA.x, POSB.x)); const auto INTERSECTLEN = std::max(0.0, std::min(POSA.x + SIZEA.x, POSB.x + SIZEB.x) - std::max(POSA.x, POSB.x));
if (INTERSECTLEN > longestIntersect) { if (INTERSECTLEN > longestIntersect) {
longestIntersect = INTERSECTLEN; longestIntersect = INTERSECTLEN;
longestIntersectMonitor = m.get(); longestIntersectMonitor = m;
} }
} }
break; break;
@ -1843,7 +1843,7 @@ CMonitor* CCompositor::getMonitorInDirection(CMonitor* pSourceMonitor, const cha
const auto INTERSECTLEN = std::max(0.0, std::min(POSA.x + SIZEA.x, POSB.x + SIZEB.x) - std::max(POSA.x, POSB.x)); const auto INTERSECTLEN = std::max(0.0, std::min(POSA.x + SIZEA.x, POSB.x + SIZEB.x) - std::max(POSA.x, POSB.x));
if (INTERSECTLEN > longestIntersect) { if (INTERSECTLEN > longestIntersect) {
longestIntersect = INTERSECTLEN; longestIntersect = INTERSECTLEN;
longestIntersectMonitor = m.get(); longestIntersectMonitor = m;
} }
} }
break; break;
@ -1990,7 +1990,7 @@ MONITORID CCompositor::getNextAvailableMonitorID(std::string const& name) {
return nextID; return nextID;
} }
void CCompositor::swapActiveWorkspaces(CMonitor* pMonitorA, CMonitor* pMonitorB) { void CCompositor::swapActiveWorkspaces(PHLMONITOR pMonitorA, PHLMONITOR pMonitorB) {
const auto PWORKSPACEA = pMonitorA->activeWorkspace; const auto PWORKSPACEA = pMonitorA->activeWorkspace;
const auto PWORKSPACEB = pMonitorB->activeWorkspace; const auto PWORKSPACEB = pMonitorB->activeWorkspace;
@ -2077,16 +2077,16 @@ void CCompositor::swapActiveWorkspaces(CMonitor* pMonitorA, CMonitor* pMonitorB)
EMIT_HOOK_EVENT("moveWorkspace", (std::vector<std::any>{PWORKSPACEB, pMonitorA})); EMIT_HOOK_EVENT("moveWorkspace", (std::vector<std::any>{PWORKSPACEB, pMonitorA}));
} }
CMonitor* CCompositor::getMonitorFromString(const std::string& name) { PHLMONITOR CCompositor::getMonitorFromString(const std::string& name) {
if (name == "current") if (name == "current")
return g_pCompositor->m_pLastMonitor.get(); return g_pCompositor->m_pLastMonitor.lock();
else if (isDirection(name)) else if (isDirection(name))
return getMonitorInDirection(name[0]); return getMonitorInDirection(name[0]);
else if (name[0] == '+' || name[0] == '-') { else if (name[0] == '+' || name[0] == '-') {
// relative // relative
if (m_vMonitors.size() == 1) if (m_vMonitors.size() == 1)
return m_vMonitors.begin()->get(); return *m_vMonitors.begin();
const auto OFFSET = name[0] == '-' ? name : name.substr(1); const auto OFFSET = name[0] == '-' ? name : name.substr(1);
@ -2119,7 +2119,7 @@ CMonitor* CCompositor::getMonitorFromString(const std::string& name) {
currentPlace = std::clamp(currentPlace, 0, (int)m_vMonitors.size() - 1); currentPlace = std::clamp(currentPlace, 0, (int)m_vMonitors.size() - 1);
} }
return m_vMonitors[currentPlace].get(); return m_vMonitors[currentPlace];
} else if (isNumber(name)) { } else if (isNumber(name)) {
// change by ID // change by ID
MONITORID monID = MONITOR_INVALID; MONITORID monID = MONITOR_INVALID;
@ -2143,7 +2143,7 @@ CMonitor* CCompositor::getMonitorFromString(const std::string& name) {
continue; continue;
if (m->matchesStaticSelector(name)) { if (m->matchesStaticSelector(name)) {
return m.get(); return m;
} }
} }
} }
@ -2151,7 +2151,7 @@ CMonitor* CCompositor::getMonitorFromString(const std::string& name) {
return nullptr; return nullptr;
} }
void CCompositor::moveWorkspaceToMonitor(PHLWORKSPACE pWorkspace, CMonitor* pMonitor, bool noWarpCursor) { void CCompositor::moveWorkspaceToMonitor(PHLWORKSPACE pWorkspace, PHLMONITOR pMonitor, bool noWarpCursor) {
// We trust the monitor to be correct. // We trust the monitor to be correct.
@ -2226,7 +2226,7 @@ void CCompositor::moveWorkspaceToMonitor(PHLWORKSPACE pWorkspace, CMonitor* pMon
} }
} }
if (SWITCHINGISACTIVE && POLDMON == g_pCompositor->m_pLastMonitor.get()) { // if it was active, preserve its' status. If it wasn't, don't. if (SWITCHINGISACTIVE && POLDMON == g_pCompositor->m_pLastMonitor) { // if it was active, preserve its' status. If it wasn't, don't.
Debug::log(LOG, "moveWorkspaceToMonitor: SWITCHINGISACTIVE, active {} -> {}", pMonitor->activeWorkspaceID(), pWorkspace->m_iID); Debug::log(LOG, "moveWorkspaceToMonitor: SWITCHINGISACTIVE, active {} -> {}", pMonitor->activeWorkspaceID(), pWorkspace->m_iID);
if (valid(pMonitor->activeWorkspace)) { if (valid(pMonitor->activeWorkspace)) {
@ -2438,7 +2438,7 @@ void CCompositor::updateWorkspaceWindowData(const WORKSPACEID& id) {
} }
} }
void CCompositor::scheduleFrameForMonitor(CMonitor* pMonitor, IOutput::scheduleFrameReason reason) { void CCompositor::scheduleFrameForMonitor(PHLMONITOR pMonitor, IOutput::scheduleFrameReason reason) {
if ((m_pAqBackend->hasSession() && !m_pAqBackend->session->active) || !m_bSessionActive) if ((m_pAqBackend->hasSession() && !m_pAqBackend->session->active) || !m_bSessionActive)
return; return;
@ -2555,7 +2555,7 @@ void CCompositor::warpCursorTo(const Vector2D& pos, bool force) {
if (*PNOWARPS && !force) { if (*PNOWARPS && !force) {
const auto PMONITORNEW = getMonitorFromVector(pos); const auto PMONITORNEW = getMonitorFromVector(pos);
if (PMONITORNEW != m_pLastMonitor.get()) if (PMONITORNEW != m_pLastMonitor)
setActiveMonitor(PMONITORNEW); setActiveMonitor(PMONITORNEW);
return; return;
} }
@ -2563,7 +2563,7 @@ void CCompositor::warpCursorTo(const Vector2D& pos, bool force) {
g_pPointerManager->warpTo(pos); g_pPointerManager->warpTo(pos);
const auto PMONITORNEW = getMonitorFromVector(pos); const auto PMONITORNEW = getMonitorFromVector(pos);
if (PMONITORNEW != m_pLastMonitor.get()) if (PMONITORNEW != m_pLastMonitor)
setActiveMonitor(PMONITORNEW); setActiveMonitor(PMONITORNEW);
} }
@ -2690,8 +2690,8 @@ void CCompositor::renameWorkspace(const WORKSPACEID& id, const std::string& name
g_pEventManager->postEvent({"renameworkspace", std::to_string(PWORKSPACE->m_iID) + "," + PWORKSPACE->m_szName}); g_pEventManager->postEvent({"renameworkspace", std::to_string(PWORKSPACE->m_iID) + "," + PWORKSPACE->m_szName});
} }
void CCompositor::setActiveMonitor(CMonitor* pMonitor) { void CCompositor::setActiveMonitor(PHLMONITOR pMonitor) {
if (m_pLastMonitor.get() == pMonitor) if (m_pLastMonitor == pMonitor)
return; return;
if (!pMonitor) { if (!pMonitor) {
@ -2803,11 +2803,11 @@ PHLWINDOW CCompositor::getForceFocus() {
void CCompositor::arrangeMonitors() { void CCompositor::arrangeMonitors() {
static auto* const PXWLFORCESCALEZERO = (Hyprlang::INT* const*)g_pConfigManager->getConfigValuePtr("xwayland:force_zero_scaling"); static auto* const PXWLFORCESCALEZERO = (Hyprlang::INT* const*)g_pConfigManager->getConfigValuePtr("xwayland:force_zero_scaling");
std::vector<CMonitor*> toArrange; std::vector<PHLMONITOR> toArrange;
std::vector<CMonitor*> arranged; std::vector<PHLMONITOR> arranged;
for (auto const& m : m_vMonitors) for (auto const& m : m_vMonitors)
toArrange.push_back(m.get()); toArrange.push_back(m);
Debug::log(LOG, "arrangeMonitors: {} to arrange", toArrange.size()); Debug::log(LOG, "arrangeMonitors: {} to arrange", toArrange.size());
@ -2906,7 +2906,7 @@ void CCompositor::enterUnsafeState() {
m_bUnsafeState = true; m_bUnsafeState = true;
setActiveMonitor(m_pUnsafeOutput); setActiveMonitor(m_pUnsafeOutput.lock());
} }
void CCompositor::leaveUnsafeState() { void CCompositor::leaveUnsafeState() {
@ -2917,10 +2917,10 @@ void CCompositor::leaveUnsafeState() {
m_bUnsafeState = false; m_bUnsafeState = false;
CMonitor* pNewMonitor = nullptr; PHLMONITOR pNewMonitor = nullptr;
for (auto const& pMonitor : m_vMonitors) { for (auto const& pMonitor : m_vMonitors) {
if (pMonitor->output != m_pUnsafeOutput->output) { if (pMonitor->output != m_pUnsafeOutput->output) {
pNewMonitor = pMonitor.get(); pNewMonitor = pMonitor;
break; break;
} }
} }
@ -2931,7 +2931,7 @@ void CCompositor::leaveUnsafeState() {
m_pUnsafeOutput->onDisconnect(); m_pUnsafeOutput->onDisconnect();
for (auto const& m : m_vMonitors) { for (auto const& m : m_vMonitors) {
scheduleFrameForMonitor(m.get()); scheduleFrameForMonitor(m);
} }
} }
@ -3007,7 +3007,7 @@ static void checkDefaultCursorWarp(SP<CMonitor> monitor) {
} }
// modechange happend check if cursor is on that monitor and warp it to middle to not place it out of bounds if resolution changed. // modechange happend check if cursor is on that monitor and warp it to middle to not place it out of bounds if resolution changed.
if (g_pCompositor->getMonitorFromCursor() == monitor.get()) { if (g_pCompositor->getMonitorFromCursor() == monitor) {
g_pCompositor->warpCursorTo(POS, true); g_pCompositor->warpCursorTo(POS, true);
g_pInputManager->refocus(); g_pInputManager->refocus();
} }
@ -3017,7 +3017,7 @@ void CCompositor::onNewMonitor(SP<Aquamarine::IOutput> output) {
// add it to real // add it to real
auto PNEWMONITOR = g_pCompositor->m_vRealMonitors.emplace_back(makeShared<CMonitor>(output)); auto PNEWMONITOR = g_pCompositor->m_vRealMonitors.emplace_back(makeShared<CMonitor>(output));
if (std::string("HEADLESS-1") == output->name) { if (std::string("HEADLESS-1") == output->name) {
g_pCompositor->m_pUnsafeOutput = PNEWMONITOR.get(); g_pCompositor->m_pUnsafeOutput = PNEWMONITOR;
output->name = "FALLBACK"; // we are allowed to do this :) output->name = "FALLBACK"; // we are allowed to do this :)
} }
@ -3040,12 +3040,12 @@ void CCompositor::onNewMonitor(SP<Aquamarine::IOutput> output) {
// ready to process if we have a real monitor // ready to process if we have a real monitor
if ((!g_pHyprRenderer->m_pMostHzMonitor || PNEWMONITOR->refreshRate > g_pHyprRenderer->m_pMostHzMonitor->refreshRate) && PNEWMONITOR->m_bEnabled) if ((!g_pHyprRenderer->m_pMostHzMonitor || PNEWMONITOR->refreshRate > g_pHyprRenderer->m_pMostHzMonitor->refreshRate) && PNEWMONITOR->m_bEnabled)
g_pHyprRenderer->m_pMostHzMonitor = PNEWMONITOR.get(); g_pHyprRenderer->m_pMostHzMonitor = PNEWMONITOR;
g_pCompositor->m_bReadyToProcess = true; g_pCompositor->m_bReadyToProcess = true;
g_pConfigManager->m_bWantsMonitorReload = true; g_pConfigManager->m_bWantsMonitorReload = true;
g_pCompositor->scheduleFrameForMonitor(PNEWMONITOR.get(), IOutput::AQ_SCHEDULE_NEW_MONITOR); g_pCompositor->scheduleFrameForMonitor(PNEWMONITOR, IOutput::AQ_SCHEDULE_NEW_MONITOR);
checkDefaultCursorWarp(PNEWMONITOR); checkDefaultCursorWarp(PNEWMONITOR);
@ -3056,6 +3056,6 @@ void CCompositor::onNewMonitor(SP<Aquamarine::IOutput> output) {
} }
} }
g_pHyprRenderer->damageMonitor(PNEWMONITOR.get()); g_pHyprRenderer->damageMonitor(PNEWMONITOR);
Events::listener_monitorFrame(PNEWMONITOR.get(), nullptr); PNEWMONITOR->onMonitorFrame();
} }

View file

@ -89,7 +89,7 @@ class CCompositor {
bool m_bDPMSStateON = true; bool m_bDPMSStateON = true;
bool m_bUnsafeState = false; // unsafe state is when there is no monitors. bool m_bUnsafeState = false; // unsafe state is when there is no monitors.
bool m_bNextIsUnsafe = false; bool m_bNextIsUnsafe = false;
CMonitor* m_pUnsafeOutput = nullptr; // fallback output for the unsafe state PHLMONITORREF m_pUnsafeOutput; // fallback output for the unsafe state
bool m_bIsShuttingDown = false; bool m_bIsShuttingDown = false;
bool m_bFinalRequests = false; bool m_bFinalRequests = false;
bool m_bDesktopEnvSet = false; bool m_bDesktopEnvSet = false;
@ -97,22 +97,22 @@ class CCompositor {
// ------------------------------------------------- // // ------------------------------------------------- //
CMonitor* getMonitorFromID(const MONITORID&); PHLMONITOR getMonitorFromID(const MONITORID&);
CMonitor* getMonitorFromName(const std::string&); PHLMONITOR getMonitorFromName(const std::string&);
CMonitor* getMonitorFromDesc(const std::string&); PHLMONITOR getMonitorFromDesc(const std::string&);
CMonitor* getMonitorFromCursor(); PHLMONITOR getMonitorFromCursor();
CMonitor* getMonitorFromVector(const Vector2D&); PHLMONITOR getMonitorFromVector(const Vector2D&);
void removeWindowFromVectorSafe(PHLWINDOW); void removeWindowFromVectorSafe(PHLWINDOW);
void focusWindow(PHLWINDOW, SP<CWLSurfaceResource> pSurface = nullptr); void focusWindow(PHLWINDOW, SP<CWLSurfaceResource> pSurface = nullptr);
void focusSurface(SP<CWLSurfaceResource>, PHLWINDOW pWindowOwner = nullptr); void focusSurface(SP<CWLSurfaceResource>, PHLWINDOW pWindowOwner = nullptr);
bool monitorExists(CMonitor*); bool monitorExists(PHLMONITOR);
PHLWINDOW vectorToWindowUnified(const Vector2D&, uint8_t properties, PHLWINDOW pIgnoreWindow = nullptr); PHLWINDOW vectorToWindowUnified(const Vector2D&, uint8_t properties, PHLWINDOW pIgnoreWindow = nullptr);
SP<CWLSurfaceResource> vectorToLayerSurface(const Vector2D&, std::vector<PHLLSREF>*, Vector2D*, PHLLS*); SP<CWLSurfaceResource> vectorToLayerSurface(const Vector2D&, std::vector<PHLLSREF>*, Vector2D*, PHLLS*);
SP<CWLSurfaceResource> vectorToLayerPopupSurface(const Vector2D&, CMonitor* monitor, Vector2D*, PHLLS*); SP<CWLSurfaceResource> vectorToLayerPopupSurface(const Vector2D&, PHLMONITOR monitor, Vector2D*, PHLLS*);
SP<CWLSurfaceResource> vectorWindowToSurface(const Vector2D&, PHLWINDOW, Vector2D& sl); SP<CWLSurfaceResource> vectorWindowToSurface(const Vector2D&, PHLWINDOW, Vector2D& sl);
Vector2D vectorToSurfaceLocal(const Vector2D&, PHLWINDOW, SP<CWLSurfaceResource>); Vector2D vectorToSurfaceLocal(const Vector2D&, PHLWINDOW, SP<CWLSurfaceResource>);
CMonitor* getMonitorFromOutput(SP<Aquamarine::IOutput>); PHLMONITOR getMonitorFromOutput(SP<Aquamarine::IOutput>);
CMonitor* getRealMonitorFromOutput(SP<Aquamarine::IOutput>); PHLMONITOR getRealMonitorFromOutput(SP<Aquamarine::IOutput>);
PHLWINDOW getWindowFromSurface(SP<CWLSurfaceResource>); PHLWINDOW getWindowFromSurface(SP<CWLSurfaceResource>);
PHLWINDOW getWindowFromHandle(uint32_t); PHLWINDOW getWindowFromHandle(uint32_t);
bool isWorkspaceVisible(PHLWORKSPACE); bool isWorkspaceVisible(PHLWORKSPACE);
@ -138,16 +138,16 @@ class CCompositor {
PHLWINDOW getPrevWindowOnWorkspace(PHLWINDOW, bool focusableOnly = false, std::optional<bool> floating = {}); PHLWINDOW getPrevWindowOnWorkspace(PHLWINDOW, bool focusableOnly = false, std::optional<bool> floating = {});
WORKSPACEID getNextAvailableNamedWorkspace(); WORKSPACEID getNextAvailableNamedWorkspace();
bool isPointOnAnyMonitor(const Vector2D&); bool isPointOnAnyMonitor(const Vector2D&);
bool isPointOnReservedArea(const Vector2D& point, const CMonitor* monitor = nullptr); bool isPointOnReservedArea(const Vector2D& point, const PHLMONITOR monitor = nullptr);
CMonitor* getMonitorInDirection(const char&); PHLMONITOR getMonitorInDirection(const char&);
CMonitor* getMonitorInDirection(CMonitor*, const char&); PHLMONITOR getMonitorInDirection(PHLMONITOR, const char&);
void updateAllWindowsAnimatedDecorationValues(); void updateAllWindowsAnimatedDecorationValues();
void updateWorkspaceWindows(const WORKSPACEID& id); void updateWorkspaceWindows(const WORKSPACEID& id);
void updateWindowAnimatedDecorationValues(PHLWINDOW); void updateWindowAnimatedDecorationValues(PHLWINDOW);
MONITORID getNextAvailableMonitorID(std::string const& name); MONITORID getNextAvailableMonitorID(std::string const& name);
void moveWorkspaceToMonitor(PHLWORKSPACE, CMonitor*, bool noWarpCursor = false); void moveWorkspaceToMonitor(PHLWORKSPACE, PHLMONITOR, bool noWarpCursor = false);
void swapActiveWorkspaces(CMonitor*, CMonitor*); void swapActiveWorkspaces(PHLMONITOR, PHLMONITOR);
CMonitor* getMonitorFromString(const std::string&); PHLMONITOR getMonitorFromString(const std::string&);
bool workspaceIDOutOfBounds(const WORKSPACEID&); bool workspaceIDOutOfBounds(const WORKSPACEID&);
void setWindowFullscreenInternal(const PHLWINDOW PWINDOW, const eFullscreenMode MODE); void setWindowFullscreenInternal(const PHLWINDOW PWINDOW, const eFullscreenMode MODE);
void setWindowFullscreenClient(const PHLWINDOW PWINDOW, const eFullscreenMode MODE); void setWindowFullscreenClient(const PHLWINDOW PWINDOW, const eFullscreenMode MODE);
@ -156,7 +156,7 @@ class CCompositor {
void changeWindowFullscreenModeClient(const PHLWINDOW PWINDOW, const eFullscreenMode MODE, const bool ON); void changeWindowFullscreenModeClient(const PHLWINDOW PWINDOW, const eFullscreenMode MODE, const bool ON);
void updateFullscreenFadeOnWorkspace(PHLWORKSPACE); void updateFullscreenFadeOnWorkspace(PHLWORKSPACE);
PHLWINDOW getX11Parent(PHLWINDOW); PHLWINDOW getX11Parent(PHLWINDOW);
void scheduleFrameForMonitor(CMonitor*, Aquamarine::IOutput::scheduleFrameReason reason = Aquamarine::IOutput::AQ_SCHEDULE_CLIENT_UNKNOWN); void scheduleFrameForMonitor(PHLMONITOR, Aquamarine::IOutput::scheduleFrameReason reason = Aquamarine::IOutput::AQ_SCHEDULE_CLIENT_UNKNOWN);
void addToFadingOutSafe(PHLLS); void addToFadingOutSafe(PHLLS);
void removeFromFadingOutSafe(PHLLS); void removeFromFadingOutSafe(PHLLS);
void addToFadingOutSafe(PHLWINDOW); void addToFadingOutSafe(PHLWINDOW);
@ -169,7 +169,7 @@ class CCompositor {
PHLWORKSPACE createNewWorkspace(const WORKSPACEID&, const MONITORID&, const std::string& name = "", PHLWORKSPACE createNewWorkspace(const WORKSPACEID&, const MONITORID&, const std::string& name = "",
bool isEmpty = true); // will be deleted next frame if left empty and unfocused! bool isEmpty = true); // will be deleted next frame if left empty and unfocused!
void renameWorkspace(const WORKSPACEID&, const std::string& name = ""); void renameWorkspace(const WORKSPACEID&, const std::string& name = "");
void setActiveMonitor(CMonitor*); void setActiveMonitor(PHLMONITOR);
bool isWorkspaceSpecial(const WORKSPACEID&); bool isWorkspaceSpecial(const WORKSPACEID&);
WORKSPACEID getNewSpecialID(); WORKSPACEID getNewSpecialID();
void performUserChecks(); void performUserChecks();

View file

@ -689,14 +689,13 @@ std::string CConfigManager::getMainConfigPath() {
if (const auto CFG_ENV = getenv("HYPRLAND_CONFIG"); CFG_ENV) if (const auto CFG_ENV = getenv("HYPRLAND_CONFIG"); CFG_ENV)
return CFG_ENV; return CFG_ENV;
Debug::log(TRACE, "Seems as if HYPRLAND_CONFIG isn't set, let's see what we can do with HOME.");
static const auto paths = Hyprutils::Path::findConfig(ISDEBUG ? "hyprlandd" : "hyprland"); const auto PATHS = Hyprutils::Path::findConfig(ISDEBUG ? "hyprlandd" : "hyprland");
if (paths.first.has_value()) { if (PATHS.first.has_value()) {
return paths.first.value(); return PATHS.first.value();
} else if (paths.second.has_value()) { } else if (PATHS.second.has_value()) {
auto configPath = Hyprutils::Path::fullConfigPath(paths.second.value(), ISDEBUG ? "hyprlandd" : "hyprland"); const auto CONFIGPATH = Hyprutils::Path::fullConfigPath(PATHS.second.value(), ISDEBUG ? "hyprlandd" : "hyprland");
return generateConfig(configPath).value(); return generateConfig(CONFIGPATH).value();
} else } else
throw std::runtime_error("Neither HOME nor XDG_CONFIG_HOME are set in the environment. Could not find config in XDG_CONFIG_DIRS or /etc/xdg."); throw std::runtime_error("Neither HOME nor XDG_CONFIG_HOME are set in the environment. Could not find config in XDG_CONFIG_DIRS or /etc/xdg.");
} }
@ -945,9 +944,9 @@ void CConfigManager::postConfigReload(const Hyprlang::CParseResult& result) {
for (auto const& m : g_pCompositor->m_vMonitors) { for (auto const& m : g_pCompositor->m_vMonitors) {
// mark blur dirty // mark blur dirty
g_pHyprOpenGL->markBlurDirtyForMonitor(m.get()); g_pHyprOpenGL->markBlurDirtyForMonitor(m);
g_pCompositor->scheduleFrameForMonitor(m.get()); g_pCompositor->scheduleFrameForMonitor(m);
// Force the compositor to fully re-render all monitors // Force the compositor to fully re-render all monitors
m->forceFullFrames = 2; m->forceFullFrames = 2;
@ -1508,7 +1507,7 @@ void CConfigManager::performMonitorReload() {
auto rule = getMonitorRuleFor(m); auto rule = getMonitorRuleFor(m);
if (!g_pHyprRenderer->applyMonitorRule(m.get(), &rule)) { if (!g_pHyprRenderer->applyMonitorRule(m, &rule)) {
overAgain = true; overAgain = true;
break; break;
} }
@ -1566,14 +1565,14 @@ void CConfigManager::ensureMonitorStatus() {
auto rule = getMonitorRuleFor(rm); auto rule = getMonitorRuleFor(rm);
if (rule.disabled == rm->m_bEnabled) if (rule.disabled == rm->m_bEnabled)
g_pHyprRenderer->applyMonitorRule(rm.get(), &rule); g_pHyprRenderer->applyMonitorRule(rm, &rule);
} }
} }
void CConfigManager::ensureVRR(CMonitor* pMonitor) { void CConfigManager::ensureVRR(PHLMONITOR pMonitor) {
static auto PVRR = reinterpret_cast<Hyprlang::INT* const*>(getConfigValuePtr("misc:vrr")); static auto PVRR = reinterpret_cast<Hyprlang::INT* const*>(getConfigValuePtr("misc:vrr"));
static auto ensureVRRForDisplay = [&](CMonitor* m) -> void { static auto ensureVRRForDisplay = [&](PHLMONITOR m) -> void {
if (!m->output || m->createdByUser) if (!m->output || m->createdByUser)
return; return;
@ -1643,7 +1642,7 @@ void CConfigManager::ensureVRR(CMonitor* pMonitor) {
} }
for (auto const& m : g_pCompositor->m_vMonitors) { for (auto const& m : g_pCompositor->m_vMonitors) {
ensureVRRForDisplay(m.get()); ensureVRRForDisplay(m);
} }
} }
@ -1655,7 +1654,7 @@ void CConfigManager::addParseError(const std::string& err) {
g_pHyprError->queueCreate(err + "\nHyprland may not work correctly.", CColor(1.0, 50.0 / 255.0, 50.0 / 255.0, 1.0)); g_pHyprError->queueCreate(err + "\nHyprland may not work correctly.", CColor(1.0, 50.0 / 255.0, 50.0 / 255.0, 1.0));
} }
CMonitor* CConfigManager::getBoundMonitorForWS(const std::string& wsname) { PHLMONITOR CConfigManager::getBoundMonitorForWS(const std::string& wsname) {
auto monitor = getBoundMonitorStringForWS(wsname); auto monitor = getBoundMonitorStringForWS(wsname);
if (monitor.substr(0, 5) == "desc:") if (monitor.substr(0, 5) == "desc:")
return g_pCompositor->getMonitorFromDesc(monitor.substr(5)); return g_pCompositor->getMonitorFromDesc(monitor.substr(5));

View file

@ -173,7 +173,7 @@ class CConfigManager {
SWorkspaceRule getWorkspaceRuleFor(PHLWORKSPACE workspace); SWorkspaceRule getWorkspaceRuleFor(PHLWORKSPACE workspace);
std::string getDefaultWorkspaceFor(const std::string&); std::string getDefaultWorkspaceFor(const std::string&);
CMonitor* getBoundMonitorForWS(const std::string&); PHLMONITOR getBoundMonitorForWS(const std::string&);
std::string getBoundMonitorStringForWS(const std::string&); std::string getBoundMonitorStringForWS(const std::string&);
const std::deque<SWorkspaceRule>& getAllWorkspaceRules(); const std::deque<SWorkspaceRule>& getAllWorkspaceRules();
@ -198,7 +198,7 @@ class CConfigManager {
void appendMonitorRule(const SMonitorRule&); void appendMonitorRule(const SMonitorRule&);
bool replaceMonitorRule(const SMonitorRule&); bool replaceMonitorRule(const SMonitorRule&);
void ensureMonitorStatus(); void ensureMonitorStatus();
void ensureVRR(CMonitor* pMonitor = nullptr); void ensureVRR(PHLMONITOR pMonitor = nullptr);
std::string parseKeyword(const std::string&, const std::string&); std::string parseKeyword(const std::string&, const std::string&);

View file

@ -132,10 +132,16 @@ animations {
# Ref https://wiki.hyprland.org/Configuring/Workspace-Rules/ # Ref https://wiki.hyprland.org/Configuring/Workspace-Rules/
# "Smart gaps" / "No gaps when only" # "Smart gaps" / "No gaps when only"
# uncomment all three if you wish to use that. # uncomment all if you wish to use that.
# workspace = w[t1], gapsout:0, gapsin:0, border: 0, rounding:0 # workspace = w[t1], gapsout:0, gapsin:0
# workspace = w[tg1], gapsout:0, gapsin:0, border: 0, rounding:0 # workspace = w[tg1], gapsout:0, gapsin:0
# workspace = f[1], gapsout:0, gapsin:0, border: 0, rounding:0 # workspace = f[1], gapsout:0, gapsin:0
# windowrulev2 = bordersize 0, floating:0, onworkspace:w[t1]
# windowrulev2 = rounding 0, floating:0, onworkspace:w[t1]
# windowrulev2 = bordersize 0, floating:0, onworkspace:w[tg1]
# windowrulev2 = rounding 0, floating:0, onworkspace:w[tg1]
# windowrulev2 = bordersize 0, floating:0, onworkspace:f[1]
# windowrulev2 = rounding 0, floating:0, onworkspace:f[1]
# See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more # See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more
dwindle { dwindle {

View file

@ -54,7 +54,7 @@ static std::string formatToString(uint32_t drmFormat) {
return "Invalid"; return "Invalid";
} }
static std::string availableModesForOutput(CMonitor* pMonitor, eHyprCtlOutputFormat format) { static std::string availableModesForOutput(PHLMONITOR pMonitor, eHyprCtlOutputFormat format) {
std::string result; std::string result;
for (auto const& m : pMonitor->output->modes) { for (auto const& m : pMonitor->output->modes) {
@ -117,7 +117,7 @@ std::string CHyprCtl::getMonitorData(Hyprutils::Memory::CSharedPointer<CMonitor>
(int)m->vecReservedBottomRight.x, (int)m->vecReservedBottomRight.y, m->scale, (int)m->transform, (m == g_pCompositor->m_pLastMonitor ? "true" : "false"), (int)m->vecReservedBottomRight.x, (int)m->vecReservedBottomRight.y, m->scale, (int)m->transform, (m == g_pCompositor->m_pLastMonitor ? "true" : "false"),
(m->dpmsStatus ? "true" : "false"), (m->output->state->state().adaptiveSync ? "true" : "false"), (uint64_t)m->solitaryClient.get(), (m->dpmsStatus ? "true" : "false"), (m->output->state->state().adaptiveSync ? "true" : "false"), (uint64_t)m->solitaryClient.get(),
(m->tearingState.activelyTearing ? "true" : "false"), (m->m_bEnabled ? "false" : "true"), formatToString(m->output->state->state().drmFormat), (m->tearingState.activelyTearing ? "true" : "false"), (m->m_bEnabled ? "false" : "true"), formatToString(m->output->state->state().drmFormat),
availableModesForOutput(m.get(), format)); availableModesForOutput(m, format));
} else { } else {
result += std::format("Monitor {} (ID {}):\n\t{}x{}@{:.5f} at {}x{}\n\tdescription: {}\n\tmake: {}\n\tmodel: {}\n\tserial: {}\n\tactive workspace: {} ({})\n\t" result += std::format("Monitor {} (ID {}):\n\t{}x{}@{:.5f} at {}x{}\n\tdescription: {}\n\tmake: {}\n\tmodel: {}\n\tserial: {}\n\tactive workspace: {} ({})\n\t"
@ -128,7 +128,7 @@ std::string CHyprCtl::getMonitorData(Hyprutils::Memory::CSharedPointer<CMonitor>
m->activeSpecialWorkspaceID(), (m->activeSpecialWorkspace ? m->activeSpecialWorkspace->m_szName : ""), (int)m->vecReservedTopLeft.x, m->activeSpecialWorkspaceID(), (m->activeSpecialWorkspace ? m->activeSpecialWorkspace->m_szName : ""), (int)m->vecReservedTopLeft.x,
(int)m->vecReservedTopLeft.y, (int)m->vecReservedBottomRight.x, (int)m->vecReservedBottomRight.y, m->scale, (int)m->transform, (int)m->vecReservedTopLeft.y, (int)m->vecReservedBottomRight.x, (int)m->vecReservedBottomRight.y, m->scale, (int)m->transform,
(m == g_pCompositor->m_pLastMonitor ? "yes" : "no"), (int)m->dpmsStatus, m->output->state->state().adaptiveSync, (uint64_t)m->solitaryClient.get(), (m == g_pCompositor->m_pLastMonitor ? "yes" : "no"), (int)m->dpmsStatus, m->output->state->state().adaptiveSync, (uint64_t)m->solitaryClient.get(),
m->tearingState.activelyTearing, !m->m_bEnabled, formatToString(m->output->state->state().drmFormat), availableModesForOutput(m.get(), format)); m->tearingState.activelyTearing, !m->m_bEnabled, formatToString(m->output->state->state().drmFormat), availableModesForOutput(m, format));
} }
return result; return result;
@ -1030,7 +1030,7 @@ std::string dispatchKeyword(eHyprCtlOutputFormat format, std::string in) {
// decorations will probably need a repaint // decorations will probably need a repaint
if (COMMAND.contains("decoration:") || COMMAND.contains("border") || COMMAND == "workspace" || COMMAND.contains("zoom_factor") || COMMAND == "source") { if (COMMAND.contains("decoration:") || COMMAND.contains("border") || COMMAND == "workspace" || COMMAND.contains("zoom_factor") || COMMAND == "source") {
for (auto const& m : g_pCompositor->m_vMonitors) { for (auto const& m : g_pCompositor->m_vMonitors) {
g_pHyprRenderer->damageMonitor(m.get()); g_pHyprRenderer->damageMonitor(m);
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m->ID); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m->ID);
} }
} }
@ -1779,7 +1779,7 @@ std::string CHyprCtl::getReply(std::string request) {
} }
for (auto const& m : g_pCompositor->m_vMonitors) { for (auto const& m : g_pCompositor->m_vMonitors) {
g_pHyprRenderer->damageMonitor(m.get()); g_pHyprRenderer->damageMonitor(m);
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m->ID); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m->ID);
} }
} }

View file

@ -7,7 +7,7 @@ CHyprDebugOverlay::CHyprDebugOverlay() {
m_pTexture = makeShared<CTexture>(); m_pTexture = makeShared<CTexture>();
} }
void CHyprMonitorDebugOverlay::renderData(CMonitor* pMonitor, float durationUs) { void CHyprMonitorDebugOverlay::renderData(PHLMONITOR pMonitor, float durationUs) {
m_dLastRenderTimes.push_back(durationUs / 1000.f); m_dLastRenderTimes.push_back(durationUs / 1000.f);
if (m_dLastRenderTimes.size() > (long unsigned int)pMonitor->refreshRate) if (m_dLastRenderTimes.size() > (long unsigned int)pMonitor->refreshRate)
@ -17,7 +17,7 @@ void CHyprMonitorDebugOverlay::renderData(CMonitor* pMonitor, float durationUs)
m_pMonitor = pMonitor; m_pMonitor = pMonitor;
} }
void CHyprMonitorDebugOverlay::renderDataNoOverlay(CMonitor* pMonitor, float durationUs) { void CHyprMonitorDebugOverlay::renderDataNoOverlay(PHLMONITOR pMonitor, float durationUs) {
m_dLastRenderTimesNoOverlay.push_back(durationUs / 1000.f); m_dLastRenderTimesNoOverlay.push_back(durationUs / 1000.f);
if (m_dLastRenderTimesNoOverlay.size() > (long unsigned int)pMonitor->refreshRate) if (m_dLastRenderTimesNoOverlay.size() > (long unsigned int)pMonitor->refreshRate)
@ -27,7 +27,7 @@ void CHyprMonitorDebugOverlay::renderDataNoOverlay(CMonitor* pMonitor, float dur
m_pMonitor = pMonitor; m_pMonitor = pMonitor;
} }
void CHyprMonitorDebugOverlay::frameData(CMonitor* pMonitor) { void CHyprMonitorDebugOverlay::frameData(PHLMONITOR pMonitor) {
m_dLastFrametimes.push_back(std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - m_tpLastFrame).count() / 1000.f); m_dLastFrametimes.push_back(std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - m_tpLastFrame).count() / 1000.f);
if (m_dLastFrametimes.size() > (long unsigned int)pMonitor->refreshRate) if (m_dLastFrametimes.size() > (long unsigned int)pMonitor->refreshRate)
@ -39,7 +39,7 @@ void CHyprMonitorDebugOverlay::frameData(CMonitor* pMonitor) {
m_pMonitor = pMonitor; m_pMonitor = pMonitor;
// anim data too // anim data too
const auto PMONITORFORTICKS = g_pHyprRenderer->m_pMostHzMonitor ? g_pHyprRenderer->m_pMostHzMonitor : g_pCompositor->m_pLastMonitor.get(); const auto PMONITORFORTICKS = g_pHyprRenderer->m_pMostHzMonitor ? g_pHyprRenderer->m_pMostHzMonitor.lock() : g_pCompositor->m_pLastMonitor.lock();
if (PMONITORFORTICKS) { if (PMONITORFORTICKS) {
if (m_dLastAnimationTicks.size() > (long unsigned int)PMONITORFORTICKS->refreshRate) if (m_dLastAnimationTicks.size() > (long unsigned int)PMONITORFORTICKS->refreshRate)
m_dLastAnimationTicks.pop_front(); m_dLastAnimationTicks.pop_front();
@ -188,21 +188,21 @@ int CHyprMonitorDebugOverlay::draw(int offset) {
return posY - offset; return posY - offset;
} }
void CHyprDebugOverlay::renderData(CMonitor* pMonitor, float durationUs) { void CHyprDebugOverlay::renderData(PHLMONITOR pMonitor, float durationUs) {
m_mMonitorOverlays[pMonitor].renderData(pMonitor, durationUs); m_mMonitorOverlays[pMonitor].renderData(pMonitor, durationUs);
} }
void CHyprDebugOverlay::renderDataNoOverlay(CMonitor* pMonitor, float durationUs) { void CHyprDebugOverlay::renderDataNoOverlay(PHLMONITOR pMonitor, float durationUs) {
m_mMonitorOverlays[pMonitor].renderDataNoOverlay(pMonitor, durationUs); m_mMonitorOverlays[pMonitor].renderDataNoOverlay(pMonitor, durationUs);
} }
void CHyprDebugOverlay::frameData(CMonitor* pMonitor) { void CHyprDebugOverlay::frameData(PHLMONITOR pMonitor) {
m_mMonitorOverlays[pMonitor].frameData(pMonitor); m_mMonitorOverlays[pMonitor].frameData(pMonitor);
} }
void CHyprDebugOverlay::draw() { void CHyprDebugOverlay::draw() {
const auto PMONITOR = g_pCompositor->m_vMonitors.front().get(); const auto PMONITOR = g_pCompositor->m_vMonitors.front();
if (!m_pCairoSurface || !m_pCairo) { if (!m_pCairoSurface || !m_pCairo) {
m_pCairoSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y); m_pCairoSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y);
@ -218,7 +218,7 @@ void CHyprDebugOverlay::draw() {
// draw the things // draw the things
int offsetY = 0; int offsetY = 0;
for (auto const& m : g_pCompositor->m_vMonitors) { for (auto const& m : g_pCompositor->m_vMonitors) {
offsetY += m_mMonitorOverlays[m.get()].draw(offsetY); offsetY += m_mMonitorOverlays[m].draw(offsetY);
offsetY += 5; // for padding between mons offsetY += 5; // for padding between mons
} }

View file

@ -5,7 +5,7 @@
#include "../render/Texture.hpp" #include "../render/Texture.hpp"
#include <deque> #include <deque>
#include <cairo/cairo.h> #include <cairo/cairo.h>
#include <unordered_map> #include <map>
class CHyprRenderer; class CHyprRenderer;
@ -13,9 +13,9 @@ class CHyprMonitorDebugOverlay {
public: public:
int draw(int offset); int draw(int offset);
void renderData(CMonitor* pMonitor, float durationUs); void renderData(PHLMONITOR pMonitor, float durationUs);
void renderDataNoOverlay(CMonitor* pMonitor, float durationUs); void renderDataNoOverlay(PHLMONITOR pMonitor, float durationUs);
void frameData(CMonitor* pMonitor); void frameData(PHLMONITOR pMonitor);
private: private:
std::deque<float> m_dLastFrametimes; std::deque<float> m_dLastFrametimes;
@ -23,7 +23,7 @@ class CHyprMonitorDebugOverlay {
std::deque<float> m_dLastRenderTimesNoOverlay; std::deque<float> m_dLastRenderTimesNoOverlay;
std::deque<float> m_dLastAnimationTicks; std::deque<float> m_dLastAnimationTicks;
std::chrono::high_resolution_clock::time_point m_tpLastFrame; std::chrono::high_resolution_clock::time_point m_tpLastFrame;
CMonitor* m_pMonitor = nullptr; PHLMONITORREF m_pMonitor;
CBox m_wbLastDrawnBox; CBox m_wbLastDrawnBox;
friend class CHyprRenderer; friend class CHyprRenderer;
@ -33,12 +33,12 @@ class CHyprDebugOverlay {
public: public:
CHyprDebugOverlay(); CHyprDebugOverlay();
void draw(); void draw();
void renderData(CMonitor*, float durationUs); void renderData(PHLMONITOR, float durationUs);
void renderDataNoOverlay(CMonitor*, float durationUs); void renderDataNoOverlay(PHLMONITOR, float durationUs);
void frameData(CMonitor*); void frameData(PHLMONITOR);
private: private:
std::unordered_map<CMonitor*, CHyprMonitorDebugOverlay> m_mMonitorOverlays; std::map<PHLMONITOR, CHyprMonitorDebugOverlay> m_mMonitorOverlays;
cairo_surface_t* m_pCairoSurface = nullptr; cairo_surface_t* m_pCairoSurface = nullptr;
cairo_t* m_pCairo = nullptr; cairo_t* m_pCairo = nullptr;

View file

@ -45,7 +45,7 @@ void CHyprNotificationOverlay::addNotification(const std::string& text, const CC
PNOTIF->fontSize = fontSize; PNOTIF->fontSize = fontSize;
for (auto const& m : g_pCompositor->m_vMonitors) { for (auto const& m : g_pCompositor->m_vMonitors) {
g_pCompositor->scheduleFrameForMonitor(m.get()); g_pCompositor->scheduleFrameForMonitor(m);
} }
} }
@ -61,7 +61,7 @@ void CHyprNotificationOverlay::dismissNotifications(const int amount) {
} }
} }
CBox CHyprNotificationOverlay::drawNotifications(CMonitor* pMonitor) { CBox CHyprNotificationOverlay::drawNotifications(PHLMONITOR pMonitor) {
static constexpr auto ANIM_DURATION_MS = 600.0; static constexpr auto ANIM_DURATION_MS = 600.0;
static constexpr auto ANIM_LAG_MS = 100.0; static constexpr auto ANIM_LAG_MS = 100.0;
static constexpr auto NOTIF_LEFTBAR_SIZE = 5.0; static constexpr auto NOTIF_LEFTBAR_SIZE = 5.0;
@ -187,7 +187,7 @@ CBox CHyprNotificationOverlay::drawNotifications(CMonitor* pMonitor) {
return CBox{(int)(pMonitor->vecPosition.x + pMonitor->vecSize.x - maxWidth - 20), (int)pMonitor->vecPosition.y, (int)maxWidth + 20, (int)offsetY + 10}; return CBox{(int)(pMonitor->vecPosition.x + pMonitor->vecSize.x - maxWidth - 20), (int)pMonitor->vecPosition.y, (int)maxWidth + 20, (int)offsetY + 10};
} }
void CHyprNotificationOverlay::draw(CMonitor* pMonitor) { void CHyprNotificationOverlay::draw(PHLMONITOR pMonitor) {
const auto MONSIZE = pMonitor->vecTransformedSize; const auto MONSIZE = pMonitor->vecTransformedSize;

View file

@ -41,13 +41,13 @@ class CHyprNotificationOverlay {
CHyprNotificationOverlay(); CHyprNotificationOverlay();
~CHyprNotificationOverlay(); ~CHyprNotificationOverlay();
void draw(CMonitor* pMonitor); void draw(PHLMONITOR pMonitor);
void addNotification(const std::string& text, const CColor& color, const float timeMs, const eIcons icon = ICON_NONE, const float fontSize = 13.f); void addNotification(const std::string& text, const CColor& color, const float timeMs, const eIcons icon = ICON_NONE, const float fontSize = 13.f);
void dismissNotifications(const int amount); void dismissNotifications(const int amount);
bool hasAny(); bool hasAny();
private: private:
CBox drawNotifications(CMonitor* pMonitor); CBox drawNotifications(PHLMONITOR pMonitor);
CBox m_bLastDamage; CBox m_bLastDamage;
std::deque<std::unique_ptr<SNotification>> m_dNotifications; std::deque<std::unique_ptr<SNotification>> m_dNotifications;
@ -55,7 +55,7 @@ class CHyprNotificationOverlay {
cairo_surface_t* m_pCairoSurface = nullptr; cairo_surface_t* m_pCairoSurface = nullptr;
cairo_t* m_pCairo = nullptr; cairo_t* m_pCairo = nullptr;
CMonitor* m_pLastMonitor = nullptr; PHLMONITORREF m_pLastMonitor;
Vector2D m_vecLastSize = Vector2D(-1, -1); Vector2D m_vecLastSize = Vector2D(-1, -1);
SP<CTexture> m_pTexture; SP<CTexture> m_pTexture;

View file

@ -3,6 +3,7 @@
class CWorkspace; class CWorkspace;
class CWindow; class CWindow;
class CLayerSurface; class CLayerSurface;
class CMonitor;
/* Shared pointer to a workspace */ /* Shared pointer to a workspace */
typedef SP<CWorkspace> PHLWORKSPACE; typedef SP<CWorkspace> PHLWORKSPACE;
@ -18,3 +19,8 @@ typedef WP<CWindow> PHLWINDOWREF;
typedef SP<CLayerSurface> PHLLS; typedef SP<CLayerSurface> PHLLS;
/* Weak pointer to a layer surface */ /* Weak pointer to a layer surface */
typedef WP<CLayerSurface> PHLLSREF; typedef WP<CLayerSurface> PHLLSREF;
/* Shared pointer to a monitor */
typedef SP<CMonitor> PHLMONITOR;
/* Weak pointer to a monitor */
typedef WP<CMonitor> PHLMONITORREF;

View file

@ -8,7 +8,7 @@
PHLLS CLayerSurface::create(SP<CLayerShellResource> resource) { PHLLS CLayerSurface::create(SP<CLayerShellResource> resource) {
PHLLS pLS = SP<CLayerSurface>(new CLayerSurface(resource)); PHLLS pLS = SP<CLayerSurface>(new CLayerSurface(resource));
CMonitor* pMonitor = resource->monitor.empty() ? g_pCompositor->getMonitorFromCursor() : g_pCompositor->getMonitorFromName(resource->monitor); auto pMonitor = resource->monitor.empty() ? g_pCompositor->getMonitorFromCursor() : g_pCompositor->getMonitorFromName(resource->monitor);
pLS->surface->assign(resource->surface.lock(), pLS); pLS->surface->assign(resource->surface.lock(), pLS);
@ -18,7 +18,7 @@ PHLLS CLayerSurface::create(SP<CLayerShellResource> resource) {
} }
if (pMonitor->pMirrorOf) if (pMonitor->pMirrorOf)
pMonitor = g_pCompositor->m_vMonitors.front().get(); pMonitor = g_pCompositor->m_vMonitors.front();
pLS->self = pLS; pLS->self = pLS;

View file

@ -1188,7 +1188,7 @@ void CWindow::setSuspended(bool suspend) {
m_bSuspended = suspend; m_bSuspended = suspend;
} }
bool CWindow::visibleOnMonitor(CMonitor* pMonitor) { bool CWindow::visibleOnMonitor(PHLMONITOR pMonitor) {
CBox wbox = {m_vRealPosition.value(), m_vRealSize.value()}; CBox wbox = {m_vRealPosition.value(), m_vRealSize.value()};
return !wbox.intersection({pMonitor->vecPosition, pMonitor->vecSize}).empty(); return !wbox.intersection({pMonitor->vecPosition, pMonitor->vecSize}).empty();

View file

@ -424,7 +424,7 @@ class CWindow {
float rounding(); float rounding();
bool canBeTorn(); bool canBeTorn();
void setSuspended(bool suspend); void setSuspended(bool suspend);
bool visibleOnMonitor(CMonitor* pMonitor); bool visibleOnMonitor(PHLMONITOR pMonitor);
WORKSPACEID workspaceID(); WORKSPACEID workspaceID();
bool onSpecialWorkspace(); bool onSpecialWorkspace();
void activate(bool force = false); void activate(bool force = false);

View file

@ -24,12 +24,4 @@ namespace Events {
DYNLISTENFUNC(requestMaximize); DYNLISTENFUNC(requestMaximize);
DYNLISTENFUNC(setOverrideRedirect); DYNLISTENFUNC(setOverrideRedirect);
DYNLISTENFUNC(ackConfigure); DYNLISTENFUNC(ackConfigure);
// Monitor part 2 the sequel
DYNLISTENFUNC(monitorFrame);
DYNLISTENFUNC(monitorStateRequest);
DYNLISTENFUNC(monitorDamage);
DYNLISTENFUNC(monitorNeedsFrame);
DYNLISTENFUNC(monitorCommit);
DYNLISTENFUNC(monitorBind);
}; };

View file

@ -1,105 +0,0 @@
#include "../Compositor.hpp"
#include "../helpers/WLClasses.hpp"
#include "../managers/input/InputManager.hpp"
#include "../render/Renderer.hpp"
#include "Events.hpp"
#include "../debug/HyprCtl.hpp"
#include "../config/ConfigValue.hpp"
#include "../protocols/Screencopy.hpp"
#include "../protocols/ToplevelExport.hpp"
#include <aquamarine/output/Output.hpp>
// --------------------------------------------------------- //
// __ __ ____ _ _ _____ _______ ____ _____ _____ //
// | \/ |/ __ \| \ | |_ _|__ __/ __ \| __ \ / ____| //
// | \ / | | | | \| | | | | | | | | | |__) | (___ //
// | |\/| | | | | . ` | | | | | | | | | _ / \___ \ //
// | | | | |__| | |\ |_| |_ | | | |__| | | \ \ ____) | //
// |_| |_|\____/|_| \_|_____| |_| \____/|_| \_\_____/ //
// //
// --------------------------------------------------------- //
void Events::listener_monitorFrame(void* owner, void* data) {
CMonitor* const PMONITOR = (CMonitor*)owner;
if ((g_pCompositor->m_pAqBackend->hasSession() && !g_pCompositor->m_pAqBackend->session->active) || !g_pCompositor->m_bSessionActive || g_pCompositor->m_bUnsafeState) {
Debug::log(WARN, "Attempted to render frame on inactive session!");
if (g_pCompositor->m_bUnsafeState && std::ranges::any_of(g_pCompositor->m_vMonitors.begin(), g_pCompositor->m_vMonitors.end(), [&](auto& m) {
return m->output != g_pCompositor->m_pUnsafeOutput->output;
})) {
// restore from unsafe state
g_pCompositor->leaveUnsafeState();
}
return; // cannot draw on session inactive (different tty)
}
if (!PMONITOR->m_bEnabled)
return;
g_pHyprRenderer->recheckSolitaryForMonitor(PMONITOR);
PMONITOR->tearingState.busy = false;
if (PMONITOR->tearingState.activelyTearing && PMONITOR->solitaryClient.lock() /* can be invalidated by a recheck */) {
if (!PMONITOR->tearingState.frameScheduledWhileBusy)
return; // we did not schedule a frame yet to be displayed, but we are tearing. Why render?
PMONITOR->tearingState.nextRenderTorn = true;
PMONITOR->tearingState.frameScheduledWhileBusy = false;
}
static auto PENABLERAT = CConfigValue<Hyprlang::INT>("misc:render_ahead_of_time");
static auto PRATSAFE = CConfigValue<Hyprlang::INT>("misc:render_ahead_safezone");
PMONITOR->lastPresentationTimer.reset();
if (*PENABLERAT && !PMONITOR->tearingState.nextRenderTorn) {
if (!PMONITOR->RATScheduled) {
// render
g_pHyprRenderer->renderMonitor(PMONITOR);
}
PMONITOR->RATScheduled = false;
const auto& [avg, max, min] = g_pHyprRenderer->getRenderTimes(PMONITOR);
if (max + *PRATSAFE > 1000.0 / PMONITOR->refreshRate)
return;
const auto MSLEFT = 1000.0 / PMONITOR->refreshRate - PMONITOR->lastPresentationTimer.getMillis();
PMONITOR->RATScheduled = true;
const auto ESTRENDERTIME = std::ceil(avg + *PRATSAFE);
const auto TIMETOSLEEP = std::floor(MSLEFT - ESTRENDERTIME);
if (MSLEFT < 1 || MSLEFT < ESTRENDERTIME || TIMETOSLEEP < 1)
g_pHyprRenderer->renderMonitor(PMONITOR);
else
wl_event_source_timer_update(PMONITOR->renderTimer, TIMETOSLEEP);
} else {
g_pHyprRenderer->renderMonitor(PMONITOR);
}
}
void Events::listener_monitorNeedsFrame(void* owner, void* data) {
const auto PMONITOR = (CMonitor*)owner;
g_pCompositor->scheduleFrameForMonitor(PMONITOR, Aquamarine::IOutput::AQ_SCHEDULE_NEEDS_FRAME);
}
void Events::listener_monitorCommit(void* owner, void* data) {
const auto PMONITOR = (CMonitor*)owner;
if (true) { // FIXME: E->state->committed & WLR_OUTPUT_STATE_BUFFER
PROTO::screencopy->onOutputCommit(PMONITOR);
PROTO::toplevelExport->onOutputCommit(PMONITOR);
}
}
void Events::listener_monitorBind(void* owner, void* data) {
;
}

View file

@ -49,10 +49,10 @@ void Events::listener_mapWindow(void* owner, void* data) {
static auto PNEWTAKESOVERFS = CConfigValue<Hyprlang::INT>("misc:new_window_takes_over_fullscreen"); static auto PNEWTAKESOVERFS = CConfigValue<Hyprlang::INT>("misc:new_window_takes_over_fullscreen");
static auto PINITIALWSTRACKING = CConfigValue<Hyprlang::INT>("misc:initial_workspace_tracking"); static auto PINITIALWSTRACKING = CConfigValue<Hyprlang::INT>("misc:initial_workspace_tracking");
auto PMONITOR = g_pCompositor->m_pLastMonitor.get(); auto PMONITOR = g_pCompositor->m_pLastMonitor.lock();
if (!g_pCompositor->m_pLastMonitor) { if (!g_pCompositor->m_pLastMonitor) {
g_pCompositor->setActiveMonitor(g_pCompositor->getMonitorFromVector({})); g_pCompositor->setActiveMonitor(g_pCompositor->getMonitorFromVector({}));
PMONITOR = g_pCompositor->m_pLastMonitor.get(); PMONITOR = g_pCompositor->m_pLastMonitor.lock();
} }
auto PWORKSPACE = PMONITOR->activeSpecialWorkspace ? PMONITOR->activeSpecialWorkspace : PMONITOR->activeWorkspace; auto PWORKSPACE = PMONITOR->activeSpecialWorkspace ? PMONITOR->activeSpecialWorkspace : PMONITOR->activeWorkspace;
PWINDOW->m_iMonitorID = PMONITOR->ID; PWINDOW->m_iMonitorID = PMONITOR->ID;
@ -314,7 +314,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
else if (PMONITOR->activeWorkspaceID() != REQUESTEDWORKSPACEID) else if (PMONITOR->activeWorkspaceID() != REQUESTEDWORKSPACEID)
g_pKeybindManager->m_mDispatchers["workspace"](requestedWorkspaceName); g_pKeybindManager->m_mDispatchers["workspace"](requestedWorkspaceName);
PMONITOR = g_pCompositor->m_pLastMonitor.get(); PMONITOR = g_pCompositor->m_pLastMonitor.lock();
} }
} else } else
workspaceSilent = false; workspaceSilent = false;
@ -330,24 +330,38 @@ void Events::listener_mapWindow(void* owner, void* data) {
for (auto const& r : PWINDOW->m_vMatchedRules) { for (auto const& r : PWINDOW->m_vMatchedRules) {
if (r.szRule.starts_with("size")) { if (r.szRule.starts_with("size")) {
try { try {
auto stringToFloatClamp = [](const std::string& VALUE, const float CURR, const float REL) {
auto stringToPercentage = [](const std::string& VALUE, const float REL) {
if (VALUE.ends_with('%'))
return (std::stof(VALUE.substr(0, VALUE.length() - 1)) * REL) / 100;
else
return std::stof(VALUE);
};
if (VALUE.starts_with('<'))
return std::min(CURR, stringToPercentage(VALUE.substr(1, VALUE.length() - 1), REL));
else if (VALUE.starts_with('>'))
return std::max(CURR, stringToPercentage(VALUE.substr(1, VALUE.length() - 1), REL));
return stringToPercentage(VALUE, REL);
};
const auto VALUE = r.szRule.substr(r.szRule.find(' ') + 1); const auto VALUE = r.szRule.substr(r.szRule.find(' ') + 1);
const auto SIZEXSTR = VALUE.substr(0, VALUE.find(' ')); const auto SIZEXSTR = VALUE.substr(0, VALUE.find(' '));
const auto SIZEYSTR = VALUE.substr(VALUE.find(' ') + 1); const auto SIZEYSTR = VALUE.substr(VALUE.find(' ') + 1);
const auto MAXSIZE = g_pXWaylandManager->getMaxSizeForWindow(PWINDOW); const auto MAXSIZE = g_pXWaylandManager->getMaxSizeForWindow(PWINDOW);
const auto SIZEX = SIZEXSTR == "max" ? const float SIZEX =
std::clamp(MAXSIZE.x, 20.0, PMONITOR->vecSize.x) : SIZEXSTR == "max" ? std::clamp(MAXSIZE.x, 20.0, PMONITOR->vecSize.x) : stringToFloatClamp(SIZEXSTR, PWINDOW->m_vRealSize.goal().x, PMONITOR->vecSize.x);
(!SIZEXSTR.contains('%') ? std::stoi(SIZEXSTR) : std::stof(SIZEXSTR.substr(0, SIZEXSTR.length() - 1)) * 0.01 * PMONITOR->vecSize.x);
const auto SIZEY = SIZEYSTR == "max" ? const float SIZEY =
std::clamp(MAXSIZE.y, 20.0, PMONITOR->vecSize.y) : SIZEYSTR == "max" ? std::clamp(MAXSIZE.y, 20.0, PMONITOR->vecSize.y) : stringToFloatClamp(SIZEYSTR, PWINDOW->m_vRealSize.goal().y, PMONITOR->vecSize.y);
(!SIZEYSTR.contains('%') ? std::stoi(SIZEYSTR) : std::stof(SIZEYSTR.substr(0, SIZEYSTR.length() - 1)) * 0.01 * PMONITOR->vecSize.y);
Debug::log(LOG, "Rule size, applying to {}", PWINDOW); Debug::log(LOG, "Rule size, applying to {}", PWINDOW);
PWINDOW->m_vRealSize = Vector2D(SIZEX, SIZEY); PWINDOW->clampWindowSize(Vector2D{SIZEXSTR.starts_with("<") ? 0 : SIZEX, SIZEYSTR.starts_with("<") ? 0 : SIZEY}, Vector2D{SIZEX, SIZEY});
PWINDOW->m_vPseudoSize = PWINDOW->m_vRealSize.goal();
g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goal());
PWINDOW->setHidden(false); PWINDOW->setHidden(false);
} catch (...) { Debug::log(LOG, "Rule size failed, rule: {} -> {}", r.szRule, r.szValue); } } catch (...) { Debug::log(LOG, "Rule size failed, rule: {} -> {}", r.szRule, r.szValue); }
@ -761,7 +775,9 @@ void Events::listener_commitWindow(void* owner, void* data) {
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID); const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
if (PMONITOR)
PMONITOR->debugLastPresentation(g_pSeatManager->isPointerFrameCommit ? "listener_commitWindow skip" : "listener_commitWindow"); PMONITOR->debugLastPresentation(g_pSeatManager->isPointerFrameCommit ? "listener_commitWindow skip" : "listener_commitWindow");
if (g_pSeatManager->isPointerFrameCommit) { if (g_pSeatManager->isPointerFrameCommit) {
g_pSeatManager->isPointerFrameSkipped = false; g_pSeatManager->isPointerFrameSkipped = false;
g_pSeatManager->isPointerFrameCommit = false; g_pSeatManager->isPointerFrameCommit = false;

View file

@ -11,6 +11,8 @@
#include "../protocols/DRMLease.hpp" #include "../protocols/DRMLease.hpp"
#include "../protocols/DRMSyncobj.hpp" #include "../protocols/DRMSyncobj.hpp"
#include "../protocols/core/Output.hpp" #include "../protocols/core/Output.hpp"
#include "../protocols/Screencopy.hpp"
#include "../protocols/ToplevelExport.hpp"
#include "../managers/PointerManager.hpp" #include "../managers/PointerManager.hpp"
#include "../managers/eventLoop/EventLoopManager.hpp" #include "../managers/eventLoop/EventLoopManager.hpp"
#include "../protocols/core/Compositor.hpp" #include "../protocols/core/Compositor.hpp"
@ -23,7 +25,7 @@ using namespace Hyprutils::String;
using namespace Hyprutils::Utils; using namespace Hyprutils::Utils;
int ratHandler(void* data) { int ratHandler(void* data) {
g_pHyprRenderer->renderMonitor((CMonitor*)data); g_pHyprRenderer->renderMonitor(((CMonitor*)data)->self.lock());
return 1; return 1;
} }
@ -44,10 +46,15 @@ void CMonitor::onConnect(bool noRule) {
outTimeline = CSyncTimeline::create(output->getBackend()->drmFD()); outTimeline = CSyncTimeline::create(output->getBackend()->drmFD());
} }
listeners.frame = output->events.frame.registerListener([this](std::any d) { Events::listener_monitorFrame(this, nullptr); }); listeners.frame = output->events.frame.registerListener([this](std::any d) { onMonitorFrame(); });
listeners.commit = output->events.commit.registerListener([this](std::any d) { Events::listener_monitorCommit(this, nullptr); }); listeners.commit = output->events.commit.registerListener([this](std::any d) {
if (true) { // FIXME: E->state->committed & WLR_OUTPUT_STATE_BUFFER
PROTO::screencopy->onOutputCommit(self.lock());
PROTO::toplevelExport->onOutputCommit(self.lock());
}
});
listeners.needsFrame = listeners.needsFrame =
output->events.needsFrame.registerListener([this](std::any d) { g_pCompositor->scheduleFrameForMonitor(this, Aquamarine::IOutput::AQ_SCHEDULE_NEEDS_FRAME); }); output->events.needsFrame.registerListener([this](std::any d) { g_pCompositor->scheduleFrameForMonitor(self.lock(), Aquamarine::IOutput::AQ_SCHEDULE_NEEDS_FRAME); });
listeners.presented = output->events.present.registerListener([this](std::any d) { listeners.presented = output->events.present.registerListener([this](std::any d) {
auto E = std::any_cast<Aquamarine::IOutput::SPresentEvent>(d); auto E = std::any_cast<Aquamarine::IOutput::SPresentEvent>(d);
@ -77,7 +84,7 @@ void CMonitor::onConnect(bool noRule) {
return; return;
Debug::log(LOG, "Reapplying monitor rule for {} from a state request", szName); Debug::log(LOG, "Reapplying monitor rule for {} from a state request", szName);
g_pHyprRenderer->applyMonitorRule(this, &activeMonitorRule, true); g_pHyprRenderer->applyMonitorRule(self.lock(), &activeMonitorRule, true);
return; return;
} }
@ -91,7 +98,7 @@ void CMonitor::onConnect(bool noRule) {
SMonitorRule rule = activeMonitorRule; SMonitorRule rule = activeMonitorRule;
rule.resolution = SIZE; rule.resolution = SIZE;
g_pHyprRenderer->applyMonitorRule(this, &rule); g_pHyprRenderer->applyMonitorRule(self.lock(), &rule);
}); });
tearingState.canTear = output->getBackend()->type() == Aquamarine::AQ_BACKEND_DRM; tearingState.canTear = output->getBackend()->type() == Aquamarine::AQ_BACKEND_DRM;
@ -164,7 +171,7 @@ void CMonitor::onConnect(bool noRule) {
// set mode, also applies // set mode, also applies
if (!noRule) if (!noRule)
g_pHyprRenderer->applyMonitorRule(this, &monitorRule, true); g_pHyprRenderer->applyMonitorRule(self.lock(), &monitorRule, true);
if (!state.commit()) if (!state.commit())
Debug::log(WARN, "state.commit() failed in CMonitor::onCommit"); Debug::log(WARN, "state.commit() failed in CMonitor::onCommit");
@ -180,7 +187,7 @@ void CMonitor::onConnect(bool noRule) {
continue; continue;
if (ws->m_szLastMonitor == szName || g_pCompositor->m_vMonitors.size() == 1 /* avoid lost workspaces on recover */) { if (ws->m_szLastMonitor == szName || g_pCompositor->m_vMonitors.size() == 1 /* avoid lost workspaces on recover */) {
g_pCompositor->moveWorkspaceToMonitor(ws, this); g_pCompositor->moveWorkspaceToMonitor(ws, self.lock());
ws->startAnim(true, true, true); ws->startAnim(true, true, true);
ws->m_szLastMonitor = ""; ws->m_szLastMonitor = "";
} }
@ -197,13 +204,13 @@ void CMonitor::onConnect(bool noRule) {
setMirror(activeMonitorRule.mirrorOf); setMirror(activeMonitorRule.mirrorOf);
if (!g_pCompositor->m_pLastMonitor) // set the last monitor if it isnt set yet if (!g_pCompositor->m_pLastMonitor) // set the last monitor if it isnt set yet
g_pCompositor->setActiveMonitor(this); g_pCompositor->setActiveMonitor(self.lock());
g_pHyprRenderer->arrangeLayersForMonitor(ID); g_pHyprRenderer->arrangeLayersForMonitor(ID);
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID);
// ensure VRR (will enable if necessary) // ensure VRR (will enable if necessary)
g_pConfigManager->ensureVRR(this); g_pConfigManager->ensureVRR(self.lock());
// verify last mon valid // verify last mon valid
bool found = false; bool found = false;
@ -215,19 +222,19 @@ void CMonitor::onConnect(bool noRule) {
} }
if (!found) if (!found)
g_pCompositor->setActiveMonitor(this); g_pCompositor->setActiveMonitor(self.lock());
renderTimer = wl_event_loop_add_timer(g_pCompositor->m_sWLEventLoop, ratHandler, this); renderTimer = wl_event_loop_add_timer(g_pCompositor->m_sWLEventLoop, ratHandler, this);
g_pCompositor->scheduleFrameForMonitor(this, Aquamarine::IOutput::AQ_SCHEDULE_NEW_MONITOR); g_pCompositor->scheduleFrameForMonitor(self.lock(), Aquamarine::IOutput::AQ_SCHEDULE_NEW_MONITOR);
PROTO::gamma->applyGammaToState(this); PROTO::gamma->applyGammaToState(self.lock());
events.connect.emit(); events.connect.emit();
g_pEventManager->postEvent(SHyprIPCEvent{"monitoradded", szName}); g_pEventManager->postEvent(SHyprIPCEvent{"monitoradded", szName});
g_pEventManager->postEvent(SHyprIPCEvent{"monitoraddedv2", std::format("{},{},{}", ID, szName, szShortDescription)}); g_pEventManager->postEvent(SHyprIPCEvent{"monitoraddedv2", std::format("{},{},{}", ID, szName, szShortDescription)});
EMIT_HOOK_EVENT("monitorAdded", this); EMIT_HOOK_EVENT("monitorAdded", self.lock());
} }
void CMonitor::onDisconnect(bool destroy) { void CMonitor::onDisconnect(bool destroy) {
@ -235,7 +242,7 @@ void CMonitor::onDisconnect(bool destroy) {
if (g_pCompositor->m_bIsShuttingDown) if (g_pCompositor->m_bIsShuttingDown)
return; return;
g_pEventManager->postEvent(SHyprIPCEvent{"monitorremoved", szName}); g_pEventManager->postEvent(SHyprIPCEvent{"monitorremoved", szName});
EMIT_HOOK_EVENT("monitorRemoved", this); EMIT_HOOK_EVENT("monitorRemoved", self.lock());
g_pCompositor->arrangeMonitors(); g_pCompositor->arrangeMonitors();
}}; }};
@ -252,21 +259,21 @@ void CMonitor::onDisconnect(bool destroy) {
events.disconnect.emit(); events.disconnect.emit();
// Cleanup everything. Move windows back, snap cursor, shit. // Cleanup everything. Move windows back, snap cursor, shit.
CMonitor* BACKUPMON = nullptr; PHLMONITOR BACKUPMON = nullptr;
for (auto const& m : g_pCompositor->m_vMonitors) { for (auto const& m : g_pCompositor->m_vMonitors) {
if (m.get() != this) { if (m.get() != this) {
BACKUPMON = m.get(); BACKUPMON = m;
break; break;
} }
} }
// remove mirror // remove mirror
if (pMirrorOf) { if (pMirrorOf) {
pMirrorOf->mirrors.erase(std::find_if(pMirrorOf->mirrors.begin(), pMirrorOf->mirrors.end(), [&](const auto& other) { return other == this; })); pMirrorOf->mirrors.erase(std::find_if(pMirrorOf->mirrors.begin(), pMirrorOf->mirrors.end(), [&](const auto& other) { return other == self; }));
// unlock software for mirrored monitor // unlock software for mirrored monitor
g_pPointerManager->unlockSoftwareForMonitor(pMirrorOf); g_pPointerManager->unlockSoftwareForMonitor(pMirrorOf.lock());
pMirrorOf = nullptr; pMirrorOf.reset();
} }
if (!mirrors.empty()) { if (!mirrors.empty()) {
@ -333,16 +340,16 @@ void CMonitor::onDisconnect(bool destroy) {
if (!state.commit()) if (!state.commit())
Debug::log(WARN, "state.commit() failed in CMonitor::onDisconnect"); Debug::log(WARN, "state.commit() failed in CMonitor::onDisconnect");
if (g_pCompositor->m_pLastMonitor.get() == this) if (g_pCompositor->m_pLastMonitor == self)
g_pCompositor->setActiveMonitor(BACKUPMON ? BACKUPMON : g_pCompositor->m_pUnsafeOutput); g_pCompositor->setActiveMonitor(BACKUPMON ? BACKUPMON : g_pCompositor->m_pUnsafeOutput.lock());
if (g_pHyprRenderer->m_pMostHzMonitor == this) { if (g_pHyprRenderer->m_pMostHzMonitor == self) {
int mostHz = 0; int mostHz = 0;
CMonitor* pMonitorMostHz = nullptr; PHLMONITOR pMonitorMostHz = nullptr;
for (auto const& m : g_pCompositor->m_vMonitors) { for (auto const& m : g_pCompositor->m_vMonitors) {
if (m->refreshRate > mostHz && m.get() != this) { if (m->refreshRate > mostHz && m != self) {
pMonitorMostHz = m.get(); pMonitorMostHz = m;
mostHz = m->refreshRate; mostHz = m->refreshRate;
} }
} }
@ -354,11 +361,11 @@ void CMonitor::onDisconnect(bool destroy) {
void CMonitor::addDamage(const pixman_region32_t* rg) { void CMonitor::addDamage(const pixman_region32_t* rg) {
static auto PZOOMFACTOR = CConfigValue<Hyprlang::FLOAT>("cursor:zoom_factor"); static auto PZOOMFACTOR = CConfigValue<Hyprlang::FLOAT>("cursor:zoom_factor");
if (*PZOOMFACTOR != 1.f && g_pCompositor->getMonitorFromCursor() == this) { if (*PZOOMFACTOR != 1.f && g_pCompositor->getMonitorFromCursor() == self) {
damage.damageEntire(); damage.damageEntire();
g_pCompositor->scheduleFrameForMonitor(this, Aquamarine::IOutput::AQ_SCHEDULE_DAMAGE); g_pCompositor->scheduleFrameForMonitor(self.lock(), Aquamarine::IOutput::AQ_SCHEDULE_DAMAGE);
} else if (damage.damage(rg)) } else if (damage.damage(rg))
g_pCompositor->scheduleFrameForMonitor(this, Aquamarine::IOutput::AQ_SCHEDULE_DAMAGE); g_pCompositor->scheduleFrameForMonitor(self.lock(), Aquamarine::IOutput::AQ_SCHEDULE_DAMAGE);
} }
void CMonitor::addDamage(const CRegion* rg) { void CMonitor::addDamage(const CRegion* rg) {
@ -367,13 +374,13 @@ void CMonitor::addDamage(const CRegion* rg) {
void CMonitor::addDamage(const CBox* box) { void CMonitor::addDamage(const CBox* box) {
static auto PZOOMFACTOR = CConfigValue<Hyprlang::FLOAT>("cursor:zoom_factor"); static auto PZOOMFACTOR = CConfigValue<Hyprlang::FLOAT>("cursor:zoom_factor");
if (*PZOOMFACTOR != 1.f && g_pCompositor->getMonitorFromCursor() == this) { if (*PZOOMFACTOR != 1.f && g_pCompositor->getMonitorFromCursor() == self) {
damage.damageEntire(); damage.damageEntire();
g_pCompositor->scheduleFrameForMonitor(this, Aquamarine::IOutput::AQ_SCHEDULE_DAMAGE); g_pCompositor->scheduleFrameForMonitor(self.lock(), Aquamarine::IOutput::AQ_SCHEDULE_DAMAGE);
} }
if (damage.damage(*box)) if (damage.damage(*box))
g_pCompositor->scheduleFrameForMonitor(this, Aquamarine::IOutput::AQ_SCHEDULE_DAMAGE); g_pCompositor->scheduleFrameForMonitor(self.lock(), Aquamarine::IOutput::AQ_SCHEDULE_DAMAGE);
} }
bool CMonitor::shouldSkipScheduleFrameOnMouseEvent() { bool CMonitor::shouldSkipScheduleFrameOnMouseEvent() {
@ -449,7 +456,7 @@ void CMonitor::setupDefaultWS(const SMonitorRule& monitorRule) {
if (PNEWWORKSPACE) { if (PNEWWORKSPACE) {
// workspace exists, move it to the newly connected monitor // workspace exists, move it to the newly connected monitor
g_pCompositor->moveWorkspaceToMonitor(PNEWWORKSPACE, this); g_pCompositor->moveWorkspaceToMonitor(PNEWWORKSPACE, self.lock());
activeWorkspace = PNEWWORKSPACE; activeWorkspace = PNEWWORKSPACE;
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID); g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID);
PNEWWORKSPACE->startAnim(true, true, true); PNEWWORKSPACE->startAnim(true, true, true);
@ -478,7 +485,7 @@ void CMonitor::setMirror(const std::string& mirrorOf) {
return; return;
} }
if (PMIRRORMON == this) { if (PMIRRORMON == self) {
Debug::log(ERR, "Cannot mirror self!"); Debug::log(ERR, "Cannot mirror self!");
return; return;
} }
@ -487,13 +494,13 @@ void CMonitor::setMirror(const std::string& mirrorOf) {
// disable mirroring // disable mirroring
if (pMirrorOf) { if (pMirrorOf) {
pMirrorOf->mirrors.erase(std::find_if(pMirrorOf->mirrors.begin(), pMirrorOf->mirrors.end(), [&](const auto& other) { return other == this; })); pMirrorOf->mirrors.erase(std::find_if(pMirrorOf->mirrors.begin(), pMirrorOf->mirrors.end(), [&](const auto& other) { return other == self; }));
// unlock software for mirrored monitor // unlock software for mirrored monitor
g_pPointerManager->unlockSoftwareForMonitor(pMirrorOf); g_pPointerManager->unlockSoftwareForMonitor(pMirrorOf.lock());
} }
pMirrorOf = nullptr; pMirrorOf.reset();
// set rule // set rule
const auto RULE = g_pConfigManager->getMonitorRuleFor(self.lock()); const auto RULE = g_pConfigManager->getMonitorRuleFor(self.lock());
@ -521,12 +528,12 @@ void CMonitor::setMirror(const std::string& mirrorOf) {
setupDefaultWS(RULE); setupDefaultWS(RULE);
g_pHyprRenderer->applyMonitorRule(this, (SMonitorRule*)&RULE, true); // will apply the offset and stuff g_pHyprRenderer->applyMonitorRule(self.lock(), (SMonitorRule*)&RULE, true); // will apply the offset and stuff
} else { } else {
CMonitor* BACKUPMON = nullptr; PHLMONITOR BACKUPMON = nullptr;
for (auto const& m : g_pCompositor->m_vMonitors) { for (auto const& m : g_pCompositor->m_vMonitors) {
if (m.get() != this) { if (m.get() != this) {
BACKUPMON = m.get(); BACKUPMON = m;
break; break;
} }
} }
@ -550,14 +557,14 @@ void CMonitor::setMirror(const std::string& mirrorOf) {
pMirrorOf = PMIRRORMON; pMirrorOf = PMIRRORMON;
pMirrorOf->mirrors.push_back(this); pMirrorOf->mirrors.push_back(self);
// remove from mvmonitors // remove from mvmonitors
std::erase_if(g_pCompositor->m_vMonitors, [&](const auto& other) { return other.get() == this; }); std::erase_if(g_pCompositor->m_vMonitors, [&](const auto& other) { return other == self; });
g_pCompositor->arrangeMonitors(); g_pCompositor->arrangeMonitors();
g_pCompositor->setActiveMonitor(g_pCompositor->m_vMonitors.front().get()); g_pCompositor->setActiveMonitor(g_pCompositor->m_vMonitors.front());
g_pCompositor->sanityCheckWorkspaces(); g_pCompositor->sanityCheckWorkspaces();
@ -647,11 +654,11 @@ void CMonitor::changeWorkspace(const PHLWORKSPACE& pWorkspace, bool internal, bo
EMIT_HOOK_EVENT("workspace", pWorkspace); EMIT_HOOK_EVENT("workspace", pWorkspace);
} }
g_pHyprRenderer->damageMonitor(this); g_pHyprRenderer->damageMonitor(self.lock());
g_pCompositor->updateFullscreenFadeOnWorkspace(pWorkspace); g_pCompositor->updateFullscreenFadeOnWorkspace(pWorkspace);
g_pConfigManager->ensureVRR(this); g_pConfigManager->ensureVRR(self.lock());
g_pCompositor->updateSuspendedStates(); g_pCompositor->updateSuspendedStates();
@ -667,7 +674,7 @@ void CMonitor::setSpecialWorkspace(const PHLWORKSPACE& pWorkspace) {
if (activeSpecialWorkspace == pWorkspace) if (activeSpecialWorkspace == pWorkspace)
return; return;
g_pHyprRenderer->damageMonitor(this); g_pHyprRenderer->damageMonitor(self.lock());
if (!pWorkspace) { if (!pWorkspace) {
// remove special if exists // remove special if exists
@ -689,7 +696,7 @@ void CMonitor::setSpecialWorkspace(const PHLWORKSPACE& pWorkspace) {
g_pCompositor->updateFullscreenFadeOnWorkspace(activeWorkspace); g_pCompositor->updateFullscreenFadeOnWorkspace(activeWorkspace);
g_pConfigManager->ensureVRR(this); g_pConfigManager->ensureVRR(self.lock());
g_pCompositor->updateSuspendedStates(); g_pCompositor->updateSuspendedStates();
@ -757,11 +764,11 @@ void CMonitor::setSpecialWorkspace(const PHLWORKSPACE& pWorkspace) {
g_pEventManager->postEvent(SHyprIPCEvent{"activespecial", pWorkspace->m_szName + "," + szName}); g_pEventManager->postEvent(SHyprIPCEvent{"activespecial", pWorkspace->m_szName + "," + szName});
g_pHyprRenderer->damageMonitor(this); g_pHyprRenderer->damageMonitor(self.lock());
g_pCompositor->updateFullscreenFadeOnWorkspace(pWorkspace); g_pCompositor->updateFullscreenFadeOnWorkspace(pWorkspace);
g_pConfigManager->ensureVRR(this); g_pConfigManager->ensureVRR(self.lock());
g_pCompositor->updateSuspendedStates(); g_pCompositor->updateSuspendedStates();
} }
@ -817,7 +824,7 @@ void CMonitor::scheduleDone() {
void CMonitor::setCTM(const Mat3x3& ctm_) { void CMonitor::setCTM(const Mat3x3& ctm_) {
ctm = ctm_; ctm = ctm_;
ctmUpdated = true; ctmUpdated = true;
g_pCompositor->scheduleFrameForMonitor(this, Aquamarine::IOutput::scheduleFrameReason::AQ_SCHEDULE_NEEDS_FRAME); g_pCompositor->scheduleFrameForMonitor(self.lock(), Aquamarine::IOutput::scheduleFrameReason::AQ_SCHEDULE_NEEDS_FRAME);
} }
bool CMonitor::attemptDirectScanout() { bool CMonitor::attemptDirectScanout() {
@ -838,7 +845,7 @@ bool CMonitor::attemptDirectScanout() {
return false; return false;
// we can't scanout shm buffers. // we can't scanout shm buffers.
if (!PSURFACE->current.buffer || !PSURFACE->current.texture || !PSURFACE->current.texture->m_pEglImage /* dmabuf */) if (!PSURFACE->current.buffer || !PSURFACE->current.buffer->buffer || !PSURFACE->current.texture || !PSURFACE->current.texture->m_pEglImage /* dmabuf */)
return false; return false;
Debug::log(TRACE, "attemptDirectScanout: surface {:x} passed, will attempt", (uintptr_t)PSURFACE.get()); Debug::log(TRACE, "attemptDirectScanout: surface {:x} passed, will attempt", (uintptr_t)PSURFACE.get());
@ -939,6 +946,69 @@ void CMonitor::debugLastPresentation(const std::string& message) {
lastPresentationTimer.getMillis() > 0 ? 1000.0f / lastPresentationTimer.getMillis() : 0.0f); lastPresentationTimer.getMillis() > 0 ? 1000.0f / lastPresentationTimer.getMillis() : 0.0f);
} }
void CMonitor::onMonitorFrame() {
if ((g_pCompositor->m_pAqBackend->hasSession() && !g_pCompositor->m_pAqBackend->session->active) || !g_pCompositor->m_bSessionActive || g_pCompositor->m_bUnsafeState) {
Debug::log(WARN, "Attempted to render frame on inactive session!");
if (g_pCompositor->m_bUnsafeState && std::ranges::any_of(g_pCompositor->m_vMonitors.begin(), g_pCompositor->m_vMonitors.end(), [&](auto& m) {
return m->output != g_pCompositor->m_pUnsafeOutput->output;
})) {
// restore from unsafe state
g_pCompositor->leaveUnsafeState();
}
return; // cannot draw on session inactive (different tty)
}
if (!m_bEnabled)
return;
g_pHyprRenderer->recheckSolitaryForMonitor(self.lock());
tearingState.busy = false;
if (tearingState.activelyTearing && solitaryClient.lock() /* can be invalidated by a recheck */) {
if (!tearingState.frameScheduledWhileBusy)
return; // we did not schedule a frame yet to be displayed, but we are tearing. Why render?
tearingState.nextRenderTorn = true;
tearingState.frameScheduledWhileBusy = false;
}
static auto PENABLERAT = CConfigValue<Hyprlang::INT>("misc:render_ahead_of_time");
static auto PRATSAFE = CConfigValue<Hyprlang::INT>("misc:render_ahead_safezone");
lastPresentationTimer.reset();
if (*PENABLERAT && !tearingState.nextRenderTorn) {
if (!RATScheduled) {
// render
g_pHyprRenderer->renderMonitor(self.lock());
}
RATScheduled = false;
const auto& [avg, max, min] = g_pHyprRenderer->getRenderTimes(self.lock());
if (max + *PRATSAFE > 1000.0 / refreshRate)
return;
const auto MSLEFT = 1000.0 / refreshRate - lastPresentationTimer.getMillis();
RATScheduled = true;
const auto ESTRENDERTIME = std::ceil(avg + *PRATSAFE);
const auto TIMETOSLEEP = std::floor(MSLEFT - ESTRENDERTIME);
if (MSLEFT < 1 || MSLEFT < ESTRENDERTIME || TIMETOSLEEP < 1)
g_pHyprRenderer->renderMonitor(self.lock());
else
wl_event_source_timer_update(renderTimer, TIMETOSLEEP);
} else
g_pHyprRenderer->renderMonitor(self.lock());
}
CMonitorState::CMonitorState(CMonitor* owner) { CMonitorState::CMonitorState(CMonitor* owner) {
m_pOwner = owner; m_pOwner = owner;
} }
@ -970,7 +1040,7 @@ bool CMonitorState::commit() {
if (!updateSwapchain()) if (!updateSwapchain())
return false; return false;
EMIT_HOOK_EVENT("preMonitorCommit", m_pOwner); EMIT_HOOK_EVENT("preMonitorCommit", m_pOwner->self.lock());
ensureBufferPresent(); ensureBufferPresent();

View file

@ -54,7 +54,7 @@ class CMonitorState {
private: private:
void ensureBufferPresent(); void ensureBufferPresent();
CMonitor* m_pOwner; CMonitor* m_pOwner = nullptr;
}; };
class CMonitor { class CMonitor {
@ -128,8 +128,8 @@ class CMonitor {
WP<CMonitor> self; WP<CMonitor> self;
// mirroring // mirroring
CMonitor* pMirrorOf = nullptr; PHLMONITORREF pMirrorOf;
std::vector<CMonitor*> mirrors; std::vector<PHLMONITORREF> mirrors;
// ctm // ctm
Mat3x3 ctm = Mat3x3::identity(); Mat3x3 ctm = Mat3x3::identity();
@ -186,6 +186,7 @@ class CMonitor {
void setCTM(const Mat3x3& ctm); void setCTM(const Mat3x3& ctm);
void debugLastPresentation(const std::string& message); void debugLastPresentation(const std::string& message);
void onMonitorFrame();
bool m_bEnabled = false; bool m_bEnabled = false;
bool m_bRenderingInitPassed = false; bool m_bRenderingInitPassed = false;

View file

@ -18,7 +18,7 @@ class CWLSurfaceResource;
AQUAMARINE_FORWARD(ISwitch); AQUAMARINE_FORWARD(ISwitch);
struct SRenderData { struct SRenderData {
CMonitor* pMonitor; PHLMONITORREF pMonitor;
timespec* when; timespec* when;
double x, y; double x, y;
@ -68,7 +68,7 @@ struct SSwipeGesture {
int speedPoints = 0; int speedPoints = 0;
int touch_id = 0; int touch_id = 0;
CMonitor* pMonitor = nullptr; PHLMONITORREF pMonitor;
}; };
struct SSwitchDevice { struct SSwitchDevice {

View file

@ -14,7 +14,7 @@ CHyprError::CHyprError() {
if (!m_bIsCreated) if (!m_bIsCreated)
return; return;
g_pHyprRenderer->damageMonitor(g_pCompositor->m_pLastMonitor.get()); g_pHyprRenderer->damageMonitor(g_pCompositor->m_pLastMonitor.lock());
m_bMonitorChanged = true; m_bMonitorChanged = true;
}); });
@ -47,7 +47,7 @@ void CHyprError::createQueued() {
m_fFadeOpacity.setValueAndWarp(0.f); m_fFadeOpacity.setValueAndWarp(0.f);
m_fFadeOpacity = 1.f; m_fFadeOpacity = 1.f;
const auto PMONITOR = g_pCompositor->m_vMonitors.front().get(); const auto PMONITOR = g_pCompositor->m_vMonitors.front();
const auto SCALE = PMONITOR->scale; const auto SCALE = PMONITOR->scale;

View file

@ -101,18 +101,17 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
if (pNode->isNode) if (pNode->isNode)
return; return;
CMonitor* PMONITOR = nullptr; PHLMONITOR PMONITOR = nullptr;
if (g_pCompositor->isWorkspaceSpecial(pNode->workspaceID)) { if (g_pCompositor->isWorkspaceSpecial(pNode->workspaceID)) {
for (auto const& m : g_pCompositor->m_vMonitors) { for (auto const& m : g_pCompositor->m_vMonitors) {
if (m->activeSpecialWorkspaceID() == pNode->workspaceID) { if (m->activeSpecialWorkspaceID() == pNode->workspaceID) {
PMONITOR = m.get(); PMONITOR = m;
break; break;
} }
} }
} else { } else
PMONITOR = g_pCompositor->getMonitorFromID(g_pCompositor->getWorkspaceByID(pNode->workspaceID)->m_iMonitorID); PMONITOR = g_pCompositor->getMonitorFromID(g_pCompositor->getWorkspaceByID(pNode->workspaceID)->m_iMonitorID);
}
if (!PMONITOR) { if (!PMONITOR) {
Debug::log(ERR, "Orphaned Node {}!!", pNode); Debug::log(ERR, "Orphaned Node {}!!", pNode);

View file

@ -594,18 +594,17 @@ void CHyprMasterLayout::calculateWorkspace(PHLWORKSPACE pWorkspace) {
} }
void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) { void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
CMonitor* PMONITOR = nullptr; PHLMONITOR PMONITOR = nullptr;
if (g_pCompositor->isWorkspaceSpecial(pNode->workspaceID)) { if (g_pCompositor->isWorkspaceSpecial(pNode->workspaceID)) {
for (auto const& m : g_pCompositor->m_vMonitors) { for (auto const& m : g_pCompositor->m_vMonitors) {
if (m->activeSpecialWorkspaceID() == pNode->workspaceID) { if (m->activeSpecialWorkspaceID() == pNode->workspaceID) {
PMONITOR = m.get(); PMONITOR = m;
break; break;
} }
} }
} else { } else
PMONITOR = g_pCompositor->getMonitorFromID(g_pCompositor->getWorkspaceByID(pNode->workspaceID)->m_iMonitorID); PMONITOR = g_pCompositor->getMonitorFromID(g_pCompositor->getWorkspaceByID(pNode->workspaceID)->m_iMonitorID);
}
if (!PMONITOR) { if (!PMONITOR) {
Debug::log(ERR, "Orphaned Node {}!!", pNode); Debug::log(ERR, "Orphaned Node {}!!", pNode);

View file

@ -85,7 +85,7 @@ void CAnimationManager::tick() {
PHLWINDOW PWINDOW = av->m_pWindow.lock(); PHLWINDOW PWINDOW = av->m_pWindow.lock();
PHLWORKSPACE PWORKSPACE = av->m_pWorkspace.lock(); PHLWORKSPACE PWORKSPACE = av->m_pWorkspace.lock();
PHLLS PLAYER = av->m_pLayer.lock(); PHLLS PLAYER = av->m_pLayer.lock();
CMonitor* PMONITOR = nullptr; PHLMONITOR PMONITOR = nullptr;
bool animationsDisabled = animGlobalDisabled; bool animationsDisabled = animGlobalDisabled;
if (PWINDOW) { if (PWINDOW) {

View file

@ -309,7 +309,7 @@ void CCursorManager::updateTheme() {
for (auto const& m : g_pCompositor->m_vMonitors) { for (auto const& m : g_pCompositor->m_vMonitors) {
m->forceFullFrames = 5; m->forceFullFrames = 5;
g_pCompositor->scheduleFrameForMonitor(m.get(), Aquamarine::IOutput::AQ_SCHEDULE_CURSOR_SHAPE); g_pCompositor->scheduleFrameForMonitor(m, Aquamarine::IOutput::AQ_SCHEDULE_CURSOR_SHAPE);
} }
} }

View file

@ -271,11 +271,11 @@ void updateRelativeCursorCoords() {
g_pCompositor->m_pLastWindow->m_vRelativeCursorCoordsOnLastWarp = g_pInputManager->getMouseCoordsInternal() - g_pCompositor->m_pLastWindow->m_vPosition; g_pCompositor->m_pLastWindow->m_vRelativeCursorCoordsOnLastWarp = g_pInputManager->getMouseCoordsInternal() - g_pCompositor->m_pLastWindow->m_vPosition;
} }
bool CKeybindManager::tryMoveFocusToMonitor(CMonitor* monitor) { bool CKeybindManager::tryMoveFocusToMonitor(PHLMONITOR monitor) {
if (!monitor) if (!monitor)
return false; return false;
const auto LASTMONITOR = g_pCompositor->m_pLastMonitor.get(); const auto LASTMONITOR = g_pCompositor->m_pLastMonitor.lock();
if (!LASTMONITOR) if (!LASTMONITOR)
return false; return false;
if (LASTMONITOR == monitor) { if (LASTMONITOR == monitor) {
@ -1096,7 +1096,7 @@ SDispatchResult CKeybindManager::changeworkspace(std::string args) {
static auto PALLOWWORKSPACECYCLES = CConfigValue<Hyprlang::INT>("binds:allow_workspace_cycles"); static auto PALLOWWORKSPACECYCLES = CConfigValue<Hyprlang::INT>("binds:allow_workspace_cycles");
static auto PWORKSPACECENTERON = CConfigValue<Hyprlang::INT>("binds:workspace_center_on"); static auto PWORKSPACECENTERON = CConfigValue<Hyprlang::INT>("binds:workspace_center_on");
const auto PMONITOR = g_pCompositor->m_pLastMonitor.get(); const auto PMONITOR = g_pCompositor->m_pLastMonitor.lock();
if (!PMONITOR) if (!PMONITOR)
return {.success = false, .error = "Last monitor not found"}; return {.success = false, .error = "Last monitor not found"};
@ -1260,7 +1260,7 @@ SDispatchResult CKeybindManager::moveActiveToWorkspace(std::string args) {
} }
auto pWorkspace = g_pCompositor->getWorkspaceByID(WORKSPACEID); auto pWorkspace = g_pCompositor->getWorkspaceByID(WORKSPACEID);
CMonitor* pMonitor = nullptr; PHLMONITOR pMonitor = nullptr;
const auto POLDWS = PWINDOW->m_pWorkspace; const auto POLDWS = PWINDOW->m_pWorkspace;
static auto PALLOWWORKSPACECYCLES = CConfigValue<Hyprlang::INT>("binds:allow_workspace_cycles"); static auto PALLOWWORKSPACECYCLES = CConfigValue<Hyprlang::INT>("binds:allow_workspace_cycles");
@ -1795,7 +1795,7 @@ SDispatchResult CKeybindManager::exitHyprland(std::string argz) {
} }
SDispatchResult CKeybindManager::moveCurrentWorkspaceToMonitor(std::string args) { SDispatchResult CKeybindManager::moveCurrentWorkspaceToMonitor(std::string args) {
CMonitor* PMONITOR = g_pCompositor->getMonitorFromString(args); PHLMONITOR PMONITOR = g_pCompositor->getMonitorFromString(args);
if (!PMONITOR) { if (!PMONITOR) {
Debug::log(ERR, "Ignoring moveCurrentWorkspaceToMonitor: monitor doesnt exist"); Debug::log(ERR, "Ignoring moveCurrentWorkspaceToMonitor: monitor doesnt exist");
@ -1854,7 +1854,7 @@ SDispatchResult CKeybindManager::focusWorkspaceOnCurrentMonitor(std::string args
return {.success = false, .error = "focusWorkspaceOnCurrentMonitor invalid workspace!"}; return {.success = false, .error = "focusWorkspaceOnCurrentMonitor invalid workspace!"};
} }
const auto PCURRMONITOR = g_pCompositor->m_pLastMonitor.get(); const auto PCURRMONITOR = g_pCompositor->m_pLastMonitor.lock();
if (!PCURRMONITOR) { if (!PCURRMONITOR) {
Debug::log(ERR, "focusWorkspaceOnCurrentMonitor monitor doesn't exist!"); Debug::log(ERR, "focusWorkspaceOnCurrentMonitor monitor doesn't exist!");
@ -1944,7 +1944,7 @@ SDispatchResult CKeybindManager::forceRendererReload(std::string args) {
continue; continue;
auto rule = g_pConfigManager->getMonitorRuleFor(m); auto rule = g_pConfigManager->getMonitorRuleFor(m);
if (!g_pHyprRenderer->applyMonitorRule(m.get(), &rule, true)) { if (!g_pHyprRenderer->applyMonitorRule(m, &rule, true)) {
overAgain = true; overAgain = true;
break; break;
} }
@ -2427,7 +2427,7 @@ SDispatchResult CKeybindManager::dpms(std::string arg) {
} }
if (enable) if (enable)
g_pHyprRenderer->damageMonitor(m.get()); g_pHyprRenderer->damageMonitor(m);
m->events.dpmsChanged.emit(); m->events.dpmsChanged.emit();
} }

View file

@ -146,7 +146,7 @@ class CKeybindManager {
void updateXKBTranslationState(); void updateXKBTranslationState();
bool ensureMouseBindState(); bool ensureMouseBindState();
static bool tryMoveFocusToMonitor(CMonitor* monitor); static bool tryMoveFocusToMonitor(PHLMONITOR monitor);
static void moveWindowOutOfGroup(PHLWINDOW pWindow, const std::string& dir = ""); static void moveWindowOutOfGroup(PHLWINDOW pWindow, const std::string& dir = "");
static void moveWindowIntoGroup(PHLWINDOW pWindow, PHLWINDOW pWindowInDirection); static void moveWindowIntoGroup(PHLWINDOW pWindow, PHLWINDOW pWindowInDirection);
static void switchToWindow(PHLWINDOW PWINDOWTOCHANGETO); static void switchToWindow(PHLWINDOW PWINDOWTOCHANGETO);

View file

@ -14,7 +14,7 @@
CPointerManager::CPointerManager() { CPointerManager::CPointerManager() {
hooks.monitorAdded = g_pHookSystem->hookDynamic("monitorAdded", [this](void* self, SCallbackInfo& info, std::any data) { hooks.monitorAdded = g_pHookSystem->hookDynamic("monitorAdded", [this](void* self, SCallbackInfo& info, std::any data) {
auto PMONITOR = std::any_cast<CMonitor*>(data)->self.lock(); auto PMONITOR = std::any_cast<PHLMONITOR>(data);
onMonitorLayoutChange(); onMonitorLayoutChange();
@ -29,7 +29,7 @@ CPointerManager::CPointerManager() {
}); });
hooks.monitorPreRender = g_pHookSystem->hookDynamic("preMonitorCommit", [this](void* self, SCallbackInfo& info, std::any data) { hooks.monitorPreRender = g_pHookSystem->hookDynamic("preMonitorCommit", [this](void* self, SCallbackInfo& info, std::any data) {
auto state = stateFor(std::any_cast<CMonitor*>(data)->self.lock()); auto state = stateFor(std::any_cast<PHLMONITOR>(data));
if (!state) if (!state)
return; return;
@ -51,16 +51,7 @@ void CPointerManager::unlockSoftwareAll() {
updateCursorBackend(); updateCursorBackend();
} }
void CPointerManager::lockSoftwareForMonitor(CMonitor* Monitor) { void CPointerManager::lockSoftwareForMonitor(PHLMONITOR mon) {
for (auto const& m : g_pCompositor->m_vMonitors) {
if (m->ID == Monitor->ID) {
lockSoftwareForMonitor(m);
return;
}
}
}
void CPointerManager::lockSoftwareForMonitor(SP<CMonitor> mon) {
auto state = stateFor(mon); auto state = stateFor(mon);
state->softwareLocks++; state->softwareLocks++;
@ -68,16 +59,7 @@ void CPointerManager::lockSoftwareForMonitor(SP<CMonitor> mon) {
updateCursorBackend(); updateCursorBackend();
} }
void CPointerManager::unlockSoftwareForMonitor(CMonitor* Monitor) { void CPointerManager::unlockSoftwareForMonitor(PHLMONITOR mon) {
for (auto const& m : g_pCompositor->m_vMonitors) {
if (m->ID == Monitor->ID) {
unlockSoftwareForMonitor(m);
return;
}
}
}
void CPointerManager::unlockSoftwareForMonitor(SP<CMonitor> mon) {
auto state = stateFor(mon); auto state = stateFor(mon);
state->softwareLocks--; state->softwareLocks--;
if (state->softwareLocks < 0) if (state->softwareLocks < 0)
@ -387,7 +369,7 @@ bool CPointerManager::setHWCursorBuffer(SP<SMonitorPointerState> state, SP<Aquam
state->cursorFrontBuffer = buf; state->cursorFrontBuffer = buf;
if (!state->monitor->shouldSkipScheduleFrameOnMouseEvent()) if (!state->monitor->shouldSkipScheduleFrameOnMouseEvent())
g_pCompositor->scheduleFrameForMonitor(state->monitor.get(), Aquamarine::IOutput::AQ_SCHEDULE_CURSOR_SHAPE); g_pCompositor->scheduleFrameForMonitor(state->monitor.lock(), Aquamarine::IOutput::AQ_SCHEDULE_CURSOR_SHAPE);
return true; return true;
} }
@ -446,7 +428,7 @@ SP<Aquamarine::IBuffer> CPointerManager::renderHWCursorBuffer(SP<CPointerManager
CRegion damage = {0, 0, INT16_MAX, INT16_MAX}; CRegion damage = {0, 0, INT16_MAX, INT16_MAX};
g_pHyprRenderer->makeEGLCurrent(); g_pHyprRenderer->makeEGLCurrent();
g_pHyprOpenGL->m_RenderData.pMonitor = state->monitor.get(); g_pHyprOpenGL->m_RenderData.pMonitor = state->monitor;
auto RBO = g_pHyprRenderer->getOrCreateRenderbuffer(buf, state->monitor->cursorSwapchain->currentOptions().format); auto RBO = g_pHyprRenderer->getOrCreateRenderbuffer(buf, state->monitor->cursorSwapchain->currentOptions().format);
if (!RBO) { if (!RBO) {
@ -503,7 +485,7 @@ SP<Aquamarine::IBuffer> CPointerManager::renderHWCursorBuffer(SP<CPointerManager
RBO->bind(); RBO->bind();
g_pHyprOpenGL->beginSimple(state->monitor.get(), damage, RBO); g_pHyprOpenGL->beginSimple(state->monitor.lock(), damage, RBO);
g_pHyprOpenGL->clear(CColor{0.F, 0.F, 0.F, 0.F}); g_pHyprOpenGL->clear(CColor{0.F, 0.F, 0.F, 0.F});
CBox xbox = {{}, Vector2D{currentCursorImage.size / currentCursorImage.scale * state->monitor->scale}.round()}; CBox xbox = {{}, Vector2D{currentCursorImage.size / currentCursorImage.scale * state->monitor->scale}.round()};
@ -514,7 +496,7 @@ SP<Aquamarine::IBuffer> CPointerManager::renderHWCursorBuffer(SP<CPointerManager
g_pHyprOpenGL->end(); g_pHyprOpenGL->end();
glFlush(); glFlush();
g_pHyprOpenGL->m_RenderData.pMonitor = nullptr; g_pHyprOpenGL->m_RenderData.pMonitor.reset();
g_pHyprRenderer->onRenderbufferDestroy(RBO.get()); g_pHyprRenderer->onRenderbufferDestroy(RBO.get());

View file

@ -45,8 +45,6 @@ class CPointerManager {
void lockSoftwareForMonitor(SP<CMonitor> pMonitor); void lockSoftwareForMonitor(SP<CMonitor> pMonitor);
void unlockSoftwareForMonitor(SP<CMonitor> pMonitor); void unlockSoftwareForMonitor(SP<CMonitor> pMonitor);
void lockSoftwareForMonitor(CMonitor* pMonitor);
void unlockSoftwareForMonitor(CMonitor* pMonitor);
void lockSoftwareAll(); void lockSoftwareAll();
void unlockSoftwareAll(); void unlockSoftwareAll();
bool softwareLockedFor(SP<CMonitor> pMonitor); bool softwareLockedFor(SP<CMonitor> pMonitor);

View file

@ -62,7 +62,7 @@
#include <aquamarine/buffer/Buffer.hpp> #include <aquamarine/buffer/Buffer.hpp>
#include <aquamarine/backend/Backend.hpp> #include <aquamarine/backend/Backend.hpp>
void CProtocolManager::onMonitorModeChange(CMonitor* pMonitor) { void CProtocolManager::onMonitorModeChange(PHLMONITOR pMonitor) {
const bool ISMIRROR = pMonitor->isMirror(); const bool ISMIRROR = pMonitor->isMirror();
// onModeChanged we check if the current mirror status matches the global. // onModeChanged we check if the current mirror status matches the global.
@ -84,7 +84,7 @@ CProtocolManager::CProtocolManager() {
// Outputs are a bit dumb, we have to agree. // Outputs are a bit dumb, we have to agree.
static auto P = g_pHookSystem->hookDynamic("monitorAdded", [this](void* self, SCallbackInfo& info, std::any param) { static auto P = g_pHookSystem->hookDynamic("monitorAdded", [this](void* self, SCallbackInfo& info, std::any param) {
auto M = std::any_cast<CMonitor*>(param); auto M = std::any_cast<PHLMONITOR>(param);
// ignore mirrored outputs. I don't think this will ever be hit as mirrors are applied after // ignore mirrored outputs. I don't think this will ever be hit as mirrors are applied after
// this event is emitted iirc. // this event is emitted iirc.
@ -103,7 +103,7 @@ CProtocolManager::CProtocolManager() {
}); });
static auto P2 = g_pHookSystem->hookDynamic("monitorRemoved", [this](void* self, SCallbackInfo& info, std::any param) { static auto P2 = g_pHookSystem->hookDynamic("monitorRemoved", [this](void* self, SCallbackInfo& info, std::any param) {
auto M = std::any_cast<CMonitor*>(param); auto M = std::any_cast<PHLMONITOR>(param);
if (!PROTO::outputs.contains(M->szName)) if (!PROTO::outputs.contains(M->szName))
return; return;
PROTO::outputs.at(M->szName)->remove(); PROTO::outputs.at(M->szName)->remove();

View file

@ -16,7 +16,7 @@ class CProtocolManager {
private: private:
std::unordered_map<std::string, CHyprSignalListener> m_mModeChangeListeners; std::unordered_map<std::string, CHyprSignalListener> m_mModeChangeListeners;
void onMonitorModeChange(CMonitor* pMonitor); void onMonitorModeChange(PHLMONITOR pMonitor);
}; };
inline std::unique_ptr<CProtocolManager> g_pProtocolManager; inline std::unique_ptr<CProtocolManager> g_pProtocolManager;

View file

@ -3,6 +3,7 @@
#include "../config/ConfigValue.hpp" #include "../config/ConfigValue.hpp"
#include "../protocols/FractionalScale.hpp" #include "../protocols/FractionalScale.hpp"
#include "../protocols/SessionLock.hpp" #include "../protocols/SessionLock.hpp"
#include "../managers/SeatManager.hpp"
#include <algorithm> #include <algorithm>
#include <ranges> #include <ranges>
@ -72,7 +73,7 @@ void CSessionLockManager::onNewSessionLock(SP<CSessionLock> pLock) {
g_pInputManager->refocus(); g_pInputManager->refocus();
for (auto const& m : g_pCompositor->m_vMonitors) for (auto const& m : g_pCompositor->m_vMonitors)
g_pHyprRenderer->damageMonitor(m.get()); g_pHyprRenderer->damageMonitor(m);
}); });
m_pSessionLock->listeners.destroy = pLock->events.destroyed.registerListener([this](std::any data) { m_pSessionLock->listeners.destroy = pLock->events.destroyed.registerListener([this](std::any data) {
@ -80,10 +81,11 @@ void CSessionLockManager::onNewSessionLock(SP<CSessionLock> pLock) {
g_pCompositor->focusSurface(nullptr); g_pCompositor->focusSurface(nullptr);
for (auto const& m : g_pCompositor->m_vMonitors) for (auto const& m : g_pCompositor->m_vMonitors)
g_pHyprRenderer->damageMonitor(m.get()); g_pHyprRenderer->damageMonitor(m);
}); });
g_pCompositor->focusSurface(nullptr); g_pCompositor->focusSurface(nullptr);
g_pSeatManager->setGrab(nullptr);
} }
bool CSessionLockManager::isSessionLocked() { bool CSessionLockManager::isSessionLocked() {

View file

@ -247,7 +247,7 @@ Vector2D CHyprXWaylandManager::xwaylandToWaylandCoords(const Vector2D& coord) {
static auto PXWLFORCESCALEZERO = CConfigValue<Hyprlang::INT>("xwayland:force_zero_scaling"); static auto PXWLFORCESCALEZERO = CConfigValue<Hyprlang::INT>("xwayland:force_zero_scaling");
CMonitor* pMonitor = nullptr; PHLMONITOR pMonitor = nullptr;
double bestDistance = __FLT_MAX__; double bestDistance = __FLT_MAX__;
for (const auto& m : g_pCompositor->m_vMonitors) { for (const auto& m : g_pCompositor->m_vMonitors) {
const auto SIZ = *PXWLFORCESCALEZERO ? m->vecTransformedSize : m->vecSize; const auto SIZ = *PXWLFORCESCALEZERO ? m->vecTransformedSize : m->vecSize;
@ -257,7 +257,7 @@ Vector2D CHyprXWaylandManager::xwaylandToWaylandCoords(const Vector2D& coord) {
if (distance < bestDistance) { if (distance < bestDistance) {
bestDistance = distance; bestDistance = distance;
pMonitor = m.get(); pMonitor = m;
} }
} }

View file

@ -172,7 +172,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
m_vLastCursorPosFloored = MOUSECOORDSFLOORED; m_vLastCursorPosFloored = MOUSECOORDSFLOORED;
const auto PMONITOR = isLocked() && g_pCompositor->m_pLastMonitor ? g_pCompositor->m_pLastMonitor.get() : g_pCompositor->getMonitorFromCursor(); const auto PMONITOR = isLocked() && g_pCompositor->m_pLastMonitor ? g_pCompositor->m_pLastMonitor.lock() : g_pCompositor->getMonitorFromCursor();
// this can happen if there are no displays hooked up to Hyprland // this can happen if there are no displays hooked up to Hyprland
if (PMONITOR == nullptr) if (PMONITOR == nullptr)
@ -212,7 +212,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
Debug::log(ERR, "BUG THIS: Null SURF/CONSTRAINT in mouse refocus. Ignoring constraints. {:x} {:x}", (uintptr_t)SURF.get(), (uintptr_t)CONSTRAINT.get()); Debug::log(ERR, "BUG THIS: Null SURF/CONSTRAINT in mouse refocus. Ignoring constraints. {:x} {:x}", (uintptr_t)SURF.get(), (uintptr_t)CONSTRAINT.get());
} }
if (PMONITOR != g_pCompositor->m_pLastMonitor.get() && (*PMOUSEFOCUSMON || refocus) && m_pForcedFocus.expired()) if (PMONITOR != g_pCompositor->m_pLastMonitor && (*PMOUSEFOCUSMON || refocus) && m_pForcedFocus.expired())
g_pCompositor->setActiveMonitor(PMONITOR); g_pCompositor->setActiveMonitor(PMONITOR);
if (g_pSessionLockManager->isSessionLocked()) { if (g_pSessionLockManager->isSessionLocked()) {
@ -370,7 +370,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND], &surfaceCoords, &pFoundLayerSurface); g_pCompositor->vectorToLayerSurface(mouseCoords, &PMONITOR->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND], &surfaceCoords, &pFoundLayerSurface);
if (g_pPointerManager->softwareLockedFor(PMONITOR->self.lock()) > 0 && !skipFrameSchedule) if (g_pPointerManager->softwareLockedFor(PMONITOR->self.lock()) > 0 && !skipFrameSchedule)
g_pCompositor->scheduleFrameForMonitor(g_pCompositor->m_pLastMonitor.get(), Aquamarine::IOutput::AQ_SCHEDULE_CURSOR_MOVE); g_pCompositor->scheduleFrameForMonitor(g_pCompositor->m_pLastMonitor.lock(), Aquamarine::IOutput::AQ_SCHEDULE_CURSOR_MOVE);
// grabs // grabs
if (g_pSeatManager->seatGrab && !g_pSeatManager->seatGrab->accepts(foundSurface)) { if (g_pSeatManager->seatGrab && !g_pSeatManager->seatGrab->accepts(foundSurface)) {
@ -720,7 +720,7 @@ void CInputManager::processMouseDownNormal(const IPointer::SButtonEvent& e) {
// notify app if we didnt handle it // notify app if we didnt handle it
g_pSeatManager->sendPointerButton(e.timeMs, e.button, e.state); g_pSeatManager->sendPointerButton(e.timeMs, e.button, e.state);
if (const auto PMON = g_pCompositor->getMonitorFromVector(mouseCoords); PMON != g_pCompositor->m_pLastMonitor.get() && PMON) if (const auto PMON = g_pCompositor->getMonitorFromVector(mouseCoords); PMON != g_pCompositor->m_pLastMonitor && PMON)
g_pCompositor->setActiveMonitor(PMON); g_pCompositor->setActiveMonitor(PMON);
if (g_pSeatManager->seatGrab && e.state == WL_POINTER_BUTTON_STATE_PRESSED) { if (g_pSeatManager->seatGrab && e.state == WL_POINTER_BUTTON_STATE_PRESSED) {
@ -1359,7 +1359,7 @@ void CInputManager::refocus() {
mouseMoveUnified(0, true); mouseMoveUnified(0, true);
} }
void CInputManager::refocusLastWindow(CMonitor* pMonitor) { void CInputManager::refocusLastWindow(PHLMONITOR pMonitor) {
if (!pMonitor) { if (!pMonitor) {
refocus(); refocus();
return; return;

View file

@ -112,7 +112,7 @@ class CInputManager {
Vector2D getMouseCoordsInternal(); Vector2D getMouseCoordsInternal();
void refocus(); void refocus();
void refocusLastWindow(CMonitor* pMonitor); void refocusLastWindow(PHLMONITOR pMonitor);
void simulateMouseMovement(); void simulateMouseMovement();
void sendMotionEventsToFocused(); void sendMotionEventsToFocused();

View file

@ -102,7 +102,7 @@ void CInputPopup::updateBox() {
Vector2D currentPopupSize = surface->getViewporterCorrectedSize() / surface->resource()->current.scale; Vector2D currentPopupSize = surface->getViewporterCorrectedSize() / surface->resource()->current.scale;
CMonitor* pMonitor = g_pCompositor->getMonitorFromVector(parentBox.middle()); PHLMONITOR pMonitor = g_pCompositor->getMonitorFromVector(parentBox.middle());
Vector2D popupOffset(0, 0); Vector2D popupOffset(0, 0);

View file

@ -33,7 +33,7 @@ void CInputManager::beginWorkspaceSwipe() {
m_sActiveSwipe.pWorkspaceBegin = PWORKSPACE; m_sActiveSwipe.pWorkspaceBegin = PWORKSPACE;
m_sActiveSwipe.delta = 0; m_sActiveSwipe.delta = 0;
m_sActiveSwipe.pMonitor = g_pCompositor->m_pLastMonitor.get(); m_sActiveSwipe.pMonitor = g_pCompositor->m_pLastMonitor;
m_sActiveSwipe.avgSpeed = 0; m_sActiveSwipe.avgSpeed = 0;
m_sActiveSwipe.speedPoints = 0; m_sActiveSwipe.speedPoints = 0;
@ -179,7 +179,7 @@ void CInputManager::endWorkspaceSwipe() {
} }
m_sActiveSwipe.pWorkspaceBegin->rememberPrevWorkspace(pSwitchedTo); m_sActiveSwipe.pWorkspaceBegin->rememberPrevWorkspace(pSwitchedTo);
g_pHyprRenderer->damageMonitor(m_sActiveSwipe.pMonitor); g_pHyprRenderer->damageMonitor(m_sActiveSwipe.pMonitor.lock());
if (PWORKSPACEL) if (PWORKSPACEL)
PWORKSPACEL->m_bForceRendering = false; PWORKSPACEL->m_bForceRendering = false;
@ -264,7 +264,7 @@ void CInputManager::updateWorkspaceSwipe(double delta) {
if (workspaceIDLeft > m_sActiveSwipe.pWorkspaceBegin->m_iID || !PWORKSPACE) { if (workspaceIDLeft > m_sActiveSwipe.pWorkspaceBegin->m_iID || !PWORKSPACE) {
if (*PSWIPENEW) { if (*PSWIPENEW) {
g_pHyprRenderer->damageMonitor(m_sActiveSwipe.pMonitor); g_pHyprRenderer->damageMonitor(m_sActiveSwipe.pMonitor.lock());
if (VERTANIMS) if (VERTANIMS)
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(0.0, ((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * YDISTANCE)); m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(0.0, ((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * YDISTANCE));
@ -304,7 +304,7 @@ void CInputManager::updateWorkspaceSwipe(double delta) {
if (workspaceIDRight < m_sActiveSwipe.pWorkspaceBegin->m_iID || !PWORKSPACE) { if (workspaceIDRight < m_sActiveSwipe.pWorkspaceBegin->m_iID || !PWORKSPACE) {
if (*PSWIPENEW) { if (*PSWIPENEW) {
g_pHyprRenderer->damageMonitor(m_sActiveSwipe.pMonitor); g_pHyprRenderer->damageMonitor(m_sActiveSwipe.pMonitor.lock());
if (VERTANIMS) if (VERTANIMS)
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(0.0, ((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * YDISTANCE)); m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(0.0, ((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * YDISTANCE));
@ -341,7 +341,7 @@ void CInputManager::updateWorkspaceSwipe(double delta) {
g_pCompositor->updateWorkspaceWindowDecos(workspaceIDRight); g_pCompositor->updateWorkspaceWindowDecos(workspaceIDRight);
} }
g_pHyprRenderer->damageMonitor(m_sActiveSwipe.pMonitor); g_pHyprRenderer->damageMonitor(m_sActiveSwipe.pMonitor.lock());
g_pCompositor->updateWorkspaceWindowDecos(m_sActiveSwipe.pWorkspaceBegin->m_iID); g_pCompositor->updateWorkspaceWindowDecos(m_sActiveSwipe.pWorkspaceBegin->m_iID);

View file

@ -18,7 +18,7 @@ void CInputManager::onTouchDown(ITouch::SDownEvent e) {
auto PMONITOR = g_pCompositor->getMonitorFromName(!e.device->boundOutput.empty() ? e.device->boundOutput : ""); auto PMONITOR = g_pCompositor->getMonitorFromName(!e.device->boundOutput.empty() ? e.device->boundOutput : "");
PMONITOR = PMONITOR ? PMONITOR : g_pCompositor->m_pLastMonitor.get(); PMONITOR = PMONITOR ? PMONITOR : g_pCompositor->m_pLastMonitor.lock();
g_pCompositor->warpCursorTo({PMONITOR->vecPosition.x + e.pos.x * PMONITOR->vecSize.x, PMONITOR->vecPosition.y + e.pos.y * PMONITOR->vecSize.y}, true); g_pCompositor->warpCursorTo({PMONITOR->vecPosition.x + e.pos.x * PMONITOR->vecSize.x, PMONITOR->vecPosition.y + e.pos.y * PMONITOR->vecSize.y}, true);

View file

@ -31,8 +31,8 @@ CForeignToplevelList::CForeignToplevelList(SP<CExtForeignToplevelListV1> resourc
}); });
for (auto const& w : g_pCompositor->m_vWindows) { for (auto const& w : g_pCompositor->m_vWindows) {
if (!w->m_bIsMapped || w->m_bFadingOut) if (!PROTO::foreignToplevel->windowValidForForeign(w))
continue; return;
onMap(w); onMap(w);
} }
@ -112,20 +112,35 @@ bool CForeignToplevelList::good() {
CForeignToplevelProtocol::CForeignToplevelProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { CForeignToplevelProtocol::CForeignToplevelProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
static auto P = g_pHookSystem->hookDynamic("openWindow", [this](void* self, SCallbackInfo& info, std::any data) { static auto P = g_pHookSystem->hookDynamic("openWindow", [this](void* self, SCallbackInfo& info, std::any data) {
auto window = std::any_cast<PHLWINDOW>(data);
if (!windowValidForForeign(window))
return;
for (auto const& m : m_vManagers) { for (auto const& m : m_vManagers) {
m->onMap(std::any_cast<PHLWINDOW>(data)); m->onMap(window);
} }
}); });
static auto P1 = g_pHookSystem->hookDynamic("closeWindow", [this](void* self, SCallbackInfo& info, std::any data) { static auto P1 = g_pHookSystem->hookDynamic("closeWindow", [this](void* self, SCallbackInfo& info, std::any data) {
auto window = std::any_cast<PHLWINDOW>(data);
if (!windowValidForForeign(window))
return;
for (auto const& m : m_vManagers) { for (auto const& m : m_vManagers) {
m->onUnmap(std::any_cast<PHLWINDOW>(data)); m->onUnmap(window);
} }
}); });
static auto P2 = g_pHookSystem->hookDynamic("windowTitle", [this](void* self, SCallbackInfo& info, std::any data) { static auto P2 = g_pHookSystem->hookDynamic("windowTitle", [this](void* self, SCallbackInfo& info, std::any data) {
auto window = std::any_cast<PHLWINDOW>(data);
if (!windowValidForForeign(window))
return;
for (auto const& m : m_vManagers) { for (auto const& m : m_vManagers) {
m->onTitle(std::any_cast<PHLWINDOW>(data)); m->onTitle(window);
} }
}); });
} }
@ -148,3 +163,7 @@ void CForeignToplevelProtocol::onManagerResourceDestroy(CForeignToplevelList* mg
void CForeignToplevelProtocol::destroyHandle(CForeignToplevelHandle* handle) { void CForeignToplevelProtocol::destroyHandle(CForeignToplevelHandle* handle) {
std::erase_if(m_vHandles, [&](const auto& other) { return other.get() == handle; }); std::erase_if(m_vHandles, [&](const auto& other) { return other.get() == handle; });
} }
bool CForeignToplevelProtocol::windowValidForForeign(PHLWINDOW pWindow) {
return validMapped(pWindow) && !pWindow->isX11OverrideRedirect();
}

View file

@ -50,6 +50,7 @@ class CForeignToplevelProtocol : public IWaylandProtocol {
private: private:
void onManagerResourceDestroy(CForeignToplevelList* mgr); void onManagerResourceDestroy(CForeignToplevelList* mgr);
void destroyHandle(CForeignToplevelHandle* handle); void destroyHandle(CForeignToplevelHandle* handle);
bool windowValidForForeign(PHLWINDOW pWindow);
// //
std::vector<UP<CForeignToplevelList>> m_vManagers; std::vector<UP<CForeignToplevelList>> m_vManagers;

View file

@ -44,7 +44,7 @@ CForeignToplevelHandleWlr::CForeignToplevelHandleWlr(SP<CZwlrForeignToplevelHand
if (PWINDOW->m_pWorkspace != monitor->activeWorkspace) { if (PWINDOW->m_pWorkspace != monitor->activeWorkspace) {
g_pCompositor->moveWindowToWorkspaceSafe(PWINDOW, monitor->activeWorkspace); g_pCompositor->moveWindowToWorkspaceSafe(PWINDOW, monitor->activeWorkspace);
g_pCompositor->setActiveMonitor(monitor.get()); g_pCompositor->setActiveMonitor(monitor);
} }
} }
} }
@ -116,7 +116,7 @@ wl_resource* CForeignToplevelHandleWlr::res() {
return resource->resource(); return resource->resource();
} }
void CForeignToplevelHandleWlr::sendMonitor(CMonitor* pMonitor) { void CForeignToplevelHandleWlr::sendMonitor(PHLMONITOR pMonitor) {
if (lastMonitorID == pMonitor->ID) if (lastMonitorID == pMonitor->ID)
return; return;
@ -180,7 +180,7 @@ CForeignToplevelWlrManager::CForeignToplevelWlrManager(SP<CZwlrForeignToplevelMa
}); });
for (auto const& w : g_pCompositor->m_vWindows) { for (auto const& w : g_pCompositor->m_vWindows) {
if (!w->m_bIsMapped || w->m_bFadingOut) if (!PROTO::foreignToplevelWlr->windowValidForForeign(w))
continue; continue;
onMap(w); onMap(w);
@ -313,6 +313,10 @@ bool CForeignToplevelWlrManager::good() {
CForeignToplevelWlrProtocol::CForeignToplevelWlrProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { CForeignToplevelWlrProtocol::CForeignToplevelWlrProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
static auto P = g_pHookSystem->hookDynamic("openWindow", [this](void* self, SCallbackInfo& info, std::any data) { static auto P = g_pHookSystem->hookDynamic("openWindow", [this](void* self, SCallbackInfo& info, std::any data) {
const auto PWINDOW = std::any_cast<PHLWINDOW>(data); const auto PWINDOW = std::any_cast<PHLWINDOW>(data);
if (!windowValidForForeign(PWINDOW))
return;
for (auto const& m : m_vManagers) { for (auto const& m : m_vManagers) {
m->onMap(PWINDOW); m->onMap(PWINDOW);
} }
@ -320,6 +324,10 @@ CForeignToplevelWlrProtocol::CForeignToplevelWlrProtocol(const wl_interface* ifa
static auto P1 = g_pHookSystem->hookDynamic("closeWindow", [this](void* self, SCallbackInfo& info, std::any data) { static auto P1 = g_pHookSystem->hookDynamic("closeWindow", [this](void* self, SCallbackInfo& info, std::any data) {
const auto PWINDOW = std::any_cast<PHLWINDOW>(data); const auto PWINDOW = std::any_cast<PHLWINDOW>(data);
if (!windowValidForForeign(PWINDOW))
return;
for (auto const& m : m_vManagers) { for (auto const& m : m_vManagers) {
m->onUnmap(PWINDOW); m->onUnmap(PWINDOW);
} }
@ -327,6 +335,10 @@ CForeignToplevelWlrProtocol::CForeignToplevelWlrProtocol(const wl_interface* ifa
static auto P2 = g_pHookSystem->hookDynamic("windowTitle", [this](void* self, SCallbackInfo& info, std::any data) { static auto P2 = g_pHookSystem->hookDynamic("windowTitle", [this](void* self, SCallbackInfo& info, std::any data) {
const auto PWINDOW = std::any_cast<PHLWINDOW>(data); const auto PWINDOW = std::any_cast<PHLWINDOW>(data);
if (!windowValidForForeign(PWINDOW))
return;
for (auto const& m : m_vManagers) { for (auto const& m : m_vManagers) {
m->onTitle(PWINDOW); m->onTitle(PWINDOW);
} }
@ -334,6 +346,10 @@ CForeignToplevelWlrProtocol::CForeignToplevelWlrProtocol(const wl_interface* ifa
static auto P3 = g_pHookSystem->hookDynamic("activeWindow", [this](void* self, SCallbackInfo& info, std::any data) { static auto P3 = g_pHookSystem->hookDynamic("activeWindow", [this](void* self, SCallbackInfo& info, std::any data) {
const auto PWINDOW = std::any_cast<PHLWINDOW>(data); const auto PWINDOW = std::any_cast<PHLWINDOW>(data);
if (!windowValidForForeign(PWINDOW))
return;
for (auto const& m : m_vManagers) { for (auto const& m : m_vManagers) {
m->onNewFocus(PWINDOW); m->onNewFocus(PWINDOW);
} }
@ -348,6 +364,10 @@ CForeignToplevelWlrProtocol::CForeignToplevelWlrProtocol(const wl_interface* ifa
static auto P5 = g_pHookSystem->hookDynamic("fullscreen", [this](void* self, SCallbackInfo& info, std::any data) { static auto P5 = g_pHookSystem->hookDynamic("fullscreen", [this](void* self, SCallbackInfo& info, std::any data) {
const auto PWINDOW = std::any_cast<PHLWINDOW>(data); const auto PWINDOW = std::any_cast<PHLWINDOW>(data);
if (!windowValidForForeign(PWINDOW))
return;
for (auto const& m : m_vManagers) { for (auto const& m : m_vManagers) {
m->onFullscreen(PWINDOW); m->onFullscreen(PWINDOW);
} }
@ -383,3 +403,7 @@ PHLWINDOW CForeignToplevelWlrProtocol::windowFromHandleResource(wl_resource* res
return nullptr; return nullptr;
} }
bool CForeignToplevelWlrProtocol::windowValidForForeign(PHLWINDOW pWindow) {
return validMapped(pWindow) && !pWindow->isX11OverrideRedirect();
}

View file

@ -22,7 +22,7 @@ class CForeignToplevelHandleWlr {
bool closed = false; bool closed = false;
MONITORID lastMonitorID = MONITOR_INVALID; MONITORID lastMonitorID = MONITOR_INVALID;
void sendMonitor(CMonitor* pMonitor); void sendMonitor(PHLMONITOR pMonitor);
void sendState(); void sendState();
friend class CForeignToplevelWlrManager; friend class CForeignToplevelWlrManager;
@ -63,6 +63,7 @@ class CForeignToplevelWlrProtocol : public IWaylandProtocol {
private: private:
void onManagerResourceDestroy(CForeignToplevelWlrManager* mgr); void onManagerResourceDestroy(CForeignToplevelWlrManager* mgr);
void destroyHandle(CForeignToplevelHandleWlr* handle); void destroyHandle(CForeignToplevelHandleWlr* handle);
bool windowValidForForeign(PHLWINDOW pWindow);
// //
std::vector<UP<CForeignToplevelWlrManager>> m_vManagers; std::vector<UP<CForeignToplevelWlrManager>> m_vManagers;

View file

@ -143,11 +143,11 @@ void CGammaControl::applyToMonitor() {
pMonitor->output->state->setGammaLut({}); pMonitor->output->state->setGammaLut({});
} }
g_pHyprRenderer->damageMonitor(pMonitor.get()); g_pHyprRenderer->damageMonitor(pMonitor.lock());
} }
CMonitor* CGammaControl::getMonitor() { PHLMONITOR CGammaControl::getMonitor() {
return pMonitor ? pMonitor.get() : nullptr; return pMonitor ? pMonitor.lock() : nullptr;
} }
void CGammaControl::onMonitorDestroy() { void CGammaControl::onMonitorDestroy() {
@ -186,7 +186,7 @@ void CGammaControlProtocol::onGetGammaControl(CZwlrGammaControlManagerV1* pMgr,
} }
} }
void CGammaControlProtocol::applyGammaToState(CMonitor* pMonitor) { void CGammaControlProtocol::applyGammaToState(PHLMONITOR pMonitor) {
for (auto const& g : m_vGammaControllers) { for (auto const& g : m_vGammaControllers) {
if (g->getMonitor() != pMonitor) if (g->getMonitor() != pMonitor)
continue; continue;

View file

@ -16,11 +16,11 @@ class CGammaControl {
bool good(); bool good();
void applyToMonitor(); void applyToMonitor();
CMonitor* getMonitor(); PHLMONITOR getMonitor();
private: private:
SP<CZwlrGammaControlV1> resource; SP<CZwlrGammaControlV1> resource;
WP<CMonitor> pMonitor; PHLMONITORREF pMonitor;
size_t gammaSize = 0; size_t gammaSize = 0;
bool gammaTableSet = false; bool gammaTableSet = false;
std::vector<uint16_t> gammaTable; // [r,g,b]+ std::vector<uint16_t> gammaTable; // [r,g,b]+
@ -39,7 +39,7 @@ class CGammaControlProtocol : public IWaylandProtocol {
virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id); virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id);
void applyGammaToState(CMonitor* pMonitor); void applyGammaToState(PHLMONITOR pMonitor);
private: private:
void onManagerResourceDestroy(wl_resource* res); void onManagerResourceDestroy(wl_resource* res);

View file

@ -14,8 +14,8 @@ void CLayerShellResource::SState::reset() {
margin = {0, 0, 0, 0}; margin = {0, 0, 0, 0};
} }
CLayerShellResource::CLayerShellResource(SP<CZwlrLayerSurfaceV1> resource_, SP<CWLSurfaceResource> surf_, std::string namespace_, CMonitor* pMonitor, zwlrLayerShellV1Layer layer) : CLayerShellResource::CLayerShellResource(SP<CZwlrLayerSurfaceV1> resource_, SP<CWLSurfaceResource> surf_, std::string namespace_, PHLMONITOR pMonitor,
layerNamespace(namespace_), surface(surf_), resource(resource_) { zwlrLayerShellV1Layer layer) : layerNamespace(namespace_), surface(surf_), resource(resource_) {
if (!good()) if (!good())
return; return;
@ -218,7 +218,7 @@ void CLayerShellProtocol::destroyResource(CLayerShellResource* surf) {
void CLayerShellProtocol::onGetLayerSurface(CZwlrLayerShellV1* pMgr, uint32_t id, wl_resource* surface, wl_resource* output, zwlrLayerShellV1Layer layer, std::string namespace_) { void CLayerShellProtocol::onGetLayerSurface(CZwlrLayerShellV1* pMgr, uint32_t id, wl_resource* surface, wl_resource* output, zwlrLayerShellV1Layer layer, std::string namespace_) {
const auto CLIENT = pMgr->client(); const auto CLIENT = pMgr->client();
const auto PMONITOR = output ? CWLOutputResource::fromResource(output)->monitor.get() : nullptr; const auto PMONITOR = output ? CWLOutputResource::fromResource(output)->monitor.lock() : nullptr;
auto SURF = CWLSurfaceResource::fromResource(surface); auto SURF = CWLSurfaceResource::fromResource(surface);
if (!SURF) { if (!SURF) {

View file

@ -26,7 +26,7 @@ class CLayerShellRole : public ISurfaceRole {
}; };
class CLayerShellResource { class CLayerShellResource {
public: public:
CLayerShellResource(SP<CZwlrLayerSurfaceV1> resource_, SP<CWLSurfaceResource> surf_, std::string namespace_, CMonitor* pMonitor, zwlrLayerShellV1Layer layer); CLayerShellResource(SP<CZwlrLayerSurfaceV1> resource_, SP<CWLSurfaceResource> surf_, std::string namespace_, PHLMONITOR pMonitor, zwlrLayerShellV1Layer layer);
~CLayerShellResource(); ~CLayerShellResource();
bool good(); bool good();

View file

@ -452,7 +452,7 @@ CLinuxDMABufV1Protocol::CLinuxDMABufV1Protocol(const wl_interface* iface, const
} }
static auto monitorAdded = g_pHookSystem->hookDynamic("monitorAdded", [this](void* self, SCallbackInfo& info, std::any param) { static auto monitorAdded = g_pHookSystem->hookDynamic("monitorAdded", [this](void* self, SCallbackInfo& info, std::any param) {
auto pMonitor = std::any_cast<CMonitor*>(param); auto pMonitor = std::any_cast<PHLMONITOR>(param);
auto mon = pMonitor->self.lock(); auto mon = pMonitor->self.lock();
auto tranche = SDMABUFTranche{ auto tranche = SDMABUFTranche{
.device = mainDevice, .device = mainDevice,
@ -464,7 +464,7 @@ CLinuxDMABufV1Protocol::CLinuxDMABufV1Protocol(const wl_interface* iface, const
}); });
static auto monitorRemoved = g_pHookSystem->hookDynamic("monitorRemoved", [this](void* self, SCallbackInfo& info, std::any param) { static auto monitorRemoved = g_pHookSystem->hookDynamic("monitorRemoved", [this](void* self, SCallbackInfo& info, std::any param) {
auto pMonitor = std::any_cast<CMonitor*>(param); auto pMonitor = std::any_cast<PHLMONITOR>(param);
auto mon = pMonitor->self.lock(); auto mon = pMonitor->self.lock();
std::erase_if(formatTable->monitorTranches, [mon](std::pair<SP<CMonitor>, SDMABUFTranche> pair) { return pair.first == mon; }); std::erase_if(formatTable->monitorTranches, [mon](std::pair<SP<CMonitor>, SDMABUFTranche> pair) { return pair.first == mon; });
resetFormatTable(); resetFormatTable();

View file

@ -29,12 +29,12 @@ COutputManager::COutputManager(SP<CZwlrOutputManagerV1> resource_) : resource(re
// send all heads at start // send all heads at start
for (auto const& m : g_pCompositor->m_vRealMonitors) { for (auto const& m : g_pCompositor->m_vRealMonitors) {
if (m.get() == g_pCompositor->m_pUnsafeOutput) if (m == g_pCompositor->m_pUnsafeOutput)
continue; continue;
LOGM(LOG, " | sending output head for {}", m->szName); LOGM(LOG, " | sending output head for {}", m->szName);
makeAndSendNewHead(m.get()); makeAndSendNewHead(m);
} }
sendDone(); sendDone();
@ -44,7 +44,7 @@ bool COutputManager::good() {
return resource->resource(); return resource->resource();
} }
void COutputManager::makeAndSendNewHead(CMonitor* pMonitor) { void COutputManager::makeAndSendNewHead(PHLMONITOR pMonitor) {
if (stopped) if (stopped)
return; return;
@ -63,7 +63,7 @@ void COutputManager::makeAndSendNewHead(CMonitor* pMonitor) {
RESOURCE->sendAllData(); RESOURCE->sendAllData();
} }
void COutputManager::ensureMonitorSent(CMonitor* pMonitor) { void COutputManager::ensureMonitorSent(PHLMONITOR pMonitor) {
if (pMonitor == g_pCompositor->m_pUnsafeOutput) if (pMonitor == g_pCompositor->m_pUnsafeOutput)
return; return;
@ -86,7 +86,7 @@ void COutputManager::sendDone() {
resource->sendDone(wl_display_next_serial(g_pCompositor->m_sWLDisplay)); resource->sendDone(wl_display_next_serial(g_pCompositor->m_sWLDisplay));
} }
COutputHead::COutputHead(SP<CZwlrOutputHeadV1> resource_, CMonitor* pMonitor_) : resource(resource_), pMonitor(pMonitor_) { COutputHead::COutputHead(SP<CZwlrOutputHeadV1> resource_, PHLMONITOR pMonitor_) : resource(resource_), pMonitor(pMonitor_) {
if (!good()) if (!good())
return; return;
@ -105,7 +105,7 @@ COutputHead::COutputHead(SP<CZwlrOutputHeadV1> resource_, CMonitor* pMonitor_) :
m->resource->sendFinished(); m->resource->sendFinished();
} }
pMonitor = nullptr; pMonitor.reset();
for (auto const& m : PROTO::outputManagement->m_vManagers) { for (auto const& m : PROTO::outputManagement->m_vManagers) {
m->sendDone(); m->sendDone();
} }
@ -221,8 +221,8 @@ void COutputHead::makeAndSendNewMode(SP<Aquamarine::SOutputMode> mode) {
RESOURCE->sendAllData(); RESOURCE->sendAllData();
} }
CMonitor* COutputHead::monitor() { PHLMONITOR COutputHead::monitor() {
return pMonitor; return pMonitor.lock();
} }
COutputMode::COutputMode(SP<CZwlrOutputModeV1> resource_, SP<Aquamarine::SOutputMode> mode_) : resource(resource_), mode(mode_) { COutputMode::COutputMode(SP<CZwlrOutputModeV1> resource_, SP<Aquamarine::SOutputMode> mode_) : resource(resource_), mode(mode_) {
@ -424,14 +424,12 @@ bool COutputConfiguration::applyTestConfiguration(bool test) {
return true; return true;
} }
COutputConfigurationHead::COutputConfigurationHead(SP<CZwlrOutputConfigurationHeadV1> resource_, CMonitor* pMonitor_) : resource(resource_), pMonitor(pMonitor_) { COutputConfigurationHead::COutputConfigurationHead(SP<CZwlrOutputConfigurationHeadV1> resource_, PHLMONITOR pMonitor_) : resource(resource_), pMonitor(pMonitor_) {
if (!good()) if (!good())
return; return;
resource->setOnDestroy([this](CZwlrOutputConfigurationHeadV1* r) { PROTO::outputManagement->destroyResource(this); }); resource->setOnDestroy([this](CZwlrOutputConfigurationHeadV1* r) { PROTO::outputManagement->destroyResource(this); });
listeners.monitorDestroy = pMonitor->events.destroy.registerListener([this](std::any d) { pMonitor = nullptr; });
resource->setSetMode([this](CZwlrOutputConfigurationHeadV1* r, wl_resource* outputMode) { resource->setSetMode([this](CZwlrOutputConfigurationHeadV1* r, wl_resource* outputMode) {
const auto MODE = PROTO::outputManagement->modeFromResource(outputMode); const auto MODE = PROTO::outputManagement->modeFromResource(outputMode);
@ -612,7 +610,7 @@ void COutputManagementProtocol::destroyResource(COutputConfigurationHead* resour
void COutputManagementProtocol::updateAllOutputs() { void COutputManagementProtocol::updateAllOutputs() {
for (auto const& m : g_pCompositor->m_vRealMonitors) { for (auto const& m : g_pCompositor->m_vRealMonitors) {
for (auto const& mgr : m_vManagers) { for (auto const& mgr : m_vManagers) {
mgr->ensureMonitorSent(m.get()); mgr->ensureMonitorSent(m);
} }
} }
} }

View file

@ -56,7 +56,7 @@ class COutputManager {
COutputManager(SP<CZwlrOutputManagerV1> resource_); COutputManager(SP<CZwlrOutputManagerV1> resource_);
bool good(); bool good();
void ensureMonitorSent(CMonitor* pMonitor); void ensureMonitorSent(PHLMONITOR pMonitor);
void sendDone(); void sendDone();
// holds the states for this manager. // holds the states for this manager.
@ -70,7 +70,7 @@ class COutputManager {
std::vector<WP<COutputHead>> heads; std::vector<WP<COutputHead>> heads;
void makeAndSendNewHead(CMonitor* pMonitor); void makeAndSendNewHead(PHLMONITOR pMonitor);
friend class COutputManagementProtocol; friend class COutputManagementProtocol;
}; };
@ -92,16 +92,16 @@ class COutputMode {
class COutputHead { class COutputHead {
public: public:
COutputHead(SP<CZwlrOutputHeadV1> resource_, CMonitor* pMonitor_); COutputHead(SP<CZwlrOutputHeadV1> resource_, PHLMONITOR pMonitor_);
bool good(); bool good();
void sendAllData(); // this has to be separate as we need to send the head first, then set the data void sendAllData(); // this has to be separate as we need to send the head first, then set the data
void updateMode(); void updateMode();
CMonitor* monitor(); PHLMONITOR monitor();
private: private:
SP<CZwlrOutputHeadV1> resource; SP<CZwlrOutputHeadV1> resource;
CMonitor* pMonitor = nullptr; PHLMONITORREF pMonitor;
void makeAndSendNewMode(SP<Aquamarine::SOutputMode> mode); void makeAndSendNewMode(SP<Aquamarine::SOutputMode> mode);
void sendCurrentMode(); void sendCurrentMode();
@ -119,7 +119,7 @@ class COutputHead {
class COutputConfigurationHead { class COutputConfigurationHead {
public: public:
COutputConfigurationHead(SP<CZwlrOutputConfigurationHeadV1> resource_, CMonitor* pMonitor_); COutputConfigurationHead(SP<CZwlrOutputConfigurationHeadV1> resource_, PHLMONITOR pMonitor_);
bool good(); bool good();
@ -127,11 +127,7 @@ class COutputConfigurationHead {
private: private:
SP<CZwlrOutputConfigurationHeadV1> resource; SP<CZwlrOutputConfigurationHeadV1> resource;
CMonitor* pMonitor = nullptr; PHLMONITORREF pMonitor;
struct {
CHyprSignalListener monitorDestroy;
} listeners;
friend class COutputConfiguration; friend class COutputConfiguration;
}; };

View file

@ -2,7 +2,7 @@
#include "../Compositor.hpp" #include "../Compositor.hpp"
#include "core/Output.hpp" #include "core/Output.hpp"
COutputPower::COutputPower(SP<CZwlrOutputPowerV1> resource_, CMonitor* pMonitor_) : resource(resource_), pMonitor(pMonitor_) { COutputPower::COutputPower(SP<CZwlrOutputPowerV1> resource_, PHLMONITOR pMonitor_) : resource(resource_), pMonitor(pMonitor_) {
if (!resource->resource()) if (!resource->resource())
return; return;
@ -24,7 +24,7 @@ COutputPower::COutputPower(SP<CZwlrOutputPowerV1> resource_, CMonitor* pMonitor_
resource->sendMode(pMonitor->dpmsStatus ? ZWLR_OUTPUT_POWER_V1_MODE_ON : ZWLR_OUTPUT_POWER_V1_MODE_OFF); resource->sendMode(pMonitor->dpmsStatus ? ZWLR_OUTPUT_POWER_V1_MODE_ON : ZWLR_OUTPUT_POWER_V1_MODE_OFF);
listeners.monitorDestroy = pMonitor->events.destroy.registerListener([this](std::any v) { listeners.monitorDestroy = pMonitor->events.destroy.registerListener([this](std::any v) {
pMonitor = nullptr; pMonitor.reset();
resource->sendFailed(); resource->sendFailed();
}); });
@ -68,7 +68,7 @@ void COutputPowerProtocol::onGetOutputPower(CZwlrOutputPowerManagerV1* pMgr, uin
} }
const auto CLIENT = pMgr->client(); const auto CLIENT = pMgr->client();
const auto RESOURCE = m_vOutputPowers.emplace_back(std::make_unique<COutputPower>(makeShared<CZwlrOutputPowerV1>(CLIENT, pMgr->version(), id), OUTPUT->monitor.get())).get(); const auto RESOURCE = m_vOutputPowers.emplace_back(std::make_unique<COutputPower>(makeShared<CZwlrOutputPowerV1>(CLIENT, pMgr->version(), id), OUTPUT->monitor.lock())).get();
if (!RESOURCE->good()) { if (!RESOURCE->good()) {
pMgr->noMemory(); pMgr->noMemory();

View file

@ -11,14 +11,14 @@ class CMonitor;
class COutputPower { class COutputPower {
public: public:
COutputPower(SP<CZwlrOutputPowerV1> resource_, CMonitor* pMonitor); COutputPower(SP<CZwlrOutputPowerV1> resource_, PHLMONITOR pMonitor);
bool good(); bool good();
private: private:
SP<CZwlrOutputPowerV1> resource; SP<CZwlrOutputPowerV1> resource;
CMonitor* pMonitor = nullptr; PHLMONITORREF pMonitor;
struct { struct {
CHyprSignalListener monitorDestroy; CHyprSignalListener monitorDestroy;

View file

@ -73,8 +73,8 @@ void CPresentationFeedback::sendQueued(SP<CQueuedPresentationData> data, timespe
CPresentationProtocol::CPresentationProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) { CPresentationProtocol::CPresentationProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
static auto P = g_pHookSystem->hookDynamic("monitorRemoved", [this](void* self, SCallbackInfo& info, std::any param) { static auto P = g_pHookSystem->hookDynamic("monitorRemoved", [this](void* self, SCallbackInfo& info, std::any param) {
const auto PMONITOR = std::any_cast<CMonitor*>(param); const auto PMONITOR = std::any_cast<PHLMONITOR>(param);
std::erase_if(m_vQueue, [PMONITOR](const auto& other) { return !other->surface || other->pMonitor.get() == PMONITOR; }); std::erase_if(m_vQueue, [PMONITOR](const auto& other) { return !other->surface || other->pMonitor == PMONITOR; });
}); });
} }

View file

@ -19,7 +19,7 @@ CScreencopyFrame::CScreencopyFrame(SP<CZwlrScreencopyFrameV1> resource_, int32_t
return; return;
overlayCursor = !!overlay_cursor; overlayCursor = !!overlay_cursor;
pMonitor = CWLOutputResource::fromResource(output)->monitor.get(); pMonitor = CWLOutputResource::fromResource(output)->monitor;
if (!pMonitor) { if (!pMonitor) {
LOGM(ERR, "Client requested sharing of a monitor that doesnt exist"); LOGM(ERR, "Client requested sharing of a monitor that doesnt exist");
@ -38,7 +38,7 @@ CScreencopyFrame::CScreencopyFrame(SP<CZwlrScreencopyFrameV1> resource_, int32_t
g_pHyprRenderer->makeEGLCurrent(); g_pHyprRenderer->makeEGLCurrent();
shmFormat = g_pHyprOpenGL->getPreferredReadFormat(pMonitor); shmFormat = g_pHyprOpenGL->getPreferredReadFormat(pMonitor.lock());
if (shmFormat == DRM_FORMAT_INVALID) { if (shmFormat == DRM_FORMAT_INVALID) {
LOGM(ERR, "No format supported by renderer in capture output"); LOGM(ERR, "No format supported by renderer in capture output");
resource->sendFailed(); resource->sendFailed();
@ -87,7 +87,7 @@ void CScreencopyFrame::copy(CZwlrScreencopyFrameV1* pFrame, wl_resource* buffer_
return; return;
} }
if (!g_pCompositor->monitorExists(pMonitor)) { if (!g_pCompositor->monitorExists(pMonitor.lock())) {
LOGM(ERR, "Client requested sharing of a monitor that is gone"); LOGM(ERR, "Client requested sharing of a monitor that is gone");
resource->sendFailed(); resource->sendFailed();
PROTO::screencopy->destroyResource(this); PROTO::screencopy->destroyResource(this);
@ -165,7 +165,7 @@ void CScreencopyFrame::copy(CZwlrScreencopyFrameV1* pFrame, wl_resource* buffer_
} }
if (!withDamage) if (!withDamage)
g_pHyprRenderer->damageMonitor(pMonitor); g_pHyprRenderer->damageMonitor(pMonitor.lock());
} }
void CScreencopyFrame::share() { void CScreencopyFrame::share() {
@ -205,7 +205,7 @@ bool CScreencopyFrame::copyDmabuf() {
CRegion fakeDamage = {0, 0, INT16_MAX, INT16_MAX}; CRegion fakeDamage = {0, 0, INT16_MAX, INT16_MAX};
if (!g_pHyprRenderer->beginRender(pMonitor, fakeDamage, RENDER_MODE_TO_BUFFER, buffer.lock(), nullptr, true)) { if (!g_pHyprRenderer->beginRender(pMonitor.lock(), fakeDamage, RENDER_MODE_TO_BUFFER, buffer.lock(), nullptr, true)) {
LOGM(ERR, "Can't copy: failed to begin rendering to dma frame"); LOGM(ERR, "Can't copy: failed to begin rendering to dma frame");
return false; return false;
} }
@ -240,7 +240,7 @@ bool CScreencopyFrame::copyShm() {
CFramebuffer fb; CFramebuffer fb;
fb.alloc(box.w, box.h, pMonitor->output->state->state().drmFormat); fb.alloc(box.w, box.h, pMonitor->output->state->state().drmFormat);
if (!g_pHyprRenderer->beginRender(pMonitor, fakeDamage, RENDER_MODE_FULL_FAKE, nullptr, &fb, true)) { if (!g_pHyprRenderer->beginRender(pMonitor.lock(), fakeDamage, RENDER_MODE_FULL_FAKE, nullptr, &fb, true)) {
LOGM(ERR, "Can't copy: failed to begin rendering"); LOGM(ERR, "Can't copy: failed to begin rendering");
return false; return false;
} }
@ -288,7 +288,7 @@ bool CScreencopyFrame::copyShm() {
} }
} }
g_pHyprOpenGL->m_RenderData.pMonitor = nullptr; g_pHyprOpenGL->m_RenderData.pMonitor.reset();
LOGM(TRACE, "Copied frame via shm"); LOGM(TRACE, "Copied frame via shm");
@ -402,7 +402,7 @@ void CScreencopyProtocol::destroyResource(CScreencopyFrame* frame) {
std::erase_if(m_vFramesAwaitingWrite, [&](const auto& other) { return !other || other.get() == frame; }); std::erase_if(m_vFramesAwaitingWrite, [&](const auto& other) { return !other || other.get() == frame; });
} }
void CScreencopyProtocol::onOutputCommit(CMonitor* pMonitor) { void CScreencopyProtocol::onOutputCommit(PHLMONITOR pMonitor) {
if (m_vFramesAwaitingWrite.empty()) { if (m_vFramesAwaitingWrite.empty()) {
g_pHyprRenderer->m_bDirectScanoutBlocked = false; g_pHyprRenderer->m_bDirectScanoutBlocked = false;
return; // nothing to share return; // nothing to share

View file

@ -60,7 +60,7 @@ class CScreencopyFrame {
private: private:
SP<CZwlrScreencopyFrameV1> resource; SP<CZwlrScreencopyFrameV1> resource;
CMonitor* pMonitor = nullptr; PHLMONITORREF pMonitor;
bool overlayCursor = false; bool overlayCursor = false;
bool withDamage = false; bool withDamage = false;
bool lockedSWCursors = false; bool lockedSWCursors = false;
@ -88,7 +88,7 @@ class CScreencopyProtocol : public IWaylandProtocol {
void destroyResource(CScreencopyClient* resource); void destroyResource(CScreencopyClient* resource);
void destroyResource(CScreencopyFrame* resource); void destroyResource(CScreencopyFrame* resource);
void onOutputCommit(CMonitor* pMonitor); void onOutputCommit(PHLMONITOR pMonitor);
private: private:
std::vector<SP<CScreencopyFrame>> m_vFrames; std::vector<SP<CScreencopyFrame>> m_vFrames;
@ -98,7 +98,7 @@ class CScreencopyProtocol : public IWaylandProtocol {
SP<CEventLoopTimer> m_pSoftwareCursorTimer; SP<CEventLoopTimer> m_pSoftwareCursorTimer;
bool m_bTimerArmed = false; bool m_bTimerArmed = false;
void shareAllFrames(CMonitor* pMonitor); void shareAllFrames(PHLMONITOR pMonitor);
void shareFrame(CScreencopyFrame* frame); void shareFrame(CScreencopyFrame* frame);
void sendFrameDamage(CScreencopyFrame* frame); void sendFrameDamage(CScreencopyFrame* frame);
bool copyFrameDmabuf(CScreencopyFrame* frame); bool copyFrameDmabuf(CScreencopyFrame* frame);

View file

@ -5,7 +5,7 @@
#include "core/Compositor.hpp" #include "core/Compositor.hpp"
#include "core/Output.hpp" #include "core/Output.hpp"
CSessionLockSurface::CSessionLockSurface(SP<CExtSessionLockSurfaceV1> resource_, SP<CWLSurfaceResource> surface_, CMonitor* pMonitor_, WP<CSessionLock> owner_) : CSessionLockSurface::CSessionLockSurface(SP<CExtSessionLockSurfaceV1> resource_, SP<CWLSurfaceResource> surface_, PHLMONITOR pMonitor_, WP<CSessionLock> owner_) :
resource(resource_), sessionLock(owner_), pSurface(surface_), pMonitor(pMonitor_) { resource(resource_), sessionLock(owner_), pSurface(surface_), pMonitor(pMonitor_) {
if (!resource->resource()) if (!resource->resource())
return; return;
@ -82,8 +82,8 @@ bool CSessionLockSurface::inert() {
return sessionLock.expired(); return sessionLock.expired();
} }
CMonitor* CSessionLockSurface::monitor() { PHLMONITOR CSessionLockSurface::monitor() {
return pMonitor; return pMonitor.lock();
} }
SP<CWLSurfaceResource> CSessionLockSurface::surface() { SP<CWLSurfaceResource> CSessionLockSurface::surface() {
@ -184,7 +184,7 @@ void CSessionLockProtocol::onGetLockSurface(CExtSessionLockV1* lock, uint32_t id
LOGM(LOG, "New sessionLockSurface with id {}", id); LOGM(LOG, "New sessionLockSurface with id {}", id);
auto PSURFACE = CWLSurfaceResource::fromResource(surface); auto PSURFACE = CWLSurfaceResource::fromResource(surface);
auto PMONITOR = CWLOutputResource::fromResource(output)->monitor.get(); auto PMONITOR = CWLOutputResource::fromResource(output)->monitor.lock();
SP<CSessionLock> sessionLock; SP<CSessionLock> sessionLock;
for (auto const& l : m_vLocks) { for (auto const& l : m_vLocks) {

View file

@ -13,12 +13,12 @@ class CWLSurfaceResource;
class CSessionLockSurface { class CSessionLockSurface {
public: public:
CSessionLockSurface(SP<CExtSessionLockSurfaceV1> resource_, SP<CWLSurfaceResource> surface_, CMonitor* pMonitor_, WP<CSessionLock> owner_); CSessionLockSurface(SP<CExtSessionLockSurfaceV1> resource_, SP<CWLSurfaceResource> surface_, PHLMONITOR pMonitor_, WP<CSessionLock> owner_);
~CSessionLockSurface(); ~CSessionLockSurface();
bool good(); bool good();
bool inert(); bool inert();
CMonitor* monitor(); PHLMONITOR monitor();
SP<CWLSurfaceResource> surface(); SP<CWLSurfaceResource> surface();
struct { struct {
@ -31,7 +31,7 @@ class CSessionLockSurface {
SP<CExtSessionLockSurfaceV1> resource; SP<CExtSessionLockSurfaceV1> resource;
WP<CSessionLock> sessionLock; WP<CSessionLock> sessionLock;
WP<CWLSurfaceResource> pSurface; WP<CWLSurfaceResource> pSurface;
CMonitor* pMonitor = nullptr; PHLMONITORREF pMonitor;
bool ackdConfigure = false; bool ackdConfigure = false;
bool committed = false; bool committed = false;

View file

@ -362,7 +362,7 @@ void CToplevelExportProtocol::destroyResource(CToplevelExportFrame* frame) {
std::erase_if(m_vFramesAwaitingWrite, [&](const auto& other) { return !other || other.get() == frame; }); std::erase_if(m_vFramesAwaitingWrite, [&](const auto& other) { return !other || other.get() == frame; });
} }
void CToplevelExportProtocol::onOutputCommit(CMonitor* pMonitor) { void CToplevelExportProtocol::onOutputCommit(PHLMONITOR pMonitor) {
if (m_vFramesAwaitingWrite.empty()) if (m_vFramesAwaitingWrite.empty())
return; // nothing to share return; // nothing to share

View file

@ -80,7 +80,7 @@ class CToplevelExportProtocol : IWaylandProtocol {
void destroyResource(CToplevelExportFrame* frame); void destroyResource(CToplevelExportFrame* frame);
void onWindowUnmap(PHLWINDOW pWindow); void onWindowUnmap(PHLWINDOW pWindow);
void onOutputCommit(CMonitor* pMonitor); void onOutputCommit(PHLMONITOR pMonitor);
private: private:
std::vector<SP<CToplevelExportClient>> m_vClients; std::vector<SP<CToplevelExportClient>> m_vClients;

View file

@ -681,7 +681,7 @@ void CWLDataDeviceProtocol::abortDrag() {
g_pSeatManager->resendEnterEvents(); g_pSeatManager->resendEnterEvents();
} }
void CWLDataDeviceProtocol::renderDND(CMonitor* pMonitor, timespec* when) { void CWLDataDeviceProtocol::renderDND(PHLMONITOR pMonitor, timespec* when) {
if (!dnd.dndSurface || !dnd.dndSurface->current.texture) if (!dnd.dndSurface || !dnd.dndSurface->current.texture)
return; return;

View file

@ -131,7 +131,7 @@ class CWLDataDeviceProtocol : public IWaylandProtocol {
virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id); virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id);
// renders and damages the dnd icon, if present // renders and damages the dnd icon, if present
void renderDND(CMonitor* pMonitor, timespec* when); void renderDND(PHLMONITOR pMonitor, timespec* when);
// for inputmgr to force refocus // for inputmgr to force refocus
// TODO: move handling to seatmgr // TODO: move handling to seatmgr
bool dndActive(); bool dndActive();

View file

@ -340,7 +340,7 @@ CHyprOpenGLImpl::CHyprOpenGLImpl() {
initAssets(); initAssets();
static auto P = g_pHookSystem->hookDynamic("preRender", [&](void* self, SCallbackInfo& info, std::any data) { preRender(std::any_cast<CMonitor*>(data)); }); static auto P = g_pHookSystem->hookDynamic("preRender", [&](void* self, SCallbackInfo& info, std::any data) { preRender(std::any_cast<PHLMONITOR>(data)); });
RASSERT(eglMakeCurrent(m_pEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT), "Couldn't unset current EGL!"); RASSERT(eglMakeCurrent(m_pEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT), "Couldn't unset current EGL!");
@ -625,7 +625,7 @@ GLuint CHyprOpenGLImpl::compileShader(const GLuint& type, std::string src, bool
return shader; return shader;
} }
bool CHyprOpenGLImpl::passRequiresIntrospection(CMonitor* pMonitor) { bool CHyprOpenGLImpl::passRequiresIntrospection(PHLMONITOR pMonitor) {
// passes requiring introspection are the ones that need to render blur, // passes requiring introspection are the ones that need to render blur,
// or when we are rendering to a multigpu target // or when we are rendering to a multigpu target
@ -731,7 +731,7 @@ bool CHyprOpenGLImpl::passRequiresIntrospection(CMonitor* pMonitor) {
return false; return false;
} }
void CHyprOpenGLImpl::beginSimple(CMonitor* pMonitor, const CRegion& damage, SP<CRenderbuffer> rb, CFramebuffer* fb) { void CHyprOpenGLImpl::beginSimple(PHLMONITOR pMonitor, const CRegion& damage, SP<CRenderbuffer> rb, CFramebuffer* fb) {
m_RenderData.pMonitor = pMonitor; m_RenderData.pMonitor = pMonitor;
#ifndef GLES2 #ifndef GLES2
@ -783,7 +783,7 @@ void CHyprOpenGLImpl::beginSimple(CMonitor* pMonitor, const CRegion& damage, SP<
m_RenderData.simplePass = true; m_RenderData.simplePass = true;
} }
void CHyprOpenGLImpl::begin(CMonitor* pMonitor, const CRegion& damage_, CFramebuffer* fb, std::optional<CRegion> finalDamage) { void CHyprOpenGLImpl::begin(PHLMONITOR pMonitor, const CRegion& damage_, CFramebuffer* fb, std::optional<CRegion> finalDamage) {
m_RenderData.pMonitor = pMonitor; m_RenderData.pMonitor = pMonitor;
static auto PFORCEINTROSPECTION = CConfigValue<Hyprlang::INT>("opengl:force_introspection"); static auto PFORCEINTROSPECTION = CConfigValue<Hyprlang::INT>("opengl:force_introspection");
@ -929,7 +929,7 @@ void CHyprOpenGLImpl::end() {
} }
// reset our data // reset our data
m_RenderData.pMonitor = nullptr; m_RenderData.pMonitor.reset();
m_RenderData.mouseZoomFactor = 1.f; m_RenderData.mouseZoomFactor = 1.f;
m_RenderData.mouseZoomUseMouse = true; m_RenderData.mouseZoomUseMouse = true;
m_RenderData.forceIntrospection = false; m_RenderData.forceIntrospection = false;
@ -1858,11 +1858,11 @@ CFramebuffer* CHyprOpenGLImpl::blurMainFramebufferWithDamage(float a, CRegion* o
return currentRenderToFB; return currentRenderToFB;
} }
void CHyprOpenGLImpl::markBlurDirtyForMonitor(CMonitor* pMonitor) { void CHyprOpenGLImpl::markBlurDirtyForMonitor(PHLMONITOR pMonitor) {
m_mMonitorRenderResources[pMonitor].blurFBDirty = true; m_mMonitorRenderResources[pMonitor].blurFBDirty = true;
} }
void CHyprOpenGLImpl::preRender(CMonitor* pMonitor) { void CHyprOpenGLImpl::preRender(PHLMONITOR pMonitor) {
static auto PBLURNEWOPTIMIZE = CConfigValue<Hyprlang::INT>("decoration:blur:new_optimizations"); static auto PBLURNEWOPTIMIZE = CConfigValue<Hyprlang::INT>("decoration:blur:new_optimizations");
static auto PBLURXRAY = CConfigValue<Hyprlang::INT>("decoration:blur:xray"); static auto PBLURXRAY = CConfigValue<Hyprlang::INT>("decoration:blur:xray");
static auto PBLUR = CConfigValue<Hyprlang::INT>("decoration:blur:enabled"); static auto PBLUR = CConfigValue<Hyprlang::INT>("decoration:blur:enabled");
@ -2728,7 +2728,7 @@ void CHyprOpenGLImpl::initAssets() {
CColor{0.9F, 0.9F, 0.9F, 0.7F}, 20, true); CColor{0.9F, 0.9F, 0.9F, 0.7F}, 20, true);
} }
void CHyprOpenGLImpl::createBGTextureForMonitor(CMonitor* pMonitor) { void CHyprOpenGLImpl::createBGTextureForMonitor(PHLMONITOR pMonitor) {
RASSERT(m_RenderData.pMonitor, "Tried to createBGTex without begin()!"); RASSERT(m_RenderData.pMonitor, "Tried to createBGTex without begin()!");
Debug::log(LOG, "Creating a texture for BGTex"); Debug::log(LOG, "Creating a texture for BGTex");
@ -2860,7 +2860,7 @@ void CHyprOpenGLImpl::clearWithTex() {
auto TEXIT = m_mMonitorBGFBs.find(m_RenderData.pMonitor); auto TEXIT = m_mMonitorBGFBs.find(m_RenderData.pMonitor);
if (TEXIT == m_mMonitorBGFBs.end()) { if (TEXIT == m_mMonitorBGFBs.end()) {
createBGTextureForMonitor(m_RenderData.pMonitor); createBGTextureForMonitor(m_RenderData.pMonitor.lock());
TEXIT = m_mMonitorBGFBs.find(m_RenderData.pMonitor); TEXIT = m_mMonitorBGFBs.find(m_RenderData.pMonitor);
} }
@ -2872,7 +2872,7 @@ void CHyprOpenGLImpl::clearWithTex() {
} }
} }
void CHyprOpenGLImpl::destroyMonitorResources(CMonitor* pMonitor) { void CHyprOpenGLImpl::destroyMonitorResources(PHLMONITOR pMonitor) {
g_pHyprRenderer->makeEGLCurrent(); g_pHyprRenderer->makeEGLCurrent();
if (!g_pHyprOpenGL) if (!g_pHyprOpenGL)
@ -2935,7 +2935,7 @@ void CHyprOpenGLImpl::setRenderModifEnabled(bool enabled) {
m_RenderData.renderModif.enabled = enabled; m_RenderData.renderModif.enabled = enabled;
} }
uint32_t CHyprOpenGLImpl::getPreferredReadFormat(CMonitor* pMonitor) { uint32_t CHyprOpenGLImpl::getPreferredReadFormat(PHLMONITOR pMonitor) {
return pMonitor->output->state->state().drmFormat; return pMonitor->output->state->state().drmFormat;
} }

View file

@ -94,7 +94,7 @@ struct SMonitorRenderData {
}; };
struct SCurrentRenderData { struct SCurrentRenderData {
CMonitor* pMonitor = nullptr; PHLMONITORREF pMonitor;
PHLWORKSPACE pWorkspace = nullptr; PHLWORKSPACE pWorkspace = nullptr;
Mat3x3 projection; Mat3x3 projection;
Mat3x3 savedProjection; Mat3x3 savedProjection;
@ -149,8 +149,8 @@ class CHyprOpenGLImpl {
CHyprOpenGLImpl(); CHyprOpenGLImpl();
~CHyprOpenGLImpl(); ~CHyprOpenGLImpl();
void begin(CMonitor*, const CRegion& damage, CFramebuffer* fb = nullptr, std::optional<CRegion> finalDamage = {}); void begin(PHLMONITOR, const CRegion& damage, CFramebuffer* fb = nullptr, std::optional<CRegion> finalDamage = {});
void beginSimple(CMonitor*, const CRegion& damage, SP<CRenderbuffer> rb = nullptr, CFramebuffer* fb = nullptr); void beginSimple(PHLMONITOR, const CRegion& damage, SP<CRenderbuffer> rb = nullptr, CFramebuffer* fb = nullptr);
void end(); void end();
void renderRect(CBox*, const CColor&, int round = 0); void renderRect(CBox*, const CColor&, int round = 0);
@ -186,13 +186,13 @@ class CHyprOpenGLImpl {
void scissor(const pixman_box32*, bool transform = true); void scissor(const pixman_box32*, bool transform = true);
void scissor(const int x, const int y, const int w, const int h, bool transform = true); void scissor(const int x, const int y, const int w, const int h, bool transform = true);
void destroyMonitorResources(CMonitor*); void destroyMonitorResources(PHLMONITOR);
void markBlurDirtyForMonitor(CMonitor*); void markBlurDirtyForMonitor(PHLMONITOR);
void preWindowPass(); void preWindowPass();
bool preBlurQueued(); bool preBlurQueued();
void preRender(CMonitor*); void preRender(PHLMONITOR);
void saveBufferForMirror(CBox*); void saveBufferForMirror(CBox*);
void renderMirrored(); void renderMirrored();
@ -205,7 +205,7 @@ class CHyprOpenGLImpl {
void setDamage(const CRegion& damage, std::optional<CRegion> finalDamage = {}); void setDamage(const CRegion& damage, std::optional<CRegion> finalDamage = {});
uint32_t getPreferredReadFormat(CMonitor* pMonitor); uint32_t getPreferredReadFormat(PHLMONITOR pMonitor);
std::vector<SDRMFormat> getDRMFormats(); std::vector<SDRMFormat> getDRMFormats();
EGLImageKHR createEGLImage(const Aquamarine::SDMABUFAttrs& attrs); EGLImageKHR createEGLImage(const Aquamarine::SDMABUFAttrs& attrs);
SP<CEGLSync> createEGLSync(int fenceFD); SP<CEGLSync> createEGLSync(int fenceFD);
@ -228,8 +228,8 @@ class CHyprOpenGLImpl {
std::map<PHLWINDOWREF, CFramebuffer> m_mWindowFramebuffers; std::map<PHLWINDOWREF, CFramebuffer> m_mWindowFramebuffers;
std::map<PHLLSREF, CFramebuffer> m_mLayerFramebuffers; std::map<PHLLSREF, CFramebuffer> m_mLayerFramebuffers;
std::unordered_map<CMonitor*, SMonitorRenderData> m_mMonitorRenderResources; std::unordered_map<PHLMONITORREF, SMonitorRenderData> m_mMonitorRenderResources;
std::unordered_map<CMonitor*, CFramebuffer> m_mMonitorBGFBs; std::unordered_map<PHLMONITORREF, CFramebuffer> m_mMonitorBGFBs;
struct { struct {
PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC glEGLImageTargetRenderbufferStorageOES = nullptr; PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC glEGLImageTargetRenderbufferStorageOES = nullptr;
@ -282,7 +282,7 @@ class CHyprOpenGLImpl {
void logShaderError(const GLuint&, bool program = false); void logShaderError(const GLuint&, bool program = false);
GLuint createProgram(const std::string&, const std::string&, bool dynamic = false); GLuint createProgram(const std::string&, const std::string&, bool dynamic = false);
GLuint compileShader(const GLuint&, std::string, bool dynamic = false); GLuint compileShader(const GLuint&, std::string, bool dynamic = false);
void createBGTextureForMonitor(CMonitor*); void createBGTextureForMonitor(PHLMONITOR);
void initShaders(); void initShaders();
void initDRMFormats(); void initDRMFormats();
void initEGL(bool gbm); void initEGL(bool gbm);
@ -304,7 +304,7 @@ class CHyprOpenGLImpl {
void preBlurForCurrentMonitor(); void preBlurForCurrentMonitor();
bool passRequiresIntrospection(CMonitor* pMonitor); bool passRequiresIntrospection(PHLMONITOR pMonitor);
friend class CHyprRenderer; friend class CHyprRenderer;
}; };

View file

@ -295,7 +295,7 @@ static void renderSurface(SP<CWLSurfaceResource> surface, int x, int y, void* da
RDATA->surfaceCounter++; RDATA->surfaceCounter++;
} }
bool CHyprRenderer::shouldRenderWindow(PHLWINDOW pWindow, CMonitor* pMonitor) { bool CHyprRenderer::shouldRenderWindow(PHLWINDOW pWindow, PHLMONITOR pMonitor) {
if (!pWindow->visibleOnMonitor(pMonitor)) if (!pWindow->visibleOnMonitor(pMonitor))
return false; return false;
@ -389,7 +389,7 @@ bool CHyprRenderer::shouldRenderWindow(PHLWINDOW pWindow) {
return false; return false;
} }
void CHyprRenderer::renderWorkspaceWindowsFullscreen(CMonitor* pMonitor, PHLWORKSPACE pWorkspace, timespec* time) { void CHyprRenderer::renderWorkspaceWindowsFullscreen(PHLMONITOR pMonitor, PHLWORKSPACE pWorkspace, timespec* time) {
PHLWINDOW pWorkspaceWindow = nullptr; PHLWINDOW pWorkspaceWindow = nullptr;
EMIT_HOOK_EVENT("render", RENDER_PRE_WINDOWS); EMIT_HOOK_EVENT("render", RENDER_PRE_WINDOWS);
@ -479,7 +479,7 @@ void CHyprRenderer::renderWorkspaceWindowsFullscreen(CMonitor* pMonitor, PHLWORK
} }
} }
void CHyprRenderer::renderWorkspaceWindows(CMonitor* pMonitor, PHLWORKSPACE pWorkspace, timespec* time) { void CHyprRenderer::renderWorkspaceWindows(PHLMONITOR pMonitor, PHLWORKSPACE pWorkspace, timespec* time) {
PHLWINDOW lastWindow; PHLWINDOW lastWindow;
EMIT_HOOK_EVENT("render", RENDER_PRE_WINDOWS); EMIT_HOOK_EVENT("render", RENDER_PRE_WINDOWS);
@ -551,7 +551,7 @@ void CHyprRenderer::renderWorkspaceWindows(CMonitor* pMonitor, PHLWORKSPACE pWor
} }
} }
void CHyprRenderer::renderWindow(PHLWINDOW pWindow, CMonitor* pMonitor, timespec* time, bool decorate, eRenderPassMode mode, bool ignorePosition, bool ignoreAllGeometry) { void CHyprRenderer::renderWindow(PHLWINDOW pWindow, PHLMONITOR pMonitor, timespec* time, bool decorate, eRenderPassMode mode, bool ignorePosition, bool ignoreAllGeometry) {
if (pWindow->isHidden()) if (pWindow->isHidden())
return; return;
@ -766,7 +766,7 @@ void CHyprRenderer::renderWindow(PHLWINDOW pWindow, CMonitor* pMonitor, timespec
g_pHyprOpenGL->m_RenderData.clipBox = CBox(); g_pHyprOpenGL->m_RenderData.clipBox = CBox();
} }
void CHyprRenderer::renderLayer(PHLLS pLayer, CMonitor* pMonitor, timespec* time, bool popups) { void CHyprRenderer::renderLayer(PHLLS pLayer, PHLMONITOR pMonitor, timespec* time, bool popups) {
if (!pLayer) if (!pLayer)
return; return;
@ -835,7 +835,7 @@ void CHyprRenderer::renderLayer(PHLLS pLayer, CMonitor* pMonitor, timespec* time
g_pHyprOpenGL->m_RenderData.discardOpacity = DA; g_pHyprOpenGL->m_RenderData.discardOpacity = DA;
} }
void CHyprRenderer::renderIMEPopup(CInputPopup* pPopup, CMonitor* pMonitor, timespec* time) { void CHyprRenderer::renderIMEPopup(CInputPopup* pPopup, PHLMONITOR pMonitor, timespec* time) {
const auto POS = pPopup->globalBox().pos(); const auto POS = pPopup->globalBox().pos();
SRenderData renderdata = {pMonitor, time, POS.x, POS.y}; SRenderData renderdata = {pMonitor, time, POS.x, POS.y};
@ -851,7 +851,7 @@ void CHyprRenderer::renderIMEPopup(CInputPopup* pPopup, CMonitor* pMonitor, time
SURF->breadthfirst([](SP<CWLSurfaceResource> s, const Vector2D& offset, void* data) { renderSurface(s, offset.x, offset.y, data); }, &renderdata); SURF->breadthfirst([](SP<CWLSurfaceResource> s, const Vector2D& offset, void* data) { renderSurface(s, offset.x, offset.y, data); }, &renderdata);
} }
void CHyprRenderer::renderSessionLockSurface(SSessionLockSurface* pSurface, CMonitor* pMonitor, timespec* time) { void CHyprRenderer::renderSessionLockSurface(SSessionLockSurface* pSurface, PHLMONITOR pMonitor, timespec* time) {
SRenderData renderdata = {pMonitor, time, pMonitor->vecPosition.x, pMonitor->vecPosition.y}; SRenderData renderdata = {pMonitor, time, pMonitor->vecPosition.x, pMonitor->vecPosition.y};
renderdata.blur = false; renderdata.blur = false;
@ -863,7 +863,7 @@ void CHyprRenderer::renderSessionLockSurface(SSessionLockSurface* pSurface, CMon
renderdata.surface->breadthfirst([](SP<CWLSurfaceResource> s, const Vector2D& offset, void* data) { renderSurface(s, offset.x, offset.y, data); }, &renderdata); renderdata.surface->breadthfirst([](SP<CWLSurfaceResource> s, const Vector2D& offset, void* data) { renderSurface(s, offset.x, offset.y, data); }, &renderdata);
} }
void CHyprRenderer::renderAllClientsForWorkspace(CMonitor* pMonitor, PHLWORKSPACE pWorkspace, timespec* time, const Vector2D& translate, const float& scale) { void CHyprRenderer::renderAllClientsForWorkspace(PHLMONITOR pMonitor, PHLWORKSPACE pWorkspace, timespec* time, const Vector2D& translate, const float& scale) {
static auto PDIMSPECIAL = CConfigValue<Hyprlang::FLOAT>("decoration:dim_special"); static auto PDIMSPECIAL = CConfigValue<Hyprlang::FLOAT>("decoration:dim_special");
static auto PBLURSPECIAL = CConfigValue<Hyprlang::INT>("decoration:blur:special"); static auto PBLURSPECIAL = CConfigValue<Hyprlang::INT>("decoration:blur:special");
static auto PBLUR = CConfigValue<Hyprlang::INT>("decoration:blur:enabled"); static auto PBLUR = CConfigValue<Hyprlang::INT>("decoration:blur:enabled");
@ -1036,7 +1036,7 @@ void CHyprRenderer::renderAllClientsForWorkspace(CMonitor* pMonitor, PHLWORKSPAC
g_pHyprOpenGL->m_RenderData.renderModif = {}; g_pHyprOpenGL->m_RenderData.renderModif = {};
} }
void CHyprRenderer::renderLockscreen(CMonitor* pMonitor, timespec* now, const CBox& geometry) { void CHyprRenderer::renderLockscreen(PHLMONITOR pMonitor, timespec* now, const CBox& geometry) {
TRACY_GPU_ZONE("RenderLockscreen"); TRACY_GPU_ZONE("RenderLockscreen");
if (g_pSessionLockManager->isSessionLocked()) { if (g_pSessionLockManager->isSessionLocked()) {
@ -1052,7 +1052,7 @@ void CHyprRenderer::renderLockscreen(CMonitor* pMonitor, timespec* now, const CB
} }
} }
void CHyprRenderer::renderSessionLockMissing(CMonitor* pMonitor) { void CHyprRenderer::renderSessionLockMissing(PHLMONITOR pMonitor) {
const auto ALPHA = g_pSessionLockManager->getRedScreenAlphaForMonitor(pMonitor->ID); const auto ALPHA = g_pSessionLockManager->getRedScreenAlphaForMonitor(pMonitor->ID);
CBox monbox = {{}, pMonitor->vecPixelSize}; CBox monbox = {{}, pMonitor->vecPixelSize};
@ -1181,7 +1181,7 @@ void CHyprRenderer::calculateUVForSurface(PHLWINDOW pWindow, SP<CWLSurfaceResour
} }
} }
void CHyprRenderer::renderMonitor(CMonitor* pMonitor) { void CHyprRenderer::renderMonitor(PHLMONITOR pMonitor) {
static std::chrono::high_resolution_clock::time_point renderStart = std::chrono::high_resolution_clock::now(); static std::chrono::high_resolution_clock::time_point renderStart = std::chrono::high_resolution_clock::now();
static std::chrono::high_resolution_clock::time_point renderStartOverlay = std::chrono::high_resolution_clock::now(); static std::chrono::high_resolution_clock::time_point renderStartOverlay = std::chrono::high_resolution_clock::now();
static std::chrono::high_resolution_clock::time_point endRenderOverlay = std::chrono::high_resolution_clock::now(); static std::chrono::high_resolution_clock::time_point endRenderOverlay = std::chrono::high_resolution_clock::now();
@ -1410,13 +1410,13 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
renderLockscreen(pMonitor, &now, renderBox); renderLockscreen(pMonitor, &now, renderBox);
if (pMonitor == g_pCompositor->m_pLastMonitor.get()) { if (pMonitor == g_pCompositor->m_pLastMonitor) {
g_pHyprNotificationOverlay->draw(pMonitor); g_pHyprNotificationOverlay->draw(pMonitor);
g_pHyprError->draw(); g_pHyprError->draw();
} }
// for drawing the debug overlay // for drawing the debug overlay
if (pMonitor == g_pCompositor->m_vMonitors.front().get() && *PDEBUGOVERLAY == 1) { if (pMonitor == g_pCompositor->m_vMonitors.front() && *PDEBUGOVERLAY == 1) {
renderStartOverlay = std::chrono::high_resolution_clock::now(); renderStartOverlay = std::chrono::high_resolution_clock::now();
g_pDebugOverlay->draw(); g_pDebugOverlay->draw();
endRenderOverlay = std::chrono::high_resolution_clock::now(); endRenderOverlay = std::chrono::high_resolution_clock::now();
@ -1491,7 +1491,7 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
g_pDebugOverlay->renderData(pMonitor, durationUs); g_pDebugOverlay->renderData(pMonitor, durationUs);
if (*PDEBUGOVERLAY == 1) { if (*PDEBUGOVERLAY == 1) {
if (pMonitor == g_pCompositor->m_vMonitors.front().get()) { if (pMonitor == g_pCompositor->m_vMonitors.front()) {
const float noOverlayUs = durationUs - std::chrono::duration_cast<std::chrono::nanoseconds>(endRenderOverlay - renderStartOverlay).count() / 1000.f; const float noOverlayUs = durationUs - std::chrono::duration_cast<std::chrono::nanoseconds>(endRenderOverlay - renderStartOverlay).count() / 1000.f;
g_pDebugOverlay->renderDataNoOverlay(pMonitor, noOverlayUs); g_pDebugOverlay->renderDataNoOverlay(pMonitor, noOverlayUs);
} else { } else {
@ -1500,7 +1500,7 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
} }
} }
bool CHyprRenderer::commitPendingAndDoExplicitSync(CMonitor* pMonitor) { bool CHyprRenderer::commitPendingAndDoExplicitSync(PHLMONITOR pMonitor) {
// apply timelines for explicit sync // apply timelines for explicit sync
// save inFD otherwise reset will reset it // save inFD otherwise reset will reset it
auto inFD = pMonitor->output->state->state().explicitInFence; auto inFD = pMonitor->output->state->state().explicitInFence;
@ -1565,7 +1565,7 @@ bool CHyprRenderer::commitPendingAndDoExplicitSync(CMonitor* pMonitor) {
return ok; return ok;
} }
void CHyprRenderer::renderWorkspace(CMonitor* pMonitor, PHLWORKSPACE pWorkspace, timespec* now, const CBox& geometry) { void CHyprRenderer::renderWorkspace(PHLMONITOR pMonitor, PHLWORKSPACE pWorkspace, timespec* now, const CBox& geometry) {
Vector2D translate = {geometry.x, geometry.y}; Vector2D translate = {geometry.x, geometry.y};
float scale = (float)geometry.width / pMonitor->vecPixelSize.x; float scale = (float)geometry.width / pMonitor->vecPixelSize.x;
@ -1582,7 +1582,7 @@ void CHyprRenderer::renderWorkspace(CMonitor* pMonitor, PHLWORKSPACE pWorkspace,
g_pHyprOpenGL->m_RenderData.pWorkspace = nullptr; g_pHyprOpenGL->m_RenderData.pWorkspace = nullptr;
} }
void CHyprRenderer::sendFrameEventsToWorkspace(CMonitor* pMonitor, PHLWORKSPACE pWorkspace, timespec* now) { void CHyprRenderer::sendFrameEventsToWorkspace(PHLMONITOR pMonitor, PHLWORKSPACE pWorkspace, timespec* now) {
for (auto const& w : g_pCompositor->m_vWindows) { for (auto const& w : g_pCompositor->m_vWindows) {
if (w->isHidden() || !w->m_bIsMapped || w->m_bFadingOut || !w->m_pWLSurface->resource()) if (w->isHidden() || !w->m_bIsMapped || w->m_bFadingOut || !w->m_pWLSurface->resource())
continue; continue;
@ -1670,7 +1670,7 @@ static void applyExclusive(CBox& usableArea, uint32_t anchor, int32_t exclusive,
} }
} }
void CHyprRenderer::arrangeLayerArray(CMonitor* pMonitor, const std::vector<PHLLSREF>& layerSurfaces, bool exclusiveZone, CBox* usableArea) { void CHyprRenderer::arrangeLayerArray(PHLMONITOR pMonitor, const std::vector<PHLLSREF>& layerSurfaces, bool exclusiveZone, CBox* usableArea) {
CBox full_area = {pMonitor->vecPosition.x, pMonitor->vecPosition.y, pMonitor->vecSize.x, pMonitor->vecSize.y}; CBox full_area = {pMonitor->vecPosition.x, pMonitor->vecPosition.y, pMonitor->vecSize.x, pMonitor->vecSize.y};
for (auto const& ls : layerSurfaces) { for (auto const& ls : layerSurfaces) {
@ -1693,56 +1693,58 @@ void CHyprRenderer::arrangeLayerArray(CMonitor* pMonitor, const std::vector<PHLL
CBox box = {{}, PSTATE->desiredSize}; CBox box = {{}, PSTATE->desiredSize};
// Horizontal axis // Horizontal axis
const uint32_t both_horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT; const uint32_t both_horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
if (box.width == 0) { if (box.width == 0)
box.x = bounds.x; box.x = bounds.x;
} else if ((PSTATE->anchor & both_horiz) == both_horiz) { else if ((PSTATE->anchor & both_horiz) == both_horiz)
box.x = bounds.x + ((bounds.width / 2) - (box.width / 2)); box.x = bounds.x + ((bounds.width / 2) - (box.width / 2));
} else if ((PSTATE->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT)) { else if ((PSTATE->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT))
box.x = bounds.x; box.x = bounds.x;
} else if ((PSTATE->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT)) { else if ((PSTATE->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT))
box.x = bounds.x + (bounds.width - box.width); box.x = bounds.x + (bounds.width - box.width);
} else { else
box.x = bounds.x + ((bounds.width / 2) - (box.width / 2)); box.x = bounds.x + ((bounds.width / 2) - (box.width / 2));
}
// Vertical axis // Vertical axis
const uint32_t both_vert = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM; const uint32_t both_vert = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM;
if (box.height == 0) { if (box.height == 0)
box.y = bounds.y; box.y = bounds.y;
} else if ((PSTATE->anchor & both_vert) == both_vert) { else if ((PSTATE->anchor & both_vert) == both_vert)
box.y = bounds.y + ((bounds.height / 2) - (box.height / 2)); box.y = bounds.y + ((bounds.height / 2) - (box.height / 2));
} else if ((PSTATE->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP)) { else if ((PSTATE->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP))
box.y = bounds.y; box.y = bounds.y;
} else if ((PSTATE->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM)) { else if ((PSTATE->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM))
box.y = bounds.y + (bounds.height - box.height); box.y = bounds.y + (bounds.height - box.height);
} else { else
box.y = bounds.y + ((bounds.height / 2) - (box.height / 2)); box.y = bounds.y + ((bounds.height / 2) - (box.height / 2));
}
// Margin // Margin
if (box.width == 0) { if (box.width == 0) {
box.x += PSTATE->margin.left; box.x += PSTATE->margin.left;
box.width = bounds.width - (PSTATE->margin.left + PSTATE->margin.right); box.width = bounds.width - (PSTATE->margin.left + PSTATE->margin.right);
} else if ((PSTATE->anchor & both_horiz) == both_horiz) { } else if ((PSTATE->anchor & both_horiz) == both_horiz)
// don't apply margins ; // don't apply margins
} else if ((PSTATE->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT)) { else if ((PSTATE->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT))
box.x += PSTATE->margin.left; box.x += PSTATE->margin.left;
} else if ((PSTATE->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT)) { else if ((PSTATE->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT))
box.x -= PSTATE->margin.right; box.x -= PSTATE->margin.right;
}
if (box.height == 0) { if (box.height == 0) {
box.y += PSTATE->margin.top; box.y += PSTATE->margin.top;
box.height = bounds.height - (PSTATE->margin.top + PSTATE->margin.bottom); box.height = bounds.height - (PSTATE->margin.top + PSTATE->margin.bottom);
} else if ((PSTATE->anchor & both_vert) == both_vert) { } else if ((PSTATE->anchor & both_vert) == both_vert)
// don't apply margins ; // don't apply margins
} else if ((PSTATE->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP)) { else if ((PSTATE->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP))
box.y += PSTATE->margin.top; box.y += PSTATE->margin.top;
} else if ((PSTATE->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM)) { else if ((PSTATE->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM))
box.y -= PSTATE->margin.bottom; box.y -= PSTATE->margin.bottom;
}
if (box.width <= 0 || box.height <= 0) { if (box.width <= 0 || box.height <= 0) {
Debug::log(ERR, "LayerSurface {:x} has a negative/zero w/h???", (uintptr_t)ls.get()); Debug::log(ERR, "LayerSurface {:x} has a negative/zero w/h???", (uintptr_t)ls.get());
continue; continue;
} }
// Apply
box.round(); // fix rounding errors
ls->geometry = box; ls->geometry = box;
applyExclusive(*usableArea, PSTATE->anchor, PSTATE->exclusive, PSTATE->exclusiveEdge, PSTATE->margin.top, PSTATE->margin.right, PSTATE->margin.bottom, PSTATE->margin.left); applyExclusive(*usableArea, PSTATE->anchor, PSTATE->exclusive, PSTATE->exclusiveEdge, PSTATE->margin.top, PSTATE->margin.right, PSTATE->margin.bottom, PSTATE->margin.left);
@ -1865,7 +1867,7 @@ void CHyprRenderer::damageWindow(PHLWINDOW pWindow, bool forceFull) {
windowBox.translate(pWindow->m_vFloatingOffset); windowBox.translate(pWindow->m_vFloatingOffset);
for (auto const& m : g_pCompositor->m_vMonitors) { for (auto const& m : g_pCompositor->m_vMonitors) {
if (forceFull || g_pHyprRenderer->shouldRenderWindow(pWindow, m.get())) { // only damage if window is rendered on monitor if (forceFull || g_pHyprRenderer->shouldRenderWindow(pWindow, m)) { // only damage if window is rendered on monitor
CBox fixedDamageBox = {windowBox.x - m->vecPosition.x, windowBox.y - m->vecPosition.y, windowBox.width, windowBox.height}; CBox fixedDamageBox = {windowBox.x - m->vecPosition.x, windowBox.y - m->vecPosition.y, windowBox.width, windowBox.height};
fixedDamageBox.scale(m->scale); fixedDamageBox.scale(m->scale);
m->addDamage(&fixedDamageBox); m->addDamage(&fixedDamageBox);
@ -1881,7 +1883,7 @@ void CHyprRenderer::damageWindow(PHLWINDOW pWindow, bool forceFull) {
Debug::log(LOG, "Damage: Window ({}): xy: {}, {} wh: {}, {}", pWindow->m_szTitle, windowBox.x, windowBox.y, windowBox.width, windowBox.height); Debug::log(LOG, "Damage: Window ({}): xy: {}, {} wh: {}, {}", pWindow->m_szTitle, windowBox.x, windowBox.y, windowBox.width, windowBox.height);
} }
void CHyprRenderer::damageMonitor(CMonitor* pMonitor) { void CHyprRenderer::damageMonitor(PHLMONITOR pMonitor) {
if (g_pCompositor->m_bUnsafeState || pMonitor->isMirror()) if (g_pCompositor->m_bUnsafeState || pMonitor->isMirror())
return; return;
@ -1925,7 +1927,7 @@ void CHyprRenderer::damageRegion(const CRegion& rg) {
} }
} }
void CHyprRenderer::damageMirrorsWith(CMonitor* pMonitor, const CRegion& pRegion) { void CHyprRenderer::damageMirrorsWith(PHLMONITOR pMonitor, const CRegion& pRegion) {
for (auto const& mirror : pMonitor->mirrors) { for (auto const& mirror : pMonitor->mirrors) {
// transform the damage here, so it won't get clipped by the monitor damage ring // transform the damage here, so it won't get clipped by the monitor damage ring
@ -1946,11 +1948,11 @@ void CHyprRenderer::damageMirrorsWith(CMonitor* pMonitor, const CRegion& pRegion
mirror->addDamage(&transformed); mirror->addDamage(&transformed);
g_pCompositor->scheduleFrameForMonitor(mirror, Aquamarine::IOutput::AQ_SCHEDULE_DAMAGE); g_pCompositor->scheduleFrameForMonitor(mirror.lock(), Aquamarine::IOutput::AQ_SCHEDULE_DAMAGE);
} }
} }
void CHyprRenderer::renderDragIcon(CMonitor* pMonitor, timespec* time) { void CHyprRenderer::renderDragIcon(PHLMONITOR pMonitor, timespec* time) {
PROTO::data->renderDND(pMonitor, time); PROTO::data->renderDND(pMonitor, time);
} }
@ -1965,7 +1967,7 @@ DAMAGETRACKINGMODES CHyprRenderer::damageTrackingModeFromStr(const std::string&
return DAMAGE_TRACKING_INVALID; return DAMAGE_TRACKING_INVALID;
} }
bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorRule, bool force) { bool CHyprRenderer::applyMonitorRule(PHLMONITOR pMonitor, SMonitorRule* pMonitorRule, bool force) {
static auto PDISABLESCALECHECKS = CConfigValue<Hyprlang::INT>("debug:disable_scale_checks"); static auto PDISABLESCALECHECKS = CConfigValue<Hyprlang::INT>("debug:disable_scale_checks");
@ -2436,7 +2438,7 @@ void CHyprRenderer::ensureCursorRenderingMode() {
if (!g_pPointerManager->softwareLockedFor(m)) if (!g_pPointerManager->softwareLockedFor(m))
continue; continue;
g_pHyprRenderer->damageMonitor(m.get()); // TODO: maybe just damage the cursor area? g_pHyprRenderer->damageMonitor(m); // TODO: maybe just damage the cursor area?
} }
setCursorHidden(true); setCursorHidden(true);
@ -2448,7 +2450,7 @@ void CHyprRenderer::ensureCursorRenderingMode() {
if (!g_pPointerManager->softwareLockedFor(m)) if (!g_pPointerManager->softwareLockedFor(m))
continue; continue;
g_pHyprRenderer->damageMonitor(m.get()); // TODO: maybe just damage the cursor area? g_pHyprRenderer->damageMonitor(m); // TODO: maybe just damage the cursor area?
} }
setCursorHidden(false); setCursorHidden(false);
@ -2479,7 +2481,7 @@ bool CHyprRenderer::shouldRenderCursor() {
return !m_bCursorHidden && m_bCursorHasSurface; return !m_bCursorHidden && m_bCursorHasSurface;
} }
std::tuple<float, float, float> CHyprRenderer::getRenderTimes(CMonitor* pMonitor) { std::tuple<float, float, float> CHyprRenderer::getRenderTimes(PHLMONITOR pMonitor) {
const auto POVERLAY = &g_pDebugOverlay->m_mMonitorOverlays[pMonitor]; const auto POVERLAY = &g_pDebugOverlay->m_mMonitorOverlays[pMonitor];
float avgRenderTime = 0; float avgRenderTime = 0;
@ -2590,7 +2592,7 @@ void CHyprRenderer::setOccludedForBackLayers(CRegion& region, PHLWORKSPACE pWork
region.subtract(rg); region.subtract(rg);
} }
bool CHyprRenderer::canSkipBackBufferClear(CMonitor* pMonitor) { bool CHyprRenderer::canSkipBackBufferClear(PHLMONITOR pMonitor) {
for (auto const& ls : pMonitor->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND]) { for (auto const& ls : pMonitor->m_aLayerSurfaceLayers[ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND]) {
if (!ls->layerSurface) if (!ls->layerSurface)
continue; continue;
@ -2616,7 +2618,7 @@ bool CHyprRenderer::canSkipBackBufferClear(CMonitor* pMonitor) {
return false; return false;
} }
void CHyprRenderer::recheckSolitaryForMonitor(CMonitor* pMonitor) { void CHyprRenderer::recheckSolitaryForMonitor(PHLMONITOR pMonitor) {
pMonitor->solitaryClient.reset(); // reset it, if we find one it will be set. pMonitor->solitaryClient.reset(); // reset it, if we find one it will be set.
if (g_pHyprNotificationOverlay->hasAny() || g_pSessionLockManager->isSessionLocked()) if (g_pHyprNotificationOverlay->hasAny() || g_pSessionLockManager->isSessionLocked())
@ -2704,7 +2706,7 @@ void CHyprRenderer::unsetEGL() {
eglMakeCurrent(g_pHyprOpenGL->m_pEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglMakeCurrent(g_pHyprOpenGL->m_pEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
} }
bool CHyprRenderer::beginRender(CMonitor* pMonitor, CRegion& damage, eRenderMode mode, SP<IHLBuffer> buffer, CFramebuffer* fb, bool simple) { bool CHyprRenderer::beginRender(PHLMONITOR pMonitor, CRegion& damage, eRenderMode mode, SP<IHLBuffer> buffer, CFramebuffer* fb, bool simple) {
makeEGLCurrent(); makeEGLCurrent();
@ -2777,7 +2779,7 @@ void CHyprRenderer::endRender() {
if (m_eRenderMode != RENDER_MODE_TO_BUFFER_READ_ONLY) if (m_eRenderMode != RENDER_MODE_TO_BUFFER_READ_ONLY)
g_pHyprOpenGL->end(); g_pHyprOpenGL->end();
else { else {
g_pHyprOpenGL->m_RenderData.pMonitor = nullptr; g_pHyprOpenGL->m_RenderData.pMonitor.reset();
g_pHyprOpenGL->m_RenderData.mouseZoomFactor = 1.f; g_pHyprOpenGL->m_RenderData.mouseZoomFactor = 1.f;
g_pHyprOpenGL->m_RenderData.mouseZoomUseMouse = true; g_pHyprOpenGL->m_RenderData.mouseZoomUseMouse = true;
} }

View file

@ -49,29 +49,29 @@ class CHyprRenderer {
CHyprRenderer(); CHyprRenderer();
~CHyprRenderer(); ~CHyprRenderer();
void renderMonitor(CMonitor* pMonitor); void renderMonitor(PHLMONITOR pMonitor);
void arrangeLayersForMonitor(const MONITORID&); void arrangeLayersForMonitor(const MONITORID&);
void damageSurface(SP<CWLSurfaceResource>, double, double, double scale = 1.0); void damageSurface(SP<CWLSurfaceResource>, double, double, double scale = 1.0);
void damageWindow(PHLWINDOW, bool forceFull = false); void damageWindow(PHLWINDOW, bool forceFull = false);
void damageBox(CBox*, bool skipFrameSchedule = false); void damageBox(CBox*, bool skipFrameSchedule = false);
void damageBox(const int& x, const int& y, const int& w, const int& h); void damageBox(const int& x, const int& y, const int& w, const int& h);
void damageRegion(const CRegion&); void damageRegion(const CRegion&);
void damageMonitor(CMonitor*); void damageMonitor(PHLMONITOR);
void damageMirrorsWith(CMonitor*, const CRegion&); void damageMirrorsWith(PHLMONITOR, const CRegion&);
bool applyMonitorRule(CMonitor*, SMonitorRule*, bool force = false); bool applyMonitorRule(PHLMONITOR, SMonitorRule*, bool force = false);
bool shouldRenderWindow(PHLWINDOW, CMonitor*); bool shouldRenderWindow(PHLWINDOW, PHLMONITOR);
bool shouldRenderWindow(PHLWINDOW); bool shouldRenderWindow(PHLWINDOW);
void ensureCursorRenderingMode(); void ensureCursorRenderingMode();
bool shouldRenderCursor(); bool shouldRenderCursor();
void setCursorHidden(bool hide); void setCursorHidden(bool hide);
void calculateUVForSurface(PHLWINDOW, SP<CWLSurfaceResource>, SP<CMonitor> pMonitor, bool main = false, const Vector2D& projSize = {}, const Vector2D& projSizeUnscaled = {}, void calculateUVForSurface(PHLWINDOW, SP<CWLSurfaceResource>, SP<CMonitor> pMonitor, bool main = false, const Vector2D& projSize = {}, const Vector2D& projSizeUnscaled = {},
bool fixMisalignedFSV1 = false); bool fixMisalignedFSV1 = false);
std::tuple<float, float, float> getRenderTimes(CMonitor* pMonitor); // avg max min std::tuple<float, float, float> getRenderTimes(PHLMONITOR pMonitor); // avg max min
void renderLockscreen(CMonitor* pMonitor, timespec* now, const CBox& geometry); void renderLockscreen(PHLMONITOR pMonitor, timespec* now, const CBox& geometry);
void setOccludedForBackLayers(CRegion& region, PHLWORKSPACE pWorkspace); void setOccludedForBackLayers(CRegion& region, PHLWORKSPACE pWorkspace);
void setOccludedForMainWorkspace(CRegion& region, PHLWORKSPACE pWorkspace); // TODO: merge occlusion methods void setOccludedForMainWorkspace(CRegion& region, PHLWORKSPACE pWorkspace); // TODO: merge occlusion methods
bool canSkipBackBufferClear(CMonitor* pMonitor); bool canSkipBackBufferClear(PHLMONITOR pMonitor);
void recheckSolitaryForMonitor(CMonitor* pMonitor); void recheckSolitaryForMonitor(PHLMONITOR pMonitor);
void setCursorSurface(SP<CWLSurface> surf, int hotspotX, int hotspotY, bool force = false); void setCursorSurface(SP<CWLSurface> surf, int hotspotX, int hotspotY, bool force = false);
void setCursorFromName(const std::string& name, bool force = false); void setCursorFromName(const std::string& name, bool force = false);
void onRenderbufferDestroy(CRenderbuffer* rb); void onRenderbufferDestroy(CRenderbuffer* rb);
@ -84,12 +84,12 @@ class CHyprRenderer {
// if RENDER_MODE_NORMAL, provided damage will be written to. // if RENDER_MODE_NORMAL, provided damage will be written to.
// otherwise, it will be the one used. // otherwise, it will be the one used.
bool beginRender(CMonitor* pMonitor, CRegion& damage, eRenderMode mode = RENDER_MODE_NORMAL, SP<IHLBuffer> buffer = {}, CFramebuffer* fb = nullptr, bool simple = false); bool beginRender(PHLMONITOR pMonitor, CRegion& damage, eRenderMode mode = RENDER_MODE_NORMAL, SP<IHLBuffer> buffer = {}, CFramebuffer* fb = nullptr, bool simple = false);
void endRender(); void endRender();
bool m_bBlockSurfaceFeedback = false; bool m_bBlockSurfaceFeedback = false;
bool m_bRenderingSnapshot = false; bool m_bRenderingSnapshot = false;
CMonitor* m_pMostHzMonitor = nullptr; PHLMONITORREF m_pMostHzMonitor;
bool m_bDirectScanoutBlocked = false; bool m_bDirectScanoutBlocked = false;
DAMAGETRACKINGMODES DAMAGETRACKINGMODES
@ -115,20 +115,20 @@ class CHyprRenderer {
} m_sLastCursorData; } m_sLastCursorData;
private: private:
void arrangeLayerArray(CMonitor*, const std::vector<PHLLSREF>&, bool, CBox*); void arrangeLayerArray(PHLMONITOR, const std::vector<PHLLSREF>&, bool, CBox*);
void renderWorkspaceWindowsFullscreen(CMonitor*, PHLWORKSPACE, timespec*); // renders workspace windows (fullscreen) (tiled, floating, pinned, but no special) void renderWorkspaceWindowsFullscreen(PHLMONITOR, PHLWORKSPACE, timespec*); // renders workspace windows (fullscreen) (tiled, floating, pinned, but no special)
void renderWorkspaceWindows(CMonitor*, PHLWORKSPACE, timespec*); // renders workspace windows (no fullscreen) (tiled, floating, pinned, but no special) void renderWorkspaceWindows(PHLMONITOR, PHLWORKSPACE, timespec*); // renders workspace windows (no fullscreen) (tiled, floating, pinned, but no special)
void renderWindow(PHLWINDOW, CMonitor*, timespec*, bool, eRenderPassMode, bool ignorePosition = false, bool ignoreAllGeometry = false); void renderWindow(PHLWINDOW, PHLMONITOR, timespec*, bool, eRenderPassMode, bool ignorePosition = false, bool ignoreAllGeometry = false);
void renderLayer(PHLLS, CMonitor*, timespec*, bool popups = false); void renderLayer(PHLLS, PHLMONITOR, timespec*, bool popups = false);
void renderSessionLockSurface(SSessionLockSurface*, CMonitor*, timespec*); void renderSessionLockSurface(SSessionLockSurface*, PHLMONITOR, timespec*);
void renderDragIcon(CMonitor*, timespec*); void renderDragIcon(PHLMONITOR, timespec*);
void renderIMEPopup(CInputPopup*, CMonitor*, timespec*); void renderIMEPopup(CInputPopup*, PHLMONITOR, timespec*);
void renderWorkspace(CMonitor* pMonitor, PHLWORKSPACE pWorkspace, timespec* now, const CBox& geometry); void renderWorkspace(PHLMONITOR pMonitor, PHLWORKSPACE pWorkspace, timespec* now, const CBox& geometry);
void sendFrameEventsToWorkspace(CMonitor* pMonitor, PHLWORKSPACE pWorkspace, timespec* now); // sends frame displayed events but doesn't actually render anything void sendFrameEventsToWorkspace(PHLMONITOR pMonitor, PHLWORKSPACE pWorkspace, timespec* now); // sends frame displayed events but doesn't actually render anything
void renderAllClientsForWorkspace(CMonitor* pMonitor, PHLWORKSPACE pWorkspace, timespec* now, const Vector2D& translate = {0, 0}, const float& scale = 1.f); void renderAllClientsForWorkspace(PHLMONITOR pMonitor, PHLWORKSPACE pWorkspace, timespec* now, const Vector2D& translate = {0, 0}, const float& scale = 1.f);
void renderSessionLockMissing(CMonitor* pMonitor); void renderSessionLockMissing(PHLMONITOR pMonitor);
bool commitPendingAndDoExplicitSync(CMonitor* pMonitor); bool commitPendingAndDoExplicitSync(PHLMONITOR pMonitor);
bool m_bCursorHidden = false; bool m_bCursorHidden = false;
bool m_bCursorHasSurface = false; bool m_bCursorHasSurface = false;

View file

@ -46,7 +46,7 @@ CBox CHyprBorderDecoration::assignedBoxGlobal() {
return box.translate(WORKSPACEOFFSET); return box.translate(WORKSPACEOFFSET);
} }
void CHyprBorderDecoration::draw(CMonitor* pMonitor, float a) { void CHyprBorderDecoration::draw(PHLMONITOR pMonitor, float a) {
if (doesntWantBorders()) if (doesntWantBorders())
return; return;
@ -119,7 +119,7 @@ void CHyprBorderDecoration::damageEntire() {
borderRegion.subtract(surfaceBoxShrunkRounding); borderRegion.subtract(surfaceBoxShrunkRounding);
for (auto const& m : g_pCompositor->m_vMonitors) { for (auto const& m : g_pCompositor->m_vMonitors) {
if (!g_pHyprRenderer->shouldRenderWindow(m_pWindow.lock(), m.get())) { if (!g_pHyprRenderer->shouldRenderWindow(m_pWindow.lock(), m)) {
const CRegion monitorRegion({m->vecPosition, m->vecSize}); const CRegion monitorRegion({m->vecPosition, m->vecSize});
borderRegion.subtract(monitorRegion); borderRegion.subtract(monitorRegion);
} }

View file

@ -11,7 +11,7 @@ class CHyprBorderDecoration : public IHyprWindowDecoration {
virtual void onPositioningReply(const SDecorationPositioningReply& reply); virtual void onPositioningReply(const SDecorationPositioningReply& reply);
virtual void draw(CMonitor*, float a); virtual void draw(PHLMONITOR, float a);
virtual eDecorationType getDecorationType(); virtual eDecorationType getDecorationType();

View file

@ -67,7 +67,7 @@ void CHyprDropShadowDecoration::damageEntire() {
} }
for (auto const& m : g_pCompositor->m_vMonitors) { for (auto const& m : g_pCompositor->m_vMonitors) {
if (!g_pHyprRenderer->shouldRenderWindow(PWINDOW, m.get())) { if (!g_pHyprRenderer->shouldRenderWindow(PWINDOW, m)) {
const CRegion monitorRegion({m->vecPosition, m->vecSize}); const CRegion monitorRegion({m->vecPosition, m->vecSize});
shadowRegion.subtract(monitorRegion); shadowRegion.subtract(monitorRegion);
} }
@ -86,7 +86,7 @@ void CHyprDropShadowDecoration::updateWindow(PHLWINDOW pWindow) {
m_bLastWindowBoxWithDecos = g_pDecorationPositioner->getBoxWithIncludedDecos(pWindow); m_bLastWindowBoxWithDecos = g_pDecorationPositioner->getBoxWithIncludedDecos(pWindow);
} }
void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a) { void CHyprDropShadowDecoration::draw(PHLMONITOR pMonitor, float a) {
const auto PWINDOW = m_pWindow.lock(); const auto PWINDOW = m_pWindow.lock();

View file

@ -11,7 +11,7 @@ class CHyprDropShadowDecoration : public IHyprWindowDecoration {
virtual void onPositioningReply(const SDecorationPositioningReply& reply); virtual void onPositioningReply(const SDecorationPositioningReply& reply);
virtual void draw(CMonitor*, float a); virtual void draw(PHLMONITOR, float a);
virtual eDecorationType getDecorationType(); virtual eDecorationType getDecorationType();

View file

@ -94,7 +94,7 @@ void CHyprGroupBarDecoration::damageEntire() {
g_pHyprRenderer->damageBox(&box); g_pHyprRenderer->damageBox(&box);
} }
void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a) { void CHyprGroupBarDecoration::draw(PHLMONITOR pMonitor, float a) {
// get how many bars we will draw // get how many bars we will draw
int barsToDraw = m_dwGroupMembers.size(); int barsToDraw = m_dwGroupMembers.size();

View file

@ -31,7 +31,7 @@ class CHyprGroupBarDecoration : public IHyprWindowDecoration {
virtual void onPositioningReply(const SDecorationPositioningReply& reply); virtual void onPositioningReply(const SDecorationPositioningReply& reply);
virtual void draw(CMonitor*, float a); virtual void draw(PHLMONITOR, float a);
virtual eDecorationType getDecorationType(); virtual eDecorationType getDecorationType();

View file

@ -39,7 +39,7 @@ class IHyprWindowDecoration {
virtual void onPositioningReply(const SDecorationPositioningReply& reply) = 0; virtual void onPositioningReply(const SDecorationPositioningReply& reply) = 0;
virtual void draw(CMonitor*, float a) = 0; virtual void draw(PHLMONITOR, float a) = 0;
virtual eDecorationType getDecorationType() = 0; virtual eDecorationType getDecorationType() = 0;