diff options
| author | davc0n <dconti.dev@gmail.com> | 2025-04-30 23:45:20 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-30 23:45:20 +0200 |
| commit | 50e1bec85f8febdd78f50d94f140d07f9b34148d (patch) | |
| tree | ac8f53553ef3ca5dedb956a09442a23f762e0428 /src/helpers/Monitor.cpp | |
| parent | b8a204c21d6b36a5b3ccf4c125553c61a9fd6b90 (diff) | |
helpers: refactor class member vars (#10218)
Diffstat (limited to 'src/helpers/Monitor.cpp')
| -rw-r--r-- | src/helpers/Monitor.cpp | 911 |
1 files changed, 456 insertions, 455 deletions
diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index 4ee0166f..2edba78a 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -39,133 +39,133 @@ using namespace Hyprutils::OS; using enum NContentType::eContentType; static int ratHandler(void* data) { - g_pHyprRenderer->renderMonitor(((CMonitor*)data)->self.lock()); + g_pHyprRenderer->renderMonitor(((CMonitor*)data)->m_self.lock()); return 1; } -CMonitor::CMonitor(SP<Aquamarine::IOutput> output_) : state(this), output(output_) { +CMonitor::CMonitor(SP<Aquamarine::IOutput> output_) : m_state(this), m_output(output_) { ; } CMonitor::~CMonitor() { - events.destroy.emit(); + m_events.destroy.emit(); if (g_pHyprOpenGL) - g_pHyprOpenGL->destroyMonitorResources(self); + g_pHyprOpenGL->destroyMonitorResources(m_self); } void CMonitor::onConnect(bool noRule) { - EMIT_HOOK_EVENT("preMonitorAdded", self.lock()); + EMIT_HOOK_EVENT("preMonitorAdded", m_self.lock()); CScopeGuard x = {[]() { g_pCompositor->arrangeMonitors(); }}; g_pEventLoopManager->doLater([] { g_pConfigManager->ensurePersistentWorkspacesPresent(); }); - listeners.frame = output->events.frame.registerListener([this](std::any d) { onMonitorFrame(); }); - listeners.commit = output->events.commit.registerListener([this](std::any d) { + m_listeners.frame = m_output->events.frame.registerListener([this](std::any d) { onMonitorFrame(); }); + m_listeners.commit = m_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()); + PROTO::screencopy->onOutputCommit(m_self.lock()); + PROTO::toplevelExport->onOutputCommit(m_self.lock()); } }); - listeners.needsFrame = - output->events.needsFrame.registerListener([this](std::any d) { g_pCompositor->scheduleFrameForMonitor(self.lock(), Aquamarine::IOutput::AQ_SCHEDULE_NEEDS_FRAME); }); + m_listeners.needsFrame = + m_output->events.needsFrame.registerListener([this](std::any d) { g_pCompositor->scheduleFrameForMonitor(m_self.lock(), Aquamarine::IOutput::AQ_SCHEDULE_NEEDS_FRAME); }); - listeners.presented = output->events.present.registerListener([this](std::any d) { + m_listeners.presented = m_output->events.present.registerListener([this](std::any d) { auto E = std::any_cast<Aquamarine::IOutput::SPresentEvent>(d); timespec* ts = E.when; if (!ts) { timespec now; clock_gettime(CLOCK_MONOTONIC, &now); - PROTO::presentation->onPresented(self.lock(), Time::fromTimespec(&now), E.refresh, E.seq, E.flags); + PROTO::presentation->onPresented(m_self.lock(), Time::fromTimespec(&now), E.refresh, E.seq, E.flags); } else - PROTO::presentation->onPresented(self.lock(), Time::fromTimespec(E.when), E.refresh, E.seq, E.flags); + PROTO::presentation->onPresented(m_self.lock(), Time::fromTimespec(E.when), E.refresh, E.seq, E.flags); }); - listeners.destroy = output->events.destroy.registerListener([this](std::any d) { - Debug::log(LOG, "Destroy called for monitor {}", szName); + m_listeners.destroy = m_output->events.destroy.registerListener([this](std::any d) { + Debug::log(LOG, "Destroy called for monitor {}", m_name); onDisconnect(true); - output = nullptr; - m_bRenderingInitPassed = false; + m_output = nullptr; + m_renderingInitPassed = false; - Debug::log(LOG, "Removing monitor {} from realMonitors", szName); + Debug::log(LOG, "Removing monitor {} from realMonitors", m_name); std::erase_if(g_pCompositor->m_realMonitors, [&](PHLMONITOR& el) { return el.get() == this; }); }); - listeners.state = output->events.state.registerListener([this](std::any d) { + m_listeners.state = m_output->events.state.registerListener([this](std::any d) { auto E = std::any_cast<Aquamarine::IOutput::SStateEvent>(d); if (E.size == Vector2D{}) { // an indication to re-set state // we can't do much for createdByUser displays I think - if (createdByUser) + if (m_createdByUser) return; - Debug::log(LOG, "Reapplying monitor rule for {} from a state request", szName); - applyMonitorRule(&activeMonitorRule, true); + Debug::log(LOG, "Reapplying monitor rule for {} from a state request", m_name); + applyMonitorRule(&m_activeMonitorRule, true); return; } - if (!createdByUser) + if (!m_createdByUser) return; const auto SIZE = E.size; - forceSize = SIZE; + m_forceSize = SIZE; - SMonitorRule rule = activeMonitorRule; + SMonitorRule rule = m_activeMonitorRule; rule.resolution = SIZE; applyMonitorRule(&rule); }); - tearingState.canTear = output->getBackend()->type() == Aquamarine::AQ_BACKEND_DRM; + m_tearingState.canTear = m_output->getBackend()->type() == Aquamarine::AQ_BACKEND_DRM; - if (m_bEnabled) { - output->state->resetExplicitFences(); - output->state->setEnabled(true); - state.commit(); + if (m_enabled) { + m_output->state->resetExplicitFences(); + m_output->state->setEnabled(true); + m_state.commit(); return; } - szName = output->name; + m_name = m_output->name; - szDescription = output->description; + m_description = m_output->description; // remove comma character from description. This allow monitor specific rules to work on monitor with comma on their description - std::erase(szDescription, ','); + std::erase(m_description, ','); // field is backwards-compatible with intended usage of `szDescription` but excludes the parenthesized DRM node name suffix - szShortDescription = trim(std::format("{} {} {}", output->make, output->model, output->serial)); - std::erase(szShortDescription, ','); + m_shortDescription = trim(std::format("{} {} {}", m_output->make, m_output->model, m_output->serial)); + std::erase(m_shortDescription, ','); - if (output->getBackend()->type() != Aquamarine::AQ_BACKEND_DRM) - createdByUser = true; // should be true. WL and Headless backends should be addable / removable + if (m_output->getBackend()->type() != Aquamarine::AQ_BACKEND_DRM) + m_createdByUser = true; // should be true. WL and Headless backends should be addable / removable // get monitor rule that matches - SMonitorRule monitorRule = g_pConfigManager->getMonitorRuleFor(self.lock()); + SMonitorRule monitorRule = g_pConfigManager->getMonitorRuleFor(m_self.lock()); // if it's disabled, disable and ignore if (monitorRule.disabled) { - output->state->resetExplicitFences(); - output->state->setEnabled(false); + m_output->state->resetExplicitFences(); + m_output->state->setEnabled(false); - if (!state.commit()) - Debug::log(ERR, "Couldn't commit disabled state on output {}", output->name); + if (!m_state.commit()) + Debug::log(ERR, "Couldn't commit disabled state on output {}", m_output->name); - m_bEnabled = false; + m_enabled = false; - listeners.frame.reset(); + m_listeners.frame.reset(); return; } - if (output->nonDesktop) { + if (m_output->nonDesktop) { Debug::log(LOG, "Not configuring non-desktop output"); if (PROTO::lease) - PROTO::lease->offer(self.lock()); + PROTO::lease->offer(m_self.lock()); return; } @@ -174,7 +174,7 @@ void CMonitor::onConnect(bool noRule) { // find the wrap for (auto& m : g_pCompositor->m_realMonitors) { - if (m->ID == ID) { + if (m->m_id == m_id) { thisWrapper = &m; break; } @@ -185,21 +185,21 @@ void CMonitor::onConnect(bool noRule) { if (std::find_if(g_pCompositor->m_monitors.begin(), g_pCompositor->m_monitors.end(), [&](auto& other) { return other.get() == this; }) == g_pCompositor->m_monitors.end()) g_pCompositor->m_monitors.push_back(*thisWrapper); - m_bEnabled = true; + m_enabled = true; - output->state->resetExplicitFences(); - output->state->setEnabled(true); + m_output->state->resetExplicitFences(); + m_output->state->setEnabled(true); // set mode, also applies if (!noRule) applyMonitorRule(&monitorRule, true); - if (!state.commit()) + if (!m_state.commit()) Debug::log(WARN, "state.commit() failed in CMonitor::onCommit"); - damage.setSize(vecTransformedSize); + m_damage.setSize(m_transformedSize); - Debug::log(LOG, "Added new monitor with name {} at {:j0} with size {:j0}, pointer {:x}", output->name, vecPosition, vecPixelSize, (uintptr_t)output.get()); + Debug::log(LOG, "Added new monitor with name {} at {:j0} with size {:j0}, pointer {:x}", m_output->name, m_position, m_pixelSize, (uintptr_t)m_output.get()); setupDefaultWS(monitorRule); @@ -207,31 +207,31 @@ void CMonitor::onConnect(bool noRule) { if (!valid(ws)) continue; - if (ws->m_lastMonitor == szName || g_pCompositor->m_monitors.size() == 1 /* avoid lost workspaces on recover */) { - g_pCompositor->moveWorkspaceToMonitor(ws, self.lock()); + if (ws->m_lastMonitor == m_name || g_pCompositor->m_monitors.size() == 1 /* avoid lost workspaces on recover */) { + g_pCompositor->moveWorkspaceToMonitor(ws, m_self.lock()); ws->startAnim(true, true, true); ws->m_lastMonitor = ""; } } - scale = monitorRule.scale; - if (scale < 0.1) - scale = getDefaultScale(); + m_scale = monitorRule.scale; + if (m_scale < 0.1) + m_scale = getDefaultScale(); - forceFullFrames = 3; // force 3 full frames to make sure there is no blinking due to double-buffering. + m_forceFullFrames = 3; // force 3 full frames to make sure there is no blinking due to double-buffering. // - if (!activeMonitorRule.mirrorOf.empty()) - setMirror(activeMonitorRule.mirrorOf); + if (!m_activeMonitorRule.mirrorOf.empty()) + setMirror(m_activeMonitorRule.mirrorOf); if (!g_pCompositor->m_lastMonitor) // set the last monitor if it isnt set yet - g_pCompositor->setActiveMonitor(self.lock()); + g_pCompositor->setActiveMonitor(m_self.lock()); - g_pHyprRenderer->arrangeLayersForMonitor(ID); - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID); + g_pHyprRenderer->arrangeLayersForMonitor(m_id); + g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m_id); // ensure VRR (will enable if necessary) - g_pConfigManager->ensureVRR(self.lock()); + g_pConfigManager->ensureVRR(m_self.lock()); // verify last mon valid bool found = false; @@ -242,63 +242,63 @@ void CMonitor::onConnect(bool noRule) { } } - Debug::log(LOG, "checking if we have seen this monitor before: {}", szName); + Debug::log(LOG, "checking if we have seen this monitor before: {}", m_name); // if we saw this monitor before, set it to the workspace it was on - if (g_pCompositor->m_seenMonitorWorkspaceMap.contains(szName)) { - auto workspaceID = g_pCompositor->m_seenMonitorWorkspaceMap[szName]; - Debug::log(LOG, "Monitor {} was on workspace {}, setting it to that", szName, workspaceID); + if (g_pCompositor->m_seenMonitorWorkspaceMap.contains(m_name)) { + auto workspaceID = g_pCompositor->m_seenMonitorWorkspaceMap[m_name]; + Debug::log(LOG, "Monitor {} was on workspace {}, setting it to that", m_name, workspaceID); auto ws = g_pCompositor->getWorkspaceByID(workspaceID); if (ws) { - g_pCompositor->moveWorkspaceToMonitor(ws, self.lock()); + g_pCompositor->moveWorkspaceToMonitor(ws, m_self.lock()); changeWorkspace(ws, true, false, false); } } else - Debug::log(LOG, "Monitor {} was not on any workspace", szName); + Debug::log(LOG, "Monitor {} was not on any workspace", m_name); if (!found) - g_pCompositor->setActiveMonitor(self.lock()); + g_pCompositor->setActiveMonitor(m_self.lock()); - renderTimer = wl_event_loop_add_timer(g_pCompositor->m_wlEventLoop, ratHandler, this); + m_renderTimer = wl_event_loop_add_timer(g_pCompositor->m_wlEventLoop, ratHandler, this); - g_pCompositor->scheduleFrameForMonitor(self.lock(), Aquamarine::IOutput::AQ_SCHEDULE_NEW_MONITOR); + g_pCompositor->scheduleFrameForMonitor(m_self.lock(), Aquamarine::IOutput::AQ_SCHEDULE_NEW_MONITOR); - PROTO::gamma->applyGammaToState(self.lock()); + PROTO::gamma->applyGammaToState(m_self.lock()); - events.connect.emit(); + m_events.connect.emit(); - g_pEventManager->postEvent(SHyprIPCEvent{"monitoradded", szName}); - g_pEventManager->postEvent(SHyprIPCEvent{"monitoraddedv2", std::format("{},{},{}", ID, szName, szShortDescription)}); - EMIT_HOOK_EVENT("monitorAdded", self.lock()); + g_pEventManager->postEvent(SHyprIPCEvent{"monitoradded", m_name}); + g_pEventManager->postEvent(SHyprIPCEvent{"monitoraddedv2", std::format("{},{},{}", m_id, m_name, m_shortDescription)}); + EMIT_HOOK_EVENT("monitorAdded", m_self.lock()); } void CMonitor::onDisconnect(bool destroy) { - EMIT_HOOK_EVENT("preMonitorRemoved", self.lock()); + EMIT_HOOK_EVENT("preMonitorRemoved", m_self.lock()); CScopeGuard x = {[this]() { if (g_pCompositor->m_isShuttingDown) return; - g_pEventManager->postEvent(SHyprIPCEvent{"monitorremoved", szName}); - EMIT_HOOK_EVENT("monitorRemoved", self.lock()); + g_pEventManager->postEvent(SHyprIPCEvent{"monitorremoved", m_name}); + EMIT_HOOK_EVENT("monitorRemoved", m_self.lock()); g_pCompositor->arrangeMonitors(); }}; - if (renderTimer) { - wl_event_source_remove(renderTimer); - renderTimer = nullptr; + if (m_renderTimer) { + wl_event_source_remove(m_renderTimer); + m_renderTimer = nullptr; } - if (!m_bEnabled || g_pCompositor->m_isShuttingDown) + if (!m_enabled || g_pCompositor->m_isShuttingDown) return; - Debug::log(LOG, "onDisconnect called for {}", output->name); + Debug::log(LOG, "onDisconnect called for {}", m_output->name); - events.disconnect.emit(); + m_events.disconnect.emit(); if (g_pHyprOpenGL) - g_pHyprOpenGL->destroyMonitorResources(self); + g_pHyprOpenGL->destroyMonitorResources(m_self); // record what workspace this monitor was on - if (activeWorkspace) { - Debug::log(LOG, "Disconnecting Monitor {} was on workspace {}", szName, activeWorkspace->m_id); - g_pCompositor->m_seenMonitorWorkspaceMap[szName] = activeWorkspace->m_id; + if (m_activeWorkspace) { + Debug::log(LOG, "Disconnecting Monitor {} was on workspace {}", m_name, m_activeWorkspace->m_id); + g_pCompositor->m_seenMonitorWorkspaceMap[m_name] = m_activeWorkspace->m_id; } // Cleanup everything. Move windows back, snap cursor, shit. @@ -311,58 +311,58 @@ void CMonitor::onDisconnect(bool destroy) { } // remove mirror - if (pMirrorOf) { - pMirrorOf->mirrors.erase(std::find_if(pMirrorOf->mirrors.begin(), pMirrorOf->mirrors.end(), [&](const auto& other) { return other == self; })); + if (m_mirrorOf) { + m_mirrorOf->m_mirrors.erase(std::find_if(m_mirrorOf->m_mirrors.begin(), m_mirrorOf->m_mirrors.end(), [&](const auto& other) { return other == m_self; })); // unlock software for mirrored monitor - g_pPointerManager->unlockSoftwareForMonitor(pMirrorOf.lock()); - pMirrorOf.reset(); + g_pPointerManager->unlockSoftwareForMonitor(m_mirrorOf.lock()); + m_mirrorOf.reset(); } - if (!mirrors.empty()) { - for (auto const& m : mirrors) { + if (!m_mirrors.empty()) { + for (auto const& m : m_mirrors) { m->setMirror(""); } g_pConfigManager->m_wantsMonitorReload = true; } - listeners.frame.reset(); - listeners.presented.reset(); - listeners.needsFrame.reset(); - listeners.commit.reset(); + m_listeners.frame.reset(); + m_listeners.presented.reset(); + m_listeners.needsFrame.reset(); + m_listeners.commit.reset(); for (size_t i = 0; i < 4; ++i) { - for (auto const& ls : m_aLayerSurfaceLayers[i]) { + for (auto const& ls : m_layerSurfaceLayers[i]) { if (ls->m_layerSurface && !ls->m_fadingOut) ls->m_layerSurface->sendClosed(); } - m_aLayerSurfaceLayers[i].clear(); + m_layerSurfaceLayers[i].clear(); } - Debug::log(LOG, "Removed monitor {}!", szName); + Debug::log(LOG, "Removed monitor {}!", m_name); if (!BACKUPMON) { Debug::log(WARN, "Unplugged last monitor, entering an unsafe state. Good luck my friend."); g_pCompositor->enterUnsafeState(); } - m_bEnabled = false; - m_bRenderingInitPassed = false; + m_enabled = false; + m_renderingInitPassed = false; if (BACKUPMON) { // snap cursor - g_pCompositor->warpCursorTo(BACKUPMON->vecPosition + BACKUPMON->vecTransformedSize / 2.F, true); + g_pCompositor->warpCursorTo(BACKUPMON->m_position + BACKUPMON->m_transformedSize / 2.F, true); // move workspaces std::vector<PHLWORKSPACE> wspToMove; for (auto const& w : g_pCompositor->m_workspaces) { - if (w->m_monitor == self || !w->m_monitor) + if (w->m_monitor == m_self || !w->m_monitor) wspToMove.push_back(w); } for (auto const& w : wspToMove) { - w->m_lastMonitor = szName; + w->m_lastMonitor = m_name; g_pCompositor->moveWorkspaceToMonitor(w, BACKUPMON); w->startAnim(true, true, true); } @@ -372,28 +372,28 @@ void CMonitor::onDisconnect(bool destroy) { g_pCompositor->m_lastMonitor.reset(); } - if (activeWorkspace) - activeWorkspace->m_visible = false; - activeWorkspace.reset(); + if (m_activeWorkspace) + m_activeWorkspace->m_visible = false; + m_activeWorkspace.reset(); - output->state->resetExplicitFences(); - output->state->setAdaptiveSync(false); - output->state->setEnabled(false); + m_output->state->resetExplicitFences(); + m_output->state->setAdaptiveSync(false); + m_output->state->setEnabled(false); - if (!state.commit()) + if (!m_state.commit()) Debug::log(WARN, "state.commit() failed in CMonitor::onDisconnect"); - if (g_pCompositor->m_lastMonitor == self) + if (g_pCompositor->m_lastMonitor == m_self) g_pCompositor->setActiveMonitor(BACKUPMON ? BACKUPMON : g_pCompositor->m_unsafeOutput.lock()); - if (g_pHyprRenderer->m_pMostHzMonitor == self) { + if (g_pHyprRenderer->m_pMostHzMonitor == m_self) { int mostHz = 0; PHLMONITOR pMonitorMostHz = nullptr; for (auto const& m : g_pCompositor->m_monitors) { - if (m->refreshRate > mostHz && m != self) { + if (m->m_refreshRate > mostHz && m != m_self) { pMonitorMostHz = m; - mostHz = m->refreshRate; + mostHz = m->m_refreshRate; } } @@ -406,44 +406,44 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) { static auto PDISABLESCALECHECKS = CConfigValue<Hyprlang::INT>("debug:disable_scale_checks"); - Debug::log(LOG, "Applying monitor rule for {}", szName); + Debug::log(LOG, "Applying monitor rule for {}", m_name); - activeMonitorRule = *pMonitorRule; + m_activeMonitorRule = *pMonitorRule; - if (forceSize.has_value()) - activeMonitorRule.resolution = forceSize.value(); + if (m_forceSize.has_value()) + m_activeMonitorRule.resolution = m_forceSize.value(); - const auto RULE = &activeMonitorRule; + const auto RULE = &m_activeMonitorRule; // if it's disabled, disable and ignore if (RULE->disabled) { - if (m_bEnabled) + if (m_enabled) onDisconnect(); - events.modeChanged.emit(); + m_events.modeChanged.emit(); return true; } // don't touch VR headsets - if (output->nonDesktop) + if (m_output->nonDesktop) return true; - if (!m_bEnabled) { + if (!m_enabled) { onConnect(true); // enable it. - Debug::log(LOG, "Monitor {} is disabled but is requested to be enabled", szName); + Debug::log(LOG, "Monitor {} is disabled but is requested to be enabled", m_name); force = true; } // Check if the rule isn't already applied // TODO: clean this up lol - if (!force && DELTALESSTHAN(vecPixelSize.x, RULE->resolution.x, 1) && DELTALESSTHAN(vecPixelSize.y, RULE->resolution.y, 1) && - DELTALESSTHAN(refreshRate, RULE->refreshRate, 1) && setScale == RULE->scale && - ((DELTALESSTHAN(vecPosition.x, RULE->offset.x, 1) && DELTALESSTHAN(vecPosition.y, RULE->offset.y, 1)) || RULE->offset == Vector2D(-INT32_MAX, -INT32_MAX)) && - transform == RULE->transform && RULE->enable10bit == enabled10bit && RULE->cmType == cmType && RULE->sdrSaturation == sdrSaturation && - RULE->sdrBrightness == sdrBrightness && !std::memcmp(&customDrmMode, &RULE->drmMode, sizeof(customDrmMode))) { + if (!force && DELTALESSTHAN(m_pixelSize.x, RULE->resolution.x, 1) && DELTALESSTHAN(m_pixelSize.y, RULE->resolution.y, 1) && + DELTALESSTHAN(m_refreshRate, RULE->refreshRate, 1) && m_setScale == RULE->scale && + ((DELTALESSTHAN(m_position.x, RULE->offset.x, 1) && DELTALESSTHAN(m_position.y, RULE->offset.y, 1)) || RULE->offset == Vector2D(-INT32_MAX, -INT32_MAX)) && + m_transform == RULE->transform && RULE->enable10bit == m_enabled10bit && RULE->cmType == m_cmType && RULE->sdrSaturation == m_sdrSaturation && + RULE->sdrBrightness == m_sdrBrightness && !std::memcmp(&m_customDrmMode, &RULE->drmMode, sizeof(m_customDrmMode))) { - Debug::log(LOG, "Not applying a new rule to {} because it's already applied!", szName); + Debug::log(LOG, "Not applying a new rule to {} because it's already applied!", m_name); setMirror(RULE->mirrorOf); @@ -453,15 +453,15 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) { bool autoScale = false; if (RULE->scale > 0.1) { - scale = RULE->scale; + m_scale = RULE->scale; } else { autoScale = true; const auto DEFAULTSCALE = getDefaultScale(); - scale = DEFAULTSCALE; + m_scale = DEFAULTSCALE; } - setScale = scale; - transform = RULE->transform; + m_setScale = m_scale; + m_transform = RULE->transform; // accumulate requested modes in reverse order (cause inesrting at front is inefficient) std::vector<SP<Aquamarine::SOutputMode>> requestedModes; @@ -469,7 +469,7 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) { // use sortFunc, add best 3 to requestedModes in reverse, since we test in reverse auto addBest3Modes = [&](auto const& sortFunc) { - auto sortedModes = output->modes; + auto sortedModes = m_output->modes; std::ranges::sort(sortedModes, sortFunc); if (sortedModes.size() > 3) sortedModes.erase(sortedModes.begin() + 3, sortedModes.end()); @@ -477,22 +477,22 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) { }; // last fallback is always preferred mode - if (!output->preferredMode()) - Debug::log(ERR, "Monitor {} has NO PREFERRED MODE", output->name); + if (!m_output->preferredMode()) + Debug::log(ERR, "Monitor {} has NO PREFERRED MODE", m_output->name); else - requestedModes.push_back(output->preferredMode()); + requestedModes.push_back(m_output->preferredMode()); if (RULE->resolution == Vector2D()) { requestedStr = "preferred"; // fallback to first 3 modes if preferred fails/doesn't exist - requestedModes = output->modes; + requestedModes = m_output->modes; if (requestedModes.size() > 3) requestedModes.erase(requestedModes.begin() + 3, requestedModes.end()); std::ranges::reverse(requestedModes.begin(), requestedModes.end()); - if (output->preferredMode()) - requestedModes.push_back(output->preferredMode()); + if (m_output->preferredMode()) + requestedModes.push_back(m_output->preferredMode()); } else if (RULE->resolution == Vector2D(-1, -1)) { requestedStr = "highrr"; @@ -541,7 +541,7 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) { // then if requested is custom, try custom mode first if (RULE->drmMode.type == DRM_MODE_TYPE_USERDEF) { - if (output->getBackend()->type() != Aquamarine::eBackendType::AQ_BACKEND_DRM) + if (m_output->getBackend()->type() != Aquamarine::eBackendType::AQ_BACKEND_DRM) Debug::log(ERR, "Tried to set custom modeline on non-DRM output"); else requestedModes.push_back(makeShared<Aquamarine::SOutputMode>( @@ -549,21 +549,21 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) { } } - const auto WAS10B = enabled10bit; - const auto OLDRES = vecPixelSize; + const auto WAS10B = m_enabled10bit; + const auto OLDRES = m_pixelSize; bool success = false; // Needed in case we are switching from a custom modeline to a standard mode - customDrmMode = {}; - currentMode = nullptr; + m_customDrmMode = {}; + m_currentMode = nullptr; - output->state->setFormat(DRM_FORMAT_XRGB8888); - prevDrmFormat = drmFormat; - drmFormat = DRM_FORMAT_XRGB8888; - output->state->resetExplicitFences(); + m_output->state->setFormat(DRM_FORMAT_XRGB8888); + m_prevDrmFormat = m_drmFormat; + m_drmFormat = DRM_FORMAT_XRGB8888; + m_output->state->resetExplicitFences(); if (Debug::m_trace) { - Debug::log(TRACE, "Monitor {} requested modes:", szName); + Debug::log(TRACE, "Monitor {} requested modes:", m_name); if (requestedModes.empty()) Debug::log(TRACE, "| None"); else { @@ -577,81 +577,81 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) { std::string modeStr = std::format("{:X0}@{:.2f}Hz", mode->pixelSize, mode->refreshRate / 1000.f); if (mode->modeInfo.has_value() && mode->modeInfo->type == DRM_MODE_TYPE_USERDEF) { - output->state->setCustomMode(mode); + m_output->state->setCustomMode(mode); - if (!state.test()) { - Debug::log(ERR, "Monitor {}: REJECTED custom mode {}!", szName, modeStr); + if (!m_state.test()) { + Debug::log(ERR, "Monitor {}: REJECTED custom mode {}!", m_name, modeStr); continue; } - customDrmMode = mode->modeInfo.value(); + m_customDrmMode = mode->modeInfo.value(); } else { - output->state->setMode(mode); + m_output->state->setMode(mode); - if (!state.test()) { - Debug::log(ERR, "Monitor {}: REJECTED available mode {}!", szName, modeStr); + if (!m_state.test()) { + Debug::log(ERR, "Monitor {}: REJECTED available mode {}!", m_name, modeStr); if (mode->preferred) - Debug::log(ERR, "Monitor {}: REJECTED preferred mode!!!", szName); + Debug::log(ERR, "Monitor {}: REJECTED preferred mode!!!", m_name); continue; } - customDrmMode = {}; + m_customDrmMode = {}; } - refreshRate = mode->refreshRate / 1000.f; - vecSize = mode->pixelSize; - currentMode = mode; + m_refreshRate = mode->refreshRate / 1000.f; + m_size = mode->pixelSize; + m_currentMode = mode; success = true; if (mode->preferred) - Debug::log(LOG, "Monitor {}: requested {}, using preferred mode {}", szName, requestedStr, modeStr); + Debug::log(LOG, "Monitor {}: requested {}, using preferred mode {}", m_name, requestedStr, modeStr); else if (mode->modeInfo.has_value() && mode->modeInfo->type == DRM_MODE_TYPE_USERDEF) - Debug::log(LOG, "Monitor {}: requested {}, using custom mode {}", szName, requestedStr, modeStr); + Debug::log(LOG, "Monitor {}: requested {}, using custom mode {}", m_name, requestedStr, modeStr); else - Debug::log(LOG, "Monitor {}: requested {}, using available mode {}", szName, requestedStr, modeStr); + Debug::log(LOG, "Monitor {}: requested {}, using available mode {}", m_name, requestedStr, modeStr); break; } // try requested as custom mode jic it works if (!success && RULE->resolution != Vector2D() && RULE->resolution != Vector2D(-1, -1) && RULE->resolution != Vector2D(-1, -2)) { - auto refreshRate = output->getBackend()->type() == Aquamarine::eBackendType::AQ_BACKEND_DRM ? RULE->refreshRate * 1000 : 0; + auto refreshRate = m_output->getBackend()->type() == Aquamarine::eBackendType::AQ_BACKEND_DRM ? RULE->refreshRate * 1000 : 0; auto mode = makeShared<Aquamarine::SOutputMode>(Aquamarine::SOutputMode{.pixelSize = RULE->resolution, .refreshRate = refreshRate}); std::string modeStr = std::format("{:X0}@{:.2f}Hz", mode->pixelSize, mode->refreshRate / 1000.f); - output->state->setCustomMode(mode); + m_output->state->setCustomMode(mode); - if (state.test()) { - Debug::log(LOG, "Monitor {}: requested {}, using custom mode {}", szName, requestedStr, modeStr); + if (m_state.test()) { + Debug::log(LOG, "Monitor {}: requested {}, using custom mode {}", m_name, requestedStr, modeStr); - refreshRate = mode->refreshRate / 1000.f; - vecSize = mode->pixelSize; - currentMode = mode; - customDrmMode = {}; + refreshRate = mode->refreshRate / 1000.f; + m_size = mode->pixelSize; + m_currentMode = mode; + m_customDrmMode = {}; success = true; } else - Debug::log(ERR, "Monitor {}: REJECTED custom mode {}!", szName, modeStr); + Debug::log(ERR, "Monitor {}: REJECTED custom mode {}!", m_name, modeStr); } // try any of the modes if none of the above work if (!success) { - for (auto const& mode : output->modes) { - output->state->setMode(mode); + for (auto const& mode : m_output->modes) { + m_output->state->setMode(mode); - if (!state.test()) + if (!m_state.test()) continue; auto errorMessage = - std::format("Monitor {} failed to set any requested modes, falling back to mode {:X0}@{:.2f}Hz", szName, mode->pixelSize, mode->refreshRate / 1000.f); + std::format("Monitor {} failed to set any requested modes, falling back to mode {:X0}@{:.2f}Hz", m_name, mode->pixelSize, mode->refreshRate / 1000.f); Debug::log(WARN, errorMessage); g_pHyprNotificationOverlay->addNotification(errorMessage, CHyprColor(0xff0000ff), 5000, ICON_WARNING); - refreshRate = mode->refreshRate / 1000.f; - vecSize = mode->pixelSize; - currentMode = mode; - customDrmMode = {}; + m_refreshRate = mode->refreshRate / 1000.f; + m_size = mode->pixelSize; + m_currentMode = mode; + m_customDrmMode = {}; success = true; @@ -660,14 +660,14 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) { } if (!success) { - Debug::log(ERR, "Monitor {} has NO FALLBACK MODES, and an INVALID one was requested: {:X0}@{:.2f}Hz", szName, RULE->resolution, RULE->refreshRate); + Debug::log(ERR, "Monitor {} has NO FALLBACK MODES, and an INVALID one was requested: {:X0}@{:.2f}Hz", m_name, RULE->resolution, RULE->refreshRate); return true; } - vrrActive = output->state->state().adaptiveSync // disabled here, will be tested in CConfigManager::ensureVRR() - || createdByUser; // wayland backend doesn't allow for disabling adaptive_sync + m_vrrActive = m_output->state->state().adaptiveSync // disabled here, will be tested in CConfigManager::ensureVRR() + || m_createdByUser; // wayland backend doesn't allow for disabling adaptive_sync - vecPixelSize = vecSize; + m_pixelSize = m_size; // clang-format off static const std::array<std::vector<std::pair<std::string, uint32_t>>, 2> formats{ @@ -683,102 +683,102 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) { bool set10bit = false; for (auto const& fmt : formats[(int)!RULE->enable10bit]) { - output->state->setFormat(fmt.second); - prevDrmFormat = drmFormat; - drmFormat = fmt.second; + m_output->state->setFormat(fmt.second); + m_prevDrmFormat = m_drmFormat; + m_drmFormat = fmt.second; - if (!state.test()) { - Debug::log(ERR, "output {} failed basic test on format {}", szName, fmt.first); + if (!m_state.test()) { + Debug::log(ERR, "output {} failed basic test on format {}", m_name, fmt.first); } else { - Debug::log(LOG, "output {} succeeded basic test on format {}", szName, fmt.first); + Debug::log(LOG, "output {} succeeded basic test on format {}", m_name, fmt.first); if (RULE->enable10bit && fmt.first.contains("101010")) set10bit = true; break; } } - enabled10bit = set10bit; + m_enabled10bit = set10bit; - auto oldImageDescription = imageDescription; - cmType = RULE->cmType; - switch (cmType) { - case CM_AUTO: cmType = enabled10bit && output->parsedEDID.supportsBT2020 ? CM_WIDE : CM_SRGB; break; - case CM_EDID: cmType = output->parsedEDID.chromaticityCoords.has_value() ? CM_EDID : CM_SRGB; break; + auto oldImageDescription = m_imageDescription; + m_cmType = RULE->cmType; + switch (m_cmType) { + case CM_AUTO: m_cmType = m_enabled10bit && m_output->parsedEDID.supportsBT2020 ? CM_WIDE : CM_SRGB; break; + case CM_EDID: m_cmType = m_output->parsedEDID.chromaticityCoords.has_value() ? CM_EDID : CM_SRGB; break; case CM_HDR: case CM_HDR_EDID: - cmType = output->parsedEDID.supportsBT2020 && output->parsedEDID.hdrMetadata.has_value() && output->parsedEDID.hdrMetadata->supportsPQ ? cmType : CM_SRGB; + m_cmType = m_output->parsedEDID.supportsBT2020 && m_output->parsedEDID.hdrMetadata.has_value() && m_output->parsedEDID.hdrMetadata->supportsPQ ? m_cmType : CM_SRGB; break; default: break; } - switch (cmType) { - case CM_SRGB: imageDescription = {}; break; // assumes SImageDescirption defaults to sRGB + switch (m_cmType) { + case CM_SRGB: m_imageDescription = {}; break; // assumes SImageDescirption defaults to sRGB case CM_WIDE: - imageDescription = {.primariesNameSet = true, - .primariesNamed = NColorManagement::CM_PRIMARIES_BT2020, - .primaries = NColorManagement::getPrimaries(NColorManagement::CM_PRIMARIES_BT2020)}; + m_imageDescription = {.primariesNameSet = true, + .primariesNamed = NColorManagement::CM_PRIMARIES_BT2020, + .primaries = NColorManagement::getPrimaries(NColorManagement::CM_PRIMARIES_BT2020)}; break; case CM_EDID: - imageDescription = {.primariesNameSet = false, - .primariesNamed = NColorManagement::CM_PRIMARIES_BT2020, - .primaries = { - .red = {.x = output->parsedEDID.chromaticityCoords->red.x, .y = output->parsedEDID.chromaticityCoords->red.y}, - .green = {.x = output->parsedEDID.chromaticityCoords->green.x, .y = output->parsedEDID.chromaticityCoords->green.y}, - .blue = {.x = output->parsedEDID.chromaticityCoords->blue.x, .y = output->parsedEDID.chromaticityCoords->blue.y}, - .white = {.x = output->parsedEDID.chromaticityCoords->white.x, .y = output->parsedEDID.chromaticityCoords->white.y}, - }}; + m_imageDescription = {.primariesNameSet = false, + .primariesNamed = NColorManagement::CM_PRIMARIES_BT2020, + .primaries = { + .red = {.x = m_output->parsedEDID.chromaticityCoords->red.x, .y = m_output->parsedEDID.chromaticityCoords->red.y}, + .green = {.x = m_output->parsedEDID.chromaticityCoords->green.x, .y = m_output->parsedEDID.chromaticityCoords->green.y}, + .blue = {.x = m_output->parsedEDID.chromaticityCoords->blue.x, .y = m_output->parsedEDID.chromaticityCoords->blue.y}, + .white = {.x = m_output->parsedEDID.chromaticityCoords->white.x, .y = m_output->parsedEDID.chromaticityCoords->white.y}, + }}; break; case CM_HDR: - imageDescription = {.transferFunction = NColorManagement::CM_TRANSFER_FUNCTION_ST2084_PQ, - .primariesNameSet = true, - .primariesNamed = NColorManagement::CM_PRIMARIES_BT2020, - .primaries = NColorManagement::getPrimaries(NColorManagement::CM_PRIMARIES_BT2020), - .luminances = {.min = 0, .max = 10000, .reference = 203}}; + m_imageDescription = {.transferFunction = NColorManagement::CM_TRANSFER_FUNCTION_ST2084_PQ, + .primariesNameSet = true, + .primariesNamed = NColorManagement::CM_PRIMARIES_BT2020, + .primaries = NColorManagement::getPrimaries(NColorManagement::CM_PRIMARIES_BT2020), + .luminances = {.min = 0, .max = 10000, .reference = 203}}; break; case CM_HDR_EDID: - imageDescription = {.transferFunction = NColorManagement::CM_TRANSFER_FUNCTION_ST2084_PQ, - .primariesNameSet = false, - .primariesNamed = NColorManagement::CM_PRIMARIES_BT2020, - .primaries = output->parsedEDID.chromaticityCoords.has_value() ? - NColorManagement::SPCPRimaries{ - .red = {.x = output->parsedEDID.chromaticityCoords->red.x, .y = output->parsedEDID.chromaticityCoords->red.y}, - .green = {.x = output->parsedEDID.chromaticityCoords->green.x, .y = output->parsedEDID.chromaticityCoords->green.y}, - .blue = {.x = output->parsedEDID.chromaticityCoords->blue.x, .y = output->parsedEDID.chromaticityCoords->blue.y}, - .white = {.x = output->parsedEDID.chromaticityCoords->white.x, .y = output->parsedEDID.chromaticityCoords->white.y}, - } : - NColorManagement::getPrimaries(NColorManagement::CM_PRIMARIES_BT2020), - .luminances = {.min = output->parsedEDID.hdrMetadata->desiredContentMinLuminance, - .max = output->parsedEDID.hdrMetadata->desiredContentMaxLuminance, - .reference = output->parsedEDID.hdrMetadata->desiredMaxFrameAverageLuminance}}; + m_imageDescription = {.transferFunction = NColorManagement::CM_TRANSFER_FUNCTION_ST2084_PQ, + .primariesNameSet = false, + .primariesNamed = NColorManagement::CM_PRIMARIES_BT2020, + .primaries = m_output->parsedEDID.chromaticityCoords.has_value() ? + NColorManagement::SPCPRimaries{ + .red = {.x = m_output->parsedEDID.chromaticityCoords->red.x, .y = m_output->parsedEDID.chromaticityCoords->red.y}, + .green = {.x = m_output->parsedEDID.chromaticityCoords->green.x, .y = m_output->parsedEDID.chromaticityCoords->green.y}, + .blue = {.x = m_output->parsedEDID.chromaticityCoords->blue.x, .y = m_output->parsedEDID.chromaticityCoords->blue.y}, + .white = {.x = m_output->parsedEDID.chromaticityCoords->white.x, .y = m_output->parsedEDID.chromaticityCoords->white.y}, + } : + NColorManagement::getPrimaries(NColorManagement::CM_PRIMARIES_BT2020), + .luminances = {.min = m_output->parsedEDID.hdrMetadata->desiredContentMinLuminance, + .max = m_output->parsedEDID.hdrMetadata->desiredContentMaxLuminance, + .reference = m_output->parsedEDID.hdrMetadata->desiredMaxFrameAverageLuminance}}; break; default: UNREACHABLE(); } - if (oldImageDescription != imageDescription) - PROTO::colorManagement->onMonitorImageDescriptionChanged(self); + if (oldImageDescription != m_imageDescription) + PROTO::colorManagement->onMonitorImageDescriptionChanged(m_self); - sdrSaturation = RULE->sdrSaturation; - sdrBrightness = RULE->sdrBrightness; + m_sdrSaturation = RULE->sdrSaturation; + m_sdrBrightness = RULE->sdrBrightness; - Vector2D logicalSize = vecPixelSize / scale; + Vector2D logicalSize = m_pixelSize / m_scale; if (!*PDISABLESCALECHECKS && (logicalSize.x != std::round(logicalSize.x) || logicalSize.y != std::round(logicalSize.y))) { // invalid scale, will produce fractional pixels. // find the nearest valid. - float searchScale = std::round(scale * 120.0); + float searchScale = std::round(m_scale * 120.0); bool found = false; double scaleZero = searchScale / 120.0; - Vector2D logicalZero = vecPixelSize / scaleZero; + Vector2D logicalZero = m_pixelSize / scaleZero; if (logicalZero == logicalZero.round()) - scale = scaleZero; + m_scale = scaleZero; else { for (size_t i = 1; i < 90; ++i) { double scaleUp = (searchScale + i) / 120.0; double scaleDown = (searchScale - i) / 120.0; - Vector2D logicalUp = vecPixelSize / scaleUp; - Vector2D logicalDown = vecPixelSize / scaleDown; + Vector2D logicalUp = m_pixelSize / scaleUp; + Vector2D logicalDown = m_pixelSize / scaleDown; if (logicalUp == logicalUp.round()) { found = true; @@ -794,48 +794,48 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) { if (!found) { if (autoScale) - scale = std::round(scaleZero); + m_scale = std::round(scaleZero); else { - Debug::log(ERR, "Invalid scale passed to monitor, {} failed to find a clean divisor", scale); - g_pConfigManager->addParseError("Invalid scale passed to monitor " + szName + ", failed to find a clean divisor"); - scale = getDefaultScale(); + Debug::log(ERR, "Invalid scale passed to monitor, {} failed to find a clean divisor", m_scale); + g_pConfigManager->addParseError("Invalid scale passed to monitor " + m_name + ", failed to find a clean divisor"); + m_scale = getDefaultScale(); } } else { if (!autoScale) { - Debug::log(ERR, "Invalid scale passed to monitor, {} found suggestion {}", scale, searchScale); + Debug::log(ERR, "Invalid scale passed to monitor, {} found suggestion {}", m_scale, searchScale); g_pConfigManager->addParseError( - std::format("Invalid scale passed to monitor {}, failed to find a clean divisor. Suggested nearest scale: {:5f}", szName, searchScale)); - scale = getDefaultScale(); + std::format("Invalid scale passed to monitor {}, failed to find a clean divisor. Suggested nearest scale: {:5f}", m_name, searchScale)); + m_scale = getDefaultScale(); } else - scale = searchScale; + m_scale = searchScale; } } } - output->scheduleFrame(); + m_output->scheduleFrame(); - if (!state.commit()) - Debug::log(ERR, "Couldn't commit output named {}", output->name); + if (!m_state.commit()) + Debug::log(ERR, "Couldn't commit output named {}", m_output->name); - Vector2D xfmd = transform % 2 == 1 ? Vector2D{vecPixelSize.y, vecPixelSize.x} : vecPixelSize; - vecSize = (xfmd / scale).round(); - vecTransformedSize = xfmd; + Vector2D xfmd = m_transform % 2 == 1 ? Vector2D{m_pixelSize.y, m_pixelSize.x} : m_pixelSize; + m_size = (xfmd / m_scale).round(); + m_transformedSize = xfmd; - if (createdByUser) { - CBox transformedBox = {0, 0, vecTransformedSize.x, vecTransformedSize.y}; - transformedBox.transform(wlTransformToHyprutils(invertTransform(transform)), vecTransformedSize.x, vecTransformedSize.y); + if (m_createdByUser) { + CBox transformedBox = {0, 0, m_transformedSize.x, m_transformedSize.y}; + transformedBox.transform(wlTransformToHyprutils(invertTransform(m_transform)), m_transformedSize.x, m_transformedSize.y); - vecPixelSize = Vector2D(transformedBox.width, transformedBox.height); + m_pixelSize = Vector2D(transformedBox.width, transformedBox.height); } updateMatrix(); - if (WAS10B != enabled10bit || OLDRES != vecPixelSize) - g_pHyprOpenGL->destroyMonitorResources(self); + if (WAS10B != m_enabled10bit || OLDRES != m_pixelSize) + g_pHyprOpenGL->destroyMonitorResources(m_self); g_pCompositor->arrangeMonitors(); - damage.setSize(vecTransformedSize); + m_damage.setSize(m_transformedSize); // Set scale for all surfaces on this monitor, needed for some clients // but not on unsafe state to avoid crashes @@ -845,28 +845,28 @@ bool CMonitor::applyMonitorRule(SMonitorRule* pMonitorRule, bool force) { } } // updato us - g_pHyprRenderer->arrangeLayersForMonitor(ID); + g_pHyprRenderer->arrangeLayersForMonitor(m_id); // reload to fix mirrors g_pConfigManager->m_wantsMonitorReload = true; - Debug::log(LOG, "Monitor {} data dump: res {:X}@{:.2f}Hz, scale {:.2f}, transform {}, pos {:X}, 10b {}", szName, vecPixelSize, refreshRate, scale, (int)transform, vecPosition, - (int)enabled10bit); + Debug::log(LOG, "Monitor {} data dump: res {:X}@{:.2f}Hz, scale {:.2f}, transform {}, pos {:X}, 10b {}", m_name, m_pixelSize, m_refreshRate, m_scale, (int)m_transform, + m_position, (int)m_enabled10bit); EMIT_HOOK_EVENT("monitorLayoutChanged", nullptr); - events.modeChanged.emit(); + m_events.modeChanged.emit(); return true; } void CMonitor::addDamage(const pixman_region32_t* rg) { static auto PZOOMFACTOR = CConfigValue<Hyprlang::FLOAT>("cursor:zoom_factor"); - if (*PZOOMFACTOR != 1.f && g_pCompositor->getMonitorFromCursor() == self) { - damage.damageEntire(); - g_pCompositor->scheduleFrameForMonitor(self.lock(), Aquamarine::IOutput::AQ_SCHEDULE_DAMAGE); - } else if (damage.damage(rg)) - g_pCompositor->scheduleFrameForMonitor(self.lock(), Aquamarine::IOutput::AQ_SCHEDULE_DAMAGE); + if (*PZOOMFACTOR != 1.f && g_pCompositor->getMonitorFromCursor() == m_self) { + m_damage.damageEntire(); + g_pCompositor->scheduleFrameForMonitor(m_self.lock(), Aquamarine::IOutput::AQ_SCHEDULE_DAMAGE); + } else if (m_damage.damage(rg)) + g_pCompositor->scheduleFrameForMonitor(m_self.lock(), Aquamarine::IOutput::AQ_SCHEDULE_DAMAGE); } void CMonitor::addDamage(const CRegion& rg) { @@ -875,13 +875,13 @@ void CMonitor::addDamage(const CRegion& rg) { void CMonitor::addDamage(const CBox& box) { static auto PZOOMFACTOR = CConfigValue<Hyprlang::FLOAT>("cursor:zoom_factor"); - if (*PZOOMFACTOR != 1.f && g_pCompositor->getMonitorFromCursor() == self) { - damage.damageEntire(); - g_pCompositor->scheduleFrameForMonitor(self.lock(), Aquamarine::IOutput::AQ_SCHEDULE_DAMAGE); + if (*PZOOMFACTOR != 1.f && g_pCompositor->getMonitorFromCursor() == m_self) { + m_damage.damageEntire(); + g_pCompositor->scheduleFrameForMonitor(m_self.lock(), Aquamarine::IOutput::AQ_SCHEDULE_DAMAGE); } - if (damage.damage(box)) - g_pCompositor->scheduleFrameForMonitor(self.lock(), Aquamarine::IOutput::AQ_SCHEDULE_DAMAGE); + if (m_damage.damage(box)) + g_pCompositor->scheduleFrameForMonitor(m_self.lock(), Aquamarine::IOutput::AQ_SCHEDULE_DAMAGE); } bool CMonitor::shouldSkipScheduleFrameOnMouseEvent() { @@ -889,13 +889,13 @@ bool CMonitor::shouldSkipScheduleFrameOnMouseEvent() { static auto PMINRR = CConfigValue<Hyprlang::INT>("cursor:min_refresh_rate"); // skip scheduling extra frames for fullsreen apps with vrr - const bool shouldSkip = activeWorkspace && activeWorkspace->m_hasFullscreenWindow && activeWorkspace->m_fullscreenMode == FSMODE_FULLSCREEN && - (*PNOBREAK == 1 || (*PNOBREAK == 2 && activeWorkspace->getFullscreenWindow()->getContentType() == CONTENT_TYPE_GAME)) && output->state->state().adaptiveSync; + const bool shouldSkip = m_activeWorkspace && m_activeWorkspace->m_hasFullscreenWindow && m_activeWorkspace->m_fullscreenMode == FSMODE_FULLSCREEN && + (*PNOBREAK == 1 || (*PNOBREAK == 2 && m_activeWorkspace->getFullscreenWindow()->getContentType() == CONTENT_TYPE_GAME)) && m_output->state->state().adaptiveSync; // keep requested minimum refresh rate - if (shouldSkip && *PMINRR && lastPresentationTimer.getMillis() > 1000.0f / *PMINRR) { + if (shouldSkip && *PMINRR && m_lastPresentationTimer.getMillis() > 1000.0f / *PMINRR) { // damage whole screen because some previous cursor box damages were skipped - damage.damageEntire(); + m_damage.damageEntire(); return false; } @@ -903,7 +903,7 @@ bool CMonitor::shouldSkipScheduleFrameOnMouseEvent() { } bool CMonitor::isMirror() { - return pMirrorOf != nullptr; + return m_mirrorOf != nullptr; } bool CMonitor::matchesStaticSelector(const std::string& selector) const { @@ -911,10 +911,10 @@ bool CMonitor::matchesStaticSelector(const std::string& selector) const { // match by description const auto DESCRIPTIONSELECTOR = trim(selector.substr(5)); - return szDescription.starts_with(DESCRIPTIONSELECTOR) || szShortDescription.starts_with(DESCRIPTIONSELECTOR); + return m_description.starts_with(DESCRIPTIONSELECTOR) || m_shortDescription.starts_with(DESCRIPTIONSELECTOR); } else { // match by selector - return szName == selector; + return m_name == selector; } } @@ -923,7 +923,7 @@ WORKSPACEID CMonitor::findAvailableDefaultWS() { if (g_pCompositor->getWorkspaceByID(i)) continue; - if (const auto BOUND = g_pConfigManager->getBoundMonitorStringForWS(std::to_string(i)); !BOUND.empty() && BOUND != szName) + if (const auto BOUND = g_pConfigManager->getBoundMonitorStringForWS(std::to_string(i)); !BOUND.empty() && BOUND != m_name) continue; return i; @@ -936,10 +936,10 @@ void CMonitor::setupDefaultWS(const SMonitorRule& monitorRule) { // Workspace std::string newDefaultWorkspaceName = ""; int64_t wsID = WORKSPACE_INVALID; - if (g_pConfigManager->getDefaultWorkspaceFor(szName).empty()) + if (g_pConfigManager->getDefaultWorkspaceFor(m_name).empty()) wsID = findAvailableDefaultWS(); else { - const auto ws = getWorkspaceIDNameFromString(g_pConfigManager->getDefaultWorkspaceFor(szName)); + const auto ws = getWorkspaceIDNameFromString(g_pConfigManager->getDefaultWorkspaceFor(m_name)); wsID = ws.id; newDefaultWorkspaceName = ws.name; } @@ -948,7 +948,7 @@ void CMonitor::setupDefaultWS(const SMonitorRule& monitorRule) { wsID = g_pCompositor->m_workspaces.size() + 1; newDefaultWorkspaceName = std::to_string(wsID); - Debug::log(LOG, "Invalid workspace= directive name in monitor parsing, workspace name \"{}\" is invalid.", g_pConfigManager->getDefaultWorkspaceFor(szName)); + Debug::log(LOG, "Invalid workspace= directive name in monitor parsing, workspace name \"{}\" is invalid.", g_pConfigManager->getDefaultWorkspaceFor(m_name)); } auto PNEWWORKSPACE = g_pCompositor->getWorkspaceByID(wsID); @@ -957,18 +957,18 @@ void CMonitor::setupDefaultWS(const SMonitorRule& monitorRule) { if (PNEWWORKSPACE) { // workspace exists, move it to the newly connected monitor - g_pCompositor->moveWorkspaceToMonitor(PNEWWORKSPACE, self.lock()); - activeWorkspace = PNEWWORKSPACE; - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID); + g_pCompositor->moveWorkspaceToMonitor(PNEWWORKSPACE, m_self.lock()); + m_activeWorkspace = PNEWWORKSPACE; + g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m_id); PNEWWORKSPACE->startAnim(true, true, true); } else { if (newDefaultWorkspaceName == "") newDefaultWorkspaceName = std::to_string(wsID); - PNEWWORKSPACE = g_pCompositor->m_workspaces.emplace_back(CWorkspace::create(wsID, self.lock(), newDefaultWorkspaceName)); + PNEWWORKSPACE = g_pCompositor->m_workspaces.emplace_back(CWorkspace::create(wsID, m_self.lock(), newDefaultWorkspaceName)); } - activeWorkspace = PNEWWORKSPACE; + m_activeWorkspace = PNEWWORKSPACE; PNEWWORKSPACE->setActive(true); PNEWWORKSPACE->m_visible = true; @@ -978,7 +978,7 @@ void CMonitor::setupDefaultWS(const SMonitorRule& monitorRule) { void CMonitor::setMirror(const std::string& mirrorOf) { const auto PMIRRORMON = g_pCompositor->getMonitorFromString(mirrorOf); - if (PMIRRORMON == pMirrorOf) + if (PMIRRORMON == m_mirrorOf) return; if (PMIRRORMON && PMIRRORMON->isMirror()) { @@ -986,7 +986,7 @@ void CMonitor::setMirror(const std::string& mirrorOf) { return; } - if (PMIRRORMON == self) { + if (PMIRRORMON == m_self) { Debug::log(ERR, "Cannot mirror self!"); return; } @@ -994,19 +994,19 @@ void CMonitor::setMirror(const std::string& mirrorOf) { if (!PMIRRORMON) { // disable mirroring - if (pMirrorOf) { - pMirrorOf->mirrors.erase(std::find_if(pMirrorOf->mirrors.begin(), pMirrorOf->mirrors.end(), [&](const auto& other) { return other == self; })); + if (m_mirrorOf) { + m_mirrorOf->m_mirrors.erase(std::find_if(m_mirrorOf->m_mirrors.begin(), m_mirrorOf->m_mirrors.end(), [&](const auto& other) { return other == m_self; })); // unlock software for mirrored monitor - g_pPointerManager->unlockSoftwareForMonitor(pMirrorOf.lock()); + g_pPointerManager->unlockSoftwareForMonitor(m_mirrorOf.lock()); } - pMirrorOf.reset(); + m_mirrorOf.reset(); // set rule - const auto RULE = g_pConfigManager->getMonitorRuleFor(self.lock()); + const auto RULE = g_pConfigManager->getMonitorRuleFor(m_self.lock()); - vecPosition = RULE.offset; + m_position = RULE.offset; // push to mvmonitors @@ -1014,7 +1014,7 @@ void CMonitor::setMirror(const std::string& mirrorOf) { // find the wrap for (auto& m : g_pCompositor->m_realMonitors) { - if (m->ID == ID) { + if (m->m_id == m_id) { thisWrapper = &m; break; } @@ -1041,7 +1041,7 @@ void CMonitor::setMirror(const std::string& mirrorOf) { // move all the WS std::vector<PHLWORKSPACE> wspToMove; for (auto const& w : g_pCompositor->m_workspaces) { - if (w->m_monitor == self || !w->m_monitor) + if (w->m_monitor == m_self || !w->m_monitor) wspToMove.push_back(w); } @@ -1050,16 +1050,16 @@ void CMonitor::setMirror(const std::string& mirrorOf) { w->startAnim(true, true, true); } - activeWorkspace.reset(); + m_activeWorkspace.reset(); - vecPosition = PMIRRORMON->vecPosition; + m_position = PMIRRORMON->m_position; - pMirrorOf = PMIRRORMON; + m_mirrorOf = PMIRRORMON; - pMirrorOf->mirrors.push_back(self); + m_mirrorOf->m_mirrors.push_back(m_self); // remove from mvmonitors - std::erase_if(g_pCompositor->m_monitors, [&](const auto& other) { return other == self; }); + std::erase_if(g_pCompositor->m_monitors, [&](const auto& other) { return other == m_self; }); g_pCompositor->arrangeMonitors(); @@ -1071,17 +1071,17 @@ void CMonitor::setMirror(const std::string& mirrorOf) { g_pPointerManager->lockSoftwareForMonitor(PMIRRORMON); } - events.modeChanged.emit(); + m_events.modeChanged.emit(); } float CMonitor::getDefaultScale() { - if (!m_bEnabled) + if (!m_enabled) return 1; static constexpr double MMPERINCH = 25.4; - const auto DIAGONALPX = sqrt(pow(vecPixelSize.x, 2) + pow(vecPixelSize.y, 2)); - const auto DIAGONALIN = sqrt(pow(output->physicalSize.x / MMPERINCH, 2) + pow(output->physicalSize.y / MMPERINCH, 2)); + const auto DIAGONALPX = sqrt(pow(m_pixelSize.x, 2) + pow(m_pixelSize.y, 2)); + const auto DIAGONALIN = sqrt(pow(m_output->physicalSize.x / MMPERINCH, 2) + pow(m_output->physicalSize.y / MMPERINCH, 2)); const auto PPI = DIAGONALPX / DIAGONALIN; @@ -1097,22 +1097,22 @@ void CMonitor::changeWorkspace(const PHLWORKSPACE& pWorkspace, bool internal, bo return; if (pWorkspace->m_isSpecialWorkspace) { - if (activeSpecialWorkspace != pWorkspace) { + if (m_activeSpecialWorkspace != pWorkspace) { Debug::log(LOG, "changeworkspace on special, togglespecialworkspace to id {}", pWorkspace->m_id); setSpecialWorkspace(pWorkspace); } return; } - if (pWorkspace == activeWorkspace) + if (pWorkspace == m_activeWorkspace) return; - const auto POLDWORKSPACE = activeWorkspace; + const auto POLDWORKSPACE = m_activeWorkspace; if (POLDWORKSPACE) POLDWORKSPACE->m_visible = false; pWorkspace->m_visible = true; - activeWorkspace = pWorkspace; + m_activeWorkspace = pWorkspace; if (!internal) { const auto ANIMTOLEFT = POLDWORKSPACE && pWorkspace->m_id > POLDWORKSPACE->m_id; @@ -1126,8 +1126,8 @@ void CMonitor::changeWorkspace(const PHLWORKSPACE& pWorkspace, bool internal, bo w->moveToWorkspace(pWorkspace); } - if (!noFocus && !g_pCompositor->m_lastMonitor->activeSpecialWorkspace && - !(g_pCompositor->m_lastWindow.lock() && g_pCompositor->m_lastWindow->m_pinned && g_pCompositor->m_lastWindow->m_monitor == self)) { + if (!noFocus && !g_pCompositor->m_lastMonitor->m_activeSpecialWorkspace && + !(g_pCompositor->m_lastWindow.lock() && g_pCompositor->m_lastWindow->m_pinned && g_pCompositor->m_lastWindow->m_monitor == m_self)) { static auto PFOLLOWMOUSE = CConfigValue<Hyprlang::INT>("input:follow_mouse"); auto pWindow = pWorkspace->m_hasFullscreenWindow ? pWorkspace->getFullscreenWindow() : pWorkspace->getLastFocusedWindow(); @@ -1148,23 +1148,23 @@ void CMonitor::changeWorkspace(const PHLWORKSPACE& pWorkspace, bool internal, bo if (!noMouseMove) g_pInputManager->simulateMouseMovement(); - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID); + g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m_id); g_pEventManager->postEvent(SHyprIPCEvent{"workspace", pWorkspace->m_name}); g_pEventManager->postEvent(SHyprIPCEvent{"workspacev2", std::format("{},{}", pWorkspace->m_id, pWorkspace->m_name)}); EMIT_HOOK_EVENT("workspace", pWorkspace); } - g_pHyprRenderer->damageMonitor(self.lock()); + g_pHyprRenderer->damageMonitor(m_self.lock()); g_pCompositor->updateFullscreenFadeOnWorkspace(pWorkspace); - g_pConfigManager->ensureVRR(self.lock()); + g_pConfigManager->ensureVRR(m_self.lock()); g_pCompositor->updateSuspendedStates(); - if (activeSpecialWorkspace) - g_pCompositor->updateFullscreenFadeOnWorkspace(activeSpecialWorkspace); + if (m_activeSpecialWorkspace) + g_pCompositor->updateFullscreenFadeOnWorkspace(m_activeSpecialWorkspace); } void CMonitor::changeWorkspace(const WORKSPACEID& id, bool internal, bool noMouseMove, bool noFocus) { @@ -1172,83 +1172,83 @@ void CMonitor::changeWorkspace(const WORKSPACEID& id, bool internal, bool noMous } void CMonitor::setSpecialWorkspace(const PHLWORKSPACE& pWorkspace) { - if (activeSpecialWorkspace == pWorkspace) + if (m_activeSpecialWorkspace == pWorkspace) return; - g_pHyprRenderer->damageMonitor(self.lock()); + g_pHyprRenderer->damageMonitor(m_self.lock()); if (!pWorkspace) { // remove special if exists - if (activeSpecialWorkspace) { - activeSpecialWorkspace->m_visible = false; - activeSpecialWorkspace->startAnim(false, false); - g_pEventManager->postEvent(SHyprIPCEvent{"activespecial", "," + szName}); - g_pEventManager->postEvent(SHyprIPCEvent{"activespecialv2", ",," + szName}); + if (m_activeSpecialWorkspace) { + m_activeSpecialWorkspace->m_visible = false; + m_activeSpecialWorkspace->startAnim(false, false); + g_pEventManager->postEvent(SHyprIPCEvent{"activespecial", "," + m_name}); + g_pEventManager->postEvent(SHyprIPCEvent{"activespecialv2", ",," + m_name}); } - activeSpecialWorkspace.reset(); + m_activeSpecialWorkspace.reset(); - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID); + g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m_id); - if (!(g_pCompositor->m_lastWindow.lock() && g_pCompositor->m_lastWindow->m_pinned && g_pCompositor->m_lastWindow->m_monitor == self)) { - if (const auto PLAST = activeWorkspace->getLastFocusedWindow(); PLAST) + if (!(g_pCompositor->m_lastWindow.lock() && g_pCompositor->m_lastWindow->m_pinned && g_pCompositor->m_lastWindow->m_monitor == m_self)) { + if (const auto PLAST = m_activeWorkspace->getLastFocusedWindow(); PLAST) g_pCompositor->focusWindow(PLAST); else g_pInputManager->refocus(); } - g_pCompositor->updateFullscreenFadeOnWorkspace(activeWorkspace); + g_pCompositor->updateFullscreenFadeOnWorkspace(m_activeWorkspace); - g_pConfigManager->ensureVRR(self.lock()); + g_pConfigManager->ensureVRR(m_self.lock()); g_pCompositor->updateSuspendedStates(); return; } - if (activeSpecialWorkspace) { - activeSpecialWorkspace->m_visible = false; - activeSpecialWorkspace->startAnim(false, false); + if (m_activeSpecialWorkspace) { + m_activeSpecialWorkspace->m_visible = false; + m_activeSpecialWorkspace->startAnim(false, false); } bool animate = true; //close if open elsewhere const auto PMONITORWORKSPACEOWNER = pWorkspace->m_monitor.lock(); - if (const auto PMWSOWNER = pWorkspace->m_monitor.lock(); PMWSOWNER && PMWSOWNER->activeSpecialWorkspace == pWorkspace) { - PMWSOWNER->activeSpecialWorkspace.reset(); - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PMWSOWNER->ID); - g_pEventManager->postEvent(SHyprIPCEvent{"activespecial", "," + PMWSOWNER->szName}); - g_pEventManager->postEvent(SHyprIPCEvent{"activespecialv2", ",," + PMWSOWNER->szName}); + if (const auto PMWSOWNER = pWorkspace->m_monitor.lock(); PMWSOWNER && PMWSOWNER->m_activeSpecialWorkspace == pWorkspace) { + PMWSOWNER->m_activeSpecialWorkspace.reset(); + g_pLayoutManager->getCurrentLayout()->recalculateMonitor(PMWSOWNER->m_id); + g_pEventManager->postEvent(SHyprIPCEvent{"activespecial", "," + PMWSOWNER->m_name}); + g_pEventManager->postEvent(SHyprIPCEvent{"activespecialv2", ",," + PMWSOWNER->m_name}); - const auto PACTIVEWORKSPACE = PMWSOWNER->activeWorkspace; + const auto PACTIVEWORKSPACE = PMWSOWNER->m_activeWorkspace; g_pCompositor->updateFullscreenFadeOnWorkspace(PACTIVEWORKSPACE); animate = false; } // open special - pWorkspace->m_monitor = self; - activeSpecialWorkspace = pWorkspace; - activeSpecialWorkspace->m_visible = true; + pWorkspace->m_monitor = m_self; + m_activeSpecialWorkspace = pWorkspace; + m_activeSpecialWorkspace->m_visible = true; if (animate) pWorkspace->startAnim(true, true); for (auto const& w : g_pCompositor->m_windows) { if (w->m_workspace == pWorkspace) { - w->m_monitor = self; + w->m_monitor = m_self; w->updateSurfaceScaleTransformDetails(); w->setAnimationsToMove(); const auto MIDDLE = w->middle(); - if (w->m_isFloating && !VECINRECT(MIDDLE, vecPosition.x, vecPosition.y, vecPosition.x + vecSize.x, vecPosition.y + vecSize.y) && !w->isX11OverrideRedirect()) { + if (w->m_isFloating && !VECINRECT(MIDDLE, m_position.x, m_position.y, m_position.x + m_size.x, m_position.y + m_size.y) && !w->isX11OverrideRedirect()) { // if it's floating and the middle isnt on the current mon, move it to the center const auto PMONFROMMIDDLE = g_pCompositor->getMonitorFromVector(MIDDLE); Vector2D pos = w->m_realPosition->goal(); - if (!VECINRECT(MIDDLE, PMONFROMMIDDLE->vecPosition.x, PMONFROMMIDDLE->vecPosition.y, PMONFROMMIDDLE->vecPosition.x + PMONFROMMIDDLE->vecSize.x, - PMONFROMMIDDLE->vecPosition.y + PMONFROMMIDDLE->vecSize.y)) { + if (!VECINRECT(MIDDLE, PMONFROMMIDDLE->m_position.x, PMONFROMMIDDLE->m_position.y, PMONFROMMIDDLE->m_position.x + PMONFROMMIDDLE->m_size.x, + PMONFROMMIDDLE->m_position.y + PMONFROMMIDDLE->m_size.y)) { // not on any monitor, center pos = middle() / 2.f - w->m_realSize->goal() / 2.f; } else - pos = pos - PMONFROMMIDDLE->vecPosition + vecPosition; + pos = pos - PMONFROMMIDDLE->m_position + m_position; *w->m_realPosition = pos; w->m_position = pos; @@ -1256,23 +1256,23 @@ void CMonitor::setSpecialWorkspace(const PHLWORKSPACE& pWorkspace) { } } - g_pLayoutManager->getCurrentLayout()->recalculateMonitor(ID); + g_pLayoutManager->getCurrentLayout()->recalculateMonitor(m_id); - if (!(g_pCompositor->m_lastWindow.lock() && g_pCompositor->m_lastWindow->m_pinned && g_pCompositor->m_lastWindow->m_monitor == self)) { + if (!(g_pCompositor->m_lastWindow.lock() && g_pCompositor->m_lastWindow->m_pinned && g_pCompositor->m_lastWindow->m_monitor == m_self)) { if (const auto PLAST = pWorkspace->getLastFocusedWindow(); PLAST) g_pCompositor->focusWindow(PLAST); else g_pInputManager->refocus(); } - g_pEventManager->postEvent(SHyprIPCEvent{"activespecial", pWorkspace->m_name + "," + szName}); - g_pEventManager->postEvent(SHyprIPCEvent{"activespecialv2", std::to_string(pWorkspace->m_id) + "," + pWorkspace->m_name + "," + szName}); + g_pEventManager->postEvent(SHyprIPCEvent{"activespecial", pWorkspace->m_name + "," + m_name}); + g_pEventManager->postEvent(SHyprIPCEvent{"activespecialv2", std::to_string(pWorkspace->m_id) + "," + pWorkspace->m_name + "," + m_name}); - g_pHyprRenderer->damageMonitor(self.lock()); + g_pHyprRenderer->damageMonitor(m_self.lock()); g_pCompositor->updateFullscreenFadeOnWorkspace(pWorkspace); - g_pConfigManager->ensureVRR(self.lock()); + g_pConfigManager->ensureVRR(m_self.lock()); g_pCompositor->updateSuspendedStates(); } @@ -1282,19 +1282,19 @@ void CMonitor::setSpecialWorkspace(const WORKSPACEID& id) { } void CMonitor::moveTo(const Vector2D& pos) { - vecPosition = pos; + m_position = pos; } SWorkspaceIDName CMonitor::getPrevWorkspaceIDName(const WORKSPACEID id) { - while (!prevWorkSpaces.empty()) { - const int PREVID = prevWorkSpaces.top(); - prevWorkSpaces.pop(); + while (!m_prevWorkSpaces.empty()) { + const int PREVID = m_prevWorkSpaces.top(); + m_prevWorkSpaces.pop(); if (PREVID == id) // skip same workspace continue; // recheck if previous workspace's was moved to another monitor const auto ws = g_pCompositor->getWorkspaceByID(PREVID); - if (ws && ws->monitorID() == ID) + if (ws && ws->monitorID() == m_id) return {.id = PREVID, .name = ws->m_name}; } @@ -1302,66 +1302,66 @@ SWorkspaceIDName CMonitor::getPrevWorkspaceIDName(const WORKSPACEID id) { } void CMonitor::addPrevWorkspaceID(const WORKSPACEID id) { - if (!prevWorkSpaces.empty() && prevWorkSpaces.top() == id) + if (!m_prevWorkSpaces.empty() && m_prevWorkSpaces.top() == id) return; - prevWorkSpaces.emplace(id); + m_prevWorkSpaces.emplace(id); } Vector2D CMonitor::middle() { - return vecPosition + vecSize / 2.f; + return m_position + m_size / 2.f; } void CMonitor::updateMatrix() { - projMatrix = Mat3x3::identity(); - if (transform != WL_OUTPUT_TRANSFORM_NORMAL) - projMatrix.translate(vecPixelSize / 2.0).transform(wlTransformToHyprutils(transform)).translate(-vecTransformedSize / 2.0); + m_projMatrix = Mat3x3::identity(); + if (m_transform != WL_OUTPUT_TRANSFORM_NORMAL) + m_projMatrix.translate(m_pixelSize / 2.0).transform(wlTransformToHyprutils(m_transform)).translate(-m_transformedSize / 2.0); } WORKSPACEID CMonitor::activeWorkspaceID() { - return activeWorkspace ? activeWorkspace->m_id : 0; + return m_activeWorkspace ? m_activeWorkspace->m_id : 0; } WORKSPACEID CMonitor::activeSpecialWorkspaceID() { - return activeSpecialWorkspace ? activeSpecialWorkspace->m_id : 0; + return m_activeSpecialWorkspace ? m_activeSpecialWorkspace->m_id : 0; } CBox CMonitor::logicalBox() { - return {vecPosition, vecSize}; + return {m_position, m_size}; } void CMonitor::scheduleDone() { - if (doneScheduled) + if (m_doneScheduled) return; - doneScheduled = true; + m_doneScheduled = true; - g_pEventLoopManager->doLater([M = self] { + g_pEventLoopManager->doLater([M = m_self] { if (!M) // if M is gone, we got destroyed, doesn't matter. return; - if (!PROTO::outputs.contains(M->szName)) + if (!PROTO::outputs.contains(M->m_name)) return; - PROTO::outputs.at(M->szName)->sendDone(); - M->doneScheduled = false; + PROTO::outputs.at(M->m_name)->sendDone(); + M->m_doneScheduled = false; }); } void CMonitor::setCTM(const Mat3x3& ctm_) { - ctm = ctm_; - ctmUpdated = true; - g_pCompositor->scheduleFrameForMonitor(self.lock(), Aquamarine::IOutput::scheduleFrameReason::AQ_SCHEDULE_NEEDS_FRAME); + m_ctm = ctm_; + m_ctmUpdated = true; + g_pCompositor->scheduleFrameForMonitor(m_self.lock(), Aquamarine::IOutput::scheduleFrameReason::AQ_SCHEDULE_NEEDS_FRAME); } bool CMonitor::attemptDirectScanout() { - if (!mirrors.empty() || isMirror() || g_pHyprRenderer->m_bDirectScanoutBlocked) + if (!m_mirrors.empty() || isMirror() || g_pHyprRenderer->m_bDirectScanoutBlocked) return false; // do not DS if this monitor is being mirrored. Will break the functionality. - if (g_pPointerManager->softwareLockedFor(self.lock())) + if (g_pPointerManager->softwareLockedFor(m_self.lock())) return false; - const auto PCANDIDATE = solitaryClient.lock(); + const auto PCANDIDATE = m_solitaryClient.lock(); if (!PCANDIDATE) return false; @@ -1371,7 +1371,7 @@ bool CMonitor::attemptDirectScanout() { if (!PSURFACE || !PSURFACE->current.texture || !PSURFACE->current.buffer) return false; - if (PSURFACE->current.bufferSize != vecPixelSize || PSURFACE->current.transform != transform) + if (PSURFACE->current.bufferSize != m_pixelSize || PSURFACE->current.transform != m_transform) return false; // we can't scanout shm buffers. @@ -1383,22 +1383,22 @@ bool CMonitor::attemptDirectScanout() { auto PBUFFER = PSURFACE->current.buffer.buffer; - if (PBUFFER == output->state->state().buffer) { - PSURFACE->presentFeedback(Time::steadyNow(), self.lock()); + if (PBUFFER == m_output->state->state().buffer) { + PSURFACE->presentFeedback(Time::steadyNow(), m_self.lock()); - if (scanoutNeedsCursorUpdate) { - if (!state.test()) { + if (m_scanoutNeedsCursorUpdate) { + if (!m_state.test()) { Debug::log(TRACE, "attemptDirectScanout: failed basic test"); return false; } - if (!output->commit()) { + if (!m_output->commit()) { Debug::log(TRACE, "attemptDirectScanout: failed to commit cursor update"); - lastScanout.reset(); + m_lastScanout.reset(); return false; } - scanoutNeedsCursorUpdate = false; + m_scanoutNeedsCursorUpdate = false; } return true; @@ -1408,44 +1408,44 @@ bool CMonitor::attemptDirectScanout() { // and comes from the appropriate device. This may implode on multi-gpu!! // entering into scanout, so save monitor format - if (lastScanout.expired()) - prevDrmFormat = drmFormat; + if (m_lastScanout.expired()) + m_prevDrmFormat = m_drmFormat; - if (drmFormat != params.format) { - output->state->setFormat(params.format); - drmFormat = params.format; + if (m_drmFormat != params.format) { + m_output->state->setFormat(params.format); + m_drmFormat = params.format; } - output->state->setBuffer(PBUFFER); - output->state->setPresentationMode(tearingState.activelyTearing ? Aquamarine::eOutputPresentationMode::AQ_OUTPUT_PRESENTATION_IMMEDIATE : - Aquamarine::eOutputPresentationMode::AQ_OUTPUT_PRESENTATION_VSYNC); + m_output->state->setBuffer(PBUFFER); + m_output->state->setPresentationMode(m_tearingState.activelyTearing ? Aquamarine::eOutputPresentationMode::AQ_OUTPUT_PRESENTATION_IMMEDIATE : + Aquamarine::eOutputPresentationMode::AQ_OUTPUT_PRESENTATION_VSYNC); - if (!state.test()) { + if (!m_state.test()) { Debug::log(TRACE, "attemptDirectScanout: failed basic test"); return false; } - PSURFACE->presentFeedback(Time::steadyNow(), self.lock()); + PSURFACE->presentFeedback(Time::steadyNow(), m_self.lock()); - output->state->addDamage(PSURFACE->current.accumulateBufferDamage()); - output->state->resetExplicitFences(); + m_output->state->addDamage(PSURFACE->current.accumulateBufferDamage()); + m_output->state->resetExplicitFences(); // no need to do explicit sync here as surface current can only ever be ready to read - bool ok = output->commit(); + bool ok = m_output->commit(); if (!ok) { Debug::log(TRACE, "attemptDirectScanout: failed to scanout surface"); - lastScanout.reset(); + m_lastScanout.reset(); return false; } - if (lastScanout.expired()) { - lastScanout = PCANDIDATE; + if (m_lastScanout.expired()) { + m_lastScanout = PCANDIDATE; Debug::log(LOG, "Entered a direct scanout to {:x}: \"{}\"", (uintptr_t)PCANDIDATE.get(), PCANDIDATE->m_title); } - scanoutNeedsCursorUpdate = false; + m_scanoutNeedsCursorUpdate = false; if (!PBUFFER->lockedByBackend || PBUFFER->hlEvents.backendRelease) return true; @@ -1459,16 +1459,17 @@ bool CMonitor::attemptDirectScanout() { } void CMonitor::debugLastPresentation(const std::string& message) { - Debug::log(TRACE, "{} (last presentation {} - {} fps)", message, lastPresentationTimer.getMillis(), - lastPresentationTimer.getMillis() > 0 ? 1000.0f / lastPresentationTimer.getMillis() : 0.0f); + Debug::log(TRACE, "{} (last presentation {} - {} fps)", message, m_lastPresentationTimer.getMillis(), + m_lastPresentationTimer.getMillis() > 0 ? 1000.0f / m_lastPresentationTimer.getMillis() : 0.0f); } void CMonitor::onMonitorFrame() { if ((g_pCompositor->m_aqBackend->hasSession() && !g_pCompositor->m_aqBackend->session->active) || !g_pCompositor->m_sessionActive || g_pCompositor->m_unsafeState) { Debug::log(WARN, "Attempted to render frame on inactive session!"); - if (g_pCompositor->m_unsafeState && - std::ranges::any_of(g_pCompositor->m_monitors.begin(), g_pCompositor->m_monitors.end(), [&](auto& m) { return m->output != g_pCompositor->m_unsafeOutput->output; })) { + if (g_pCompositor->m_unsafeState && std::ranges::any_of(g_pCompositor->m_monitors.begin(), g_pCompositor->m_monitors.end(), [&](auto& m) { + return m->m_output != g_pCompositor->m_unsafeOutput->m_output; + })) { // restore from unsafe state g_pCompositor->leaveUnsafeState(); } @@ -1476,57 +1477,57 @@ void CMonitor::onMonitorFrame() { return; // cannot draw on session inactive (different tty) } - if (!m_bEnabled) + if (!m_enabled) return; - g_pHyprRenderer->recheckSolitaryForMonitor(self.lock()); + g_pHyprRenderer->recheckSolitaryForMonitor(m_self.lock()); - tearingState.busy = false; + m_tearingState.busy = false; - if (tearingState.activelyTearing && solitaryClient.lock() /* can be invalidated by a recheck */) { + if (m_tearingState.activelyTearing && m_solitaryClient.lock() /* can be invalidated by a recheck */) { - if (!tearingState.frameScheduledWhileBusy) + if (!m_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; + m_tearingState.nextRenderTorn = true; + m_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(); + m_lastPresentationTimer.reset(); - if (*PENABLERAT && !tearingState.nextRenderTorn) { - if (!RATScheduled) { + if (*PENABLERAT && !m_tearingState.nextRenderTorn) { + if (!m_ratsScheduled) { // render - g_pHyprRenderer->renderMonitor(self.lock()); + g_pHyprRenderer->renderMonitor(m_self.lock()); } - RATScheduled = false; + m_ratsScheduled = false; - const auto& [avg, max, min] = g_pHyprRenderer->getRenderTimes(self.lock()); + const auto& [avg, max, min] = g_pHyprRenderer->getRenderTimes(m_self.lock()); - if (max + *PRATSAFE > 1000.0 / refreshRate) + if (max + *PRATSAFE > 1000.0 / m_refreshRate) return; - const auto MSLEFT = 1000.0 / refreshRate - lastPresentationTimer.getMillis(); + const auto MSLEFT = (1000.0 / m_refreshRate) - m_lastPresentationTimer.getMillis(); - RATScheduled = true; + m_ratsScheduled = 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()); + g_pHyprRenderer->renderMonitor(m_self.lock()); else - wl_event_source_timer_update(renderTimer, TIMETOSLEEP); + wl_event_source_timer_update(m_renderTimer, TIMETOSLEEP); } else - g_pHyprRenderer->renderMonitor(self.lock()); + g_pHyprRenderer->renderMonitor(m_self.lock()); } void CMonitor::onCursorMovedOnMonitor() { - if (!tearingState.activelyTearing || !solitaryClient || !g_pHyprRenderer->shouldRenderCursor()) + if (!m_tearingState.activelyTearing || !m_solitaryClient || !g_pHyprRenderer->shouldRenderCursor()) return; // submit a frame immediately. This will only update the cursor pos. @@ -1540,41 +1541,41 @@ void CMonitor::onCursorMovedOnMonitor() { // and throws a "nO pRoP cAn Be ChAnGeD dUrInG AsYnC fLiP" on crtc_x // this will throw too but fix it if we use sw cursors - tearingState.frameScheduledWhileBusy = true; + m_tearingState.frameScheduledWhileBusy = true; } -CMonitorState::CMonitorState(CMonitor* owner) : m_pOwner(owner) { +CMonitorState::CMonitorState(CMonitor* owner) : m_owner(owner) { ; } void CMonitorState::ensureBufferPresent() { - const auto STATE = m_pOwner->output->state->state(); + const auto STATE = m_owner->m_output->state->state(); if (!STATE.enabled) { Debug::log(TRACE, "CMonitorState::ensureBufferPresent: Ignoring, monitor is not enabled"); return; } if (STATE.buffer) { - if (const auto params = STATE.buffer->dmabuf(); params.success && params.format == m_pOwner->drmFormat) + if (const auto params = STATE.buffer->dmabuf(); params.success && params.format == m_owner->m_drmFormat) return; } // this is required for modesetting being possible and might be missing in case of first tests in the renderer // where we test modes and buffers Debug::log(LOG, "CMonitorState::ensureBufferPresent: no buffer or mismatched format, attaching one from the swapchain for modeset being possible"); - m_pOwner->output->state->setBuffer(m_pOwner->output->swapchain->next(nullptr)); - m_pOwner->output->swapchain->rollback(); // restore the counter, don't advance the swapchain + m_owner->m_output->state->setBuffer(m_owner->m_output->swapchain->next(nullptr)); + m_owner->m_output->swapchain->rollback(); // restore the counter, don't advance the swapchain } bool CMonitorState::commit() { if (!updateSwapchain()) return false; - EMIT_HOOK_EVENT("preMonitorCommit", m_pOwner->self.lock()); + EMIT_HOOK_EVENT("preMonitorCommit", m_owner->m_self.lock()); ensureBufferPresent(); - bool ret = m_pOwner->output->commit(); + bool ret = m_owner->m_output->commit(); return ret; } @@ -1584,20 +1585,20 @@ bool CMonitorState::test() { ensureBufferPresent(); - return m_pOwner->output->test(); + return m_owner->m_output->test(); } bool CMonitorState::updateSwapchain() { - auto options = m_pOwner->output->swapchain->currentOptions(); - const auto& STATE = m_pOwner->output->state->state(); + auto options = m_owner->m_output->swapchain->currentOptions(); + const auto& STATE = m_owner->m_output->state->state(); const auto& MODE = STATE.mode ? STATE.mode : STATE.customMode; if (!MODE) { Debug::log(WARN, "updateSwapchain: No mode?"); return true; } - options.format = m_pOwner->drmFormat; + options.format = m_owner->m_drmFormat; options.scanout = true; options.length = 2; options.size = MODE->pixelSize; - return m_pOwner->output->swapchain->reconfigure(options); + return m_owner->m_output->swapchain->reconfigure(options); } |
