aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorvaxerski <[email protected]>2024-12-03 21:15:25 +0000
committervaxerski <[email protected]>2024-12-03 21:15:25 +0000
commitf6ac755cf76750b8ee53389c54ef653590462c1c (patch)
treea216ea77acaf1e1165475bac00d70b28c2e55895
parent320144ae7288fe23686935ebb235d9fe0c900862 (diff)
downloadHyprland-f6ac755cf76750b8ee53389c54ef653590462c1c.tar.gz
Hyprland-f6ac755cf76750b8ee53389c54ef653590462c1c.zip
cleanup: Revert use doLater instead of adding idle event handlers (#8624)
This reverts commit 6d7544458d0fafcae410c1978a0cabce2fb4a346.
-rw-r--r--src/protocols/Tablet.cpp26
-rw-r--r--src/protocols/Tablet.hpp7
-rw-r--r--src/protocols/XDGShell.cpp18
-rw-r--r--src/protocols/XDGShell.hpp8
-rw-r--r--src/xwayland/Server.cpp12
5 files changed, 39 insertions, 32 deletions
diff --git a/src/protocols/Tablet.cpp b/src/protocols/Tablet.cpp
index 7768402b..d7f741b9 100644
--- a/src/protocols/Tablet.cpp
+++ b/src/protocols/Tablet.cpp
@@ -2,7 +2,6 @@
#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>
@@ -163,6 +162,11 @@ CTabletToolV2Resource::CTabletToolV2Resource(SP<CZwpTabletToolV2> resource_, SP<
});
}
+CTabletToolV2Resource::~CTabletToolV2Resource() {
+ if (frameSource)
+ wl_event_source_remove(frameSource);
+}
+
bool CTabletToolV2Resource::good() {
return resource->resource();
}
@@ -201,22 +205,20 @@ void CTabletToolV2Resource::sendData() {
}
void CTabletToolV2Resource::queueFrame() {
- if (frameQueued)
+ if (frameSource)
return;
- frameQueued = true;
- g_pEventLoopManager->doLater([this]() {
- if (!frameQueued || tool.expired() || inert)
- return;
-
- sendFrame();
- });
+ frameSource = wl_event_loop_add_idle(g_pCompositor->m_sWLEventLoop, [](void* data) { ((CTabletToolV2Resource*)data)->sendFrame(false); }, this);
}
-void CTabletToolV2Resource::sendFrame() {
- frameQueued = false;
+void CTabletToolV2Resource::sendFrame(bool removeSource) {
+ if (frameSource) {
+ if (removeSource)
+ wl_event_source_remove(frameSource);
+ frameSource = nullptr;
+ }
- if (!current || !resource)
+ if (!current)
return;
timespec now;
diff --git a/src/protocols/Tablet.hpp b/src/protocols/Tablet.hpp
index 8c99bee0..1ebcb1e5 100644
--- a/src/protocols/Tablet.hpp
+++ b/src/protocols/Tablet.hpp
@@ -112,20 +112,21 @@ class CTabletV2Resource {
class CTabletToolV2Resource {
public:
CTabletToolV2Resource(SP<CZwpTabletToolV2> resource_, SP<CTabletTool> tool_, SP<CTabletSeat> seat_);
+ ~CTabletToolV2Resource();
bool good();
void sendData();
void queueFrame();
- void sendFrame();
+ void sendFrame(bool removeSource = true);
bool current = false;
WP<CWLSurfaceResource> lastSurf;
WP<CTabletTool> tool;
WP<CTabletSeat> seat;
+ wl_event_source* frameSource = nullptr;
- bool frameQueued = false;
- bool inert = false; // removed was sent
+ bool inert = false; // removed was sent
private:
SP<CZwpTabletToolV2> resource;
diff --git a/src/protocols/XDGShell.cpp b/src/protocols/XDGShell.cpp
index a542c394..688d0006 100644
--- a/src/protocols/XDGShell.cpp
+++ b/src/protocols/XDGShell.cpp
@@ -3,7 +3,6 @@
#include <algorithm>
#include "../Compositor.hpp"
#include "../managers/SeatManager.hpp"
-#include "../managers/eventLoop/EventLoopManager.hpp"
#include "core/Seat.hpp"
#include "core/Compositor.hpp"
#include <cstring>
@@ -470,6 +469,8 @@ CXDGSurfaceResource::CXDGSurfaceResource(SP<CXdgSurface> resource_, SP<CXDGWMBas
CXDGSurfaceResource::~CXDGSurfaceResource() {
events.destroy.emit();
+ if (configureSource)
+ wl_event_source_remove(configureSource);
if (surface)
surface->resetRole();
}
@@ -483,23 +484,22 @@ 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 (configureScheduled)
+ if (configureSource)
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() {
- if (!resource)
- return;
-
- configureScheduled = false;
+ configureSource = nullptr;
resource->sendConfigure(scheduledSerial);
}
diff --git a/src/protocols/XDGShell.hpp b/src/protocols/XDGShell.hpp
index 3b7d2d11..ef847f3b 100644
--- a/src/protocols/XDGShell.hpp
+++ b/src/protocols/XDGShell.hpp
@@ -199,12 +199,12 @@ class CXDGSurfaceResource {
void configure();
private:
- SP<CXdgSurface> resource;
+ SP<CXdgSurface> resource;
- uint32_t lastConfigureSerial = 0;
- uint32_t scheduledSerial = 0;
+ uint32_t lastConfigureSerial = 0;
+ uint32_t scheduledSerial = 0;
- bool configureScheduled = false;
+ wl_event_source* configureSource = nullptr;
//
std::vector<WP<CXDGPopupResource>> popups;
diff --git a/src/xwayland/Server.cpp b/src/xwayland/Server.cpp
index 390ce1f6..f356af18 100644
--- a/src/xwayland/Server.cpp
+++ b/src/xwayland/Server.cpp
@@ -176,6 +176,11 @@ static bool openSockets(std::array<int, 2>& sockets, int display) {
return true;
}
+static void startServer(void* data) {
+ if (!g_pXWayland->pServer->start())
+ Debug::log(ERR, "The XWayland server could not start! XWayland will not work...");
+}
+
static int xwaylandReady(int fd, uint32_t mask, void* data) {
return g_pXWayland->pServer->ready(fd, mask);
}
@@ -303,10 +308,9 @@ bool CXWaylandServer::create() {
setenv("DISPLAY", displayName.c_str(), true);
- g_pEventLoopManager->doLater([this]() {
- if (!start())
- Debug::log(ERR, "The XWayland server could not start! XWayland will not work...");
- });
+ // TODO: lazy mode
+
+ idleSource = wl_event_loop_add_idle(g_pCompositor->m_sWLEventLoop, ::startServer, nullptr);
return true;
}