diff options
author | Vaxry <[email protected]> | 2024-07-22 16:56:51 +0200 |
---|---|---|
committer | Vaxry <[email protected]> | 2024-07-22 16:56:51 +0200 |
commit | 5bae7f150b228d3bf677d09fd0c320328b0d0ff0 (patch) | |
tree | 4713f93b61411378071abc08117e2caae137b2ab /src/managers/ProtocolManager.cpp | |
parent | 83a5395eaa99fecef777827fff1de486c06b6180 (diff) | |
download | Hyprland-5bae7f150b228d3bf677d09fd0c320328b0d0ff0.tar.gz Hyprland-5bae7f150b228d3bf677d09fd0c320328b0d0ff0.zip |
wayland/output: avoid sending events to dead outputs
ref #6835
Diffstat (limited to 'src/managers/ProtocolManager.cpp')
-rw-r--r-- | src/managers/ProtocolManager.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/managers/ProtocolManager.cpp b/src/managers/ProtocolManager.cpp index 387cac8f..5a44680f 100644 --- a/src/managers/ProtocolManager.cpp +++ b/src/managers/ProtocolManager.cpp @@ -66,8 +66,7 @@ void CProtocolManager::onMonitorModeChange(CMonitor* pMonitor) { else if (!ISMIRROR && (!PROTO::outputs.contains(pMonitor->szName) || PROTO::outputs.at(pMonitor->szName)->isDefunct())) { if (PROTO::outputs.contains(pMonitor->szName)) PROTO::outputs.erase(pMonitor->szName); - PROTO::outputs.emplace(pMonitor->szName, - std::make_unique<CWLOutputProtocol>(&wl_output_interface, 4, std::format("WLOutput ({})", pMonitor->szName), pMonitor->self.lock())); + PROTO::outputs.emplace(pMonitor->szName, makeShared<CWLOutputProtocol>(&wl_output_interface, 4, std::format("WLOutput ({})", pMonitor->szName), pMonitor->self.lock())); } } @@ -86,7 +85,10 @@ CProtocolManager::CProtocolManager() { if (PROTO::outputs.contains(M->szName)) PROTO::outputs.erase(M->szName); - PROTO::outputs.emplace(M->szName, std::make_unique<CWLOutputProtocol>(&wl_output_interface, 4, std::format("WLOutput ({})", M->szName), M->self.lock())); + + auto ref = makeShared<CWLOutputProtocol>(&wl_output_interface, 4, std::format("WLOutput ({})", M->szName), M->self.lock()); + PROTO::outputs.emplace(M->szName, ref); + ref->self = ref; m_mModeChangeListeners[M->szName] = M->events.modeChanged.registerListener([M, this](std::any d) { onMonitorModeChange(M); }); }); |