From 0ffaa8d6673c02e9360865c8cde69a606c036af7 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Sat, 19 Nov 2022 13:14:55 +0000 Subject: [PATCH] Fix minor issues with mirrors --- src/events/Monitors.cpp | 11 ++--------- src/helpers/Monitor.cpp | 13 +++++++++---- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/events/Monitors.cpp b/src/events/Monitors.cpp index be598f0f..1924fe22 100644 --- a/src/events/Monitors.cpp +++ b/src/events/Monitors.cpp @@ -66,13 +66,6 @@ void Events::listener_newOutput(wl_listener* listener, void* data) { } } - if (PNEWMONITORWRAP && PNEWMONITORWRAP->get()->m_bEnabled) { - Debug::log(LOG, "Connected an enabled monitor???"); - g_pConfigManager->m_bWantsMonitorReload = true; - g_pCompositor->scheduleFrameForMonitor(PNEWMONITORWRAP->get()); - return; - } - if (!PNEWMONITORWRAP) { Debug::log(LOG, "Adding completely new monitor."); PNEWMONITORWRAP = &g_pCompositor->m_vRealMonitors.emplace_back(std::make_shared()); @@ -326,8 +319,8 @@ void Events::listener_monitorDestroy(void* owner, void* data) { CMonitor* pMonitor = nullptr; - for (auto& m : g_pCompositor->m_vMonitors) { - if (m->szName == OUTPUT->name) { + for (auto& m : g_pCompositor->m_vRealMonitors) { + if (m->output == OUTPUT) { pMonitor = m.get(); break; } diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index 70c18aaf..c7fc6750 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -3,8 +3,16 @@ #include "../Compositor.hpp" void CMonitor::onConnect(bool noRule) { - if (m_bEnabled) + hyprListener_monitorDestroy.removeCallback(); + hyprListener_monitorFrame.removeCallback(); + hyprListener_monitorFrame.initCallback(&output->events.frame, &Events::listener_monitorFrame, this); + hyprListener_monitorDestroy.initCallback(&output->events.destroy, &Events::listener_monitorDestroy, this); + + if (m_bEnabled) { + wlr_output_enable(output, 1); + wlr_output_commit(output); return; + } szName = output->name; @@ -14,9 +22,6 @@ void CMonitor::onConnect(bool noRule) { // get monitor rule that matches SMonitorRule monitorRule = g_pConfigManager->getMonitorRuleFor(output->name, output->description ? output->description : ""); - hyprListener_monitorFrame.initCallback(&output->events.frame, &Events::listener_monitorFrame, this); - hyprListener_monitorDestroy.initCallback(&output->events.destroy, &Events::listener_monitorDestroy, this); - // if it's disabled, disable and ignore if (monitorRule.disabled) {