From f2b03e9679bc1a091fecffd98b50a4179b5c7d43 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Mon, 29 Apr 2024 17:42:07 +0100 Subject: ext-idle-notify: move to new impl --- src/managers/ProtocolManager.cpp | 3 +++ src/managers/input/IdleInhibitor.cpp | 19 ++++++++++--------- src/managers/input/InputManager.cpp | 9 +++++---- src/managers/input/Tablets.cpp | 9 +++++---- src/managers/input/Touch.cpp | 3 ++- 5 files changed, 25 insertions(+), 18 deletions(-) (limited to 'src/managers') diff --git a/src/managers/ProtocolManager.cpp b/src/managers/ProtocolManager.cpp index b00e111e..b721f17a 100644 --- a/src/managers/ProtocolManager.cpp +++ b/src/managers/ProtocolManager.cpp @@ -17,6 +17,7 @@ #include "../protocols/PointerConstraints.hpp" #include "../protocols/OutputPower.hpp" #include "../protocols/XDGActivation.hpp" +#include "../protocols/IdleNotify.hpp" #include "tearing-control-v1.hpp" #include "fractional-scale-v1.hpp" @@ -35,6 +36,7 @@ #include "pointer-constraints-unstable-v1.hpp" #include "wlr-output-power-management-unstable-v1.hpp" #include "xdg-activation-v1.hpp" +#include "ext-idle-notify-v1.hpp" CProtocolManager::CProtocolManager() { @@ -55,6 +57,7 @@ CProtocolManager::CProtocolManager() { PROTO::constraints = std::make_unique(&zwp_pointer_constraints_v1_interface, 1, "PointerConstraints"); PROTO::outputPower = std::make_unique(&zwlr_output_power_manager_v1_interface, 1, "OutputPower"); PROTO::activation = std::make_unique(&xdg_activation_v1_interface, 1, "XDGActivation"); + PROTO::idle = std::make_unique(&ext_idle_notifier_v1_interface, 1, "IdleNotify"); // Old protocol implementations. // TODO: rewrite them to use hyprwayland-scanner. diff --git a/src/managers/input/IdleInhibitor.cpp b/src/managers/input/IdleInhibitor.cpp index 6ec5fc81..40c8c637 100644 --- a/src/managers/input/IdleInhibitor.cpp +++ b/src/managers/input/IdleInhibitor.cpp @@ -1,6 +1,7 @@ #include "InputManager.hpp" #include "../../Compositor.hpp" #include "../../protocols/IdleInhibit.hpp" +#include "../../protocols/IdleNotify.hpp" void CInputManager::newIdleInhibitor(std::any inhibitor) { const auto PINHIBIT = m_vIdleInhibitors.emplace_back(std::make_unique()).get(); @@ -29,11 +30,11 @@ void CInputManager::newIdleInhibitor(std::any inhibitor) { void CInputManager::recheckIdleInhibitorStatus() { for (auto& ii : m_vIdleInhibitors) { - if (ii->pWindow.expired()) { - g_pCompositor->setIdleActivityInhibit(false); - return; - } else if (g_pHyprRenderer->shouldRenderWindow(ii->pWindow.lock())) { - g_pCompositor->setIdleActivityInhibit(false); + if (ii->pWindow.expired()) + continue; + + if (g_pHyprRenderer->shouldRenderWindow(ii->pWindow.lock())) { + PROTO::idle->setInhibit(true); return; } } @@ -44,21 +45,21 @@ void CInputManager::recheckIdleInhibitorStatus() { continue; if (w->m_eIdleInhibitMode == IDLEINHIBIT_ALWAYS) { - g_pCompositor->setIdleActivityInhibit(false); + PROTO::idle->setInhibit(true); return; } if (w->m_eIdleInhibitMode == IDLEINHIBIT_FOCUS && g_pCompositor->isWindowActive(w)) { - g_pCompositor->setIdleActivityInhibit(false); + PROTO::idle->setInhibit(true); return; } if (w->m_eIdleInhibitMode == IDLEINHIBIT_FULLSCREEN && w->m_bIsFullscreen && g_pCompositor->isWorkspaceVisible(w->m_pWorkspace)) { - g_pCompositor->setIdleActivityInhibit(false); + PROTO::idle->setInhibit(true); return; } } - g_pCompositor->setIdleActivityInhibit(true); + PROTO::idle->setInhibit(false); return; } diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index adfa5029..47dc2bf6 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -8,6 +8,7 @@ #include "../../protocols/IdleInhibit.hpp" #include "../../protocols/RelativePointer.hpp" #include "../../protocols/PointerConstraints.hpp" +#include "../../protocols/IdleNotify.hpp" CInputManager::CInputManager() { m_sListeners.setCursorShape = PROTO::cursorShape->events.setShape.registerListener([this](std::any data) { @@ -144,7 +145,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { EMIT_HOOK_EVENT_CANCELLABLE("mouseMove", MOUSECOORDSFLOORED); if (time) - g_pCompositor->notifyIdleActivity(); + PROTO::idle->onActivity(); m_vLastCursorPosFloored = MOUSECOORDSFLOORED; @@ -480,7 +481,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { void CInputManager::onMouseButton(wlr_pointer_button_event* e) { EMIT_HOOK_EVENT_CANCELLABLE("mouseButton", e); - g_pCompositor->notifyIdleActivity(); + PROTO::idle->onActivity(); m_tmrLastCursorMovement.reset(); @@ -705,7 +706,7 @@ void CInputManager::onMouseWheel(wlr_pointer_axis_event* e) { bool passEvent = g_pKeybindManager->onAxisEvent(e); - g_pCompositor->notifyIdleActivity(); + PROTO::idle->onActivity(); if (!passEvent) return; @@ -1216,7 +1217,7 @@ void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboar bool passEvent = g_pKeybindManager->onKeyEvent(e, pKeyboard); - g_pCompositor->notifyIdleActivity(); + PROTO::idle->onActivity(); if (passEvent) { diff --git a/src/managers/input/Tablets.cpp b/src/managers/input/Tablets.cpp index d60a6a6f..979eb1a7 100644 --- a/src/managers/input/Tablets.cpp +++ b/src/managers/input/Tablets.cpp @@ -1,5 +1,6 @@ #include "InputManager.hpp" #include "../../Compositor.hpp" +#include "../../protocols/IdleNotify.hpp" void CInputManager::newTabletTool(wlr_input_device* pDevice) { const auto PNEWTABLET = &m_lTablets.emplace_back(); @@ -99,7 +100,7 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) { if (EVENT->updated_axes & (WLR_TABLET_TOOL_AXIS_TILT_X | WLR_TABLET_TOOL_AXIS_TILT_Y)) wlr_tablet_v2_tablet_tool_notify_tilt(PTOOL->wlrTabletToolV2, PTOOL->tiltX, PTOOL->tiltY); - g_pCompositor->notifyIdleActivity(); + PROTO::idle->onActivity(); }, PNEWTABLET, "Tablet"); @@ -120,7 +121,7 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) { wlr_send_tablet_v2_tablet_tool_up(PTOOL->wlrTabletToolV2); } - g_pCompositor->notifyIdleActivity(); + PROTO::idle->onActivity(); }, PNEWTABLET, "Tablet"); @@ -132,7 +133,7 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) { const auto PTOOL = g_pInputManager->ensureTabletToolPresent(EVENT->tool); wlr_tablet_v2_tablet_tool_notify_button(PTOOL->wlrTabletToolV2, (zwp_tablet_pad_v2_button_state)EVENT->button, (zwp_tablet_pad_v2_button_state)EVENT->state); - g_pCompositor->notifyIdleActivity(); + PROTO::idle->onActivity(); }, PNEWTABLET, "Tablet"); @@ -158,7 +159,7 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) { g_pInputManager->focusTablet(PTAB, EVENT->tool); } - g_pCompositor->notifyIdleActivity(); + PROTO::idle->onActivity(); }, PNEWTABLET, "Tablet"); diff --git a/src/managers/input/Touch.cpp b/src/managers/input/Touch.cpp index 302d9e1d..a3f28ac0 100644 --- a/src/managers/input/Touch.cpp +++ b/src/managers/input/Touch.cpp @@ -1,6 +1,7 @@ #include "InputManager.hpp" #include "../../Compositor.hpp" #include "../../config/ConfigValue.hpp" +#include "../../protocols/IdleNotify.hpp" void CInputManager::onTouchDown(wlr_touch_down_event* e) { static auto PSWIPETOUCH = CConfigValue("gestures:workspace_swipe_touch"); @@ -83,7 +84,7 @@ void CInputManager::onTouchDown(wlr_touch_down_event* e) { wlr_seat_touch_notify_down(g_pCompositor->m_sSeat.seat, m_sTouchData.touchFocusSurface, e->time_msec, e->touch_id, local.x, local.y); - g_pCompositor->notifyIdleActivity(); + PROTO::idle->onActivity(); } void CInputManager::onTouchUp(wlr_touch_up_event* e) { -- cgit v1.2.3