Skip to content

Commit

Permalink
input: move dmps activation to input listeners (#7721)
Browse files Browse the repository at this point in the history
  • Loading branch information
PaideiaDilemma authored Sep 9, 2024
1 parent 85da1a1 commit 8237d7e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/managers/KeybindManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ class CKeybindManager {
friend class CInputManager;
friend class CConfigManager;
friend class CWorkspace;
friend class CPointerManager;
};

inline std::unique_ptr<CKeybindManager> g_pKeybindManager;
30 changes: 30 additions & 0 deletions src/managers/PointerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,9 @@ void CPointerManager::attachPointer(SP<IPointer> pointer) {
if (!pointer)
return;

static auto PMOUSEDPMS = CConfigValue<Hyprlang::INT>("misc:mouse_move_enables_dpms");

//
auto listener = pointerListeners.emplace_back(makeShared<SPointerListener>());

listener->pointer = pointer;
Expand All @@ -836,6 +839,9 @@ void CPointerManager::attachPointer(SP<IPointer> pointer) {
g_pInputManager->onMouseMoved(E);

PROTO::idle->onActivity();

if (!g_pCompositor->m_bDPMSStateON && *PMOUSEDPMS)
g_pKeybindManager->dpms("on");
});

listener->motionAbsolute = pointer->pointerEvents.motionAbsolute.registerListener([this] (std::any e) {
Expand All @@ -844,6 +850,9 @@ void CPointerManager::attachPointer(SP<IPointer> pointer) {
g_pInputManager->onMouseWarp(E);

PROTO::idle->onActivity();

if (!g_pCompositor->m_bDPMSStateON && *PMOUSEDPMS)
g_pKeybindManager->dpms("on");
});

listener->button = pointer->pointerEvents.button.registerListener([this] (std::any e) {
Expand Down Expand Up @@ -872,6 +881,9 @@ void CPointerManager::attachPointer(SP<IPointer> pointer) {
g_pInputManager->onSwipeBegin(E);

PROTO::idle->onActivity();

if (!g_pCompositor->m_bDPMSStateON && *PMOUSEDPMS)
g_pKeybindManager->dpms("on");
});

listener->swipeEnd = pointer->pointerEvents.swipeEnd.registerListener([this] (std::any e) {
Expand All @@ -896,6 +908,9 @@ void CPointerManager::attachPointer(SP<IPointer> pointer) {
PROTO::pointerGestures->pinchBegin(E.timeMs, E.fingers);

PROTO::idle->onActivity();

if (!g_pCompositor->m_bDPMSStateON && *PMOUSEDPMS)
g_pKeybindManager->dpms("on");
});

listener->pinchEnd = pointer->pointerEvents.pinchEnd.registerListener([this] (std::any e) {
Expand Down Expand Up @@ -938,6 +953,9 @@ void CPointerManager::attachTouch(SP<ITouch> touch) {
if (!touch)
return;

static auto PMOUSEDPMS = CConfigValue<Hyprlang::INT>("misc:mouse_move_enables_dpms");

//
auto listener = touchListeners.emplace_back(makeShared<STouchListener>());

listener->touch = touch;
Expand All @@ -953,6 +971,9 @@ void CPointerManager::attachTouch(SP<ITouch> touch) {
g_pInputManager->onTouchDown(E);

PROTO::idle->onActivity();

if (!g_pCompositor->m_bDPMSStateON && *PMOUSEDPMS)
g_pKeybindManager->dpms("on");
});

listener->up = touch->touchEvents.up.registerListener([this] (std::any e) {
Expand Down Expand Up @@ -987,6 +1008,9 @@ void CPointerManager::attachTablet(SP<CTablet> tablet) {
if (!tablet)
return;

static auto PMOUSEDPMS = CConfigValue<Hyprlang::INT>("misc:mouse_move_enables_dpms");

//
auto listener = tabletListeners.emplace_back(makeShared<STabletListener>());

listener->tablet = tablet;
Expand All @@ -1002,6 +1026,9 @@ void CPointerManager::attachTablet(SP<CTablet> tablet) {
g_pInputManager->onTabletAxis(E);

PROTO::idle->onActivity();

if (!g_pCompositor->m_bDPMSStateON && *PMOUSEDPMS)
g_pKeybindManager->dpms("on");
});

listener->proximity = tablet->tabletEvents.proximity.registerListener([this] (std::any e) {
Expand All @@ -1018,6 +1045,9 @@ void CPointerManager::attachTablet(SP<CTablet> tablet) {
g_pInputManager->onTabletTip(E);

PROTO::idle->onActivity();

if (!g_pCompositor->m_bDPMSStateON && *PMOUSEDPMS)
g_pKeybindManager->dpms("on");
});

listener->button = tablet->tabletEvents.button.registerListener([this] (std::any e) {
Expand Down
21 changes: 9 additions & 12 deletions src/managers/input/InputManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include "../../managers/PointerManager.hpp"
#include "../../managers/SeatManager.hpp"
#include "../../managers/KeybindManager.hpp"

#include <aquamarine/input/Input.hpp>

Expand Down Expand Up @@ -135,7 +136,6 @@ void CInputManager::sendMotionEventsToFocused() {
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");
static auto PFOLLOWONDND = CConfigValue<Hyprlang::INT>("misc:always_follow_on_dnd");
static auto PFLOATBEHAVIOR = CConfigValue<Hyprlang::INT>("input:float_switch_override_focus");
static auto PMOUSEFOCUSMON = CConfigValue<Hyprlang::INT>("misc:mouse_move_focuses_monitor");
Expand All @@ -157,11 +157,6 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
if (!g_pCompositor->m_bReadyToProcess || g_pCompositor->m_bIsShuttingDown || g_pCompositor->m_bUnsafeState)
return;

if (!g_pCompositor->m_bDPMSStateON && *PMOUSEDPMS) {
// enable dpms
g_pKeybindManager->dpms("on");
}

Vector2D mouseCoords = getMouseCoordsInternal();
const auto MOUSECOORDSFLOORED = mouseCoords.floor();

Expand Down Expand Up @@ -854,6 +849,8 @@ void CInputManager::newVirtualKeyboard(SP<CVirtualKeyboardV1Resource> keyboard)
}

void CInputManager::setupKeyboard(SP<IKeyboard> keeb) {
static auto PDPMS = CConfigValue<Hyprlang::INT>("misc:key_press_enables_dpms");

m_vHIDs.push_back(keeb);

try {
Expand Down Expand Up @@ -882,6 +879,9 @@ void CInputManager::setupKeyboard(SP<IKeyboard> keeb) {

if (PKEEB->enabled)
PROTO::idle->onActivity();

if (PKEEB->enabled && *PDPMS && !g_pCompositor->m_bDPMSStateON)
g_pKeybindManager->dpms("on");
},
keeb.get());

Expand All @@ -893,6 +893,9 @@ void CInputManager::setupKeyboard(SP<IKeyboard> keeb) {

if (PKEEB->enabled)
PROTO::idle->onActivity();

if (PKEEB->enabled && *PDPMS && !g_pCompositor->m_bDPMSStateON)
g_pKeybindManager->dpms("on");
},
keeb.get());

Expand Down Expand Up @@ -1284,12 +1287,6 @@ void CInputManager::onKeyboardKey(std::any event, SP<IKeyboard> pKeyboard) {
const auto EMAP = std::unordered_map<std::string, std::any>{{"keyboard", pKeyboard}, {"event", event}};
EMIT_HOOK_EVENT_CANCELLABLE("keyPress", EMAP);

static auto PDPMS = CConfigValue<Hyprlang::INT>("misc:key_press_enables_dpms");
if (*PDPMS && !g_pCompositor->m_bDPMSStateON) {
// enable dpms
g_pKeybindManager->dpms("on");
}

bool passEvent = DISALLOWACTION || g_pKeybindManager->onKeyEvent(event, pKeyboard);

auto e = std::any_cast<IKeyboard::SKeyEvent>(event);
Expand Down

0 comments on commit 8237d7e

Please sign in to comment.