input: move idle notify to input handlers (#7659)

* Revert "input: don't emit idle activity when calling simulateMouseMovement (#7649)"

This reverts commit ea10592ad3.

* input: move idle notify calls to input event listeners

* input: don't post idle activity when keyboard is not enabled
This commit is contained in:
Maximilian Seidler 2024-09-05 23:58:57 +00:00 committed by GitHub
parent 0fad7a0bb0
commit 4988e00b1d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 48 additions and 24 deletions

View file

@ -3,6 +3,7 @@
#include "../config/ConfigValue.hpp" #include "../config/ConfigValue.hpp"
#include "../protocols/PointerGestures.hpp" #include "../protocols/PointerGestures.hpp"
#include "../protocols/FractionalScale.hpp" #include "../protocols/FractionalScale.hpp"
#include "../protocols/IdleNotify.hpp"
#include "../protocols/core/Compositor.hpp" #include "../protocols/core/Compositor.hpp"
#include "../protocols/core/Seat.hpp" #include "../protocols/core/Seat.hpp"
#include "eventLoop/EventLoopManager.hpp" #include "eventLoop/EventLoopManager.hpp"
@ -833,24 +834,32 @@ void CPointerManager::attachPointer(SP<IPointer> pointer) {
auto E = std::any_cast<IPointer::SMotionEvent>(e); auto E = std::any_cast<IPointer::SMotionEvent>(e);
g_pInputManager->onMouseMoved(E); g_pInputManager->onMouseMoved(E);
PROTO::idle->onActivity();
}); });
listener->motionAbsolute = pointer->pointerEvents.motionAbsolute.registerListener([this] (std::any e) { listener->motionAbsolute = pointer->pointerEvents.motionAbsolute.registerListener([this] (std::any e) {
auto E = std::any_cast<IPointer::SMotionAbsoluteEvent>(e); auto E = std::any_cast<IPointer::SMotionAbsoluteEvent>(e);
g_pInputManager->onMouseWarp(E); g_pInputManager->onMouseWarp(E);
PROTO::idle->onActivity();
}); });
listener->button = pointer->pointerEvents.button.registerListener([this] (std::any e) { listener->button = pointer->pointerEvents.button.registerListener([this] (std::any e) {
auto E = std::any_cast<IPointer::SButtonEvent>(e); auto E = std::any_cast<IPointer::SButtonEvent>(e);
g_pInputManager->onMouseButton(E); g_pInputManager->onMouseButton(E);
PROTO::idle->onActivity();
}); });
listener->axis = pointer->pointerEvents.axis.registerListener([this] (std::any e) { listener->axis = pointer->pointerEvents.axis.registerListener([this] (std::any e) {
auto E = std::any_cast<IPointer::SAxisEvent>(e); auto E = std::any_cast<IPointer::SAxisEvent>(e);
g_pInputManager->onMouseWheel(E); g_pInputManager->onMouseWheel(E);
PROTO::idle->onActivity();
}); });
listener->frame = pointer->pointerEvents.frame.registerListener([this] (std::any e) { 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); auto E = std::any_cast<IPointer::SSwipeBeginEvent>(e);
g_pInputManager->onSwipeBegin(E); g_pInputManager->onSwipeBegin(E);
PROTO::idle->onActivity();
}); });
listener->swipeEnd = pointer->pointerEvents.swipeEnd.registerListener([this] (std::any e) { listener->swipeEnd = pointer->pointerEvents.swipeEnd.registerListener([this] (std::any e) {
auto E = std::any_cast<IPointer::SSwipeEndEvent>(e); auto E = std::any_cast<IPointer::SSwipeEndEvent>(e);
g_pInputManager->onSwipeEnd(E); g_pInputManager->onSwipeEnd(E);
PROTO::idle->onActivity();
}); });
listener->swipeUpdate = pointer->pointerEvents.swipeUpdate.registerListener([this] (std::any e) { listener->swipeUpdate = pointer->pointerEvents.swipeUpdate.registerListener([this] (std::any e) {
auto E = std::any_cast<IPointer::SSwipeUpdateEvent>(e); auto E = std::any_cast<IPointer::SSwipeUpdateEvent>(e);
g_pInputManager->onSwipeUpdate(E); g_pInputManager->onSwipeUpdate(E);
PROTO::idle->onActivity();
}); });
listener->pinchBegin = pointer->pointerEvents.pinchBegin.registerListener([this] (std::any e) { listener->pinchBegin = pointer->pointerEvents.pinchBegin.registerListener([this] (std::any e) {
auto E = std::any_cast<IPointer::SPinchBeginEvent>(e); auto E = std::any_cast<IPointer::SPinchBeginEvent>(e);
PROTO::pointerGestures->pinchBegin(E.timeMs, E.fingers); PROTO::pointerGestures->pinchBegin(E.timeMs, E.fingers);
PROTO::idle->onActivity();
}); });
listener->pinchEnd = pointer->pointerEvents.pinchEnd.registerListener([this] (std::any e) { listener->pinchEnd = pointer->pointerEvents.pinchEnd.registerListener([this] (std::any e) {
auto E = std::any_cast<IPointer::SPinchEndEvent>(e); auto E = std::any_cast<IPointer::SPinchEndEvent>(e);
PROTO::pointerGestures->pinchEnd(E.timeMs, E.cancelled); PROTO::pointerGestures->pinchEnd(E.timeMs, E.cancelled);
PROTO::idle->onActivity();
}); });
listener->pinchUpdate = pointer->pointerEvents.pinchUpdate.registerListener([this] (std::any e) { listener->pinchUpdate = pointer->pointerEvents.pinchUpdate.registerListener([this] (std::any e) {
auto E = std::any_cast<IPointer::SPinchUpdateEvent>(e); auto E = std::any_cast<IPointer::SPinchUpdateEvent>(e);
PROTO::pointerGestures->pinchUpdate(E.timeMs, E.delta, E.scale, E.rotation); PROTO::pointerGestures->pinchUpdate(E.timeMs, E.delta, E.scale, E.rotation);
PROTO::idle->onActivity();
}); });
listener->holdBegin = pointer->pointerEvents.holdBegin.registerListener([this] (std::any e) { listener->holdBegin = pointer->pointerEvents.holdBegin.registerListener([this] (std::any e) {
auto E = std::any_cast<IPointer::SHoldBeginEvent>(e); auto E = std::any_cast<IPointer::SHoldBeginEvent>(e);
PROTO::pointerGestures->holdBegin(E.timeMs, E.fingers); PROTO::pointerGestures->holdBegin(E.timeMs, E.fingers);
PROTO::idle->onActivity();
}); });
listener->holdEnd = pointer->pointerEvents.holdEnd.registerListener([this] (std::any e) { listener->holdEnd = pointer->pointerEvents.holdEnd.registerListener([this] (std::any e) {
auto E = std::any_cast<IPointer::SHoldEndEvent>(e); auto E = std::any_cast<IPointer::SHoldEndEvent>(e);
PROTO::pointerGestures->holdEnd(E.timeMs, E.cancelled); PROTO::pointerGestures->holdEnd(E.timeMs, E.cancelled);
PROTO::idle->onActivity();
}); });
// clang-format on // clang-format on
@ -926,18 +951,24 @@ void CPointerManager::attachTouch(SP<ITouch> touch) {
auto E = std::any_cast<ITouch::SDownEvent>(e); auto E = std::any_cast<ITouch::SDownEvent>(e);
g_pInputManager->onTouchDown(E); g_pInputManager->onTouchDown(E);
PROTO::idle->onActivity();
}); });
listener->up = touch->touchEvents.up.registerListener([this] (std::any e) { listener->up = touch->touchEvents.up.registerListener([this] (std::any e) {
auto E = std::any_cast<ITouch::SUpEvent>(e); auto E = std::any_cast<ITouch::SUpEvent>(e);
g_pInputManager->onTouchUp(E); g_pInputManager->onTouchUp(E);
PROTO::idle->onActivity();
}); });
listener->motion = touch->touchEvents.motion.registerListener([this] (std::any e) { listener->motion = touch->touchEvents.motion.registerListener([this] (std::any e) {
auto E = std::any_cast<ITouch::SMotionEvent>(e); auto E = std::any_cast<ITouch::SMotionEvent>(e);
g_pInputManager->onTouchMove(E); g_pInputManager->onTouchMove(E);
PROTO::idle->onActivity();
}); });
listener->cancel = touch->touchEvents.cancel.registerListener([this] (std::any e) { 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); auto E = std::any_cast<CTablet::SAxisEvent>(e);
g_pInputManager->onTabletAxis(E); g_pInputManager->onTabletAxis(E);
PROTO::idle->onActivity();
}); });
listener->proximity = tablet->tabletEvents.proximity.registerListener([this] (std::any e) { listener->proximity = tablet->tabletEvents.proximity.registerListener([this] (std::any e) {
auto E = std::any_cast<CTablet::SProximityEvent>(e); auto E = std::any_cast<CTablet::SProximityEvent>(e);
g_pInputManager->onTabletProximity(E); g_pInputManager->onTabletProximity(E);
PROTO::idle->onActivity();
}); });
listener->tip = tablet->tabletEvents.tip.registerListener([this] (std::any e) { listener->tip = tablet->tabletEvents.tip.registerListener([this] (std::any e) {
auto E = std::any_cast<CTablet::STipEvent>(e); auto E = std::any_cast<CTablet::STipEvent>(e);
g_pInputManager->onTabletTip(E); g_pInputManager->onTabletTip(E);
PROTO::idle->onActivity();
}); });
listener->button = tablet->tabletEvents.button.registerListener([this] (std::any e) { listener->button = tablet->tabletEvents.button.registerListener([this] (std::any e) {
auto E = std::any_cast<CTablet::SButtonEvent>(e); auto E = std::any_cast<CTablet::SButtonEvent>(e);
g_pInputManager->onTabletButton(E); g_pInputManager->onTabletButton(E);
PROTO::idle->onActivity();
}); });
// clang-format on // clang-format on

View file

@ -111,7 +111,7 @@ void CInputManager::simulateMouseMovement() {
timespec now; timespec now;
clock_gettime(CLOCK_MONOTONIC, &now); clock_gettime(CLOCK_MONOTONIC, &now);
m_vLastCursorPosFloored = m_vLastCursorPosFloored - Vector2D(1, 1); // hack: force the mouseMoveUnified to report without making this a refocus. 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() { void CInputManager::sendMotionEventsToFocused() {
@ -132,7 +132,7 @@ void CInputManager::sendMotionEventsToFocused() {
g_pSeatManager->setPointerFocus(g_pCompositor->m_pLastFocus.lock(), LOCAL); 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 PFOLLOWMOUSE = CConfigValue<Hyprlang::INT>("input:follow_mouse");
static auto PMOUSEREFOCUS = CConfigValue<Hyprlang::INT>("input:mouse_refocus"); static auto PMOUSEREFOCUS = CConfigValue<Hyprlang::INT>("input:mouse_refocus");
static auto PMOUSEDPMS = CConfigValue<Hyprlang::INT>("misc:mouse_move_enables_dpms"); 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); EMIT_HOOK_EVENT_CANCELLABLE("mouseMove", MOUSECOORDSFLOORED);
if (time && !silent)
PROTO::idle->onActivity();
m_vLastCursorPosFloored = MOUSECOORDSFLOORED; m_vLastCursorPosFloored = MOUSECOORDSFLOORED;
const auto PMONITOR = g_pCompositor->getMonitorFromCursor(); 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) { void CInputManager::onMouseButton(IPointer::SButtonEvent e) {
EMIT_HOOK_EVENT_CANCELLABLE("mouseButton", e); EMIT_HOOK_EVENT_CANCELLABLE("mouseButton", e);
PROTO::idle->onActivity();
m_tmrLastCursorMovement.reset(); m_tmrLastCursorMovement.reset();
if (e.state == WL_POINTER_BUTTON_STATE_PRESSED) { if (e.state == WL_POINTER_BUTTON_STATE_PRESSED) {
@ -767,8 +762,6 @@ void CInputManager::onMouseWheel(IPointer::SAxisEvent e) {
bool passEvent = g_pKeybindManager->onAxisEvent(e); bool passEvent = g_pKeybindManager->onAxisEvent(e);
PROTO::idle->onActivity();
if (!passEvent) if (!passEvent)
return; return;
@ -883,6 +876,9 @@ void CInputManager::setupKeyboard(SP<IKeyboard> keeb) {
auto PKEEB = ((IKeyboard*)owner)->self.lock(); auto PKEEB = ((IKeyboard*)owner)->self.lock();
onKeyboardKey(data, PKEEB); onKeyboardKey(data, PKEEB);
if (PKEEB->enabled)
PROTO::idle->onActivity();
}, },
keeb.get()); keeb.get());
@ -891,6 +887,9 @@ void CInputManager::setupKeyboard(SP<IKeyboard> keeb) {
auto PKEEB = ((IKeyboard*)owner)->self.lock(); auto PKEEB = ((IKeyboard*)owner)->self.lock();
onKeyboardMod(PKEEB); onKeyboardMod(PKEEB);
if (PKEEB->enabled)
PROTO::idle->onActivity();
}, },
keeb.get()); keeb.get());
@ -1292,8 +1291,6 @@ void CInputManager::onKeyboardKey(std::any event, SP<IKeyboard> pKeyboard) {
auto e = std::any_cast<IKeyboard::SKeyEvent>(event); auto e = std::any_cast<IKeyboard::SKeyEvent>(event);
PROTO::idle->onActivity();
if (passEvent) { if (passEvent) {
const auto IME = m_sIMERelay.m_pIME.lock(); const auto IME = m_sIMERelay.m_pIME.lock();

View file

@ -237,7 +237,7 @@ class CInputManager {
uint32_t m_uiCapabilities = 0; 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>); SP<CTabletTool> ensureTabletToolPresent(SP<Aquamarine::ITabletTool>);

View file

@ -1,6 +1,5 @@
#include "InputManager.hpp" #include "InputManager.hpp"
#include "../../Compositor.hpp" #include "../../Compositor.hpp"
#include "../../protocols/IdleNotify.hpp"
#include "../../protocols/Tablet.hpp" #include "../../protocols/Tablet.hpp"
#include "../../devices/Tablet.hpp" #include "../../devices/Tablet.hpp"
#include "../../managers/PointerManager.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)) 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::tablet->tilt(PTOOL, PTOOL->tilt);
PROTO::idle->onActivity();
} }
void CInputManager::onTabletTip(CTablet::STipEvent e) { void CInputManager::onTabletTip(CTablet::STipEvent e) {
@ -171,8 +168,6 @@ void CInputManager::onTabletTip(CTablet::STipEvent e) {
PROTO::tablet->up(PTOOL); PROTO::tablet->up(PTOOL);
PTOOL->isDown = e.in; PTOOL->isDown = e.in;
PROTO::idle->onActivity();
} }
void CInputManager::onTabletButton(CTablet::SButtonEvent e) { void CInputManager::onTabletButton(CTablet::SButtonEvent e) {
@ -184,8 +179,6 @@ void CInputManager::onTabletButton(CTablet::SButtonEvent e) {
PTOOL->buttonsDown.push_back(e.button); PTOOL->buttonsDown.push_back(e.button);
else else
std::erase(PTOOL->buttonsDown, e.button); std::erase(PTOOL->buttonsDown, e.button);
PROTO::idle->onActivity();
} }
void CInputManager::onTabletProximity(CTablet::SProximityEvent e) { void CInputManager::onTabletProximity(CTablet::SProximityEvent e) {
@ -201,8 +194,6 @@ void CInputManager::onTabletProximity(CTablet::SProximityEvent e) {
simulateMouseMovement(); simulateMouseMovement();
refocusTablet(PTAB, PTOOL); refocusTablet(PTAB, PTOOL);
} }
PROTO::idle->onActivity();
} }
void CInputManager::newTablet(SP<Aquamarine::ITablet> pDevice) { void CInputManager::newTablet(SP<Aquamarine::ITablet> pDevice) {

View file

@ -1,7 +1,6 @@
#include "InputManager.hpp" #include "InputManager.hpp"
#include "../../Compositor.hpp" #include "../../Compositor.hpp"
#include "../../config/ConfigValue.hpp" #include "../../config/ConfigValue.hpp"
#include "../../protocols/IdleNotify.hpp"
#include "../../devices/ITouch.hpp" #include "../../devices/ITouch.hpp"
#include "../SeatManager.hpp" #include "../SeatManager.hpp"
@ -78,8 +77,6 @@ void CInputManager::onTouchDown(ITouch::SDownEvent e) {
return; // oops, nothing found. return; // oops, nothing found.
g_pSeatManager->sendTouchDown(m_sTouchData.touchFocusSurface.lock(), e.timeMs, e.touchID, local); g_pSeatManager->sendTouchDown(m_sTouchData.touchFocusSurface.lock(), e.timeMs, e.touchID, local);
PROTO::idle->onActivity();
} }
void CInputManager::onTouchUp(ITouch::SUpEvent e) { void CInputManager::onTouchUp(ITouch::SUpEvent e) {