summaryrefslogtreecommitdiff
path: root/src/managers/input
diff options
context:
space:
mode:
Diffstat (limited to 'src/managers/input')
-rw-r--r--src/managers/input/InputManager.cpp69
-rw-r--r--src/managers/input/InputMethodRelay.cpp5
-rw-r--r--src/managers/input/Tablets.cpp22
-rw-r--r--src/managers/input/Touch.cpp26
4 files changed, 90 insertions, 32 deletions
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index e0b1a452..4a87a878 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -35,7 +35,6 @@
#include "../../managers/SeatManager.hpp"
#include "../../managers/KeybindManager.hpp"
#include "../../render/Renderer.hpp"
-#include "../../managers/HookSystemManager.hpp"
#include "../../managers/EventManager.hpp"
#include "../../managers/permissions/DynamicPermissionManager.hpp"
@@ -44,6 +43,8 @@
#include "../../layout/LayoutManager.hpp"
+#include "../../event/EventBus.hpp"
+
#include "trackpad/TrackpadGestures.hpp"
#include "../cursor/CursorShapeOverrideController.hpp"
@@ -233,7 +234,10 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse, st
PHLLS pFoundLayerSurface;
const auto FOCUS_REASON = refocus ? Desktop::FOCUS_REASON_CLICK : Desktop::FOCUS_REASON_FFM;
- EMIT_HOOK_EVENT_CANCELLABLE("mouseMove", MOUSECOORDSFLOORED);
+ Event::SCallbackInfo info;
+ Event::bus()->m_events.input.mouse.move.emit(MOUSECOORDSFLOORED, info);
+ if (info.cancelled)
+ return;
m_lastCursorPosFloored = MOUSECOORDSFLOORED;
@@ -644,7 +648,10 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse, st
}
void CInputManager::onMouseButton(IPointer::SButtonEvent e) {
- EMIT_HOOK_EVENT_CANCELLABLE("mouseButton", e);
+ Event::SCallbackInfo info;
+ Event::bus()->m_events.input.mouse.button.emit(e, info);
+ if (info.cancelled)
+ return;
if (e.mouse)
recheckMouseWarpOnMouseInput();
@@ -866,8 +873,10 @@ void CInputManager::onMouseWheel(IPointer::SAxisEvent e, SP<IPointer> pointer) {
if (pointer && pointer->m_scrollFactor.has_value())
factor = *pointer->m_scrollFactor;
- const auto EMAP = std::unordered_map<std::string, std::any>{{"event", e}};
- EMIT_HOOK_EVENT_CANCELLABLE("mouseAxis", EMAP);
+ Event::SCallbackInfo info;
+ Event::bus()->m_events.input.mouse.axis.emit(e, info);
+ if (info.cancelled)
+ return;
if (e.mouse)
recheckMouseWarpOnMouseInput();
@@ -1056,7 +1065,7 @@ void CInputManager::setupKeyboard(SP<IKeyboard> keeb) {
}
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", PKEEB->m_hlName + "," + LAYOUT});
- EMIT_HOOK_EVENT("activeLayout", (std::vector<std::any>{PKEEB, LAYOUT}));
+ Event::bus()->m_events.input.keyboard.layout.emit(PKEEB, LAYOUT);
});
disableAllKeyboards(false);
@@ -1153,7 +1162,7 @@ void CInputManager::applyConfigToKeyboard(SP<IKeyboard> pKeyboard) {
const auto LAYOUTSTR = pKeyboard->getActiveLayout();
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", pKeyboard->m_hlName + "," + LAYOUTSTR});
- EMIT_HOOK_EVENT("activeLayout", (std::vector<std::any>{pKeyboard, LAYOUTSTR}));
+ Event::bus()->m_events.input.keyboard.layout.emit(pKeyboard, LAYOUTSTR);
Log::logger->log(Log::DEBUG, "Set the keyboard layout to {} and variant to {} for keyboard \"{}\"", pKeyboard->m_currentRules.layout, pKeyboard->m_currentRules.variant,
pKeyboard->m_hlName);
@@ -1475,14 +1484,16 @@ void CInputManager::onKeyboardKey(const IKeyboard::SKeyEvent& event, SP<IKeyboar
if (!pKeyboard->m_enabled || !pKeyboard->m_allowed)
return;
- const bool DISALLOWACTION = pKeyboard->isVirtual() && shouldIgnoreVirtualKeyboard(pKeyboard);
+ const bool DISALLOWACTION = pKeyboard->isVirtual() && shouldIgnoreVirtualKeyboard(pKeyboard);
- const auto IME = m_relay.m_inputMethod.lock();
- const bool HASIME = IME && IME->hasGrab();
- const bool USEIME = HASIME && !DISALLOWACTION;
+ const auto IME = m_relay.m_inputMethod.lock();
+ const bool HASIME = IME && IME->hasGrab();
+ const bool USEIME = HASIME && !DISALLOWACTION;
- const auto EMAP = std::unordered_map<std::string, std::any>{{"keyboard", pKeyboard}, {"event", event}};
- EMIT_HOOK_EVENT_CANCELLABLE("keyPress", EMAP);
+ Event::SCallbackInfo info;
+ Event::bus()->m_events.input.keyboard.key.emit(event, info);
+ if (info.cancelled)
+ return;
bool passEvent = DISALLOWACTION;
@@ -1571,7 +1582,7 @@ void CInputManager::onKeyboardMod(SP<IKeyboard> pKeyboard) {
Log::logger->log(Log::DEBUG, "LAYOUT CHANGED TO {} GROUP {}", LAYOUT, MODS.group);
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", pKeyboard->m_hlName + "," + LAYOUT});
- EMIT_HOOK_EVENT("activeLayout", (std::vector<std::any>{pKeyboard, LAYOUT}));
+ Event::bus()->m_events.input.keyboard.layout.emit(pKeyboard, LAYOUT);
}
}
@@ -2039,7 +2050,10 @@ void CInputManager::recheckMouseWarpOnMouseInput() {
}
void CInputManager::onSwipeBegin(IPointer::SSwipeBeginEvent e) {
- EMIT_HOOK_EVENT_CANCELLABLE("swipeBegin", e);
+ Event::SCallbackInfo info;
+ Event::bus()->m_events.gesture.swipe.begin.emit(e, info);
+ if (info.cancelled)
+ return;
g_pTrackpadGestures->gestureBegin(e);
@@ -2047,7 +2061,10 @@ void CInputManager::onSwipeBegin(IPointer::SSwipeBeginEvent e) {
}
void CInputManager::onSwipeUpdate(IPointer::SSwipeUpdateEvent e) {
- EMIT_HOOK_EVENT_CANCELLABLE("swipeUpdate", e);
+ Event::SCallbackInfo info;
+ Event::bus()->m_events.gesture.swipe.update.emit(e, info);
+ if (info.cancelled)
+ return;
g_pTrackpadGestures->gestureUpdate(e);
@@ -2055,7 +2072,10 @@ void CInputManager::onSwipeUpdate(IPointer::SSwipeUpdateEvent e) {
}
void CInputManager::onSwipeEnd(IPointer::SSwipeEndEvent e) {
- EMIT_HOOK_EVENT_CANCELLABLE("swipeEnd", e);
+ Event::SCallbackInfo info;
+ Event::bus()->m_events.gesture.swipe.end.emit(e, info);
+ if (info.cancelled)
+ return;
g_pTrackpadGestures->gestureEnd(e);
@@ -2063,7 +2083,10 @@ void CInputManager::onSwipeEnd(IPointer::SSwipeEndEvent e) {
}
void CInputManager::onPinchBegin(IPointer::SPinchBeginEvent e) {
- EMIT_HOOK_EVENT_CANCELLABLE("pinchBegin", e);
+ Event::SCallbackInfo info;
+ Event::bus()->m_events.gesture.pinch.begin.emit(e, info);
+ if (info.cancelled)
+ return;
g_pTrackpadGestures->gestureBegin(e);
@@ -2071,7 +2094,10 @@ void CInputManager::onPinchBegin(IPointer::SPinchBeginEvent e) {
}
void CInputManager::onPinchUpdate(IPointer::SPinchUpdateEvent e) {
- EMIT_HOOK_EVENT_CANCELLABLE("pinchUpdate", e);
+ Event::SCallbackInfo info;
+ Event::bus()->m_events.gesture.pinch.update.emit(e, info);
+ if (info.cancelled)
+ return;
g_pTrackpadGestures->gestureUpdate(e);
@@ -2079,7 +2105,10 @@ void CInputManager::onPinchUpdate(IPointer::SPinchUpdateEvent e) {
}
void CInputManager::onPinchEnd(IPointer::SPinchEndEvent e) {
- EMIT_HOOK_EVENT_CANCELLABLE("pinchEnd", e);
+ Event::SCallbackInfo info;
+ Event::bus()->m_events.gesture.pinch.end.emit(e, info);
+ if (info.cancelled)
+ return;
g_pTrackpadGestures->gestureEnd(e);
diff --git a/src/managers/input/InputMethodRelay.cpp b/src/managers/input/InputMethodRelay.cpp
index 6ee3c836..27fd80b6 100644
--- a/src/managers/input/InputMethodRelay.cpp
+++ b/src/managers/input/InputMethodRelay.cpp
@@ -1,14 +1,13 @@
#include "InputMethodRelay.hpp"
#include "../../desktop/state/FocusState.hpp"
+#include "../../event/EventBus.hpp"
#include "../../protocols/TextInputV3.hpp"
#include "../../protocols/TextInputV1.hpp"
#include "../../protocols/InputMethodV2.hpp"
#include "../../protocols/core/Compositor.hpp"
-#include "../../managers/HookSystemManager.hpp"
CInputMethodRelay::CInputMethodRelay() {
- static auto P =
- g_pHookSystem->hookDynamic("keyboardFocus", [&](void* self, SCallbackInfo& info, std::any param) { onKeyboardFocus(std::any_cast<SP<CWLSurfaceResource>>(param)); });
+ static auto P = Event::bus()->m_events.input.keyboard.focus.listen([&](SP<CWLSurfaceResource> surf) { onKeyboardFocus(surf); });
m_listeners.newTIV3 = PROTO::textInputV3->m_events.newTextInput.listen([this](const auto& input) { onNewTextInput(input); });
m_listeners.newTIV1 = PROTO::textInputV1->m_events.newTextInput.listen([this](const auto& input) { onNewTextInput(input); });
diff --git a/src/managers/input/Tablets.cpp b/src/managers/input/Tablets.cpp
index 52be6eee..a2fec15c 100644
--- a/src/managers/input/Tablets.cpp
+++ b/src/managers/input/Tablets.cpp
@@ -2,11 +2,11 @@
#include "../../desktop/view/Window.hpp"
#include "../../protocols/Tablet.hpp"
#include "../../devices/Tablet.hpp"
-#include "../../managers/HookSystemManager.hpp"
#include "../../managers/PointerManager.hpp"
#include "../../managers/SeatManager.hpp"
#include "../../protocols/PointerConstraints.hpp"
#include "../../protocols/core/DataDevice.hpp"
+#include "../../event/EventBus.hpp"
static void unfocusTool(SP<CTabletTool> tool) {
if (!tool->getSurface())
@@ -107,6 +107,11 @@ static Vector2D transformToActiveRegion(const Vector2D pos, const CBox activeAre
}
void CInputManager::onTabletAxis(CTablet::SAxisEvent e) {
+ Event::SCallbackInfo info;
+ Event::bus()->m_events.input.tablet.axis.emit(e, info);
+ if (info.cancelled)
+ return;
+
const auto PTAB = e.tablet;
const auto PTOOL = ensureTabletToolPresent(e.tool);
@@ -171,7 +176,10 @@ void CInputManager::onTabletAxis(CTablet::SAxisEvent e) {
}
void CInputManager::onTabletTip(CTablet::STipEvent e) {
- EMIT_HOOK_EVENT_CANCELLABLE("tabletTip", e);
+ Event::SCallbackInfo info;
+ Event::bus()->m_events.input.tablet.tip.emit(e, info);
+ if (info.cancelled)
+ return;
const auto PTAB = e.tablet;
const auto PTOOL = ensureTabletToolPresent(e.tool);
@@ -196,6 +204,11 @@ void CInputManager::onTabletTip(CTablet::STipEvent e) {
}
void CInputManager::onTabletButton(CTablet::SButtonEvent e) {
+ Event::SCallbackInfo info;
+ Event::bus()->m_events.input.tablet.button.emit(e, info);
+ if (info.cancelled)
+ return;
+
const auto PTOOL = ensureTabletToolPresent(e.tool);
if (e.down)
@@ -210,6 +223,11 @@ void CInputManager::onTabletButton(CTablet::SButtonEvent e) {
}
void CInputManager::onTabletProximity(CTablet::SProximityEvent e) {
+ Event::SCallbackInfo info;
+ Event::bus()->m_events.input.tablet.proximity.emit(e, info);
+ if (info.cancelled)
+ return;
+
const auto PTAB = e.tablet;
const auto PTOOL = ensureTabletToolPresent(e.tool);
diff --git a/src/managers/input/Touch.cpp b/src/managers/input/Touch.cpp
index 6136cb3f..e45bfd28 100644
--- a/src/managers/input/Touch.cpp
+++ b/src/managers/input/Touch.cpp
@@ -7,8 +7,8 @@
#include "../../config/ConfigValue.hpp"
#include "../../helpers/Monitor.hpp"
#include "../../devices/ITouch.hpp"
+#include "../../event/EventBus.hpp"
#include "../SeatManager.hpp"
-#include "../HookSystemManager.hpp"
#include "debug/log/Logger.hpp"
#include "UnifiedWorkspaceSwipeGesture.hpp"
@@ -19,10 +19,14 @@ void CInputManager::onTouchDown(ITouch::SDownEvent e) {
static auto PGAPSOUTDATA = CConfigValue<Hyprlang::CUSTOMTYPE>("general:gaps_out");
auto* const PGAPSOUT = sc<CCssGapData*>((PGAPSOUTDATA.ptr())->getData());
// TODO: WORKSPACERULE.gapsOut.value_or()
- auto gapsOut = *PGAPSOUT;
- static auto PBORDERSIZE = CConfigValue<Hyprlang::INT>("general:border_size");
- static auto PSWIPEINVR = CConfigValue<Hyprlang::INT>("gestures:workspace_swipe_touch_invert");
- EMIT_HOOK_EVENT_CANCELLABLE("touchDown", e);
+ auto gapsOut = *PGAPSOUT;
+ static auto PBORDERSIZE = CConfigValue<Hyprlang::INT>("general:border_size");
+ static auto PSWIPEINVR = CConfigValue<Hyprlang::INT>("gestures:workspace_swipe_touch_invert");
+
+ Event::SCallbackInfo info;
+ Event::bus()->m_events.input.touch.down.emit(e, info);
+ if (info.cancelled)
+ return;
auto PMONITOR = g_pCompositor->getMonitorFromName(!e.device->m_boundOutput.empty() ? e.device->m_boundOutput : "");
@@ -109,7 +113,11 @@ void CInputManager::onTouchDown(ITouch::SDownEvent e) {
void CInputManager::onTouchUp(ITouch::SUpEvent e) {
m_lastInputTouch = true;
- EMIT_HOOK_EVENT_CANCELLABLE("touchUp", e);
+ Event::SCallbackInfo info;
+ Event::bus()->m_events.input.touch.up.emit(e, info);
+ if (info.cancelled)
+ return;
+
if (g_pUnifiedWorkspaceSwipe->isGestureInProgress()) {
// If there was a swipe from this finger, end it.
if (e.touchID == g_pUnifiedWorkspaceSwipe->m_touchID)
@@ -126,7 +134,11 @@ void CInputManager::onTouchMove(ITouch::SMotionEvent e) {
m_lastCursorMovement.reset();
- EMIT_HOOK_EVENT_CANCELLABLE("touchMove", e);
+ Event::SCallbackInfo info;
+ Event::bus()->m_events.input.touch.motion.emit(e, info);
+ if (info.cancelled)
+ return;
+
if (g_pUnifiedWorkspaceSwipe->isGestureInProgress()) {
// Do nothing if this is using a different finger.
if (e.touchID != g_pUnifiedWorkspaceSwipe->m_touchID)