aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMaximilian Seidler <[email protected]>2024-09-05 23:58:57 +0000
committerGitHub <[email protected]>2024-09-06 00:58:57 +0100
commit4988e00b1d72edb8ca8e87eecdbed8c2ecc6a7dc (patch)
treeb7c8fafbb5c3680cf245385a8fe6e280f22eb971
parent0fad7a0bb03d4181901952a0df620d42ab6bbe4d (diff)
downloadHyprland-4988e00b1d72edb8ca8e87eecdbed8c2ecc6a7dc.tar.gz
Hyprland-4988e00b1d72edb8ca8e87eecdbed8c2ecc6a7dc.zip
input: move idle notify to input handlers (#7659)
* Revert "input: don't emit idle activity when calling simulateMouseMovement (#7649)" This reverts commit ea10592ad3c861ff2ce73ad7785bcb5a45a9e400. * input: move idle notify calls to input event listeners * input: don't post idle activity when keyboard is not enabled
-rw-r--r--src/managers/PointerManager.cpp39
-rw-r--r--src/managers/input/InputManager.cpp19
-rw-r--r--src/managers/input/InputManager.hpp2
-rw-r--r--src/managers/input/Tablets.cpp9
-rw-r--r--src/managers/input/Touch.cpp3
5 files changed, 48 insertions, 24 deletions
diff --git a/src/managers/PointerManager.cpp b/src/managers/PointerManager.cpp
index f0f74428..ce9ea4a4 100644
--- a/src/managers/PointerManager.cpp
+++ b/src/managers/PointerManager.cpp
@@ -3,6 +3,7 @@
#include "../config/ConfigValue.hpp"
#include "../protocols/PointerGestures.hpp"
#include "../protocols/FractionalScale.hpp"
+#include "../protocols/IdleNotify.hpp"
#include "../protocols/core/Compositor.hpp"
#include "../protocols/core/Seat.hpp"
#include "eventLoop/EventLoopManager.hpp"
@@ -833,24 +834,32 @@ void CPointerManager::attachPointer(SP<IPointer> pointer) {
auto E = std::any_cast<IPointer::SMotionEvent>(e);
g_pInputManager->onMouseMoved(E);
+
+ PROTO::idle->onActivity();
});
listener->motionAbsolute = pointer->pointerEvents.motionAbsolute.registerListener([this] (std::any e) {
auto E = std::any_cast<IPointer::SMotionAbsoluteEvent>(e);
g_pInputManager->onMouseWarp(E);
+
+ PROTO::idle->onActivity();
});
listener->button = pointer->pointerEvents.button.registerListener([this] (std::any e) {
auto E = std::any_cast<IPointer::SButtonEvent>(e);
g_pInputManager->onMouseButton(E);
+
+ PROTO::idle->onActivity();
});
listener->axis = pointer->pointerEvents.axis.registerListener([this] (std::any e) {
auto E = std::any_cast<IPointer::SAxisEvent>(e);
g_pInputManager->onMouseWheel(E);
+
+ PROTO::idle->onActivity();
});
listener->frame = pointer->pointerEvents.frame.registerListener([this] (std::any e) {
@@ -861,48 +870,64 @@ void CPointerManager::attachPointer(SP<IPointer> pointer) {
auto E = std::any_cast<IPointer::SSwipeBeginEvent>(e);
g_pInputManager->onSwipeBegin(E);
+
+ PROTO::idle->onActivity();
});
listener->swipeEnd = pointer->pointerEvents.swipeEnd.registerListener([this] (std::any e) {
auto E = std::any_cast<IPointer::SSwipeEndEvent>(e);
g_pInputManager->onSwipeEnd(E);
+
+ PROTO::idle->onActivity();
});
listener->swipeUpdate = pointer->pointerEvents.swipeUpdate.registerListener([this] (std::any e) {
auto E = std::any_cast<IPointer::SSwipeUpdateEvent>(e);
g_pInputManager->onSwipeUpdate(E);
+
+ PROTO::idle->onActivity();
});
listener->pinchBegin = pointer->pointerEvents.pinchBegin.registerListener([this] (std::any e) {
auto E = std::any_cast<IPointer::SPinchBeginEvent>(e);
PROTO::pointerGestures->pinchBegin(E.timeMs, E.fingers);
+
+ PROTO::idle->onActivity();
});
listener->pinchEnd = pointer->pointerEvents.pinchEnd.registerListener([this] (std::any e) {
auto E = std::any_cast<IPointer::SPinchEndEvent>(e);
PROTO::pointerGestures->pinchEnd(E.timeMs, E.cancelled);
+
+ PROTO::idle->onActivity();
});
listener->pinchUpdate = pointer->pointerEvents.pinchUpdate.registerListener([this] (std::any e) {
auto E = std::any_cast<IPointer::SPinchUpdateEvent>(e);
PROTO::pointerGestures->pinchUpdate(E.timeMs, E.delta, E.scale, E.rotation);
+
+ PROTO::idle->onActivity();
});
listener->holdBegin = pointer->pointerEvents.holdBegin.registerListener([this] (std::any e) {
auto E = std::any_cast<IPointer::SHoldBeginEvent>(e);
PROTO::pointerGestures->holdBegin(E.timeMs, E.fingers);
+
+ PROTO::idle->onActivity();
});
listener->holdEnd = pointer->pointerEvents.holdEnd.registerListener([this] (std::any e) {
auto E = std::any_cast<IPointer::SHoldEndEvent>(e);
PROTO::pointerGestures->holdEnd(E.timeMs, E.cancelled);
+
+ PROTO::idle->onActivity();
});
// clang-format on
@@ -926,18 +951,24 @@ void CPointerManager::attachTouch(SP<ITouch> touch) {
auto E = std::any_cast<ITouch::SDownEvent>(e);
g_pInputManager->onTouchDown(E);
+
+ PROTO::idle->onActivity();
});
listener->up = touch->touchEvents.up.registerListener([this] (std::any e) {
auto E = std::any_cast<ITouch::SUpEvent>(e);
g_pInputManager->onTouchUp(E);
+
+ PROTO::idle->onActivity();
});
listener->motion = touch->touchEvents.motion.registerListener([this] (std::any e) {
auto E = std::any_cast<ITouch::SMotionEvent>(e);
g_pInputManager->onTouchMove(E);
+
+ PROTO::idle->onActivity();
});
listener->cancel = touch->touchEvents.cancel.registerListener([this] (std::any e) {
@@ -969,24 +1000,32 @@ void CPointerManager::attachTablet(SP<CTablet> tablet) {
auto E = std::any_cast<CTablet::SAxisEvent>(e);
g_pInputManager->onTabletAxis(E);
+
+ PROTO::idle->onActivity();
});
listener->proximity = tablet->tabletEvents.proximity.registerListener([this] (std::any e) {
auto E = std::any_cast<CTablet::SProximityEvent>(e);
g_pInputManager->onTabletProximity(E);
+
+ PROTO::idle->onActivity();
});
listener->tip = tablet->tabletEvents.tip.registerListener([this] (std::any e) {
auto E = std::any_cast<CTablet::STipEvent>(e);
g_pInputManager->onTabletTip(E);
+
+ PROTO::idle->onActivity();
});
listener->button = tablet->tabletEvents.button.registerListener([this] (std::any e) {
auto E = std::any_cast<CTablet::SButtonEvent>(e);
g_pInputManager->onTabletButton(E);
+
+ PROTO::idle->onActivity();
});
// clang-format on
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index cdf7d615..66ca4eb2 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -111,7 +111,7 @@ void CInputManager::simulateMouseMovement() {
timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
m_vLastCursorPosFloored = m_vLastCursorPosFloored - Vector2D(1, 1); // hack: force the mouseMoveUnified to report without making this a refocus.
- mouseMoveUnified(now.tv_sec * 1000 + now.tv_nsec / 10000000, false, true);
+ mouseMoveUnified(now.tv_sec * 1000 + now.tv_nsec / 10000000);
}
void CInputManager::sendMotionEventsToFocused() {
@@ -132,7 +132,7 @@ void CInputManager::sendMotionEventsToFocused() {
g_pSeatManager->setPointerFocus(g_pCompositor->m_pLastFocus.lock(), LOCAL);
}
-void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool silent) {
+void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
static auto PFOLLOWMOUSE = CConfigValue<Hyprlang::INT>("input:follow_mouse");
static auto PMOUSEREFOCUS = CConfigValue<Hyprlang::INT>("input:mouse_refocus");
static auto PMOUSEDPMS = CConfigValue<Hyprlang::INT>("misc:mouse_move_enables_dpms");
@@ -170,9 +170,6 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool silent) {
EMIT_HOOK_EVENT_CANCELLABLE("mouseMove", MOUSECOORDSFLOORED);
- if (time && !silent)
- PROTO::idle->onActivity();
-
m_vLastCursorPosFloored = MOUSECOORDSFLOORED;
const auto PMONITOR = g_pCompositor->getMonitorFromCursor();
@@ -531,8 +528,6 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool silent) {
void CInputManager::onMouseButton(IPointer::SButtonEvent e) {
EMIT_HOOK_EVENT_CANCELLABLE("mouseButton", e);
- PROTO::idle->onActivity();
-
m_tmrLastCursorMovement.reset();
if (e.state == WL_POINTER_BUTTON_STATE_PRESSED) {
@@ -767,8 +762,6 @@ void CInputManager::onMouseWheel(IPointer::SAxisEvent e) {
bool passEvent = g_pKeybindManager->onAxisEvent(e);
- PROTO::idle->onActivity();
-
if (!passEvent)
return;
@@ -883,6 +876,9 @@ void CInputManager::setupKeyboard(SP<IKeyboard> keeb) {
auto PKEEB = ((IKeyboard*)owner)->self.lock();
onKeyboardKey(data, PKEEB);
+
+ if (PKEEB->enabled)
+ PROTO::idle->onActivity();
},
keeb.get());
@@ -891,6 +887,9 @@ void CInputManager::setupKeyboard(SP<IKeyboard> keeb) {
auto PKEEB = ((IKeyboard*)owner)->self.lock();
onKeyboardMod(PKEEB);
+
+ if (PKEEB->enabled)
+ PROTO::idle->onActivity();
},
keeb.get());
@@ -1292,8 +1291,6 @@ void CInputManager::onKeyboardKey(std::any event, SP<IKeyboard> pKeyboard) {
auto e = std::any_cast<IKeyboard::SKeyEvent>(event);
- PROTO::idle->onActivity();
-
if (passEvent) {
const auto IME = m_sIMERelay.m_pIME.lock();
diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp
index 70e4d40f..ebf00b2d 100644
--- a/src/managers/input/InputManager.hpp
+++ b/src/managers/input/InputManager.hpp
@@ -237,7 +237,7 @@ class CInputManager {
uint32_t m_uiCapabilities = 0;
- void mouseMoveUnified(uint32_t, bool refocus = false, bool silent = false);
+ void mouseMoveUnified(uint32_t, bool refocus = false);
SP<CTabletTool> ensureTabletToolPresent(SP<Aquamarine::ITabletTool>);
diff --git a/src/managers/input/Tablets.cpp b/src/managers/input/Tablets.cpp
index f33937e8..9f80726e 100644
--- a/src/managers/input/Tablets.cpp
+++ b/src/managers/input/Tablets.cpp
@@ -1,6 +1,5 @@
#include "InputManager.hpp"
#include "../../Compositor.hpp"
-#include "../../protocols/IdleNotify.hpp"
#include "../../protocols/Tablet.hpp"
#include "../../devices/Tablet.hpp"
#include "../../managers/PointerManager.hpp"
@@ -155,8 +154,6 @@ void CInputManager::onTabletAxis(CTablet::SAxisEvent e) {
if (e.updatedAxes & (CTablet::eTabletToolAxes::HID_TABLET_TOOL_AXIS_TILT_X | CTablet::eTabletToolAxes::HID_TABLET_TOOL_AXIS_TILT_Y))
PROTO::tablet->tilt(PTOOL, PTOOL->tilt);
-
- PROTO::idle->onActivity();
}
void CInputManager::onTabletTip(CTablet::STipEvent e) {
@@ -171,8 +168,6 @@ void CInputManager::onTabletTip(CTablet::STipEvent e) {
PROTO::tablet->up(PTOOL);
PTOOL->isDown = e.in;
-
- PROTO::idle->onActivity();
}
void CInputManager::onTabletButton(CTablet::SButtonEvent e) {
@@ -184,8 +179,6 @@ void CInputManager::onTabletButton(CTablet::SButtonEvent e) {
PTOOL->buttonsDown.push_back(e.button);
else
std::erase(PTOOL->buttonsDown, e.button);
-
- PROTO::idle->onActivity();
}
void CInputManager::onTabletProximity(CTablet::SProximityEvent e) {
@@ -201,8 +194,6 @@ void CInputManager::onTabletProximity(CTablet::SProximityEvent e) {
simulateMouseMovement();
refocusTablet(PTAB, PTOOL);
}
-
- PROTO::idle->onActivity();
}
void CInputManager::newTablet(SP<Aquamarine::ITablet> pDevice) {
diff --git a/src/managers/input/Touch.cpp b/src/managers/input/Touch.cpp
index 40af4b1e..9b03168e 100644
--- a/src/managers/input/Touch.cpp
+++ b/src/managers/input/Touch.cpp
@@ -1,7 +1,6 @@
#include "InputManager.hpp"
#include "../../Compositor.hpp"
#include "../../config/ConfigValue.hpp"
-#include "../../protocols/IdleNotify.hpp"
#include "../../devices/ITouch.hpp"
#include "../SeatManager.hpp"
@@ -78,8 +77,6 @@ void CInputManager::onTouchDown(ITouch::SDownEvent e) {
return; // oops, nothing found.
g_pSeatManager->sendTouchDown(m_sTouchData.touchFocusSurface.lock(), e.timeMs, e.touchID, local);
-
- PROTO::idle->onActivity();
}
void CInputManager::onTouchUp(ITouch::SUpEvent e) {