cleanup: use doLater instead of adding idle event handlers (#8624)

This commit is contained in:
Ikalco
2024-12-01 11:14:35 -06:00
committed by GitHub
parent d26439a0fe
commit 6d7544458d
5 changed files with 32 additions and 39 deletions

View File

@@ -3,6 +3,7 @@
#include <algorithm>
#include "../Compositor.hpp"
#include "../managers/SeatManager.hpp"
#include "../managers/eventLoop/EventLoopManager.hpp"
#include "core/Seat.hpp"
#include "core/Compositor.hpp"
#include <cstring>
@@ -469,8 +470,6 @@ CXDGSurfaceResource::CXDGSurfaceResource(SP<CXdgSurface> resource_, SP<CXDGWMBas
CXDGSurfaceResource::~CXDGSurfaceResource() {
events.destroy.emit();
if (configureSource)
wl_event_source_remove(configureSource);
if (surface)
surface->resetRole();
}
@@ -484,22 +483,23 @@ SP<CXDGSurfaceResource> CXDGSurfaceResource::fromResource(wl_resource* res) {
return data ? data->self.lock() : nullptr;
}
static void onConfigure(void* data) {
((CXDGSurfaceResource*)data)->configure();
}
uint32_t CXDGSurfaceResource::scheduleConfigure() {
if (configureSource)
if (configureScheduled)
return scheduledSerial;
configureSource = wl_event_loop_add_idle(g_pCompositor->m_sWLEventLoop, onConfigure, this);
scheduledSerial = wl_display_next_serial(g_pCompositor->m_sWLDisplay);
configureScheduled = true;
g_pEventLoopManager->doLater([this]() { configure(); });
return scheduledSerial;
}
void CXDGSurfaceResource::configure() {
configureSource = nullptr;
if (!resource)
return;
configureScheduled = false;
resource->sendConfigure(scheduledSerial);
}