diff options
| author | Ikalco <73481042+ikalco@users.noreply.github.com> | 2024-12-01 11:14:35 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-01 17:14:35 +0000 |
| commit | 6d7544458d0fafcae410c1978a0cabce2fb4a346 (patch) | |
| tree | 77bac5cd967326e3f643cbb91fc7e7ae910d401c /src/protocols/Tablet.cpp | |
| parent | d26439a0fe5594fb26d5a3c01571f9490a9a2d2c (diff) | |
cleanup: use doLater instead of adding idle event handlers (#8624)
Diffstat (limited to 'src/protocols/Tablet.cpp')
| -rw-r--r-- | src/protocols/Tablet.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/protocols/Tablet.cpp b/src/protocols/Tablet.cpp index d7f741b9..7768402b 100644 --- a/src/protocols/Tablet.cpp +++ b/src/protocols/Tablet.cpp @@ -2,6 +2,7 @@ #include "../devices/Tablet.hpp" #include "../Compositor.hpp" #include "../managers/SeatManager.hpp" +#include "../managers/eventLoop/EventLoopManager.hpp" #include "core/Seat.hpp" #include "core/Compositor.hpp" #include <algorithm> @@ -162,11 +163,6 @@ CTabletToolV2Resource::CTabletToolV2Resource(SP<CZwpTabletToolV2> resource_, SP< }); } -CTabletToolV2Resource::~CTabletToolV2Resource() { - if (frameSource) - wl_event_source_remove(frameSource); -} - bool CTabletToolV2Resource::good() { return resource->resource(); } @@ -205,20 +201,22 @@ void CTabletToolV2Resource::sendData() { } void CTabletToolV2Resource::queueFrame() { - if (frameSource) + if (frameQueued) return; - frameSource = wl_event_loop_add_idle(g_pCompositor->m_sWLEventLoop, [](void* data) { ((CTabletToolV2Resource*)data)->sendFrame(false); }, this); + frameQueued = true; + g_pEventLoopManager->doLater([this]() { + if (!frameQueued || tool.expired() || inert) + return; + + sendFrame(); + }); } -void CTabletToolV2Resource::sendFrame(bool removeSource) { - if (frameSource) { - if (removeSource) - wl_event_source_remove(frameSource); - frameSource = nullptr; - } +void CTabletToolV2Resource::sendFrame() { + frameQueued = false; - if (!current) + if (!current || !resource) return; timespec now; |
