aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorVaxry <[email protected]>2024-10-09 00:26:40 +0100
committerVaxry <[email protected]>2024-10-09 00:26:40 +0100
commitbc299928ad5571300180eb8edb6742ed3bbf0282 (patch)
tree4b98fc9ff65e95a126c116e3ecc00618a259e90b /src
parentac658500fbebe607f2db83f11c37f0a3a05ef734 (diff)
downloadHyprland-bc299928ad5571300180eb8edb6742ed3bbf0282.tar.gz
Hyprland-bc299928ad5571300180eb8edb6742ed3bbf0282.zip
output/xdg-output: avoid sending events to released globals
ref #6835
Diffstat (limited to 'src')
-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();
}