aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/helpers/Monitor.cpp
diff options
context:
space:
mode:
authorVaxry <[email protected]>2024-10-05 00:44:30 +0100
committerVaxry <[email protected]>2024-10-05 01:01:21 +0100
commita815b14bf1b69b92f82bd09f6845fbdbb2fbe516 (patch)
tree9203d29ed6318bb8832ec72c7f16f0f2d982727b /src/helpers/Monitor.cpp
parent3a5052a714e2a6a2b002dddcac1204960b298f8b (diff)
downloadHyprland-a815b14bf1b69b92f82bd09f6845fbdbb2fbe516.tar.gz
Hyprland-a815b14bf1b69b92f82bd09f6845fbdbb2fbe516.zip
monitor: cleanup and modernize scheduleDone
Diffstat (limited to 'src/helpers/Monitor.cpp')
-rw-r--r--src/helpers/Monitor.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp
index a9569699..03a1d92b 100644
--- a/src/helpers/Monitor.cpp
+++ b/src/helpers/Monitor.cpp
@@ -12,6 +12,7 @@
#include "../protocols/DRMSyncobj.hpp"
#include "../protocols/core/Output.hpp"
#include "../managers/PointerManager.hpp"
+#include "../managers/eventLoop/EventLoopManager.hpp"
#include "../protocols/core/Compositor.hpp"
#include "sync/SyncTimeline.hpp"
#include <aquamarine/output/Output.hpp>
@@ -789,20 +790,22 @@ CBox CMonitor::logicalBox() {
return {vecPosition, vecSize};
}
-static void onDoneSource(void* data) {
- auto pMonitor = (CMonitor*)data;
-
- if (!PROTO::outputs.contains(pMonitor->szName))
+void CMonitor::scheduleDone() {
+ if (doneScheduled)
return;
- PROTO::outputs.at(pMonitor->szName)->sendDone();
-}
+ doneScheduled = true;
-void CMonitor::scheduleDone() {
- if (doneSource)
- return;
+ g_pEventLoopManager->doLater([M = self] {
+ if (!M) // if M is gone, we got destroyed, doesn't matter.
+ return;
+
+ if (!PROTO::outputs.contains(M->szName))
+ return;
- doneSource = wl_event_loop_add_idle(g_pCompositor->m_sWLEventLoop, ::onDoneSource, this);
+ PROTO::outputs.at(M->szName)->sendDone();
+ M->doneScheduled = false;
+ });
}
bool CMonitor::attemptDirectScanout() {