summaryrefslogtreecommitdiff
path: root/src/protocols
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2026-02-22 23:30:10 +0000
committerGitHub <noreply@github.com>2026-02-22 23:30:10 +0000
commitb88813c7efa4b7b0c5fe01471c5fa5b67a61dc7e (patch)
tree4454e82bc033d7e28a23ee372d0e3f48341d0aaa /src/protocols
parentb4ee4674f9a74e3d602c7fb17bc09f79d221583c (diff)
event: refactor HookSystem into a typed event bus (#13333)
Refactors the old HookSystem into a typed event bus with clear separation, discovery and types.
Diffstat (limited to 'src/protocols')
-rw-r--r--src/protocols/ExtWorkspace.cpp13
-rw-r--r--src/protocols/Fifo.cpp6
-rw-r--r--src/protocols/ForeignToplevel.cpp14
-rw-r--r--src/protocols/ForeignToplevelWlr.cpp51
-rw-r--r--src/protocols/LinuxDMABUF.cpp24
-rw-r--r--src/protocols/OutputManagement.cpp4
-rw-r--r--src/protocols/PresentationTime.cpp8
-rw-r--r--src/protocols/TearingControl.cpp5
-rw-r--r--src/protocols/ToplevelExport.cpp1
-rw-r--r--src/protocols/XDGOutput.cpp6
-rw-r--r--src/protocols/core/DataDevice.cpp28
-rw-r--r--src/protocols/core/DataDevice.hpp10
12 files changed, 67 insertions, 103 deletions
diff --git a/src/protocols/ExtWorkspace.cpp b/src/protocols/ExtWorkspace.cpp
index 876949ba..4fa3152d 100644
--- a/src/protocols/ExtWorkspace.cpp
+++ b/src/protocols/ExtWorkspace.cpp
@@ -1,9 +1,8 @@
#include "ExtWorkspace.hpp"
#include "../Compositor.hpp"
-#include "../managers/HookSystemManager.hpp"
#include "../managers/eventLoop/EventLoopManager.hpp"
+#include "../event/EventBus.hpp"
#include <algorithm>
-#include <any>
#include <utility>
#include "core/Output.hpp"
@@ -297,17 +296,13 @@ void CExtWorkspaceManagerResource::onWorkspaceCreated(const PHLWORKSPACE& worksp
}
CExtWorkspaceProtocol::CExtWorkspaceProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
- static auto P1 = g_pHookSystem->hookDynamic("createWorkspace", [this](void* self, SCallbackInfo& info, std::any data) {
- auto workspace = std::any_cast<CWorkspace*>(data)->m_self.lock();
-
+ static auto P1 = Event::bus()->m_events.workspace.created.listen([this](PHLWORKSPACEREF workspace) {
for (auto const& m : m_managers) {
- m->onWorkspaceCreated(workspace);
+ m->onWorkspaceCreated(workspace.lock());
}
});
- static auto P2 = g_pHookSystem->hookDynamic("monitorAdded", [this](void* self, SCallbackInfo& info, std::any data) {
- auto monitor = std::any_cast<PHLMONITOR>(data);
-
+ static auto P2 = Event::bus()->m_events.monitor.added.listen([this](PHLMONITOR monitor) {
for (auto const& m : m_managers) {
m->onMonitorCreated(monitor);
}
diff --git a/src/protocols/Fifo.cpp b/src/protocols/Fifo.cpp
index 8f842593..355644d9 100644
--- a/src/protocols/Fifo.cpp
+++ b/src/protocols/Fifo.cpp
@@ -1,8 +1,8 @@
#include "Fifo.hpp"
#include "Compositor.hpp"
#include "core/Compositor.hpp"
-#include "../managers/HookSystemManager.hpp"
#include "../helpers/Monitor.hpp"
+#include "../event/EventBus.hpp"
CFifoResource::CFifoResource(UP<CWpFifoV1>&& resource_, SP<CWLSurfaceResource> surface) : m_resource(std::move(resource_)), m_surface(surface) {
if UNLIKELY (!m_resource->resource())
@@ -153,9 +153,7 @@ bool CFifoManagerResource::good() {
}
CFifoProtocol::CFifoProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
- static auto P = g_pHookSystem->hookDynamic("monitorAdded", [this](void* self, SCallbackInfo& info, std::any param) {
- auto M = std::any_cast<PHLMONITOR>(param);
-
+ static auto P = Event::bus()->m_events.monitor.added.listen([this](PHLMONITOR M) {
M->m_events.presented.listenStatic([this, m = PHLMONITORREF{M}]() {
if (!m || !PROTO::fifo)
return;
diff --git a/src/protocols/ForeignToplevel.cpp b/src/protocols/ForeignToplevel.cpp
index 93506410..baabda7c 100644
--- a/src/protocols/ForeignToplevel.cpp
+++ b/src/protocols/ForeignToplevel.cpp
@@ -1,6 +1,6 @@
#include "ForeignToplevel.hpp"
#include "../Compositor.hpp"
-#include "../managers/HookSystemManager.hpp"
+#include "../event/EventBus.hpp"
CForeignToplevelHandle::CForeignToplevelHandle(SP<CExtForeignToplevelHandleV1> resource_, PHLWINDOW pWindow_) : m_resource(resource_), m_window(pWindow_) {
if UNLIKELY (!resource_->resource())
@@ -123,9 +123,7 @@ bool CForeignToplevelList::good() {
}
CForeignToplevelProtocol::CForeignToplevelProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
- static auto P = g_pHookSystem->hookDynamic("openWindow", [this](void* self, SCallbackInfo& info, std::any data) {
- auto window = std::any_cast<PHLWINDOW>(data);
-
+ static auto P = Event::bus()->m_events.window.open.listen([this](PHLWINDOW window) {
if (!windowValidForForeign(window))
return;
@@ -134,9 +132,7 @@ CForeignToplevelProtocol::CForeignToplevelProtocol(const wl_interface* iface, co
}
});
- static auto P1 = g_pHookSystem->hookDynamic("closeWindow", [this](void* self, SCallbackInfo& info, std::any data) {
- auto window = std::any_cast<PHLWINDOW>(data);
-
+ static auto P1 = Event::bus()->m_events.window.close.listen([this](PHLWINDOW window) {
if (!windowValidForForeign(window))
return;
@@ -145,9 +141,7 @@ CForeignToplevelProtocol::CForeignToplevelProtocol(const wl_interface* iface, co
}
});
- static auto P2 = g_pHookSystem->hookDynamic("windowTitle", [this](void* self, SCallbackInfo& info, std::any data) {
- auto window = std::any_cast<PHLWINDOW>(data);
-
+ static auto P2 = Event::bus()->m_events.window.title.listen([this](PHLWINDOW window) {
if (!windowValidForForeign(window))
return;
diff --git a/src/protocols/ForeignToplevelWlr.cpp b/src/protocols/ForeignToplevelWlr.cpp
index 346c388b..56591261 100644
--- a/src/protocols/ForeignToplevelWlr.cpp
+++ b/src/protocols/ForeignToplevelWlr.cpp
@@ -5,8 +5,8 @@
#include "../managers/input/InputManager.hpp"
#include "../desktop/state/FocusState.hpp"
#include "../render/Renderer.hpp"
-#include "../managers/HookSystemManager.hpp"
#include "../managers/EventManager.hpp"
+#include "../event/EventBus.hpp"
CForeignToplevelHandleWlr::CForeignToplevelHandleWlr(SP<CZwlrForeignToplevelHandleV1> resource_, PHLWINDOW pWindow_) : m_resource(resource_), m_window(pWindow_) {
if UNLIKELY (!resource_->resource())
@@ -343,70 +343,57 @@ bool CForeignToplevelWlrManager::good() {
}
CForeignToplevelWlrProtocol::CForeignToplevelWlrProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
- static auto P = g_pHookSystem->hookDynamic("openWindow", [this](void* self, SCallbackInfo& info, std::any data) {
- const auto PWINDOW = std::any_cast<PHLWINDOW>(data);
-
- if (!windowValidForForeign(PWINDOW))
+ static auto P = Event::bus()->m_events.window.open.listen([this](PHLWINDOW window) {
+ if (!windowValidForForeign(window))
return;
for (auto const& m : m_managers) {
- m->onMap(PWINDOW);
+ m->onMap(window);
}
});
- static auto P1 = g_pHookSystem->hookDynamic("closeWindow", [this](void* self, SCallbackInfo& info, std::any data) {
- const auto PWINDOW = std::any_cast<PHLWINDOW>(data);
-
- if (!windowValidForForeign(PWINDOW))
+ static auto P1 = Event::bus()->m_events.window.close.listen([this](PHLWINDOW window) {
+ if (!windowValidForForeign(window))
return;
for (auto const& m : m_managers) {
- m->onUnmap(PWINDOW);
+ m->onUnmap(window);
}
});
- static auto P2 = g_pHookSystem->hookDynamic("windowTitle", [this](void* self, SCallbackInfo& info, std::any data) {
- const auto PWINDOW = std::any_cast<PHLWINDOW>(data);
-
- if (!windowValidForForeign(PWINDOW))
+ static auto P2 = Event::bus()->m_events.window.title.listen([this](PHLWINDOW window) {
+ if (!windowValidForForeign(window))
return;
for (auto const& m : m_managers) {
- m->onTitle(PWINDOW);
+ m->onTitle(window);
}
});
- static auto P3 = g_pHookSystem->hookDynamic("activeWindow", [this](void* self, SCallbackInfo& info, std::any data) {
- const auto PWINDOW = std::any_cast<Desktop::View::SWindowActiveEvent>(data).window;
-
- if (PWINDOW && !windowValidForForeign(PWINDOW))
+ static auto P3 = Event::bus()->m_events.window.active.listen([this](PHLWINDOW window, Desktop::eFocusReason reason) {
+ if (window && !windowValidForForeign(window))
return;
for (auto const& m : m_managers) {
- m->onNewFocus(PWINDOW);
+ m->onNewFocus(window);
}
});
- static auto P4 = g_pHookSystem->hookDynamic("moveWindow", [this](void* self, SCallbackInfo& info, std::any data) {
- const auto PWINDOW = std::any_cast<PHLWINDOW>(std::any_cast<std::vector<std::any>>(data).at(0));
- const auto PWORKSPACE = std::any_cast<PHLWORKSPACE>(std::any_cast<std::vector<std::any>>(data).at(1));
-
- if (!PWORKSPACE)
+ static auto P4 = Event::bus()->m_events.window.moveToWorkspace.listen([this](PHLWINDOW window, PHLWORKSPACE ws) {
+ if (!ws)
return;
for (auto const& m : m_managers) {
- m->onMoveMonitor(PWINDOW, PWORKSPACE->m_monitor.lock());
+ m->onMoveMonitor(window, ws->m_monitor.lock());
}
});
- static auto P5 = g_pHookSystem->hookDynamic("fullscreen", [this](void* self, SCallbackInfo& info, std::any data) {
- const auto PWINDOW = std::any_cast<PHLWINDOW>(data);
-
- if (!windowValidForForeign(PWINDOW))
+ static auto P5 = Event::bus()->m_events.window.fullscreen.listen([this](PHLWINDOW window) {
+ if (!windowValidForForeign(window))
return;
for (auto const& m : m_managers) {
- m->onFullscreen(PWINDOW);
+ m->onFullscreen(window);
}
});
}
diff --git a/src/protocols/LinuxDMABUF.cpp b/src/protocols/LinuxDMABUF.cpp
index e49e2b6e..f16c8c56 100644
--- a/src/protocols/LinuxDMABUF.cpp
+++ b/src/protocols/LinuxDMABUF.cpp
@@ -10,9 +10,9 @@
#include "core/Compositor.hpp"
#include "types/DMABuffer.hpp"
#include "types/WLBuffer.hpp"
-#include "../managers/HookSystemManager.hpp"
#include "../render/OpenGL.hpp"
#include "../Compositor.hpp"
+#include "../event/EventBus.hpp"
using namespace Hyprutils::OS;
@@ -434,7 +434,7 @@ void CLinuxDMABUFResource::sendMods() {
}
CLinuxDMABufV1Protocol::CLinuxDMABufV1Protocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
- static auto P = g_pHookSystem->hookDynamic("ready", [this](void* self, SCallbackInfo& info, std::any d) {
+ static auto P = Event::bus()->m_events.ready.listen([this] {
int rendererFD = g_pCompositor->m_drmRenderNode.fd >= 0 ? g_pCompositor->m_drmRenderNode.fd : g_pCompositor->m_drm.fd;
auto dev = devIDFromFD(rendererFD);
@@ -467,24 +467,22 @@ CLinuxDMABufV1Protocol::CLinuxDMABufV1Protocol(const wl_interface* iface, const
tches.emplace_back(std::make_pair<>(mon, tranche));
}
- static auto monitorAdded = g_pHookSystem->hookDynamic("monitorAdded", [this](void* self, SCallbackInfo& info, std::any param) {
- auto pMonitor = std::any_cast<PHLMONITOR>(param);
- auto tranche = SDMABUFTranche{
- .device = m_mainDevice,
- .flags = ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT,
- .formats = pMonitor->m_output->getRenderFormats(),
+ static auto monitorAdded = Event::bus()->m_events.monitor.added.listen([this](PHLMONITOR mon) {
+ auto tranche = SDMABUFTranche{
+ .device = m_mainDevice,
+ .flags = ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT,
+ .formats = mon->m_output->getRenderFormats(),
};
- m_formatTable->m_monitorTranches.emplace_back(std::make_pair<>(pMonitor, tranche));
+ m_formatTable->m_monitorTranches.emplace_back(std::make_pair<>(mon, tranche));
resetFormatTable();
});
- static auto monitorRemoved = g_pHookSystem->hookDynamic("monitorRemoved", [this](void* self, SCallbackInfo& info, std::any param) {
- auto pMonitor = std::any_cast<PHLMONITOR>(param);
- std::erase_if(m_formatTable->m_monitorTranches, [pMonitor](std::pair<PHLMONITORREF, SDMABUFTranche> pair) { return pair.first == pMonitor; });
+ static auto monitorRemoved = Event::bus()->m_events.monitor.removed.listen([this](PHLMONITOR mon) {
+ std::erase_if(m_formatTable->m_monitorTranches, [mon](std::pair<PHLMONITORREF, SDMABUFTranche> pair) { return pair.first == mon; });
resetFormatTable();
});
- static auto configReloaded = g_pHookSystem->hookDynamic("configReloaded", [this](void* self, SCallbackInfo& info, std::any param) {
+ static auto configReloaded = Event::bus()->m_events.config.reloaded.listen([this] {
static const auto PSKIP_NON_KMS = CConfigValue<Hyprlang::INT>("quirks:skip_non_kms_dmabuf_formats");
static auto prev = *PSKIP_NON_KMS;
if (prev != *PSKIP_NON_KMS) {
diff --git a/src/protocols/OutputManagement.cpp b/src/protocols/OutputManagement.cpp
index 57d39371..f85578e2 100644
--- a/src/protocols/OutputManagement.cpp
+++ b/src/protocols/OutputManagement.cpp
@@ -2,8 +2,8 @@
#include <algorithm>
#include "../Compositor.hpp"
#include "../managers/input/InputManager.hpp"
-#include "../managers/HookSystemManager.hpp"
#include "../config/ConfigManager.hpp"
+#include "../event/EventBus.hpp"
using namespace Aquamarine;
@@ -578,7 +578,7 @@ bool COutputConfigurationHead::good() {
}
COutputManagementProtocol::COutputManagementProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
- static auto P = g_pHookSystem->hookDynamic("monitorLayoutChanged", [this](void* self, SCallbackInfo& info, std::any param) {
+ static auto P = Event::bus()->m_events.monitor.layoutChanged.listen([this] {
updateAllOutputs();
sendPendingSuccessEvents();
});
diff --git a/src/protocols/PresentationTime.cpp b/src/protocols/PresentationTime.cpp
index 42c0e34c..456ad724 100644
--- a/src/protocols/PresentationTime.cpp
+++ b/src/protocols/PresentationTime.cpp
@@ -1,7 +1,7 @@
#include "PresentationTime.hpp"
#include <algorithm>
#include "../helpers/Monitor.hpp"
-#include "../managers/HookSystemManager.hpp"
+#include "../event/EventBus.hpp"
#include "core/Compositor.hpp"
#include "core/Output.hpp"
#include <aquamarine/output/Output.hpp>
@@ -77,10 +77,8 @@ void CPresentationFeedback::sendQueued(WP<CQueuedPresentationData> data, const t
}
CPresentationProtocol::CPresentationProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
- static auto P = g_pHookSystem->hookDynamic("monitorRemoved", [this](void* self, SCallbackInfo& info, std::any param) {
- const auto PMONITOR = PHLMONITORREF{std::any_cast<PHLMONITOR>(param)};
- std::erase_if(m_queue, [PMONITOR](const auto& other) { return !other->m_surface || other->m_monitor == PMONITOR; });
- });
+ static auto P = Event::bus()->m_events.monitor.removed.listen(
+ [this](PHLMONITOR mon) { std::erase_if(m_queue, [mon](const auto& other) { return !other->m_surface || other->m_monitor == mon; }); });
}
void CPresentationProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
diff --git a/src/protocols/TearingControl.cpp b/src/protocols/TearingControl.cpp
index 685c84a7..3fd346a7 100644
--- a/src/protocols/TearingControl.cpp
+++ b/src/protocols/TearingControl.cpp
@@ -1,13 +1,12 @@
#include "TearingControl.hpp"
#include "../managers/ProtocolManager.hpp"
#include "../desktop/view/Window.hpp"
+#include "../event/EventBus.hpp"
#include "../Compositor.hpp"
#include "core/Compositor.hpp"
-#include "../managers/HookSystemManager.hpp"
CTearingControlProtocol::CTearingControlProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
- static auto P =
- g_pHookSystem->hookDynamic("destroyWindow", [this](void* self, SCallbackInfo& info, std::any param) { this->onWindowDestroy(std::any_cast<PHLWINDOW>(param)); });
+ static auto P = Event::bus()->m_events.window.destroy.listen([this](PHLWINDOW window) { onWindowDestroy(window); });
}
void CTearingControlProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
diff --git a/src/protocols/ToplevelExport.cpp b/src/protocols/ToplevelExport.cpp
index 3b8973ab..bf553a92 100644
--- a/src/protocols/ToplevelExport.cpp
+++ b/src/protocols/ToplevelExport.cpp
@@ -2,7 +2,6 @@
#include "../Compositor.hpp"
#include "ForeignToplevelWlr.hpp"
#include "../managers/screenshare/ScreenshareManager.hpp"
-#include "../managers/HookSystemManager.hpp"
#include "../helpers/Format.hpp"
#include "../render/Renderer.hpp"
diff --git a/src/protocols/XDGOutput.cpp b/src/protocols/XDGOutput.cpp
index 8835d4b5..3553a74b 100644
--- a/src/protocols/XDGOutput.cpp
+++ b/src/protocols/XDGOutput.cpp
@@ -2,7 +2,7 @@
#include "../config/ConfigValue.hpp"
#include "../helpers/Monitor.hpp"
#include "../xwayland/XWayland.hpp"
-#include "../managers/HookSystemManager.hpp"
+#include "../event/EventBus.hpp"
#include "core/Output.hpp"
#define OUTPUT_MANAGER_VERSION 3
@@ -36,8 +36,8 @@ void CXDGOutputProtocol::bindManager(wl_client* client, void* data, uint32_t ver
}
CXDGOutputProtocol::CXDGOutputProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
- static auto P = g_pHookSystem->hookDynamic("monitorLayoutChanged", [this](void* self, SCallbackInfo& info, std::any param) { this->updateAllOutputs(); });
- static auto P2 = g_pHookSystem->hookDynamic("configReloaded", [this](void* self, SCallbackInfo& info, std::any param) { this->updateAllOutputs(); });
+ static auto P = Event::bus()->m_events.monitor.layoutChanged.listen([this] { updateAllOutputs(); });
+ static auto P2 = Event::bus()->m_events.config.reloaded.listen([this] { updateAllOutputs(); });
}
void CXDGOutputProtocol::onManagerGetXDGOutput(CZxdgOutputManagerV1* mgr, uint32_t id, wl_resource* outputResource) {
diff --git a/src/protocols/core/DataDevice.cpp b/src/protocols/core/DataDevice.cpp
index 41f07273..22ccae6c 100644
--- a/src/protocols/core/DataDevice.cpp
+++ b/src/protocols/core/DataDevice.cpp
@@ -10,11 +10,11 @@
#include "../../xwayland/XWayland.hpp"
#include "../../xwayland/Server.hpp"
#include "../../managers/input/InputManager.hpp"
-#include "../../managers/HookSystemManager.hpp"
#include "../../managers/cursor/CursorShapeOverrideController.hpp"
#include "../../helpers/Monitor.hpp"
#include "../../render/Renderer.hpp"
#include "../../xwayland/Dnd.hpp"
+#include "../../event/EventBus.hpp"
using namespace Hyprutils::OS;
CWLDataOfferResource::CWLDataOfferResource(SP<CWlDataOffer> resource_, SP<IDataSource> source_) : m_source(source_), m_resource(resource_) {
@@ -586,29 +586,26 @@ void CWLDataDeviceProtocol::initiateDrag(WP<CWLDataSourceResource> currentSource
});
}
- m_dnd.mouseButton = g_pHookSystem->hookDynamic("mouseButton", [this](void* self, SCallbackInfo& info, std::any e) {
- auto E = std::any_cast<IPointer::SButtonEvent>(e);
- if (E.state == WL_POINTER_BUTTON_STATE_RELEASED) {
+ m_dnd.mouseButton = Event::bus()->m_events.input.mouse.button.listen([this](IPointer::SButtonEvent e, Event::SCallbackInfo&) {
+ if (e.state == WL_POINTER_BUTTON_STATE_RELEASED) {
LOGM(Log::DEBUG, "Dropping drag on mouseUp");
dropDrag();
}
});
- m_dnd.touchUp = g_pHookSystem->hookDynamic("touchUp", [this](void* self, SCallbackInfo& info, std::any e) {
+ m_dnd.touchUp = Event::bus()->m_events.input.touch.up.listen([this](ITouch::SUpEvent e, Event::SCallbackInfo&) {
LOGM(Log::DEBUG, "Dropping drag on touchUp");
dropDrag();
});
- m_dnd.tabletTip = g_pHookSystem->hookDynamic("tabletTip", [this](void* self, SCallbackInfo& info, std::any e) {
- auto E = std::any_cast<CTablet::STipEvent>(e);
- if (!E.in) {
+ m_dnd.tabletTip = Event::bus()->m_events.input.tablet.tip.listen([this](CTablet::STipEvent e, Event::SCallbackInfo&) {
+ if (!e.in) {
LOGM(Log::DEBUG, "Dropping drag on tablet tipUp");
dropDrag();
}
});
- m_dnd.mouseMove = g_pHookSystem->hookDynamic("mouseMove", [this](void* self, SCallbackInfo& info, std::any e) {
- auto V = std::any_cast<const Vector2D>(e);
+ m_dnd.mouseMove = Event::bus()->m_events.input.mouse.move.listen([this](Vector2D pos, Event::SCallbackInfo&) {
if (m_dnd.focusedDevice && g_pSeatManager->m_state.dndPointerFocus) {
auto surf = Desktop::View::CWLSurface::fromResource(g_pSeatManager->m_state.dndPointerFocus.lock());
@@ -620,13 +617,12 @@ void CWLDataDeviceProtocol::initiateDrag(WP<CWLDataSourceResource> currentSource
if (!box.has_value())
return;
- m_dnd.focusedDevice->sendMotion(Time::millis(Time::steadyNow()), V - box->pos());
- LOGM(Log::DEBUG, "Drag motion {}", V - box->pos());
+ m_dnd.focusedDevice->sendMotion(Time::millis(Time::steadyNow()), pos - box->pos());
+ LOGM(Log::DEBUG, "Drag motion {}", pos - box->pos());
}
});
- m_dnd.touchMove = g_pHookSystem->hookDynamic("touchMove", [this](void* self, SCallbackInfo& info, std::any e) {
- auto E = std::any_cast<ITouch::SMotionEvent>(e);
+ m_dnd.touchMove = Event::bus()->m_events.input.touch.motion.listen([this](ITouch::SMotionEvent e, Event::SCallbackInfo&) {
if (m_dnd.focusedDevice && g_pSeatManager->m_state.dndPointerFocus) {
auto surf = Desktop::View::CWLSurface::fromResource(g_pSeatManager->m_state.dndPointerFocus.lock());
@@ -638,8 +634,8 @@ void CWLDataDeviceProtocol::initiateDrag(WP<CWLDataSourceResource> currentSource
if (!box.has_value())
return;
- m_dnd.focusedDevice->sendMotion(E.timeMs, E.pos);
- LOGM(Log::DEBUG, "Drag motion {}", E.pos);
+ m_dnd.focusedDevice->sendMotion(e.timeMs, e.pos);
+ LOGM(Log::DEBUG, "Drag motion {}", e.pos);
}
});
diff --git a/src/protocols/core/DataDevice.hpp b/src/protocols/core/DataDevice.hpp
index b4ad378f..f3717f78 100644
--- a/src/protocols/core/DataDevice.hpp
+++ b/src/protocols/core/DataDevice.hpp
@@ -178,11 +178,11 @@ class CWLDataDeviceProtocol : public IWaylandProtocol {
CHyprSignalListener dndSurfaceCommit;
// for ending a dnd
- SP<HOOK_CALLBACK_FN> mouseMove;
- SP<HOOK_CALLBACK_FN> mouseButton;
- SP<HOOK_CALLBACK_FN> touchUp;
- SP<HOOK_CALLBACK_FN> touchMove;
- SP<HOOK_CALLBACK_FN> tabletTip;
+ CHyprSignalListener mouseMove;
+ CHyprSignalListener mouseButton;
+ CHyprSignalListener touchUp;
+ CHyprSignalListener touchMove;
+ CHyprSignalListener tabletTip;
} m_dnd;
void abortDrag();