aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorVaxry <[email protected]>2024-10-09 00:26:40 +0100
committerVaxry <[email protected]>2024-10-09 13:47:52 +0100
commitad46257ccef8cf3a87083b00d808539368436c25 (patch)
tree88eaecf5d24dcc5ffa5a86edbf52721862788fb5
parent0cfbe618b5b434f5e7b56c8a17cc7a50bf22874c (diff)
downloadHyprland-ad46257ccef8cf3a87083b00d808539368436c25.tar.gz
Hyprland-ad46257ccef8cf3a87083b00d808539368436c25.zip
output/xdg-output: avoid sending events to released globals
ref #6835
-rw-r--r--src/protocols/XDGOutput.cpp4
-rw-r--r--src/protocols/XDGOutput.hpp2
-rw-r--r--src/protocols/core/Output.cpp5
3 files changed, 9 insertions, 2 deletions
diff --git a/src/protocols/XDGOutput.cpp b/src/protocols/XDGOutput.cpp
index 0cdadd43..0598e713 100644
--- a/src/protocols/XDGOutput.cpp
+++ b/src/protocols/XDGOutput.cpp
@@ -51,6 +51,8 @@ void CXDGOutputProtocol::onManagerGetXDGOutput(CZxdgOutputManagerV1* mgr, uint32
#endif
pXDGOutput->client = CLIENT;
+ pXDGOutput->outputProto = OUTPUT->owner;
+
if (!pXDGOutput->resource->resource()) {
m_vXDGOutputs.pop_back();
mgr->noMemory();
@@ -104,7 +106,7 @@ CXDGOutput::CXDGOutput(SP<CZxdgOutputV1> resource_, SP<CMonitor> monitor_) : mon
void CXDGOutput::sendDetails() {
static auto PXWLFORCESCALEZERO = CConfigValue<Hyprlang::INT>("xwayland:force_zero_scaling");
- if (!monitor)
+ if (!monitor || !outputProto || outputProto->isDefunct())
return;
const auto POS = isXWayland ? monitor->vecXWaylandPosition : monitor->vecPosition;
diff --git a/src/protocols/XDGOutput.hpp b/src/protocols/XDGOutput.hpp
index 15d86cc7..520f3aaa 100644
--- a/src/protocols/XDGOutput.hpp
+++ b/src/protocols/XDGOutput.hpp
@@ -6,6 +6,7 @@
class CMonitor;
class CXDGOutputProtocol;
+class CWLOutputProtocol;
class CXDGOutput {
public:
@@ -16,6 +17,7 @@ class CXDGOutput {
private:
WP<CMonitor> monitor;
SP<CZxdgOutputV1> resource;
+ WP<CWLOutputProtocol> outputProto;
std::optional<Vector2D> overridePosition;
diff --git a/src/protocols/core/Output.cpp b/src/protocols/core/Output.cpp
index 7b88e0a8..4047774a 100644
--- a/src/protocols/core/Output.cpp
+++ b/src/protocols/core/Output.cpp
@@ -47,7 +47,7 @@ SP<CWlOutput> CWLOutputResource::getResource() {
}
void CWLOutputResource::updateState() {
- if (!monitor || (owner && owner->defunct))
+ if (!monitor || !owner || owner->defunct)
return;
if (resource->version() >= 2)
@@ -119,6 +119,9 @@ bool CWLOutputProtocol::isDefunct() {
}
void CWLOutputProtocol::sendDone() {
+ if (defunct)
+ return;
+
for (auto const& r : m_vOutputs) {
r->resource->sendDone();
}