diff options
| author | Vaxry <vaxry@vaxry.net> | 2024-07-22 16:56:51 +0200 |
|---|---|---|
| committer | Vaxry <vaxry@vaxry.net> | 2024-07-22 16:56:51 +0200 |
| commit | 5bae7f150b228d3bf677d09fd0c320328b0d0ff0 (patch) | |
| tree | 4713f93b61411378071abc08117e2caae137b2ab /src/protocols | |
| parent | 83a5395eaa99fecef777827fff1de486c06b6180 (diff) | |
wayland/output: avoid sending events to dead outputs
ref #6835
Diffstat (limited to 'src/protocols')
| -rw-r--r-- | src/protocols/core/Output.cpp | 5 | ||||
| -rw-r--r-- | src/protocols/core/Output.hpp | 6 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/protocols/core/Output.cpp b/src/protocols/core/Output.cpp index 4ba23cbe..878d1484 100644 --- a/src/protocols/core/Output.cpp +++ b/src/protocols/core/Output.cpp @@ -49,7 +49,7 @@ SP<CWlOutput> CWLOutputResource::getResource() { } void CWLOutputResource::updateState() { - if (!monitor) + if (!monitor || (owner && owner->defunct)) return; if (resource->version() >= 2) @@ -83,7 +83,8 @@ void CWLOutputProtocol::bindManager(wl_client* client, void* data, uint32_t ver, return; } - RESOURCE->self = RESOURCE; + RESOURCE->self = RESOURCE; + RESOURCE->owner = self; } void CWLOutputProtocol::destroyResource(CWLOutputResource* resource) { diff --git a/src/protocols/core/Output.hpp b/src/protocols/core/Output.hpp index 46e4057b..49c32ec1 100644 --- a/src/protocols/core/Output.hpp +++ b/src/protocols/core/Output.hpp @@ -8,6 +8,7 @@ #include "../../helpers/signal/Signal.hpp" class CMonitor; +class CWLOutputProtocol; class CWLOutputResource { public: @@ -20,7 +21,7 @@ class CWLOutputResource { void updateState(); WP<CMonitor> monitor; - + WP<CWLOutputProtocol> owner; WP<CWLOutputResource> self; private: @@ -40,6 +41,7 @@ class CWLOutputProtocol : public IWaylandProtocol { void sendDone(); WP<CMonitor> monitor; + WP<CWLOutputProtocol> self; // will mark the protocol for removal, will be removed when no. of bound outputs is 0 (or when overwritten by a new global) void remove(); @@ -61,5 +63,5 @@ class CWLOutputProtocol : public IWaylandProtocol { }; namespace PROTO { - inline std::unordered_map<std::string, UP<CWLOutputProtocol>> outputs; + inline std::unordered_map<std::string, SP<CWLOutputProtocol>> outputs; }; |
