From 5b3e489108d8512fb5dfacf07b2aa3a71208e0f0 Mon Sep 17 00:00:00 2001 From: davc0n Date: Thu, 1 May 2025 23:57:11 +0200 Subject: [PATCH] inputs: refactor class member vars (#10230) --- src/Compositor.cpp | 2 +- src/debug/HyprCtl.cpp | 36 +- src/desktop/LayerSurface.cpp | 12 +- src/desktop/Window.cpp | 4 +- src/events/Windows.cpp | 4 +- src/helpers/AsyncDialogBox.cpp | 2 +- src/layout/IHyprLayout.cpp | 42 +-- src/layout/MasterLayout.cpp | 10 +- src/managers/KeybindManager.cpp | 36 +- src/managers/eventLoop/EventLoopManager.cpp | 66 ++-- src/managers/eventLoop/EventLoopManager.hpp | 12 +- src/managers/input/IdleInhibitor.cpp | 10 +- src/managers/input/InputManager.cpp | 350 +++++++++--------- src/managers/input/InputManager.hpp | 85 +++-- src/managers/input/InputMethodPopup.cpp | 48 +-- src/managers/input/InputMethodPopup.hpp | 10 +- src/managers/input/InputMethodRelay.cpp | 62 ++-- src/managers/input/InputMethodRelay.hpp | 10 +- src/managers/input/Swipe.cpp | 172 ++++----- src/managers/input/Tablets.cpp | 16 +- src/managers/input/TextInput.cpp | 194 +++++----- src/managers/input/TextInput.hpp | 10 +- src/managers/input/Touch.cpp | 92 ++--- src/protocols/PointerConstraints.cpp | 8 +- src/render/Renderer.cpp | 8 +- .../decorations/CHyprGroupBarDecoration.cpp | 6 +- src/render/pass/SurfacePassElement.cpp | 4 +- 27 files changed, 655 insertions(+), 656 deletions(-) diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 154ec135..eca31e96 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -1088,7 +1088,7 @@ void CCompositor::focusWindow(PHLWINDOW pWindow, SP pSurface return; } - if (!g_pInputManager->m_dExclusiveLSes.empty()) { + if (!g_pInputManager->m_exclusiveLSes.empty()) { Debug::log(LOG, "Refusing a keyboard focus to a window because of an exclusive ls"); return; } diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index 2ad182ab..d1b879d0 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -616,7 +616,7 @@ static std::string devicesRequest(eHyprCtlOutputFormat format, std::string reque result += "{\n"; result += "\"mice\": [\n"; - for (auto const& m : g_pInputManager->m_vPointers) { + for (auto const& m : g_pInputManager->m_pointers) { result += std::format( R"#( {{ "address": "0x{:x}", @@ -631,7 +631,7 @@ static std::string devicesRequest(eHyprCtlOutputFormat format, std::string reque result += "\n],\n"; result += "\"keyboards\": [\n"; - for (auto const& k : g_pInputManager->m_vKeyboards) { + for (auto const& k : g_pInputManager->m_keyboards) { const auto KM = k->getActiveLayout(); result += std::format( R"#( {{ @@ -657,7 +657,7 @@ static std::string devicesRequest(eHyprCtlOutputFormat format, std::string reque result += "\"tablets\": [\n"; - for (auto const& d : g_pInputManager->m_vTabletPads) { + for (auto const& d : g_pInputManager->m_tabletPads) { result += std::format( R"#( {{ "address": "0x{:x}", @@ -670,7 +670,7 @@ static std::string devicesRequest(eHyprCtlOutputFormat format, std::string reque (uintptr_t)d.get(), (uintptr_t)d->m_parent.get(), escapeJSONStrings(d->m_parent ? d->m_parent->m_hlName : "")); } - for (auto const& d : g_pInputManager->m_vTablets) { + for (auto const& d : g_pInputManager->m_tablets) { result += std::format( R"#( {{ "address": "0x{:x}", @@ -679,7 +679,7 @@ static std::string devicesRequest(eHyprCtlOutputFormat format, std::string reque (uintptr_t)d.get(), escapeJSONStrings(d->m_hlName)); } - for (auto const& d : g_pInputManager->m_vTabletTools) { + for (auto const& d : g_pInputManager->m_tabletTools) { result += std::format( R"#( {{ "address": "0x{:x}", @@ -693,7 +693,7 @@ static std::string devicesRequest(eHyprCtlOutputFormat format, std::string reque result += "\"touch\": [\n"; - for (auto const& d : g_pInputManager->m_vTouches) { + for (auto const& d : g_pInputManager->m_touches) { result += std::format( R"#( {{ "address": "0x{:x}", @@ -707,7 +707,7 @@ static std::string devicesRequest(eHyprCtlOutputFormat format, std::string reque result += "\"switches\": [\n"; - for (auto const& d : g_pInputManager->m_lSwitches) { + for (auto const& d : g_pInputManager->m_switches) { result += std::format( R"#( {{ "address": "0x{:x}", @@ -724,14 +724,14 @@ static std::string devicesRequest(eHyprCtlOutputFormat format, std::string reque } else { result += "mice:\n"; - for (auto const& m : g_pInputManager->m_vPointers) { + for (auto const& m : g_pInputManager->m_pointers) { result += std::format("\tMouse at {:x}:\n\t\t{}\n\t\t\tdefault speed: {:.5f}\n", (uintptr_t)m.get(), m->m_hlName, (m->aq() && m->aq()->getLibinputHandle() ? libinput_device_config_accel_get_default_speed(m->aq()->getLibinputHandle()) : 0.f)); } result += "\n\nKeyboards:\n"; - for (auto const& k : g_pInputManager->m_vKeyboards) { + for (auto const& k : g_pInputManager->m_keyboards) { const auto KM = k->getActiveLayout(); result += std::format("\tKeyboard at {:x}:\n\t\t{}\n\t\t\trules: r \"{}\", m \"{}\", l \"{}\", v \"{}\", o \"{}\"\n\t\t\tactive keymap: {}\n\t\t\tcapsLock: " "{}\n\t\t\tnumLock: {}\n\t\t\tmain: {}\n", @@ -742,27 +742,27 @@ static std::string devicesRequest(eHyprCtlOutputFormat format, std::string reque result += "\n\nTablets:\n"; - for (auto const& d : g_pInputManager->m_vTabletPads) { + for (auto const& d : g_pInputManager->m_tabletPads) { result += std::format("\tTablet Pad at {:x} (belongs to {:x} -> {})\n", (uintptr_t)d.get(), (uintptr_t)d->m_parent.get(), d->m_parent ? d->m_parent->m_hlName : ""); } - for (auto const& d : g_pInputManager->m_vTablets) { + for (auto const& d : g_pInputManager->m_tablets) { result += std::format("\tTablet at {:x}:\n\t\t{}\n\t\t\tsize: {}x{}mm\n", (uintptr_t)d.get(), d->m_hlName, d->aq()->physicalSize.x, d->aq()->physicalSize.y); } - for (auto const& d : g_pInputManager->m_vTabletTools) { + for (auto const& d : g_pInputManager->m_tabletTools) { result += std::format("\tTablet Tool at {:x}\n", (uintptr_t)d.get()); } result += "\n\nTouch:\n"; - for (auto const& d : g_pInputManager->m_vTouches) { + for (auto const& d : g_pInputManager->m_touches) { result += std::format("\tTouch Device at {:x}:\n\t\t{}\n", (uintptr_t)d.get(), d->m_hlName); } result += "\n\nSwitches:\n"; - for (auto const& d : g_pInputManager->m_lSwitches) { + for (auto const& d : g_pInputManager->m_switches) { result += std::format("\tSwitch Device at {:x}:\n\t\t{}\n", (uintptr_t)&d, d.pDevice ? d.pDevice->getName() : ""); } } @@ -1286,7 +1286,7 @@ static std::string switchXKBLayoutRequest(eHyprCtlOutputFormat format, std::stri }; if (KB == "main" || KB == "active" || KB == "current") { - for (auto const& k : g_pInputManager->m_vKeyboards) { + for (auto const& k : g_pInputManager->m_keyboards) { if (!k->m_active) continue; @@ -1295,17 +1295,17 @@ static std::string switchXKBLayoutRequest(eHyprCtlOutputFormat format, std::stri } } else if (KB == "all") { std::string result = ""; - for (auto const& k : g_pInputManager->m_vKeyboards) { + for (auto const& k : g_pInputManager->m_keyboards) { auto res = updateKeyboard(k, CMD); if (res.has_value()) result += *res + "\n"; } return result.empty() ? "ok" : result; } else { - auto k = std::find_if(g_pInputManager->m_vKeyboards.begin(), g_pInputManager->m_vKeyboards.end(), + auto k = std::find_if(g_pInputManager->m_keyboards.begin(), g_pInputManager->m_keyboards.end(), [&](const auto& other) { return other->m_hlName == g_pInputManager->deviceNameToInternalString(KB); }); - if (k == g_pInputManager->m_vKeyboards.end()) + if (k == g_pInputManager->m_keyboards.end()) return "device not found"; pKeyboard = *k; diff --git a/src/desktop/LayerSurface.cpp b/src/desktop/LayerSurface.cpp index 5954a571..21730dff 100644 --- a/src/desktop/LayerSurface.cpp +++ b/src/desktop/LayerSurface.cpp @@ -158,7 +158,7 @@ void CLayerSurface::onMap() { const bool ISEXCLUSIVE = m_layerSurface->current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE; if (ISEXCLUSIVE) - g_pInputManager->m_dExclusiveLSes.push_back(m_self); + g_pInputManager->m_exclusiveLSes.push_back(m_self); const bool GRABSFOCUS = ISEXCLUSIVE || (m_layerSurface->current.interactivity != ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE && @@ -173,7 +173,7 @@ void CLayerSurface::onMap() { const auto LOCAL = g_pInputManager->getMouseCoordsInternal() - Vector2D(m_geometry.x + PMONITOR->m_position.x, m_geometry.y + PMONITOR->m_position.y); g_pSeatManager->setPointerFocus(m_surface->resource(), LOCAL); - g_pInputManager->m_bEmptyFocusCursorSet = false; + g_pInputManager->m_emptyFocusCursorSet = false; } m_position = Vector2D(m_geometry.x, m_geometry.y); @@ -199,7 +199,7 @@ void CLayerSurface::onUnmap() { g_pEventManager->postEvent(SHyprIPCEvent{"closelayer", m_layerSurface->layerNamespace}); EMIT_HOOK_EVENT("closeLayer", m_self.lock()); - std::erase_if(g_pInputManager->m_dExclusiveLSes, [this](const auto& other) { return !other || other == m_self; }); + std::erase_if(g_pInputManager->m_exclusiveLSes, [this](const auto& other) { return !other || other == m_self; }); if (!m_monitor || g_pCompositor->m_unsafeState) { Debug::log(WARN, "Layersurface unmapping on invalid monitor (removed?) ignoring."); @@ -346,9 +346,9 @@ void CLayerSurface::onCommit() { const bool ISEXCLUSIVE = m_layerSurface->current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE; if (!WASEXCLUSIVE && ISEXCLUSIVE) - g_pInputManager->m_dExclusiveLSes.push_back(m_self); + g_pInputManager->m_exclusiveLSes.push_back(m_self); else if (WASEXCLUSIVE && !ISEXCLUSIVE) - std::erase_if(g_pInputManager->m_dExclusiveLSes, [this](const auto& other) { return !other.lock() || other.lock() == m_self.lock(); }); + std::erase_if(g_pInputManager->m_exclusiveLSes, [this](const auto& other) { return !other.lock() || other.lock() == m_self.lock(); }); // if the surface was focused and interactive but now isn't, refocus if (WASLASTFOCUS && m_layerSurface->current.interactivity == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_NONE) { @@ -366,7 +366,7 @@ void CLayerSurface::onCommit() { const auto LOCAL = g_pInputManager->getMouseCoordsInternal() - Vector2D(m_geometry.x + PMONITOR->m_position.x, m_geometry.y + PMONITOR->m_position.y); g_pSeatManager->setPointerFocus(m_surface->resource(), LOCAL); - g_pInputManager->m_bEmptyFocusCursorSet = false; + g_pInputManager->m_emptyFocusCursorSet = false; } } diff --git a/src/desktop/Window.cpp b/src/desktop/Window.cpp index 53ecf049..c355979b 100644 --- a/src/desktop/Window.cpp +++ b/src/desktop/Window.cpp @@ -999,7 +999,7 @@ int CWindow::getGroupSize() { bool CWindow::canBeGroupedInto(PHLWINDOW pWindow) { static auto ALLOWGROUPMERGE = CConfigValue("group:merge_groups_on_drag"); bool isGroup = m_groupData.pNextWindow; - bool disallowDragIntoGroup = g_pInputManager->m_bWasDraggingWindow && isGroup && !bool(*ALLOWGROUPMERGE); + bool disallowDragIntoGroup = g_pInputManager->m_wasDraggingWindow && isGroup && !bool(*ALLOWGROUPMERGE); return !g_pKeybindManager->m_bGroupsLocked // global group lock disengaged && ((m_groupRules & GROUP_INVADE && m_firstMap) // window ignore local group locks, or || (!pWindow->getGroupHead()->m_groupData.locked // target unlocked @@ -1549,7 +1549,7 @@ void CWindow::onX11ConfigureRequest(CBox box) { g_pHyprRenderer->damageWindow(m_self.lock()); - if (!m_isFloating || isFullscreen() || g_pInputManager->currentlyDraggedWindow == m_self) { + if (!m_isFloating || isFullscreen() || g_pInputManager->m_currentlyDraggedWindow == m_self) { sendWindowSize(true); g_pInputManager->refocus(); g_pHyprRenderer->damageWindow(m_self.lock()); diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 838839d3..450f213e 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -109,7 +109,7 @@ void Events::listener_mapWindow(void* owner, void* data) { } } - if (g_pInputManager->m_bLastFocusOnLS) // waybar fix + if (g_pInputManager->m_lastFocusOnLS) // waybar fix g_pInputManager->releaseAllMouseButtons(); // checks if the window wants borders and sets the appropriate flag @@ -770,7 +770,7 @@ void Events::listener_unmapWindow(void* owner, void* data) { g_pInputManager->releaseAllMouseButtons(); } - if (PWINDOW == g_pInputManager->currentlyDraggedWindow.lock()) + if (PWINDOW == g_pInputManager->m_currentlyDraggedWindow.lock()) g_pKeybindManager->changeMouseBindMode(MBIND_INVALID); // remove the fullscreen window status from workspace if we closed it diff --git a/src/helpers/AsyncDialogBox.cpp b/src/helpers/AsyncDialogBox.cpp index da625fea..42dac469 100644 --- a/src/helpers/AsyncDialogBox.cpp +++ b/src/helpers/AsyncDialogBox.cpp @@ -96,7 +96,7 @@ SP> CAsyncDialogBox::open() { proc.setStdoutFD(outPipe[1]); - m_readEventSource = wl_event_loop_add_fd(g_pEventLoopManager->m_sWayland.loop, m_pipeReadFd.get(), WL_EVENT_READABLE, ::onFdWrite, this); + m_readEventSource = wl_event_loop_add_fd(g_pEventLoopManager->m_wayland.loop, m_pipeReadFd.get(), WL_EVENT_READABLE, ::onFdWrite, this); if (!m_readEventSource) { Debug::log(ERR, "CAsyncDialogBox::open: failed to add read fd to loop"); diff --git a/src/layout/IHyprLayout.cpp b/src/layout/IHyprLayout.cpp index 51ea5883..3b0821d7 100644 --- a/src/layout/IHyprLayout.cpp +++ b/src/layout/IHyprLayout.cpp @@ -229,7 +229,7 @@ bool IHyprLayout::onWindowCreatedAutoGroup(PHLWINDOW pWindow) { } void IHyprLayout::onBeginDragWindow() { - const auto DRAGGINGWINDOW = g_pInputManager->currentlyDraggedWindow.lock(); + const auto DRAGGINGWINDOW = g_pInputManager->m_currentlyDraggedWindow.lock(); static auto PDRAGTHRESHOLD = CConfigValue("binds:drag_threshold"); m_mouseMoveEventCount = 1; @@ -244,7 +244,7 @@ void IHyprLayout::onBeginDragWindow() { // Try to pick up dragged window now if drag_threshold is disabled // or at least update dragging related variables for the cursors - g_pInputManager->m_bDragThresholdReached = *PDRAGTHRESHOLD <= 0; + g_pInputManager->m_dragThresholdReached = *PDRAGTHRESHOLD <= 0; if (updateDragWindow()) return; @@ -287,7 +287,7 @@ void IHyprLayout::onBeginDragWindow() { } } - if (g_pInputManager->dragMode != MBIND_RESIZE && g_pInputManager->dragMode != MBIND_RESIZE_FORCE_RATIO && g_pInputManager->dragMode != MBIND_RESIZE_BLOCK_RATIO) + if (g_pInputManager->m_dragMode != MBIND_RESIZE && g_pInputManager->m_dragMode != MBIND_RESIZE_FORCE_RATIO && g_pInputManager->m_dragMode != MBIND_RESIZE_BLOCK_RATIO) g_pInputManager->setCursorImageUntilUnset("grabbing"); g_pHyprRenderer->damageWindow(DRAGGINGWINDOW); @@ -299,23 +299,23 @@ void IHyprLayout::onBeginDragWindow() { } void IHyprLayout::onEndDragWindow() { - const auto DRAGGINGWINDOW = g_pInputManager->currentlyDraggedWindow.lock(); + const auto DRAGGINGWINDOW = g_pInputManager->m_currentlyDraggedWindow.lock(); m_mouseMoveEventCount = 1; if (!validMapped(DRAGGINGWINDOW)) { if (DRAGGINGWINDOW) { g_pInputManager->unsetCursorImage(); - g_pInputManager->currentlyDraggedWindow.reset(); + g_pInputManager->m_currentlyDraggedWindow.reset(); } return; } g_pInputManager->unsetCursorImage(); - g_pInputManager->currentlyDraggedWindow.reset(); - g_pInputManager->m_bWasDraggingWindow = true; + g_pInputManager->m_currentlyDraggedWindow.reset(); + g_pInputManager->m_wasDraggingWindow = true; - if (g_pInputManager->dragMode == MBIND_MOVE) { + if (g_pInputManager->m_dragMode == MBIND_MOVE) { g_pHyprRenderer->damageWindow(DRAGGINGWINDOW); const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal(); PHLWINDOW pWindow = g_pCompositor->vectorToWindowUnified(MOUSECOORDS, RESERVED_EXTENTS | INPUT_EXTENTS | ALLOW_FLOATING, DRAGGINGWINDOW); @@ -365,7 +365,7 @@ void IHyprLayout::onEndDragWindow() { g_pHyprRenderer->damageWindow(DRAGGINGWINDOW); g_pCompositor->focusWindow(DRAGGINGWINDOW); - g_pInputManager->m_bWasDraggingWindow = false; + g_pInputManager->m_wasDraggingWindow = false; } static inline bool canSnap(const double SIDEA, const double SIDEB, const double GAP) { @@ -518,10 +518,10 @@ static void performSnap(Vector2D& sourcePos, Vector2D& sourceSize, PHLWINDOW DRA } void IHyprLayout::onMouseMove(const Vector2D& mousePos) { - if (g_pInputManager->currentlyDraggedWindow.expired()) + if (g_pInputManager->m_currentlyDraggedWindow.expired()) return; - const auto DRAGGINGWINDOW = g_pInputManager->currentlyDraggedWindow.lock(); + const auto DRAGGINGWINDOW = g_pInputManager->m_currentlyDraggedWindow.lock(); static auto PDRAGTHRESHOLD = CConfigValue("binds:drag_threshold"); // Window invalid or drag begin size 0,0 meaning we rejected it. @@ -531,10 +531,10 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) { } // Yoink dragged window here instead if using drag_threshold and it has been reached - if (*PDRAGTHRESHOLD > 0 && !g_pInputManager->m_bDragThresholdReached) { + if (*PDRAGTHRESHOLD > 0 && !g_pInputManager->m_dragThresholdReached) { if ((m_beginDragXY.distanceSq(mousePos) <= std::pow(*PDRAGTHRESHOLD, 2) && m_beginDragXY == m_lastDragXY)) return; - g_pInputManager->m_bDragThresholdReached = true; + g_pInputManager->m_dragThresholdReached = true; if (updateDragWindow()) return; } @@ -570,7 +570,7 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) { canSkipUpdate = std::clamp(MSMONITOR - TIMERDELTA, 0.0, MSMONITOR) > totalMs * 1.0 / m_mouseMoveEventCount; } - if ((abs(TICKDELTA.x) < 1.f && abs(TICKDELTA.y) < 1.f) || (TIMERDELTA < MSMONITOR && canSkipUpdate && (g_pInputManager->dragMode != MBIND_MOVE || *PANIMATEMOUSE))) + if ((abs(TICKDELTA.x) < 1.f && abs(TICKDELTA.y) < 1.f) || (TIMERDELTA < MSMONITOR && canSkipUpdate && (g_pInputManager->m_dragMode != MBIND_MOVE || *PANIMATEMOUSE))) return; TIMER = std::chrono::high_resolution_clock::now(); @@ -579,7 +579,7 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) { g_pHyprRenderer->damageWindow(DRAGGINGWINDOW); - if (g_pInputManager->dragMode == MBIND_MOVE) { + if (g_pInputManager->m_dragMode == MBIND_MOVE) { Vector2D newPos = m_beginDragPositionXY + DELTA; Vector2D newSize = DRAGGINGWINDOW->m_realSize->goal(); @@ -599,7 +599,7 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) { DRAGGINGWINDOW->m_position = wb.pos(); - } else if (g_pInputManager->dragMode == MBIND_RESIZE || g_pInputManager->dragMode == MBIND_RESIZE_FORCE_RATIO || g_pInputManager->dragMode == MBIND_RESIZE_BLOCK_RATIO) { + } else if (g_pInputManager->m_dragMode == MBIND_RESIZE || g_pInputManager->m_dragMode == MBIND_RESIZE_FORCE_RATIO || g_pInputManager->m_dragMode == MBIND_RESIZE_BLOCK_RATIO) { if (DRAGGINGWINDOW->m_isFloating) { Vector2D MINSIZE = DRAGGINGWINDOW->requestedMinSize().clamp(DRAGGINGWINDOW->m_windowData.minSize.valueOr(Vector2D(MIN_WINDOW_SIZE, MIN_WINDOW_SIZE))); @@ -621,7 +621,7 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) { else if (m_grabbedCorner == CORNER_BOTTOMLEFT) newSize = newSize + Vector2D(-DELTA.x, DELTA.y); - eMouseBindMode mode = g_pInputManager->dragMode; + eMouseBindMode mode = g_pInputManager->m_dragMode; if (DRAGGINGWINDOW->m_windowData.keepAspectRatio.valueOrDefault() && mode != MBIND_RESIZE_BLOCK_RATIO) mode = MBIND_RESIZE_FORCE_RATIO; @@ -942,10 +942,10 @@ Vector2D IHyprLayout::predictSizeForNewWindow(PHLWINDOW pWindow) { } bool IHyprLayout::updateDragWindow() { - const auto DRAGGINGWINDOW = g_pInputManager->currentlyDraggedWindow.lock(); + const auto DRAGGINGWINDOW = g_pInputManager->m_currentlyDraggedWindow.lock(); const bool WAS_FULLSCREEN = DRAGGINGWINDOW->isFullscreen(); - if (g_pInputManager->m_bDragThresholdReached) { + if (g_pInputManager->m_dragThresholdReached) { if (WAS_FULLSCREEN) { Debug::log(LOG, "Dragging a fullscreen window"); g_pCompositor->setWindowFullscreenInternal(DRAGGINGWINDOW, FSMODE_NONE); @@ -966,11 +966,11 @@ bool IHyprLayout::updateDragWindow() { if (WAS_FULLSCREEN && DRAGGINGWINDOW->m_isFloating) { const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal(); *DRAGGINGWINDOW->m_realPosition = MOUSECOORDS - DRAGGINGWINDOW->m_realSize->goal() / 2.f; - } else if (!DRAGGINGWINDOW->m_isFloating && g_pInputManager->dragMode == MBIND_MOVE) { + } else if (!DRAGGINGWINDOW->m_isFloating && g_pInputManager->m_dragMode == MBIND_MOVE) { Vector2D MINSIZE = DRAGGINGWINDOW->requestedMinSize().clamp(DRAGGINGWINDOW->m_windowData.minSize.valueOr(Vector2D(MIN_WINDOW_SIZE, MIN_WINDOW_SIZE))); DRAGGINGWINDOW->m_lastFloatingSize = (DRAGGINGWINDOW->m_realSize->goal() * 0.8489).clamp(MINSIZE, Vector2D{}).floor(); *DRAGGINGWINDOW->m_realPosition = g_pInputManager->getMouseCoordsInternal() - DRAGGINGWINDOW->m_realSize->goal() / 2.f; - if (g_pInputManager->m_bDragThresholdReached) { + if (g_pInputManager->m_dragThresholdReached) { changeWindowFloatingMode(DRAGGINGWINDOW); DRAGGINGWINDOW->m_isFloating = true; DRAGGINGWINDOW->m_draggingTiled = true; diff --git a/src/layout/MasterLayout.cpp b/src/layout/MasterLayout.cpp index d2aa7568..ef59674c 100644 --- a/src/layout/MasterLayout.cpp +++ b/src/layout/MasterLayout.cpp @@ -121,7 +121,7 @@ void CHyprMasterLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dire bool forceDropAsMaster = false; // if dragging window to move, drop it at the cursor position instead of bottom/top of stack - if (*PDROPATCURSOR && g_pInputManager->dragMode == MBIND_MOVE) { + if (*PDROPATCURSOR && g_pInputManager->m_dragMode == MBIND_MOVE) { if (WINDOWSONWORKSPACE > 2) { for (auto it = m_masterNodesData.begin(); it != m_masterNodesData.end(); ++it) { if (it->workspaceID != pWindow->workspaceID()) @@ -177,11 +177,11 @@ void CHyprMasterLayout::onWindowCreatedTiling(PHLWINDOW pWindow, eDirection dire } } - if ((BNEWISMASTER && g_pInputManager->dragMode != MBIND_MOVE) // + if ((BNEWISMASTER && g_pInputManager->m_dragMode != MBIND_MOVE) // || WINDOWSONWORKSPACE == 1 // || (WINDOWSONWORKSPACE > 2 && !pWindow->m_firstMap && OPENINGON->isMaster) // || forceDropAsMaster // - || (*PNEWSTATUS == "inherit" && OPENINGON && OPENINGON->isMaster && g_pInputManager->dragMode != MBIND_MOVE)) { + || (*PNEWSTATUS == "inherit" && OPENINGON && OPENINGON->isMaster && g_pInputManager->m_dragMode != MBIND_MOVE)) { if (BNEWBEFOREACTIVE) { for (auto& nd : m_masterNodesData | std::views::reverse) { @@ -1065,9 +1065,9 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri g_pCompositor->warpCursorTo(PWINDOWTOCHANGETO->middle()); } - g_pInputManager->m_pForcedFocus = PWINDOWTOCHANGETO; + g_pInputManager->m_forcedFocus = PWINDOWTOCHANGETO; g_pInputManager->simulateMouseMovement(); - g_pInputManager->m_pForcedFocus.reset(); + g_pInputManager->m_forcedFocus.reset(); }; CVarList vars(message, 0, ' '); diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 1bd7e1a2..98c0360b 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -313,10 +313,10 @@ void CKeybindManager::updateXKBTranslationState() { } bool CKeybindManager::ensureMouseBindState() { - if (!g_pInputManager->currentlyDraggedWindow) + if (!g_pInputManager->m_currentlyDraggedWindow) return false; - if (!g_pInputManager->currentlyDraggedWindow.expired()) { + if (!g_pInputManager->m_currentlyDraggedWindow.expired()) { changeMouseBindMode(MBIND_INVALID); return true; } @@ -364,9 +364,9 @@ bool CKeybindManager::tryMoveFocusToMonitor(PHLMONITOR monitor) { PNEWWINDOW->warpCursor(); if (*PNOWARPS == 0 || *PFOLLOWMOUSE < 2) { - g_pInputManager->m_pForcedFocus = PNEWWINDOW; + g_pInputManager->m_forcedFocus = PNEWWINDOW; g_pInputManager->simulateMouseMovement(); - g_pInputManager->m_pForcedFocus.reset(); + g_pInputManager->m_forcedFocus.reset(); } } else { g_pCompositor->focusWindow(nullptr); @@ -411,9 +411,9 @@ void CKeybindManager::switchToWindow(PHLWINDOW PWINDOWTOCHANGETO, bool preserveF // Move mouse focus to the new window if required by current follow_mouse and warp modes if (*PNOWARPS == 0 || *PFOLLOWMOUSE < 2) { - g_pInputManager->m_pForcedFocus = PWINDOWTOCHANGETO; + g_pInputManager->m_forcedFocus = PWINDOWTOCHANGETO; g_pInputManager->simulateMouseMovement(); - g_pInputManager->m_pForcedFocus.reset(); + g_pInputManager->m_forcedFocus.reset(); } if (PLASTWINDOW && PLASTWINDOW->m_monitor != PWINDOWTOCHANGETO->m_monitor) { @@ -755,9 +755,9 @@ SDispatchResult CKeybindManager::handleKeybinds(const uint32_t modmask, const SP // Require mouse to stay inside drag_threshold for clicks, outside for drags // Check if either a mouse bind has triggered or currently over the threshold (maybe there is no mouse bind on the same key) const auto THRESHOLDREACHED = key.mousePosAtPress.distanceSq(g_pInputManager->getMouseCoordsInternal()) > std::pow(*PDRAGTHRESHOLD, 2); - if (k->click && (g_pInputManager->m_bDragThresholdReached || THRESHOLDREACHED)) + if (k->click && (g_pInputManager->m_dragThresholdReached || THRESHOLDREACHED)) continue; - else if (k->drag && !g_pInputManager->m_bDragThresholdReached && !THRESHOLDREACHED) + else if (k->drag && !g_pInputManager->m_dragThresholdReached && !THRESHOLDREACHED) continue; } @@ -811,7 +811,7 @@ SDispatchResult CKeybindManager::handleKeybinds(const uint32_t modmask, const SP found = true; } - g_pInputManager->m_bDragThresholdReached = false; + g_pInputManager->m_dragThresholdReached = false; // if keybind wasn't found (or dispatcher said to) then pass event res.passEvent |= !found; @@ -1143,7 +1143,7 @@ static SDispatchResult toggleActiveFloatingCore(std::string args, std::optional< return {}; // remove drag status - if (!g_pInputManager->currentlyDraggedWindow.expired()) + if (!g_pInputManager->m_currentlyDraggedWindow.expired()) g_pKeybindManager->changeMouseBindMode(MBIND_INVALID); if (PWINDOW->m_groupData.pNextWindow.lock() && PWINDOW->m_groupData.pNextWindow.lock() != PWINDOW) { @@ -1279,7 +1279,7 @@ SDispatchResult CKeybindManager::changeworkspace(std::string args) { } g_pInputManager->unconstrainMouse(); - g_pInputManager->m_bEmptyFocusCursorSet = false; + g_pInputManager->m_emptyFocusCursorSet = false; auto pWorkspaceToChangeTo = g_pCompositor->getWorkspaceByID(BISWORKSPACECURRENT ? PPREVWS.id : workspaceToChangeTo); if (!pWorkspaceToChangeTo) @@ -1325,7 +1325,7 @@ SDispatchResult CKeybindManager::changeworkspace(std::string args) { g_pCompositor->warpCursorTo(middle); } - if (!g_pInputManager->m_bLastFocusOnLS) { + if (!g_pInputManager->m_lastFocusOnLS) { if (g_pCompositor->m_lastFocus) g_pInputManager->sendMotionEventsToFocused(); else @@ -2812,7 +2812,7 @@ SDispatchResult CKeybindManager::mouse(std::string args) { SDispatchResult CKeybindManager::changeMouseBindMode(const eMouseBindMode MODE) { if (MODE != MBIND_INVALID) { - if (!g_pInputManager->currentlyDraggedWindow.expired() || g_pInputManager->dragMode != MBIND_INVALID) + if (!g_pInputManager->m_currentlyDraggedWindow.expired() || g_pInputManager->m_dragMode != MBIND_INVALID) return {}; const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal(); @@ -2824,18 +2824,18 @@ SDispatchResult CKeybindManager::changeMouseBindMode(const eMouseBindMode MODE) if (!PWINDOW->isFullscreen() && MODE == MBIND_MOVE) PWINDOW->checkInputOnDecos(INPUT_TYPE_DRAG_START, MOUSECOORDS); - if (g_pInputManager->currentlyDraggedWindow.expired()) - g_pInputManager->currentlyDraggedWindow = PWINDOW; + if (g_pInputManager->m_currentlyDraggedWindow.expired()) + g_pInputManager->m_currentlyDraggedWindow = PWINDOW; - g_pInputManager->dragMode = MODE; + g_pInputManager->m_dragMode = MODE; g_pLayoutManager->getCurrentLayout()->onBeginDragWindow(); } else { - if (g_pInputManager->currentlyDraggedWindow.expired() || g_pInputManager->dragMode == MBIND_INVALID) + if (g_pInputManager->m_currentlyDraggedWindow.expired() || g_pInputManager->m_dragMode == MBIND_INVALID) return {}; g_pLayoutManager->getCurrentLayout()->onEndDragWindow(); - g_pInputManager->dragMode = MODE; + g_pInputManager->m_dragMode = MODE; } return {}; diff --git a/src/managers/eventLoop/EventLoopManager.cpp b/src/managers/eventLoop/EventLoopManager.cpp index 14ff75f5..338b75e3 100644 --- a/src/managers/eventLoop/EventLoopManager.cpp +++ b/src/managers/eventLoop/EventLoopManager.cpp @@ -16,25 +16,25 @@ using namespace Hyprutils::OS; #define TIMESPEC_NSEC_PER_SEC 1000000000L CEventLoopManager::CEventLoopManager(wl_display* display, wl_event_loop* wlEventLoop) { - m_sTimers.timerfd = CFileDescriptor{timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC)}; - m_sWayland.loop = wlEventLoop; - m_sWayland.display = display; + m_timers.timerfd = CFileDescriptor{timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC)}; + m_wayland.loop = wlEventLoop; + m_wayland.display = display; } CEventLoopManager::~CEventLoopManager() { - for (auto const& [_, eventSourceData] : aqEventSources) { + for (auto const& [_, eventSourceData] : m_aqEventSources) { wl_event_source_remove(eventSourceData.eventSource); } - for (auto const& w : m_vReadableWaiters) { + for (auto const& w : m_readableWaiters) { if (w->source != nullptr) wl_event_source_remove(w->source); } - if (m_sWayland.eventSource) - wl_event_source_remove(m_sWayland.eventSource); - if (m_sIdle.eventSource) - wl_event_source_remove(m_sIdle.eventSource); + if (m_wayland.eventSource) + wl_event_source_remove(m_wayland.eventSource); + if (m_idle.eventSource) + wl_event_source_remove(m_idle.eventSource); if (m_configWatcherInotifySource) wl_event_source_remove(m_configWatcherInotifySource); } @@ -68,7 +68,7 @@ static int handleWaiterFD(int fd, uint32_t mask, void* data) { } void CEventLoopManager::onFdReadable(SReadableWaiter* waiter) { - auto it = std::ranges::find_if(m_vReadableWaiters, [waiter](const UP& w) { return waiter == w.get() && w->fd == waiter->fd && w->source == waiter->source; }); + auto it = std::ranges::find_if(m_readableWaiters, [waiter](const UP& w) { return waiter == w.get() && w->fd == waiter->fd && w->source == waiter->source; }); if (waiter->source) { wl_event_source_remove(waiter->source); @@ -78,30 +78,30 @@ void CEventLoopManager::onFdReadable(SReadableWaiter* waiter) { if (waiter->fn) waiter->fn(); - if (it != m_vReadableWaiters.end()) - m_vReadableWaiters.erase(it); + if (it != m_readableWaiters.end()) + m_readableWaiters.erase(it); } void CEventLoopManager::enterLoop() { - m_sWayland.eventSource = wl_event_loop_add_fd(m_sWayland.loop, m_sTimers.timerfd.get(), WL_EVENT_READABLE, timerWrite, nullptr); + m_wayland.eventSource = wl_event_loop_add_fd(m_wayland.loop, m_timers.timerfd.get(), WL_EVENT_READABLE, timerWrite, nullptr); if (const auto& FD = g_pConfigWatcher->getInotifyFD(); FD.isValid()) - m_configWatcherInotifySource = wl_event_loop_add_fd(m_sWayland.loop, FD.get(), WL_EVENT_READABLE, configWatcherWrite, nullptr); + m_configWatcherInotifySource = wl_event_loop_add_fd(m_wayland.loop, FD.get(), WL_EVENT_READABLE, configWatcherWrite, nullptr); syncPollFDs(); - m_sListeners.pollFDsChanged = g_pCompositor->m_aqBackend->events.pollFDsChanged.registerListener([this](std::any d) { syncPollFDs(); }); + m_listeners.pollFDsChanged = g_pCompositor->m_aqBackend->events.pollFDsChanged.registerListener([this](std::any d) { syncPollFDs(); }); // if we have a session, dispatch it to get the pending input devices if (g_pCompositor->m_aqBackend->hasSession()) g_pCompositor->m_aqBackend->session->dispatchPendingEventsAsync(); - wl_display_run(m_sWayland.display); + wl_display_run(m_wayland.display); Debug::log(LOG, "Kicked off the event loop! :("); } void CEventLoopManager::onTimerFire() { - for (auto const& t : m_sTimers.timers) { + for (auto const& t : m_timers.timers) { if (t.strongRef() > 1 /* if it's 1, it was lost. Don't call it. */ && t->passed() && !t->cancelled()) t->call(t); } @@ -110,12 +110,12 @@ void CEventLoopManager::onTimerFire() { } void CEventLoopManager::addTimer(SP timer) { - m_sTimers.timers.push_back(timer); + m_timers.timers.push_back(timer); nudgeTimers(); } void CEventLoopManager::removeTimer(SP timer) { - std::erase_if(m_sTimers.timers, [timer](const auto& t) { return timer == t; }); + std::erase_if(m_timers.timers, [timer](const auto& t) { return timer == t; }); nudgeTimers(); } @@ -134,11 +134,11 @@ static void timespecAddNs(timespec* pTimespec, int64_t delta) { void CEventLoopManager::nudgeTimers() { // remove timers that have gone missing - std::erase_if(m_sTimers.timers, [](const auto& t) { return t.strongRef() <= 1; }); + std::erase_if(m_timers.timers, [](const auto& t) { return t.strongRef() <= 1; }); long nextTimerUs = 10L * 1000 * 1000; // 10s - for (auto const& t : m_sTimers.timers) { + for (auto const& t : m_timers.timers) { if (auto const& µs = t->leftUs(); µs < nextTimerUs) nextTimerUs = µs; } @@ -151,17 +151,17 @@ void CEventLoopManager::nudgeTimers() { itimerspec ts = {.it_value = now}; - timerfd_settime(m_sTimers.timerfd.get(), TFD_TIMER_ABSTIME, &ts, nullptr); + timerfd_settime(m_timers.timerfd.get(), TFD_TIMER_ABSTIME, &ts, nullptr); } void CEventLoopManager::doLater(const std::function& fn) { - m_sIdle.fns.emplace_back(fn); + m_idle.fns.emplace_back(fn); - if (m_sIdle.eventSource) + if (m_idle.eventSource) return; - m_sIdle.eventSource = wl_event_loop_add_idle( - m_sWayland.loop, + m_idle.eventSource = wl_event_loop_add_idle( + m_wayland.loop, [](void* data) { auto IDLE = (CEventLoopManager::SIdleData*)data; auto cpy = IDLE->fns; @@ -172,7 +172,7 @@ void CEventLoopManager::doLater(const std::function& fn) { c(); } }, - &m_sIdle); + &m_idle); } void CEventLoopManager::doOnReadable(CFileDescriptor fd, const std::function& fn) { @@ -181,14 +181,14 @@ void CEventLoopManager::doOnReadable(CFileDescriptor fd, const std::function(nullptr, std::move(fd), fn)); - waiter->source = wl_event_loop_add_fd(g_pEventLoopManager->m_sWayland.loop, waiter->fd.get(), WL_EVENT_READABLE, ::handleWaiterFD, waiter.get()); + auto& waiter = m_readableWaiters.emplace_back(makeUnique(nullptr, std::move(fd), fn)); + waiter->source = wl_event_loop_add_fd(g_pEventLoopManager->m_wayland.loop, waiter->fd.get(), WL_EVENT_READABLE, ::handleWaiterFD, waiter.get()); } void CEventLoopManager::syncPollFDs() { auto aqPollFDs = g_pCompositor->m_aqBackend->getPollFDs(); - std::erase_if(aqEventSources, [&](const auto& item) { + std::erase_if(m_aqEventSources, [&](const auto& item) { auto const& [fd, eventSourceData] = item; // If no pollFD has the same fd, remove this event source @@ -200,8 +200,8 @@ void CEventLoopManager::syncPollFDs() { return shouldRemove; }); - for (auto& fd : aqPollFDs | std::views::filter([&](SP fd) { return !aqEventSources.contains(fd->fd); })) { - auto eventSource = wl_event_loop_add_fd(m_sWayland.loop, fd->fd, WL_EVENT_READABLE, aquamarineFDWrite, fd.get()); - aqEventSources[fd->fd] = {.pollFD = fd, .eventSource = eventSource}; + for (auto& fd : aqPollFDs | std::views::filter([&](SP fd) { return !m_aqEventSources.contains(fd->fd); })) { + auto eventSource = wl_event_loop_add_fd(m_wayland.loop, fd->fd, WL_EVENT_READABLE, aquamarineFDWrite, fd.get()); + m_aqEventSources[fd->fd] = {.pollFD = fd, .eventSource = eventSource}; } } diff --git a/src/managers/eventLoop/EventLoopManager.hpp b/src/managers/eventLoop/EventLoopManager.hpp index 8a0e0439..a3c755a7 100644 --- a/src/managers/eventLoop/EventLoopManager.hpp +++ b/src/managers/eventLoop/EventLoopManager.hpp @@ -62,20 +62,20 @@ class CEventLoopManager { wl_event_loop* loop = nullptr; wl_display* display = nullptr; wl_event_source* eventSource = nullptr; - } m_sWayland; + } m_wayland; struct { std::vector> timers; Hyprutils::OS::CFileDescriptor timerfd; - } m_sTimers; + } m_timers; - SIdleData m_sIdle; - std::map aqEventSources; - std::vector> m_vReadableWaiters; + SIdleData m_idle; + std::map m_aqEventSources; + std::vector> m_readableWaiters; struct { CHyprSignalListener pollFDsChanged; - } m_sListeners; + } m_listeners; wl_event_source* m_configWatcherInotifySource = nullptr; diff --git a/src/managers/input/IdleInhibitor.cpp b/src/managers/input/IdleInhibitor.cpp index 2ca0f4d6..e3712ce7 100644 --- a/src/managers/input/IdleInhibitor.cpp +++ b/src/managers/input/IdleInhibitor.cpp @@ -5,13 +5,13 @@ #include "../../protocols/core/Compositor.hpp" void CInputManager::newIdleInhibitor(std::any inhibitor) { - const auto PINHIBIT = m_vIdleInhibitors.emplace_back(makeUnique()).get(); + const auto PINHIBIT = m_idleInhibitors.emplace_back(makeUnique()).get(); PINHIBIT->inhibitor = std::any_cast>(inhibitor); Debug::log(LOG, "New idle inhibitor registered for surface {:x}", (uintptr_t)PINHIBIT->inhibitor->surface.get()); PINHIBIT->inhibitor->listeners.destroy = PINHIBIT->inhibitor->resource->events.destroy.registerListener([this, PINHIBIT](std::any data) { - std::erase_if(m_vIdleInhibitors, [PINHIBIT](const auto& other) { return other.get() == PINHIBIT; }); + std::erase_if(m_idleInhibitors, [PINHIBIT](const auto& other) { return other.get() == PINHIBIT; }); recheckIdleInhibitorStatus(); }); @@ -25,14 +25,14 @@ void CInputManager::newIdleInhibitor(std::any inhibitor) { } PINHIBIT->surfaceDestroyListener = WLSurface->m_events.destroy.registerListener( - [this, PINHIBIT](std::any data) { std::erase_if(m_vIdleInhibitors, [PINHIBIT](const auto& other) { return other.get() == PINHIBIT; }); }); + [this, PINHIBIT](std::any data) { std::erase_if(m_idleInhibitors, [PINHIBIT](const auto& other) { return other.get() == PINHIBIT; }); }); recheckIdleInhibitorStatus(); } void CInputManager::recheckIdleInhibitorStatus() { - for (auto const& ii : m_vIdleInhibitors) { + for (auto const& ii : m_idleInhibitors) { if (ii->nonDesktop) { PROTO::idle->setInhibit(true); return; @@ -73,7 +73,7 @@ bool CInputManager::isWindowInhibiting(const PHLWINDOW& w, bool onlyHl) { if (onlyHl) return false; - for (auto const& ii : m_vIdleInhibitors) { + for (auto const& ii : m_idleInhibitors) { if (ii->nonDesktop || !ii->inhibitor) continue; diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index e1856f1d..804eb173 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -42,7 +42,7 @@ #include CInputManager::CInputManager() { - m_sListeners.setCursorShape = PROTO::cursorShape->events.setShape.registerListener([this](std::any data) { + m_listeners.setCursorShape = PROTO::cursorShape->events.setShape.registerListener([this](std::any data) { if (!cursorImageUnlocked()) return; @@ -56,39 +56,39 @@ CInputManager::CInputManager() { Debug::log(LOG, "cursorImage request: shape {} -> {}", (uint32_t)event.shape, event.shapeName); - m_sCursorSurfaceInfo.wlSurface->unassign(); - m_sCursorSurfaceInfo.vHotspot = {}; - m_sCursorSurfaceInfo.name = event.shapeName; - m_sCursorSurfaceInfo.hidden = false; + m_cursorSurfaceInfo.wlSurface->unassign(); + m_cursorSurfaceInfo.vHotspot = {}; + m_cursorSurfaceInfo.name = event.shapeName; + m_cursorSurfaceInfo.hidden = false; - m_sCursorSurfaceInfo.inUse = true; - g_pHyprRenderer->setCursorFromName(m_sCursorSurfaceInfo.name); + m_cursorSurfaceInfo.inUse = true; + g_pHyprRenderer->setCursorFromName(m_cursorSurfaceInfo.name); }); - m_sListeners.newIdleInhibitor = PROTO::idleInhibit->events.newIdleInhibitor.registerListener([this](std::any data) { this->newIdleInhibitor(data); }); - m_sListeners.newVirtualKeyboard = PROTO::virtualKeyboard->events.newKeyboard.registerListener([this](std::any data) { + m_listeners.newIdleInhibitor = PROTO::idleInhibit->events.newIdleInhibitor.registerListener([this](std::any data) { this->newIdleInhibitor(data); }); + m_listeners.newVirtualKeyboard = PROTO::virtualKeyboard->events.newKeyboard.registerListener([this](std::any data) { this->newVirtualKeyboard(std::any_cast>(data)); updateCapabilities(); }); - m_sListeners.newVirtualMouse = PROTO::virtualPointer->events.newPointer.registerListener([this](std::any data) { + m_listeners.newVirtualMouse = PROTO::virtualPointer->events.newPointer.registerListener([this](std::any data) { this->newVirtualMouse(std::any_cast>(data)); updateCapabilities(); }); - m_sListeners.setCursor = g_pSeatManager->events.setCursor.registerListener([this](std::any d) { this->processMouseRequest(d); }); + m_listeners.setCursor = g_pSeatManager->events.setCursor.registerListener([this](std::any d) { this->processMouseRequest(d); }); - m_sCursorSurfaceInfo.wlSurface = CWLSurface::create(); + m_cursorSurfaceInfo.wlSurface = CWLSurface::create(); } CInputManager::~CInputManager() { - m_vConstraints.clear(); - m_vKeyboards.clear(); - m_vPointers.clear(); - m_vTouches.clear(); - m_vTablets.clear(); - m_vTabletTools.clear(); - m_vTabletPads.clear(); - m_vIdleInhibitors.clear(); - m_lSwitches.clear(); + m_constraints.clear(); + m_keyboards.clear(); + m_pointers.clear(); + m_touches.clear(); + m_tablets.clear(); + m_tabletTools.clear(); + m_tabletPads.clear(); + m_idleInhibitors.clear(); + m_switches.clear(); } void CInputManager::onMouseMoved(IPointer::SMotionEvent e) { @@ -126,12 +126,12 @@ void CInputManager::onMouseMoved(IPointer::SMotionEvent e) { mouseMoveUnified(e.timeMs, false, e.mouse); - m_tmrLastCursorMovement.reset(); + m_lastCursorMovement.reset(); - m_bLastInputTouch = false; + m_lastInputTouch = false; if (e.mouse) - m_vLastMousePos = getMouseCoordsInternal(); + m_lastMousePos = getMouseCoordsInternal(); } void CInputManager::onMouseWarp(IPointer::SMotionAbsoluteEvent e) { @@ -139,13 +139,13 @@ void CInputManager::onMouseWarp(IPointer::SMotionAbsoluteEvent e) { mouseMoveUnified(e.timeMs); - m_tmrLastCursorMovement.reset(); + m_lastCursorMovement.reset(); - m_bLastInputTouch = false; + m_lastInputTouch = false; } void CInputManager::simulateMouseMovement() { - m_vLastCursorPosFloored = m_vLastCursorPosFloored - Vector2D(1, 1); // hack: force the mouseMoveUnified to report without making this a refocus. + m_lastCursorPosFloored = m_lastCursorPosFloored - Vector2D(1, 1); // hack: force the mouseMoveUnified to report without making this a refocus. mouseMoveUnified(Time::millis(Time::steadyNow())); } @@ -159,13 +159,13 @@ void CInputManager::sendMotionEventsToFocused() { const auto LOCAL = getMouseCoordsInternal() - (PWINDOW ? PWINDOW->m_realPosition->goal() : (PLS ? Vector2D{PLS->m_geometry.x, PLS->m_geometry.y} : Vector2D{})); - m_bEmptyFocusCursorSet = false; + m_emptyFocusCursorSet = false; g_pSeatManager->setPointerFocus(g_pCompositor->m_lastFocus.lock(), LOCAL); } void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) { - m_bLastInputMouse = mouse; + m_lastInputMouse = mouse; if (!g_pCompositor->m_readyToProcess || g_pCompositor->m_isShuttingDown || g_pCompositor->m_unsafeState) return; @@ -173,7 +173,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) { Vector2D const mouseCoords = getMouseCoordsInternal(); auto const MOUSECOORDSFLOORED = mouseCoords.floor(); - if (MOUSECOORDSFLOORED == m_vLastCursorPosFloored && !refocus) + if (MOUSECOORDSFLOORED == m_lastCursorPosFloored && !refocus) return; static auto PFOLLOWMOUSE = CConfigValue("input:follow_mouse"); @@ -188,14 +188,14 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) { const auto FOLLOWMOUSE = *PFOLLOWONDND && PROTO::data->dndActive() ? 1 : *PFOLLOWMOUSE; - if (FOLLOWMOUSE == 1 && m_tmrLastCursorMovement.getSeconds() < 0.5) - m_fMousePosDelta += MOUSECOORDSFLOORED.distance(m_vLastCursorPosFloored); + if (FOLLOWMOUSE == 1 && m_lastCursorMovement.getSeconds() < 0.5) + m_mousePosDelta += MOUSECOORDSFLOORED.distance(m_lastCursorPosFloored); else - m_fMousePosDelta = 0; + m_mousePosDelta = 0; - m_pFoundSurfaceToFocus.reset(); - m_pFoundLSToFocus.reset(); - m_pFoundWindowToFocus.reset(); + m_foundSurfaceToFocus.reset(); + m_foundLSToFocus.reset(); + m_foundWindowToFocus.reset(); SP foundSurface; Vector2D surfaceCoords; Vector2D surfacePos = Vector2D(-1337, -1337); @@ -204,7 +204,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) { EMIT_HOOK_EVENT_CANCELLABLE("mouseMove", MOUSECOORDSFLOORED); - m_vLastCursorPosFloored = MOUSECOORDSFLOORED; + m_lastCursorPosFloored = MOUSECOORDSFLOORED; const auto PMONITOR = isLocked() && g_pCompositor->m_lastMonitor ? g_pCompositor->m_lastMonitor.lock() : g_pCompositor->getMonitorFromCursor(); @@ -246,7 +246,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) { Debug::log(ERR, "BUG THIS: Null SURF/CONSTRAINT in mouse refocus. Ignoring constraints. {:x} {:x}", (uintptr_t)SURF.get(), (uintptr_t)CONSTRAINT.get()); } - if (PMONITOR != g_pCompositor->m_lastMonitor && (*PMOUSEFOCUSMON || refocus) && m_pForcedFocus.expired()) + if (PMONITOR != g_pCompositor->m_lastMonitor && (*PMOUSEFOCUSMON || refocus) && m_forcedFocus.expired()) g_pCompositor->setActiveMonitor(PMONITOR); if (g_pSessionLockManager->isSessionLocked()) { @@ -276,7 +276,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) { return; } - PHLWINDOW forcedFocus = m_pForcedFocus.lock(); + PHLWINDOW forcedFocus = m_forcedFocus.lock(); if (!forcedFocus) forcedFocus = g_pCompositor->getForceFocus(); @@ -289,17 +289,17 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) { // if we are holding a pointer button, // and we're not dnd-ing, don't refocus. Keep focus on last surface. - if (!PROTO::data->dndActive() && !m_lCurrentlyHeldButtons.empty() && g_pCompositor->m_lastFocus && g_pCompositor->m_lastFocus->mapped && g_pSeatManager->state.pointerFocus && - !m_bHardInput) { + if (!PROTO::data->dndActive() && !m_currentlyHeldButtons.empty() && g_pCompositor->m_lastFocus && g_pCompositor->m_lastFocus->mapped && g_pSeatManager->state.pointerFocus && + !m_hardInput) { foundSurface = g_pSeatManager->state.pointerFocus.lock(); // IME popups aren't desktop-like elements // TODO: make them. - CInputPopup* foundPopup = m_sIMERelay.popupFromSurface(foundSurface); + CInputPopup* foundPopup = m_relay.popupFromSurface(foundSurface); if (foundPopup) { - surfacePos = foundPopup->globalBox().pos(); - m_bFocusHeldByButtons = true; - m_bRefocusHeldByButtons = refocus; + surfacePos = foundPopup->globalBox().pos(); + m_focusHeldByButtons = true; + m_refocusHeldByButtons = refocus; } else { auto HLSurface = CWLSurface::fromResource(foundSurface); @@ -321,13 +321,13 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) { g_pLayoutManager->getCurrentLayout()->onMouseMove(getMouseCoordsInternal()); // forced above all - if (!g_pInputManager->m_dExclusiveLSes.empty()) { + if (!g_pInputManager->m_exclusiveLSes.empty()) { if (!foundSurface) - foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &g_pInputManager->m_dExclusiveLSes, &surfaceCoords, &pFoundLayerSurface); + foundSurface = g_pCompositor->vectorToLayerSurface(mouseCoords, &g_pInputManager->m_exclusiveLSes, &surfaceCoords, &pFoundLayerSurface); if (!foundSurface) { - foundSurface = (*g_pInputManager->m_dExclusiveLSes.begin())->m_surface->resource(); - surfacePos = (*g_pInputManager->m_dExclusiveLSes.begin())->m_realPosition->goal(); + foundSurface = (*g_pInputManager->m_exclusiveLSes.begin())->m_surface->resource(); + surfacePos = (*g_pInputManager->m_exclusiveLSes.begin())->m_realPosition->goal(); } } @@ -340,7 +340,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) { // also IME popups if (!foundSurface) { - auto popup = g_pInputManager->m_sIMERelay.popupFromCoords(mouseCoords); + auto popup = g_pInputManager->m_relay.popupFromCoords(mouseCoords); if (popup) { foundSurface = popup->getSurface(); surfacePos = popup->globalBox().pos(); @@ -437,7 +437,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) { // FIXME: This will be disabled during DnD operations because we do not exactly follow the spec // xdg-popup grabs should be keyboard-only, while they are absolute in our case... if (g_pSeatManager->seatGrab && !g_pSeatManager->seatGrab->accepts(foundSurface) && !PROTO::data->dndActive()) { - if (m_bHardInput || refocus) { + if (m_hardInput || refocus) { g_pSeatManager->setGrab(nullptr); return; // setGrab will refocus } else { @@ -456,19 +456,19 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) { } if (!foundSurface) { - if (!m_bEmptyFocusCursorSet) { - if (*PRESIZEONBORDER && *PRESIZECURSORICON && m_eBorderIconDirection != BORDERICON_NONE) { - m_eBorderIconDirection = BORDERICON_NONE; + if (!m_emptyFocusCursorSet) { + if (*PRESIZEONBORDER && *PRESIZECURSORICON && m_borderIconDirection != BORDERICON_NONE) { + m_borderIconDirection = BORDERICON_NONE; unsetCursorImage(); } // TODO: maybe wrap? - if (m_ecbClickBehavior == CLICKMODE_KILL) + if (m_clickBehavior == CLICKMODE_KILL) setCursorImageOverride("crosshair"); else setCursorImageOverride("left_ptr"); - m_bEmptyFocusCursorSet = true; + m_emptyFocusCursorSet = true; } g_pSeatManager->setPointerFocus(nullptr, {}); @@ -479,7 +479,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) { return; } - m_bEmptyFocusCursorSet = false; + m_emptyFocusCursorSet = false; Vector2D surfaceLocal = surfacePos == Vector2D(-1337, -1337) ? surfaceCoords : mouseCoords - surfacePos; @@ -504,17 +504,17 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) { // set the values for use if (refocus) { - m_pFoundLSToFocus = pFoundLayerSurface; - m_pFoundWindowToFocus = pFoundWindow; - m_pFoundSurfaceToFocus = foundSurface; + m_foundLSToFocus = pFoundLayerSurface; + m_foundWindowToFocus = pFoundWindow; + m_foundSurfaceToFocus = foundSurface; } - if (currentlyDraggedWindow.lock() && pFoundWindow != currentlyDraggedWindow) { + if (m_currentlyDraggedWindow.lock() && pFoundWindow != m_currentlyDraggedWindow) { g_pSeatManager->setPointerFocus(foundSurface, surfaceLocal); return; } - if (pFoundWindow && foundSurface == pFoundWindow->m_wlSurface->resource() && !m_bCursorImageOverridden) { + if (pFoundWindow && foundSurface == pFoundWindow->m_wlSurface->resource() && !m_cursorImageOverridden) { const auto BOX = pFoundWindow->getWindowMainSurfaceBox(); if (!VECINRECT(mouseCoords, BOX.x, BOX.y, BOX.x + BOX.width, BOX.y + BOX.height)) setCursorImageOverride("left_ptr"); @@ -527,7 +527,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) { if (*PRESIZEONBORDER && *PRESIZECURSORICON) { if (!pFoundWindow->isFullscreen() && !pFoundWindow->hasPopupAt(mouseCoords)) { setCursorIconOnBorder(pFoundWindow); - } else if (m_eBorderIconDirection != BORDERICON_NONE) { + } else if (m_borderIconDirection != BORDERICON_NONE) { unsetCursorImage(); } } @@ -551,17 +551,17 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) { if (g_pSeatManager->state.pointerFocus == foundSurface) g_pSeatManager->sendPointerMotion(time, surfaceLocal); - m_bLastFocusOnLS = false; + m_lastFocusOnLS = false; return; // don't enter any new surfaces } else { - if (allowKeyboardRefocus && ((FOLLOWMOUSE != 3 && (*PMOUSEREFOCUS || m_pLastMouseFocus.lock() != pFoundWindow)) || refocus)) { - if (m_pLastMouseFocus.lock() != pFoundWindow || g_pCompositor->m_lastWindow.lock() != pFoundWindow || g_pCompositor->m_lastFocus != foundSurface || refocus) { - m_pLastMouseFocus = pFoundWindow; + if (allowKeyboardRefocus && ((FOLLOWMOUSE != 3 && (*PMOUSEREFOCUS || m_lastMouseFocus.lock() != pFoundWindow)) || refocus)) { + if (m_lastMouseFocus.lock() != pFoundWindow || g_pCompositor->m_lastWindow.lock() != pFoundWindow || g_pCompositor->m_lastFocus != foundSurface || refocus) { + m_lastMouseFocus = pFoundWindow; // TODO: this looks wrong. When over a popup, it constantly is switching. // Temp fix until that's figured out. Otherwise spams windowrule lookups and other shit. - if (m_pLastMouseFocus.lock() != pFoundWindow || g_pCompositor->m_lastWindow.lock() != pFoundWindow) { - if (m_fMousePosDelta > *PFOLLOWMOUSETHRESHOLD || refocus) { + if (m_lastMouseFocus.lock() != pFoundWindow || g_pCompositor->m_lastWindow.lock() != pFoundWindow) { + if (m_mousePosDelta > *PFOLLOWMOUSETHRESHOLD || refocus) { const bool hasNoFollowMouse = pFoundWindow && pFoundWindow->m_windowData.noFollowMouse.valueOrDefault(); if (refocus || !hasNoFollowMouse) @@ -576,10 +576,10 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) { if (g_pSeatManager->state.keyboardFocus == nullptr) g_pCompositor->focusWindow(pFoundWindow, foundSurface); - m_bLastFocusOnLS = false; + m_lastFocusOnLS = false; } else { - if (*PRESIZEONBORDER && *PRESIZECURSORICON && m_eBorderIconDirection != BORDERICON_NONE) { - m_eBorderIconDirection = BORDERICON_NONE; + if (*PRESIZEONBORDER && *PRESIZECURSORICON && m_borderIconDirection != BORDERICON_NONE) { + m_borderIconDirection = BORDERICON_NONE; unsetCursorImage(); } @@ -589,7 +589,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus, bool mouse) { } if (pFoundLayerSurface) - m_bLastFocusOnLS = true; + m_lastFocusOnLS = true; } g_pSeatManager->setPointerFocus(foundSurface, surfaceLocal); @@ -602,30 +602,30 @@ void CInputManager::onMouseButton(IPointer::SButtonEvent e) { if (e.mouse) recheckMouseWarpOnMouseInput(); - m_tmrLastCursorMovement.reset(); + m_lastCursorMovement.reset(); if (e.state == WL_POINTER_BUTTON_STATE_PRESSED) { - m_lCurrentlyHeldButtons.push_back(e.button); + m_currentlyHeldButtons.push_back(e.button); } else { - if (std::find_if(m_lCurrentlyHeldButtons.begin(), m_lCurrentlyHeldButtons.end(), [&](const auto& other) { return other == e.button; }) == m_lCurrentlyHeldButtons.end()) + if (std::find_if(m_currentlyHeldButtons.begin(), m_currentlyHeldButtons.end(), [&](const auto& other) { return other == e.button; }) == m_currentlyHeldButtons.end()) return; - std::erase_if(m_lCurrentlyHeldButtons, [&](const auto& other) { return other == e.button; }); + std::erase_if(m_currentlyHeldButtons, [&](const auto& other) { return other == e.button; }); } - switch (m_ecbClickBehavior) { + switch (m_clickBehavior) { case CLICKMODE_DEFAULT: processMouseDownNormal(e); break; case CLICKMODE_KILL: processMouseDownKill(e); break; default: break; } - if (m_bFocusHeldByButtons && m_lCurrentlyHeldButtons.empty() && e.state == WL_POINTER_BUTTON_STATE_RELEASED) { - if (m_bRefocusHeldByButtons) + if (m_focusHeldByButtons && m_currentlyHeldButtons.empty() && e.state == WL_POINTER_BUTTON_STATE_RELEASED) { + if (m_refocusHeldByButtons) refocus(); else simulateMouseMovement(); - m_bFocusHeldByButtons = false; - m_bRefocusHeldByButtons = false; + m_focusHeldByButtons = false; + m_refocusHeldByButtons = false; } } @@ -637,79 +637,79 @@ void CInputManager::processMouseRequest(std::any E) { Debug::log(LOG, "cursorImage request: surface {:x}", (uintptr_t)e.surf.get()); - if (e.surf != m_sCursorSurfaceInfo.wlSurface->resource()) { - m_sCursorSurfaceInfo.wlSurface->unassign(); + if (e.surf != m_cursorSurfaceInfo.wlSurface->resource()) { + m_cursorSurfaceInfo.wlSurface->unassign(); if (e.surf) - m_sCursorSurfaceInfo.wlSurface->assign(e.surf); + m_cursorSurfaceInfo.wlSurface->assign(e.surf); } if (e.surf) { - m_sCursorSurfaceInfo.vHotspot = e.hotspot; - m_sCursorSurfaceInfo.hidden = false; + m_cursorSurfaceInfo.vHotspot = e.hotspot; + m_cursorSurfaceInfo.hidden = false; } else { - m_sCursorSurfaceInfo.vHotspot = {}; - m_sCursorSurfaceInfo.hidden = true; + m_cursorSurfaceInfo.vHotspot = {}; + m_cursorSurfaceInfo.hidden = true; } - m_sCursorSurfaceInfo.name = ""; + m_cursorSurfaceInfo.name = ""; - m_sCursorSurfaceInfo.inUse = true; - g_pHyprRenderer->setCursorSurface(m_sCursorSurfaceInfo.wlSurface, e.hotspot.x, e.hotspot.y); + m_cursorSurfaceInfo.inUse = true; + g_pHyprRenderer->setCursorSurface(m_cursorSurfaceInfo.wlSurface, e.hotspot.x, e.hotspot.y); } void CInputManager::restoreCursorIconToApp() { - if (m_sCursorSurfaceInfo.inUse) + if (m_cursorSurfaceInfo.inUse) return; - if (m_sCursorSurfaceInfo.hidden) { + if (m_cursorSurfaceInfo.hidden) { g_pHyprRenderer->setCursorSurface(nullptr, 0, 0); return; } - if (m_sCursorSurfaceInfo.name.empty()) { - if (m_sCursorSurfaceInfo.wlSurface->exists()) - g_pHyprRenderer->setCursorSurface(m_sCursorSurfaceInfo.wlSurface, m_sCursorSurfaceInfo.vHotspot.x, m_sCursorSurfaceInfo.vHotspot.y); + if (m_cursorSurfaceInfo.name.empty()) { + if (m_cursorSurfaceInfo.wlSurface->exists()) + g_pHyprRenderer->setCursorSurface(m_cursorSurfaceInfo.wlSurface, m_cursorSurfaceInfo.vHotspot.x, m_cursorSurfaceInfo.vHotspot.y); } else { - g_pHyprRenderer->setCursorFromName(m_sCursorSurfaceInfo.name); + g_pHyprRenderer->setCursorFromName(m_cursorSurfaceInfo.name); } - m_sCursorSurfaceInfo.inUse = true; + m_cursorSurfaceInfo.inUse = true; } void CInputManager::setCursorImageOverride(const std::string& name) { - if (m_bCursorImageOverridden) + if (m_cursorImageOverridden) return; - m_sCursorSurfaceInfo.inUse = false; + m_cursorSurfaceInfo.inUse = false; g_pHyprRenderer->setCursorFromName(name); } bool CInputManager::cursorImageUnlocked() { - if (m_ecbClickBehavior == CLICKMODE_KILL) + if (m_clickBehavior == CLICKMODE_KILL) return false; - if (m_bCursorImageOverridden) + if (m_cursorImageOverridden) return false; return true; } eClickBehaviorMode CInputManager::getClickMode() { - return m_ecbClickBehavior; + return m_clickBehavior; } void CInputManager::setClickMode(eClickBehaviorMode mode) { switch (mode) { case CLICKMODE_DEFAULT: Debug::log(LOG, "SetClickMode: DEFAULT"); - m_ecbClickBehavior = CLICKMODE_DEFAULT; + m_clickBehavior = CLICKMODE_DEFAULT; g_pHyprRenderer->setCursorFromName("left_ptr"); break; case CLICKMODE_KILL: Debug::log(LOG, "SetClickMode: KILL"); - m_ecbClickBehavior = CLICKMODE_KILL; + m_clickBehavior = CLICKMODE_KILL; // remove constraints g_pInputManager->unconstrainMouse(); @@ -739,12 +739,12 @@ void CInputManager::processMouseDownNormal(const IPointer::SButtonEvent& e) { const auto mouseCoords = g_pInputManager->getMouseCoordsInternal(); const auto w = g_pCompositor->vectorToWindowUnified(mouseCoords, ALLOW_FLOATING | RESERVED_EXTENTS | INPUT_EXTENTS); - if (w && !m_bLastFocusOnLS && w->checkInputOnDecos(INPUT_TYPE_BUTTON, mouseCoords, e)) + if (w && !m_lastFocusOnLS && w->checkInputOnDecos(INPUT_TYPE_BUTTON, mouseCoords, e)) return; // clicking on border triggers resize // TODO detect click on LS properly - if (*PRESIZEONBORDER && !m_bLastFocusOnLS && e.state == WL_POINTER_BUTTON_STATE_PRESSED && (!w || !w->isX11OverrideRedirect())) { + if (*PRESIZEONBORDER && !m_lastFocusOnLS && e.state == WL_POINTER_BUTTON_STATE_PRESSED && (!w || !w->isX11OverrideRedirect())) { if (w && !w->isFullscreen()) { const CBox real = {w->m_realPosition->value().x, w->m_realPosition->value().y, w->m_realSize->value().x, w->m_realSize->value().y}; const CBox grab = {real.x - BORDER_GRAB_AREA, real.y - BORDER_GRAB_AREA, real.width + 2 * BORDER_GRAB_AREA, real.height + 2 * BORDER_GRAB_AREA}; @@ -765,11 +765,11 @@ void CInputManager::processMouseDownNormal(const IPointer::SButtonEvent& e) { && (w && g_pCompositor->m_lastWindow.lock() != w) /* window should change */) { // a bit hacky // if we only pressed one button, allow us to refocus. m_lCurrentlyHeldButtons.size() > 0 will stick the focus - if (m_lCurrentlyHeldButtons.size() == 1) { - const auto COPY = m_lCurrentlyHeldButtons; - m_lCurrentlyHeldButtons.clear(); + if (m_currentlyHeldButtons.size() == 1) { + const auto COPY = m_currentlyHeldButtons; + m_currentlyHeldButtons.clear(); refocus(); - m_lCurrentlyHeldButtons = COPY; + m_currentlyHeldButtons = COPY; } else refocus(); } @@ -795,9 +795,9 @@ void CInputManager::processMouseDownNormal(const IPointer::SButtonEvent& e) { g_pCompositor->setActiveMonitor(PMON); if (g_pSeatManager->seatGrab && e.state == WL_POINTER_BUTTON_STATE_PRESSED) { - m_bHardInput = true; + m_hardInput = true; simulateMouseMovement(); - m_bHardInput = false; + m_hardInput = false; } } @@ -820,7 +820,7 @@ void CInputManager::processMouseDownKill(const IPointer::SButtonEvent& e) { } // reset click behavior mode - m_ecbClickBehavior = CLICKMODE_DEFAULT; + m_clickBehavior = CLICKMODE_DEFAULT; } void CInputManager::onMouseWheel(IPointer::SAxisEvent e) { @@ -844,7 +844,7 @@ void CInputManager::onMouseWheel(IPointer::SAxisEvent e) { if (!passEvent) return; - if (!m_bLastFocusOnLS) { + if (!m_lastFocusOnLS) { const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal(); const auto PWINDOW = g_pCompositor->vectorToWindowUnified(MOUSECOORDS, RESERVED_EXTENTS | INPUT_EXTENTS | ALLOW_FLOATING); @@ -890,24 +890,24 @@ void CInputManager::onMouseWheel(IPointer::SAxisEvent e) { const int interval = factor != 0 ? std::round(120 * (1 / factor)) : 120; // reset the accumulator when timeout is reached or direction/axis has changed - if (std::signbit(e.deltaDiscrete) != m_ScrollWheelState.lastEventSign || e.axis != m_ScrollWheelState.lastEventAxis || - e.timeMs - m_ScrollWheelState.lastEventTime > 500 /* 500ms taken from libinput default timeout */) { + if (std::signbit(e.deltaDiscrete) != m_scrollWheelState.lastEventSign || e.axis != m_scrollWheelState.lastEventAxis || + e.timeMs - m_scrollWheelState.lastEventTime > 500 /* 500ms taken from libinput default timeout */) { - m_ScrollWheelState.accumulatedScroll = 0; + m_scrollWheelState.accumulatedScroll = 0; // send 1 discrete on first event for responsiveness discrete = std::copysign(1, e.deltaDiscrete); } else discrete = 0; - for (int ac = m_ScrollWheelState.accumulatedScroll; ac >= interval; ac -= interval) { + for (int ac = m_scrollWheelState.accumulatedScroll; ac >= interval; ac -= interval) { discrete += std::copysign(1, e.deltaDiscrete); - m_ScrollWheelState.accumulatedScroll -= interval; + m_scrollWheelState.accumulatedScroll -= interval; } - m_ScrollWheelState.lastEventSign = std::signbit(e.deltaDiscrete); - m_ScrollWheelState.lastEventAxis = e.axis; - m_ScrollWheelState.lastEventTime = e.timeMs; - m_ScrollWheelState.accumulatedScroll += std::abs(e.deltaDiscrete); + m_scrollWheelState.lastEventSign = std::signbit(e.deltaDiscrete); + m_scrollWheelState.lastEventAxis = e.axis; + m_scrollWheelState.lastEventTime = e.timeMs; + m_scrollWheelState.accumulatedScroll += std::abs(e.deltaDiscrete); delta = 15.0 * discrete * factor; } @@ -924,7 +924,7 @@ Vector2D CInputManager::getMouseCoordsInternal() { } void CInputManager::newKeyboard(SP keyboard) { - const auto PNEWKEYBOARD = m_vKeyboards.emplace_back(CKeyboard::create(keyboard)); + const auto PNEWKEYBOARD = m_keyboards.emplace_back(CKeyboard::create(keyboard)); setupKeyboard(PNEWKEYBOARD); @@ -932,7 +932,7 @@ void CInputManager::newKeyboard(SP keyboard) { } void CInputManager::newVirtualKeyboard(SP keyboard) { - const auto PNEWKEYBOARD = m_vKeyboards.emplace_back(CVirtualKeyboard::create(keyboard)); + const auto PNEWKEYBOARD = m_keyboards.emplace_back(CVirtualKeyboard::create(keyboard)); setupKeyboard(PNEWKEYBOARD); @@ -942,7 +942,7 @@ void CInputManager::newVirtualKeyboard(SP keyboard) void CInputManager::setupKeyboard(SP keeb) { static auto PDPMS = CConfigValue("misc:key_press_enables_dpms"); - m_vHIDs.emplace_back(keeb); + m_hids.emplace_back(keeb); try { keeb->m_hlName = getNameForNewDevice(keeb->m_deviceName); @@ -1015,7 +1015,7 @@ void CInputManager::setupKeyboard(SP keeb) { } void CInputManager::setKeyboardLayout() { - for (auto const& k : m_vKeyboards) + for (auto const& k : m_keyboards) applyConfigToKeyboard(k); g_pKeybindManager->updateXKBTranslationState(); @@ -1077,7 +1077,7 @@ void CInputManager::applyConfigToKeyboard(SP pKeyboard) { } void CInputManager::newVirtualMouse(SP mouse) { - const auto PMOUSE = m_vPointers.emplace_back(CVirtualPointer::create(mouse)); + const auto PMOUSE = m_pointers.emplace_back(CVirtualPointer::create(mouse)); setupMouse(PMOUSE); @@ -1085,7 +1085,7 @@ void CInputManager::newVirtualMouse(SP mouse) { } void CInputManager::newMouse(SP mouse) { - const auto PMOUSE = m_vPointers.emplace_back(CMouse::create(mouse)); + const auto PMOUSE = m_pointers.emplace_back(CMouse::create(mouse)); setupMouse(PMOUSE); @@ -1093,7 +1093,7 @@ void CInputManager::newMouse(SP mouse) { } void CInputManager::setupMouse(SP mauz) { - m_vHIDs.emplace_back(mauz); + m_hids.emplace_back(mauz); try { mauz->m_hlName = getNameForNewDevice(mauz->m_deviceName); @@ -1128,11 +1128,11 @@ void CInputManager::setupMouse(SP mauz) { g_pSeatManager->setMouse(mauz); - m_tmrLastCursorMovement.reset(); + m_lastCursorMovement.reset(); } void CInputManager::setPointerConfigs() { - for (auto const& m : m_vPointers) { + for (auto const& m : m_pointers) { auto devname = m->m_hlName; const auto HASCONFIG = g_pConfigManager->deviceConfigExists(devname); @@ -1288,18 +1288,18 @@ void CInputManager::setPointerConfigs() { } static void removeFromHIDs(WP hid) { - std::erase_if(g_pInputManager->m_vHIDs, [hid](const auto& e) { return e.expired() || e == hid; }); + std::erase_if(g_pInputManager->m_hids, [hid](const auto& e) { return e.expired() || e == hid; }); g_pInputManager->updateCapabilities(); } void CInputManager::destroyKeyboard(SP pKeyboard) { Debug::log(LOG, "Keyboard at {:x} removed", (uintptr_t)pKeyboard.get()); - std::erase_if(m_vKeyboards, [pKeyboard](const auto& other) { return other == pKeyboard; }); + std::erase_if(m_keyboards, [pKeyboard](const auto& other) { return other == pKeyboard; }); - if (m_vKeyboards.size() > 0) { + if (m_keyboards.size() > 0) { bool found = false; - for (auto const& k : m_vKeyboards | std::views::reverse) { + for (auto const& k : m_keyboards | std::views::reverse) { if (!k) continue; @@ -1319,9 +1319,9 @@ void CInputManager::destroyKeyboard(SP pKeyboard) { void CInputManager::destroyPointer(SP mouse) { Debug::log(LOG, "Pointer at {:x} removed", (uintptr_t)mouse.get()); - std::erase_if(m_vPointers, [mouse](const auto& other) { return other == mouse; }); + std::erase_if(m_pointers, [mouse](const auto& other) { return other == mouse; }); - g_pSeatManager->setMouse(m_vPointers.size() > 0 ? m_vPointers.front() : nullptr); + g_pSeatManager->setMouse(m_pointers.size() > 0 ? m_pointers.front() : nullptr); if (!g_pSeatManager->mouse.expired()) unconstrainMouse(); @@ -1332,7 +1332,7 @@ void CInputManager::destroyPointer(SP mouse) { void CInputManager::destroyTouchDevice(SP touch) { Debug::log(LOG, "Touch device at {:x} removed", (uintptr_t)touch.get()); - std::erase_if(m_vTouches, [touch](const auto& other) { return other == touch; }); + std::erase_if(m_touches, [touch](const auto& other) { return other == touch; }); removeFromHIDs(touch); } @@ -1340,7 +1340,7 @@ void CInputManager::destroyTouchDevice(SP touch) { void CInputManager::destroyTablet(SP tablet) { Debug::log(LOG, "Tablet device at {:x} removed", (uintptr_t)tablet.get()); - std::erase_if(m_vTablets, [tablet](const auto& other) { return other == tablet; }); + std::erase_if(m_tablets, [tablet](const auto& other) { return other == tablet; }); removeFromHIDs(tablet); } @@ -1348,7 +1348,7 @@ void CInputManager::destroyTablet(SP tablet) { void CInputManager::destroyTabletTool(SP tool) { Debug::log(LOG, "Tablet tool at {:x} removed", (uintptr_t)tool.get()); - std::erase_if(m_vTabletTools, [tool](const auto& other) { return other == tool; }); + std::erase_if(m_tabletTools, [tool](const auto& other) { return other == tool; }); removeFromHIDs(tool); } @@ -1356,7 +1356,7 @@ void CInputManager::destroyTabletTool(SP tool) { void CInputManager::destroyTabletPad(SP pad) { Debug::log(LOG, "Tablet pad at {:x} removed", (uintptr_t)pad.get()); - std::erase_if(m_vTabletPads, [pad](const auto& other) { return other == pad; }); + std::erase_if(m_tabletPads, [pad](const auto& other) { return other == pad; }); removeFromHIDs(pad); } @@ -1370,7 +1370,7 @@ void CInputManager::updateKeyboardsLeds(SP pKeyboard) { if (!leds.has_value()) return; - for (auto const& k : m_vKeyboards) { + for (auto const& k : m_keyboards) { k->updateLEDs(leds.value()); } } @@ -1389,7 +1389,7 @@ void CInputManager::onKeyboardKey(std::any event, SP pKeyboard) { auto e = std::any_cast(event); if (passEvent) { - const auto IME = m_sIMERelay.m_pIME.lock(); + const auto IME = m_relay.m_inputMethod.lock(); if (IME && IME->hasGrab() && !DISALLOWACTION) { IME->setKeyboard(pKeyboard); @@ -1414,7 +1414,7 @@ void CInputManager::onKeyboardMod(SP pKeyboard) { auto MODS = pKeyboard->m_modifiersState; MODS.depressed = ALLMODS; - const auto IME = m_sIMERelay.m_pIME.lock(); + const auto IME = m_relay.m_inputMethod.lock(); if (IME && IME->hasGrab() && !DISALLOWACTION) { IME->setKeyboard(pKeyboard); @@ -1444,7 +1444,7 @@ bool CInputManager::shouldIgnoreVirtualKeyboard(SP pKeyboard) { CVirtualKeyboard* vk = (CVirtualKeyboard*)pKeyboard.get(); - return !pKeyboard || (!m_sIMERelay.m_pIME.expired() && m_sIMERelay.m_pIME->grabClient() == vk->getClient()); + return !pKeyboard || (!m_relay.m_inputMethod.expired() && m_relay.m_inputMethod->grabClient() == vk->getClient()); } void CInputManager::refocus() { @@ -1452,7 +1452,7 @@ void CInputManager::refocus() { } bool CInputManager::refocusLastWindow(PHLMONITOR pMonitor) { - if (!m_dExclusiveLSes.empty()) { + if (!m_exclusiveLSes.empty()) { Debug::log(LOG, "CInputManager::refocusLastWindow: ignoring, exclusive LS present."); return false; } @@ -1505,7 +1505,7 @@ void CInputManager::unconstrainMouse() { if (g_pSeatManager->mouse.expired()) return; - for (auto const& c : m_vConstraints) { + for (auto const& c : m_constraints) { const auto C = c.lock(); if (!C) @@ -1519,7 +1519,7 @@ void CInputManager::unconstrainMouse() { } bool CInputManager::isConstrained() { - return std::any_of(m_vConstraints.begin(), m_vConstraints.end(), [](auto const& c) { + return std::any_of(m_constraints.begin(), m_constraints.end(), [](auto const& c) { const auto constraint = c.lock(); return constraint && constraint->isActive() && constraint->owner()->resource() == g_pCompositor->m_lastFocus; }); @@ -1538,7 +1538,7 @@ bool CInputManager::isLocked() { void CInputManager::updateCapabilities() { uint32_t caps = 0; - for (auto const& h : m_vHIDs) { + for (auto const& h : m_hids) { if (h.expired()) continue; @@ -1546,14 +1546,14 @@ void CInputManager::updateCapabilities() { } g_pSeatManager->updateCapabilities(caps); - m_uiCapabilities = caps; + m_capabilities = caps; } uint32_t CInputManager::accumulateModsFromAllKBs() { uint32_t finalMask = 0; - for (auto const& kb : m_vKeyboards) { + for (auto const& kb : m_keyboards) { if (kb->isVirtual() && shouldIgnoreVirtualKeyboard(kb)) continue; @@ -1568,7 +1568,7 @@ uint32_t CInputManager::accumulateModsFromAllKBs() { void CInputManager::disableAllKeyboards(bool virt) { - for (auto const& k : m_vKeyboards) { + for (auto const& k : m_keyboards) { if (k->isVirtual() != virt) continue; @@ -1577,8 +1577,8 @@ void CInputManager::disableAllKeyboards(bool virt) { } void CInputManager::newTouchDevice(SP pDevice) { - const auto PNEWDEV = m_vTouches.emplace_back(CTouchDevice::create(pDevice)); - m_vHIDs.emplace_back(PNEWDEV); + const auto PNEWDEV = m_touches.emplace_back(CTouchDevice::create(pDevice)); + m_hids.emplace_back(PNEWDEV); try { PNEWDEV->m_hlName = getNameForNewDevice(PNEWDEV->m_deviceName); @@ -1647,13 +1647,13 @@ void CInputManager::setTouchDeviceConfigs(SP dev) { return; } - for (auto const& m : m_vTouches) { + for (auto const& m : m_touches) { setConfig(m); } } void CInputManager::setTabletConfigs() { - for (auto const& t : m_vTablets) { + for (auto const& t : m_tablets) { if (t->aq()->getLibinputHandle()) { const auto NAME = t->m_hlName; const auto LIBINPUTDEV = t->aq()->getLibinputHandle(); @@ -1696,7 +1696,7 @@ void CInputManager::setTabletConfigs() { } void CInputManager::newSwitch(SP pDevice) { - const auto PNEWDEV = &m_lSwitches.emplace_back(); + const auto PNEWDEV = &m_switches.emplace_back(); PNEWDEV->pDevice = pDevice; Debug::log(LOG, "New switch with name \"{}\" added", pDevice->getName()); @@ -1722,20 +1722,20 @@ void CInputManager::newSwitch(SP pDevice) { } void CInputManager::destroySwitch(SSwitchDevice* pDevice) { - m_lSwitches.remove(*pDevice); + m_switches.remove(*pDevice); } void CInputManager::setCursorImageUntilUnset(std::string name) { g_pHyprRenderer->setCursorFromName(name); - m_bCursorImageOverridden = true; - m_sCursorSurfaceInfo.inUse = false; + m_cursorImageOverridden = true; + m_cursorSurfaceInfo.inUse = false; } void CInputManager::unsetCursorImage() { - if (!m_bCursorImageOverridden) + if (!m_cursorImageOverridden) return; - m_bCursorImageOverridden = false; + m_cursorImageOverridden = false; restoreCursorIconToApp(); } @@ -1753,14 +1753,14 @@ std::string CInputManager::getNameForNewDevice(std::string internalName) { auto makeNewName = [&]() { return (proposedNewName.empty() ? "unknown-device" : proposedNewName) + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }; - while (std::find_if(m_vHIDs.begin(), m_vHIDs.end(), [&](const auto& other) { return other->m_hlName == makeNewName(); }) != m_vHIDs.end()) + while (std::find_if(m_hids.begin(), m_hids.end(), [&](const auto& other) { return other->m_hlName == makeNewName(); }) != m_hids.end()) dupeno++; return makeNewName(); } void CInputManager::releaseAllMouseButtons() { - const auto buttonsCopy = m_lCurrentlyHeldButtons; + const auto buttonsCopy = m_currentlyHeldButtons; if (PROTO::data->dndActive()) return; @@ -1769,13 +1769,13 @@ void CInputManager::releaseAllMouseButtons() { g_pSeatManager->sendPointerButton(Time::millis(Time::steadyNow()), mb, WL_POINTER_BUTTON_STATE_RELEASED); } - m_lCurrentlyHeldButtons.clear(); + m_currentlyHeldButtons.clear(); } void CInputManager::setCursorIconOnBorder(PHLWINDOW w) { // do not override cursor icons set by mouse binds - if (g_pInputManager->currentlyDraggedWindow.expired()) { - m_eBorderIconDirection = BORDERICON_NONE; + if (g_pInputManager->m_currentlyDraggedWindow.expired()) { + m_borderIconDirection = BORDERICON_NONE; return; } @@ -1797,7 +1797,7 @@ void CInputManager::setCursorIconOnBorder(PHLWINDOW w) { if (w->hasPopupAt(mouseCoords)) direction = BORDERICON_NONE; - else if (!boxFullGrabInput.containsPoint(mouseCoords) || (!m_lCurrentlyHeldButtons.empty() && currentlyDraggedWindow.expired())) + else if (!boxFullGrabInput.containsPoint(mouseCoords) || (!m_currentlyHeldButtons.empty() && m_currentlyDraggedWindow.expired())) direction = BORDERICON_NONE; else { @@ -1857,10 +1857,10 @@ void CInputManager::setCursorIconOnBorder(PHLWINDOW w) { } } - if (direction == m_eBorderIconDirection) + if (direction == m_borderIconDirection) return; - m_eBorderIconDirection = direction; + m_borderIconDirection = direction; switch (direction) { case BORDERICON_NONE: unsetCursorImage(); break; @@ -1878,6 +1878,6 @@ void CInputManager::setCursorIconOnBorder(PHLWINDOW w) { void CInputManager::recheckMouseWarpOnMouseInput() { static auto PWARPFORNONMOUSE = CConfigValue("cursor:warp_back_after_non_mouse_input"); - if (!m_bLastInputMouse && *PWARPFORNONMOUSE) - g_pPointerManager->warpTo(m_vLastMousePos); + if (!m_lastInputMouse && *PWARPFORNONMOUSE) + g_pPointerManager->warpTo(m_lastMousePos); } diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp index 62483c41..549a72fa 100644 --- a/src/managers/input/InputManager.hpp +++ b/src/managers/input/InputManager.hpp @@ -143,44 +143,44 @@ class CInputManager { void onTabletTip(CTablet::STipEvent); void onTabletButton(CTablet::SButtonEvent); - STouchData m_sTouchData; + STouchData m_touchData; // for dragging floating windows - PHLWINDOWREF currentlyDraggedWindow; - eMouseBindMode dragMode = MBIND_INVALID; - bool m_bWasDraggingWindow = false; - bool m_bDragThresholdReached = false; + PHLWINDOWREF m_currentlyDraggedWindow; + eMouseBindMode m_dragMode = MBIND_INVALID; + bool m_wasDraggingWindow = false; + bool m_dragThresholdReached = false; // for refocus to be forced - PHLWINDOWREF m_pForcedFocus; + PHLWINDOWREF m_forcedFocus; - std::vector> m_vKeyboards; - std::vector> m_vPointers; - std::vector> m_vTouches; - std::vector> m_vTablets; - std::vector> m_vTabletTools; - std::vector> m_vTabletPads; - std::vector> m_vHIDs; // general container for all HID devices connected to the input manager. + std::vector> m_keyboards; + std::vector> m_pointers; + std::vector> m_touches; + std::vector> m_tablets; + std::vector> m_tabletTools; + std::vector> m_tabletPads; + std::vector> m_hids; // general container for all HID devices connected to the input manager. // Switches - std::list m_lSwitches; + std::list m_switches; // Exclusive layer surfaces - std::vector m_dExclusiveLSes; + std::vector m_exclusiveLSes; // constraints - std::vector> m_vConstraints; + std::vector> m_constraints; // void newIdleInhibitor(std::any); void recheckIdleInhibitorStatus(); bool isWindowInhibiting(const PHLWINDOW& pWindow, bool onlyHl = true); - SSwipeGesture m_sActiveSwipe; + SSwipeGesture m_activeSwipe; - CTimer m_tmrLastCursorMovement; + CTimer m_lastCursorMovement; - CInputMethodRelay m_sIMERelay; + CInputMethodRelay m_relay; // for shared mods uint32_t accumulateModsFromAllKBs(); @@ -198,20 +198,19 @@ class CInputManager { void releaseAllMouseButtons(); // for some bugs in follow mouse 0 - bool m_bLastFocusOnLS = false; - bool m_bLastFocusOnIMEPopup = false; + bool m_lastFocusOnLS = false; // for hard input e.g. clicks - bool m_bHardInput = false; + bool m_hardInput = false; // for hiding cursor on touch - bool m_bLastInputTouch = false; + bool m_lastInputTouch = false; // for tracking mouse refocus - PHLWINDOWREF m_pLastMouseFocus; + PHLWINDOWREF m_lastMouseFocus; // - bool m_bEmptyFocusCursorSet = false; + bool m_emptyFocusCursorSet = false; private: // Listeners @@ -221,14 +220,14 @@ class CInputManager { CHyprSignalListener newVirtualKeyboard; CHyprSignalListener newVirtualMouse; CHyprSignalListener setCursor; - } m_sListeners; + } m_listeners; - bool m_bCursorImageOverridden = false; - eBorderIconDirection m_eBorderIconDirection = BORDERICON_NONE; + bool m_cursorImageOverridden = false; + eBorderIconDirection m_borderIconDirection = BORDERICON_NONE; // for click behavior override - eClickBehaviorMode m_ecbClickBehavior = CLICKMODE_DEFAULT; - Vector2D m_vLastCursorPosFloored = Vector2D(); + eClickBehaviorMode m_clickBehavior = CLICKMODE_DEFAULT; + Vector2D m_lastCursorPosFloored = Vector2D(); void setupKeyboard(SP keeb); void setupMouse(SP mauz); @@ -240,7 +239,7 @@ class CInputManager { void disableAllKeyboards(bool virt = false); - uint32_t m_uiCapabilities = 0; + uint32_t m_capabilities = 0; void mouseMoveUnified(uint32_t, bool refocus = false, bool mouse = false); void recheckMouseWarpOnMouseInput(); @@ -250,21 +249,21 @@ class CInputManager { void applyConfigToKeyboard(SP); // this will be set after a refocus() - WP m_pFoundSurfaceToFocus; - PHLLSREF m_pFoundLSToFocus; - PHLWINDOWREF m_pFoundWindowToFocus; + WP m_foundSurfaceToFocus; + PHLLSREF m_foundLSToFocus; + PHLWINDOWREF m_foundWindowToFocus; // used for warping back after non-mouse input - Vector2D m_vLastMousePos = {}; - double m_fMousePosDelta = 0; - bool m_bLastInputMouse = true; + Vector2D m_lastMousePos = {}; + double m_mousePosDelta = 0; + bool m_lastInputMouse = true; // for holding focus on buttons held - bool m_bFocusHeldByButtons = false; - bool m_bRefocusHeldByButtons = false; + bool m_focusHeldByButtons = false; + bool m_refocusHeldByButtons = false; // for releasing mouse buttons - std::list m_lCurrentlyHeldButtons; + std::list m_currentlyHeldButtons; // idle inhibitors struct SIdleInhibitor { @@ -272,7 +271,7 @@ class CInputManager { bool nonDesktop = false; CHyprSignalListener surfaceDestroyListener; }; - std::vector> m_vIdleInhibitors; + std::vector> m_idleInhibitors; // swipe void beginWorkspaceSwipe(); @@ -292,7 +291,7 @@ class CInputManager { Vector2D vHotspot; std::string name; // if not empty, means set by name. bool inUse = false; - } m_sCursorSurfaceInfo; + } m_cursorSurfaceInfo; void restoreCursorIconToApp(); // no-op if restored @@ -302,7 +301,7 @@ class CInputManager { bool lastEventAxis = false; uint32_t lastEventTime = 0; uint32_t accumulatedScroll = 0; - } m_ScrollWheelState; + } m_scrollWheelState; friend class CKeybindManager; friend class CWLSurface; diff --git a/src/managers/input/InputMethodPopup.cpp b/src/managers/input/InputMethodPopup.cpp index d0706bad..c374f63c 100644 --- a/src/managers/input/InputMethodPopup.cpp +++ b/src/managers/input/InputMethodPopup.cpp @@ -7,17 +7,17 @@ #include "../../helpers/Monitor.hpp" #include "../../render/Renderer.hpp" -CInputPopup::CInputPopup(SP popup_) : popup(popup_) { - listeners.commit = popup_->events.commit.registerListener([this](std::any d) { onCommit(); }); - listeners.map = popup_->events.map.registerListener([this](std::any d) { onMap(); }); - listeners.unmap = popup_->events.unmap.registerListener([this](std::any d) { onUnmap(); }); - listeners.destroy = popup_->events.destroy.registerListener([this](std::any d) { onDestroy(); }); - surface = CWLSurface::create(); - surface->assign(popup_->surface()); +CInputPopup::CInputPopup(SP popup_) : m_popup(popup_) { + m_listeners.commit = popup_->events.commit.registerListener([this](std::any d) { onCommit(); }); + m_listeners.map = popup_->events.map.registerListener([this](std::any d) { onMap(); }); + m_listeners.unmap = popup_->events.unmap.registerListener([this](std::any d) { onUnmap(); }); + m_listeners.destroy = popup_->events.destroy.registerListener([this](std::any d) { onDestroy(); }); + m_surface = CWLSurface::create(); + m_surface->assign(popup_->surface()); } SP CInputPopup::queryOwner() { - const auto FOCUSED = g_pInputManager->m_sIMERelay.getFocusedTextInput(); + const auto FOCUSED = g_pInputManager->m_relay.getFocusedTextInput(); if (!FOCUSED) return nullptr; @@ -26,7 +26,7 @@ SP CInputPopup::queryOwner() { } void CInputPopup::onDestroy() { - g_pInputManager->m_sIMERelay.removePopup(this); + g_pInputManager->m_relay.removePopup(this); } void CInputPopup::onMap() { @@ -40,7 +40,7 @@ void CInputPopup::onMap() { if (!PMONITOR) return; - PROTO::fractional->sendScale(surface->resource(), PMONITOR->m_scale); + PROTO::fractional->sendScale(m_surface->resource(), PMONITOR->m_scale); } void CInputPopup::onUnmap() { @@ -73,15 +73,15 @@ void CInputPopup::damageSurface() { } Vector2D pos = globalBox().pos(); - g_pHyprRenderer->damageSurface(surface->resource(), pos.x, pos.y); + g_pHyprRenderer->damageSurface(m_surface->resource(), pos.x, pos.y); } void CInputPopup::updateBox() { - if (!popup->mapped) + if (!m_popup->mapped) return; const auto OWNER = queryOwner(); - const auto PFOCUSEDTI = g_pInputManager->m_sIMERelay.getFocusedTextInput(); + const auto PFOCUSEDTI = g_pInputManager->m_relay.getFocusedTextInput(); if (!PFOCUSEDTI) return; @@ -102,7 +102,7 @@ void CInputPopup::updateBox() { cursorBoxParent = {0, 0, (int)parentBox.w, (int)parentBox.h}; } - Vector2D currentPopupSize = surface->getViewporterCorrectedSize() / surface->resource()->current.scale; + Vector2D currentPopupSize = m_surface->getViewporterCorrectedSize() / m_surface->resource()->current.scale; PHLMONITOR pMonitor = g_pCompositor->getMonitorFromVector(parentBox.middle()); @@ -118,24 +118,24 @@ void CInputPopup::updateBox() { popupOffset.x -= popupOverflow; CBox cursorBoxLocal({-popupOffset.x, -popupOffset.y}, cursorBoxParent.size()); - popup->sendInputRectangle(cursorBoxLocal); + m_popup->sendInputRectangle(cursorBoxLocal); CBox popupBoxParent(cursorBoxParent.pos() + popupOffset, currentPopupSize); - if (popupBoxParent != lastBoxLocal) { + if (popupBoxParent != m_lastBoxLocal) { damageEntire(); - lastBoxLocal = popupBoxParent; + m_lastBoxLocal = popupBoxParent; } damageSurface(); - if (const auto PM = g_pCompositor->getMonitorFromCursor(); PM && PM->m_id != lastMonitor) { - const auto PML = g_pCompositor->getMonitorFromID(lastMonitor); + if (const auto PM = g_pCompositor->getMonitorFromCursor(); PM && PM->m_id != m_lastMonitor) { + const auto PML = g_pCompositor->getMonitorFromID(m_lastMonitor); if (PML) - surface->resource()->leave(PML->m_self.lock()); + m_surface->resource()->leave(PML->m_self.lock()); - surface->resource()->enter(PM->m_self.lock()); + m_surface->resource()->enter(PM->m_self.lock()); - lastMonitor = PM->m_id; + m_lastMonitor = PM->m_id; } } @@ -148,7 +148,7 @@ CBox CInputPopup::globalBox() { } CBox parentBox = OWNER->getSurfaceBoxGlobal().value_or(CBox{0, 0, 500, 500}); - return lastBoxLocal.copy().translate(parentBox.pos()); + return m_lastBoxLocal.copy().translate(parentBox.pos()); } bool CInputPopup::isVecInPopup(const Vector2D& point) { @@ -156,5 +156,5 @@ bool CInputPopup::isVecInPopup(const Vector2D& point) { } SP CInputPopup::getSurface() { - return surface->resource(); + return m_surface->resource(); } diff --git a/src/managers/input/InputMethodPopup.hpp b/src/managers/input/InputMethodPopup.hpp index 53c11cff..20767963 100644 --- a/src/managers/input/InputMethodPopup.hpp +++ b/src/managers/input/InputMethodPopup.hpp @@ -29,15 +29,15 @@ class CInputPopup { void onMap(); void onUnmap(); - WP popup; - SP surface; - CBox lastBoxLocal; - MONITORID lastMonitor = MONITOR_INVALID; + WP m_popup; + SP m_surface; + CBox m_lastBoxLocal; + MONITORID m_lastMonitor = MONITOR_INVALID; struct { CHyprSignalListener map; CHyprSignalListener unmap; CHyprSignalListener destroy; CHyprSignalListener commit; - } listeners; + } m_listeners; }; diff --git a/src/managers/input/InputMethodRelay.cpp b/src/managers/input/InputMethodRelay.cpp index c51d3ebe..bafa9002 100644 --- a/src/managers/input/InputMethodRelay.cpp +++ b/src/managers/input/InputMethodRelay.cpp @@ -11,13 +11,13 @@ CInputMethodRelay::CInputMethodRelay() { static auto P = g_pHookSystem->hookDynamic("keyboardFocus", [&](void* self, SCallbackInfo& info, std::any param) { onKeyboardFocus(std::any_cast>(param)); }); - listeners.newTIV3 = PROTO::textInputV3->events.newTextInput.registerListener([this](std::any ti) { onNewTextInput(std::any_cast>(ti)); }); - listeners.newTIV1 = PROTO::textInputV1->events.newTextInput.registerListener([this](std::any ti) { onNewTextInput(std::any_cast>(ti)); }); - listeners.newIME = PROTO::ime->events.newIME.registerListener([this](std::any ime) { onNewIME(std::any_cast>(ime)); }); + m_listeners.newTIV3 = PROTO::textInputV3->events.newTextInput.registerListener([this](std::any ti) { onNewTextInput(std::any_cast>(ti)); }); + m_listeners.newTIV1 = PROTO::textInputV1->events.newTextInput.registerListener([this](std::any ti) { onNewTextInput(std::any_cast>(ti)); }); + m_listeners.newIME = PROTO::ime->events.newIME.registerListener([this](std::any ime) { onNewIME(std::any_cast>(ime)); }); } void CInputMethodRelay::onNewIME(SP pIME) { - if (!m_pIME.expired()) { + if (!m_inputMethod.expired()) { Debug::log(ERR, "Cannot register 2 IMEs at once!"); pIME->unavailable(); @@ -25,9 +25,9 @@ void CInputMethodRelay::onNewIME(SP pIME) { return; } - m_pIME = pIME; + m_inputMethod = pIME; - listeners.commitIME = pIME->events.onCommit.registerListener([this](std::any d) { + m_listeners.commitIME = pIME->events.onCommit.registerListener([this](std::any d) { const auto PTI = getFocusedTextInput(); if (!PTI) { @@ -35,10 +35,10 @@ void CInputMethodRelay::onNewIME(SP pIME) { return; } - PTI->updateIMEState(m_pIME.lock()); + PTI->updateIMEState(m_inputMethod.lock()); }); - listeners.destroyIME = pIME->events.destroy.registerListener([this](std::any d) { + m_listeners.destroyIME = pIME->events.destroy.registerListener([this](std::any d) { const auto PTI = getFocusedTextInput(); Debug::log(LOG, "IME Destroy"); @@ -46,11 +46,11 @@ void CInputMethodRelay::onNewIME(SP pIME) { if (PTI) PTI->leave(); - m_pIME.reset(); + m_inputMethod.reset(); }); - listeners.newPopup = pIME->events.newPopup.registerListener([this](std::any d) { - m_vIMEPopups.emplace_back(makeUnique(std::any_cast>(d))); + m_listeners.newPopup = pIME->events.newPopup.registerListener([this](std::any d) { + m_inputMethodPopups.emplace_back(makeUnique(std::any_cast>(d))); Debug::log(LOG, "New input popup"); }); @@ -58,7 +58,7 @@ void CInputMethodRelay::onNewIME(SP pIME) { if (!g_pCompositor->m_lastFocus) return; - for (auto const& ti : m_vTextInputs) { + for (auto const& ti : m_textInputs) { if (ti->client() != g_pCompositor->m_lastFocus->client()) continue; @@ -70,14 +70,14 @@ void CInputMethodRelay::onNewIME(SP pIME) { } void CInputMethodRelay::removePopup(CInputPopup* pPopup) { - std::erase_if(m_vIMEPopups, [pPopup](const auto& other) { return other.get() == pPopup; }); + std::erase_if(m_inputMethodPopups, [pPopup](const auto& other) { return other.get() == pPopup; }); } CTextInput* CInputMethodRelay::getFocusedTextInput() { if (!g_pCompositor->m_lastFocus) return nullptr; - for (auto const& ti : m_vTextInputs) { + for (auto const& ti : m_textInputs) { if (ti->focusedSurface() == g_pCompositor->m_lastFocus) return ti.get(); } @@ -86,58 +86,58 @@ CTextInput* CInputMethodRelay::getFocusedTextInput() { } void CInputMethodRelay::onNewTextInput(WP tiv3) { - m_vTextInputs.emplace_back(makeUnique(tiv3)); + m_textInputs.emplace_back(makeUnique(tiv3)); } void CInputMethodRelay::onNewTextInput(WP pTIV1) { - m_vTextInputs.emplace_back(makeUnique(pTIV1)); + m_textInputs.emplace_back(makeUnique(pTIV1)); } void CInputMethodRelay::removeTextInput(CTextInput* pInput) { - std::erase_if(m_vTextInputs, [pInput](const auto& other) { return other.get() == pInput; }); + std::erase_if(m_textInputs, [pInput](const auto& other) { return other.get() == pInput; }); } void CInputMethodRelay::updateAllPopups() { - for (auto const& p : m_vIMEPopups) { + for (auto const& p : m_inputMethodPopups) { p->onCommit(); } } void CInputMethodRelay::activateIME(CTextInput* pInput, bool shouldCommit) { - if (m_pIME.expired()) + if (m_inputMethod.expired()) return; - m_pIME->activate(); + m_inputMethod->activate(); if (shouldCommit) commitIMEState(pInput); } void CInputMethodRelay::deactivateIME(CTextInput* pInput, bool shouldCommit) { - if (m_pIME.expired()) + if (m_inputMethod.expired()) return; - m_pIME->deactivate(); + m_inputMethod->deactivate(); if (shouldCommit) commitIMEState(pInput); } void CInputMethodRelay::commitIMEState(CTextInput* pInput) { - if (m_pIME.expired()) + if (m_inputMethod.expired()) return; - pInput->commitStateToIME(m_pIME.lock()); + pInput->commitStateToIME(m_inputMethod.lock()); } void CInputMethodRelay::onKeyboardFocus(SP pSurface) { - if (m_pIME.expired()) + if (m_inputMethod.expired()) return; - if (pSurface == m_pLastKbFocus) + if (pSurface == m_lastKbFocus) return; - m_pLastKbFocus = pSurface; + m_lastKbFocus = pSurface; - for (auto const& ti : m_vTextInputs) { + for (auto const& ti : m_textInputs) { if (!ti->focusedSurface()) continue; @@ -147,7 +147,7 @@ void CInputMethodRelay::onKeyboardFocus(SP pSurface) { if (!pSurface) return; - for (auto const& ti : m_vTextInputs) { + for (auto const& ti : m_textInputs) { if (!ti->isV3()) continue; @@ -159,7 +159,7 @@ void CInputMethodRelay::onKeyboardFocus(SP pSurface) { } CInputPopup* CInputMethodRelay::popupFromCoords(const Vector2D& point) { - for (auto const& p : m_vIMEPopups) { + for (auto const& p : m_inputMethodPopups) { if (p->isVecInPopup(point)) return p.get(); } @@ -168,7 +168,7 @@ CInputPopup* CInputMethodRelay::popupFromCoords(const Vector2D& point) { } CInputPopup* CInputMethodRelay::popupFromSurface(const SP surface) { - for (auto const& p : m_vIMEPopups) { + for (auto const& p : m_inputMethodPopups) { if (p->getSurface() == surface) return p.get(); } diff --git a/src/managers/input/InputMethodRelay.hpp b/src/managers/input/InputMethodRelay.hpp index 602a939a..cb631b12 100644 --- a/src/managers/input/InputMethodRelay.hpp +++ b/src/managers/input/InputMethodRelay.hpp @@ -37,13 +37,13 @@ class CInputMethodRelay { void updateAllPopups(); - WP m_pIME; + WP m_inputMethod; private: - std::vector> m_vTextInputs; - std::vector> m_vIMEPopups; + std::vector> m_textInputs; + std::vector> m_inputMethodPopups; - WP m_pLastKbFocus; + WP m_lastKbFocus; struct { CHyprSignalListener newTIV3; @@ -52,7 +52,7 @@ class CInputMethodRelay { CHyprSignalListener commitIME; CHyprSignalListener destroyIME; CHyprSignalListener newPopup; - } listeners; + } m_listeners; friend class CHyprRenderer; friend class CInputManager; diff --git a/src/managers/input/Swipe.cpp b/src/managers/input/Swipe.cpp index 62c0332a..f957c96e 100644 --- a/src/managers/input/Swipe.cpp +++ b/src/managers/input/Swipe.cpp @@ -33,11 +33,11 @@ void CInputManager::beginWorkspaceSwipe() { Debug::log(LOG, "Starting a swipe from {}", PWORKSPACE->m_name); - m_sActiveSwipe.pWorkspaceBegin = PWORKSPACE; - m_sActiveSwipe.delta = 0; - m_sActiveSwipe.pMonitor = g_pCompositor->m_lastMonitor; - m_sActiveSwipe.avgSpeed = 0; - m_sActiveSwipe.speedPoints = 0; + m_activeSwipe.pWorkspaceBegin = PWORKSPACE; + m_activeSwipe.delta = 0; + m_activeSwipe.pMonitor = g_pCompositor->m_lastMonitor; + m_activeSwipe.avgSpeed = 0; + m_activeSwipe.speedPoints = 0; if (PWORKSPACE->m_hasFullscreenWindow) { for (auto const& ls : g_pCompositor->m_lastMonitor->m_layerSurfaceLayers[2]) { @@ -49,7 +49,7 @@ void CInputManager::beginWorkspaceSwipe() { void CInputManager::onSwipeEnd(IPointer::SSwipeEndEvent e) { EMIT_HOOK_EVENT_CANCELLABLE("swipeEnd", e); - if (!m_sActiveSwipe.pWorkspaceBegin) + if (!m_activeSwipe.pWorkspaceBegin) return; // no valid swipe endWorkspaceSwipe(); } @@ -61,7 +61,7 @@ void CInputManager::endWorkspaceSwipe() { static auto PSWIPENEW = CConfigValue("gestures:workspace_swipe_create_new"); static auto PSWIPEUSER = CConfigValue("gestures:workspace_swipe_use_r"); static auto PWORKSPACEGAP = CConfigValue("general:gaps_workspaces"); - const auto ANIMSTYLE = m_sActiveSwipe.pWorkspaceBegin->m_renderOffset->getStyle(); + const auto ANIMSTYLE = m_activeSwipe.pWorkspaceBegin->m_renderOffset->getStyle(); const bool VERTANIMS = ANIMSTYLE == "slidevert" || ANIMSTYLE.starts_with("slidefadevert"); // commit @@ -71,30 +71,30 @@ void CInputManager::endWorkspaceSwipe() { // If we've been swiping off the right end with PSWIPENEW enabled, there is // no workspace there yet, and we need to choose an ID for a new one now. - if (workspaceIDRight <= m_sActiveSwipe.pWorkspaceBegin->m_id && *PSWIPENEW) { + if (workspaceIDRight <= m_activeSwipe.pWorkspaceBegin->m_id && *PSWIPENEW) { workspaceIDRight = getWorkspaceIDNameFromString("r+1").id; } auto PWORKSPACER = g_pCompositor->getWorkspaceByID(workspaceIDRight); // not guaranteed if PSWIPENEW || PSWIPENUMBER auto PWORKSPACEL = g_pCompositor->getWorkspaceByID(workspaceIDLeft); // not guaranteed if PSWIPENUMBER - const auto RENDEROFFSETMIDDLE = m_sActiveSwipe.pWorkspaceBegin->m_renderOffset->value(); - const auto XDISTANCE = m_sActiveSwipe.pMonitor->m_size.x + *PWORKSPACEGAP; - const auto YDISTANCE = m_sActiveSwipe.pMonitor->m_size.y + *PWORKSPACEGAP; + const auto RENDEROFFSETMIDDLE = m_activeSwipe.pWorkspaceBegin->m_renderOffset->value(); + const auto XDISTANCE = m_activeSwipe.pMonitor->m_size.x + *PWORKSPACEGAP; + const auto YDISTANCE = m_activeSwipe.pMonitor->m_size.y + *PWORKSPACEGAP; PHLWORKSPACE pSwitchedTo = nullptr; - if ((abs(m_sActiveSwipe.delta) < SWIPEDISTANCE * *PSWIPEPERC && (*PSWIPEFORC == 0 || (*PSWIPEFORC != 0 && m_sActiveSwipe.avgSpeed < *PSWIPEFORC))) || - abs(m_sActiveSwipe.delta) < 2) { + if ((abs(m_activeSwipe.delta) < SWIPEDISTANCE * *PSWIPEPERC && (*PSWIPEFORC == 0 || (*PSWIPEFORC != 0 && m_activeSwipe.avgSpeed < *PSWIPEFORC))) || + abs(m_activeSwipe.delta) < 2) { // revert - if (abs(m_sActiveSwipe.delta) < 2) { + if (abs(m_activeSwipe.delta) < 2) { if (PWORKSPACEL) PWORKSPACEL->m_renderOffset->setValueAndWarp(Vector2D(0, 0)); if (PWORKSPACER) PWORKSPACER->m_renderOffset->setValueAndWarp(Vector2D(0, 0)); - m_sActiveSwipe.pWorkspaceBegin->m_renderOffset->setValueAndWarp(Vector2D(0, 0)); + m_activeSwipe.pWorkspaceBegin->m_renderOffset->setValueAndWarp(Vector2D(0, 0)); } else { - if (m_sActiveSwipe.delta < 0) { + if (m_activeSwipe.delta < 0) { // to left if (PWORKSPACEL) { @@ -111,31 +111,31 @@ void CInputManager::endWorkspaceSwipe() { *PWORKSPACER->m_renderOffset = Vector2D{XDISTANCE, 0.0}; } - *m_sActiveSwipe.pWorkspaceBegin->m_renderOffset = Vector2D(); + *m_activeSwipe.pWorkspaceBegin->m_renderOffset = Vector2D(); } - pSwitchedTo = m_sActiveSwipe.pWorkspaceBegin; - } else if (m_sActiveSwipe.delta < 0) { + pSwitchedTo = m_activeSwipe.pWorkspaceBegin; + } else if (m_activeSwipe.delta < 0) { // switch to left const auto RENDEROFFSET = PWORKSPACEL ? PWORKSPACEL->m_renderOffset->value() : Vector2D(); if (PWORKSPACEL) - m_sActiveSwipe.pMonitor->changeWorkspace(workspaceIDLeft); + m_activeSwipe.pMonitor->changeWorkspace(workspaceIDLeft); else { - m_sActiveSwipe.pMonitor->changeWorkspace(g_pCompositor->createNewWorkspace(workspaceIDLeft, m_sActiveSwipe.pMonitor->m_id)); + m_activeSwipe.pMonitor->changeWorkspace(g_pCompositor->createNewWorkspace(workspaceIDLeft, m_activeSwipe.pMonitor->m_id)); PWORKSPACEL = g_pCompositor->getWorkspaceByID(workspaceIDLeft); - PWORKSPACEL->rememberPrevWorkspace(m_sActiveSwipe.pWorkspaceBegin); + PWORKSPACEL->rememberPrevWorkspace(m_activeSwipe.pWorkspaceBegin); } PWORKSPACEL->m_renderOffset->setValue(RENDEROFFSET); PWORKSPACEL->m_alpha->setValueAndWarp(1.f); - m_sActiveSwipe.pWorkspaceBegin->m_renderOffset->setValue(RENDEROFFSETMIDDLE); + m_activeSwipe.pWorkspaceBegin->m_renderOffset->setValue(RENDEROFFSETMIDDLE); if (VERTANIMS) - *m_sActiveSwipe.pWorkspaceBegin->m_renderOffset = Vector2D(0.0, YDISTANCE); + *m_activeSwipe.pWorkspaceBegin->m_renderOffset = Vector2D(0.0, YDISTANCE); else - *m_sActiveSwipe.pWorkspaceBegin->m_renderOffset = Vector2D(XDISTANCE, 0.0); - m_sActiveSwipe.pWorkspaceBegin->m_alpha->setValueAndWarp(1.f); + *m_activeSwipe.pWorkspaceBegin->m_renderOffset = Vector2D(XDISTANCE, 0.0); + m_activeSwipe.pWorkspaceBegin->m_alpha->setValueAndWarp(1.f); g_pInputManager->unconstrainMouse(); @@ -147,22 +147,22 @@ void CInputManager::endWorkspaceSwipe() { const auto RENDEROFFSET = PWORKSPACER ? PWORKSPACER->m_renderOffset->value() : Vector2D(); if (PWORKSPACER) - m_sActiveSwipe.pMonitor->changeWorkspace(workspaceIDRight); + m_activeSwipe.pMonitor->changeWorkspace(workspaceIDRight); else { - m_sActiveSwipe.pMonitor->changeWorkspace(g_pCompositor->createNewWorkspace(workspaceIDRight, m_sActiveSwipe.pMonitor->m_id)); + m_activeSwipe.pMonitor->changeWorkspace(g_pCompositor->createNewWorkspace(workspaceIDRight, m_activeSwipe.pMonitor->m_id)); PWORKSPACER = g_pCompositor->getWorkspaceByID(workspaceIDRight); - PWORKSPACER->rememberPrevWorkspace(m_sActiveSwipe.pWorkspaceBegin); + PWORKSPACER->rememberPrevWorkspace(m_activeSwipe.pWorkspaceBegin); } PWORKSPACER->m_renderOffset->setValue(RENDEROFFSET); PWORKSPACER->m_alpha->setValueAndWarp(1.f); - m_sActiveSwipe.pWorkspaceBegin->m_renderOffset->setValue(RENDEROFFSETMIDDLE); + m_activeSwipe.pWorkspaceBegin->m_renderOffset->setValue(RENDEROFFSETMIDDLE); if (VERTANIMS) - *m_sActiveSwipe.pWorkspaceBegin->m_renderOffset = Vector2D(0.0, -YDISTANCE); + *m_activeSwipe.pWorkspaceBegin->m_renderOffset = Vector2D(0.0, -YDISTANCE); else - *m_sActiveSwipe.pWorkspaceBegin->m_renderOffset = Vector2D(-XDISTANCE, 0.0); - m_sActiveSwipe.pWorkspaceBegin->m_alpha->setValueAndWarp(1.f); + *m_activeSwipe.pWorkspaceBegin->m_renderOffset = Vector2D(-XDISTANCE, 0.0); + m_activeSwipe.pWorkspaceBegin->m_alpha->setValueAndWarp(1.f); g_pInputManager->unconstrainMouse(); @@ -170,18 +170,18 @@ void CInputManager::endWorkspaceSwipe() { pSwitchedTo = PWORKSPACER; } - m_sActiveSwipe.pWorkspaceBegin->rememberPrevWorkspace(pSwitchedTo); + m_activeSwipe.pWorkspaceBegin->rememberPrevWorkspace(pSwitchedTo); - g_pHyprRenderer->damageMonitor(m_sActiveSwipe.pMonitor.lock()); + g_pHyprRenderer->damageMonitor(m_activeSwipe.pMonitor.lock()); if (PWORKSPACEL) PWORKSPACEL->m_forceRendering = false; if (PWORKSPACER) PWORKSPACER->m_forceRendering = false; - m_sActiveSwipe.pWorkspaceBegin->m_forceRendering = false; + m_activeSwipe.pWorkspaceBegin->m_forceRendering = false; - m_sActiveSwipe.pWorkspaceBegin = nullptr; - m_sActiveSwipe.initialDirection = 0; + m_activeSwipe.pWorkspaceBegin = nullptr; + m_activeSwipe.initialDirection = 0; g_pInputManager->refocus(); @@ -194,13 +194,13 @@ void CInputManager::endWorkspaceSwipe() { void CInputManager::onSwipeUpdate(IPointer::SSwipeUpdateEvent e) { EMIT_HOOK_EVENT_CANCELLABLE("swipeUpdate", e); - if (!m_sActiveSwipe.pWorkspaceBegin) + if (!m_activeSwipe.pWorkspaceBegin) return; static auto PSWIPEINVR = CConfigValue("gestures:workspace_swipe_invert"); - const auto ANIMSTYLE = m_sActiveSwipe.pWorkspaceBegin->m_renderOffset->getStyle(); + const auto ANIMSTYLE = m_activeSwipe.pWorkspaceBegin->m_renderOffset->getStyle(); const bool VERTANIMS = ANIMSTYLE == "slidevert" || ANIMSTYLE.starts_with("slidefadevert"); - const double delta = m_sActiveSwipe.delta + (VERTANIMS ? (*PSWIPEINVR ? -e.delta.y : e.delta.y) : (*PSWIPEINVR ? -e.delta.x : e.delta.x)); + const double delta = m_activeSwipe.delta + (VERTANIMS ? (*PSWIPEINVR ? -e.delta.y : e.delta.y) : (*PSWIPEINVR ? -e.delta.x : e.delta.x)); updateWorkspaceSwipe(delta); } @@ -214,66 +214,66 @@ void CInputManager::updateWorkspaceSwipe(double delta) { static auto PWORKSPACEGAP = CConfigValue("general:gaps_workspaces"); const auto SWIPEDISTANCE = std::clamp(*PSWIPEDIST, (int64_t)1LL, (int64_t)UINT32_MAX); - const auto XDISTANCE = m_sActiveSwipe.pMonitor->m_size.x + *PWORKSPACEGAP; - const auto YDISTANCE = m_sActiveSwipe.pMonitor->m_size.y + *PWORKSPACEGAP; - const auto ANIMSTYLE = m_sActiveSwipe.pWorkspaceBegin->m_renderOffset->getStyle(); + const auto XDISTANCE = m_activeSwipe.pMonitor->m_size.x + *PWORKSPACEGAP; + const auto YDISTANCE = m_activeSwipe.pMonitor->m_size.y + *PWORKSPACEGAP; + const auto ANIMSTYLE = m_activeSwipe.pWorkspaceBegin->m_renderOffset->getStyle(); const bool VERTANIMS = ANIMSTYLE == "slidevert" || ANIMSTYLE.starts_with("slidefadevert"); - const double d = m_sActiveSwipe.delta - delta; - m_sActiveSwipe.delta = delta; + const double d = m_activeSwipe.delta - delta; + m_activeSwipe.delta = delta; - m_sActiveSwipe.avgSpeed = (m_sActiveSwipe.avgSpeed * m_sActiveSwipe.speedPoints + abs(d)) / (m_sActiveSwipe.speedPoints + 1); - m_sActiveSwipe.speedPoints++; + m_activeSwipe.avgSpeed = (m_activeSwipe.avgSpeed * m_activeSwipe.speedPoints + abs(d)) / (m_activeSwipe.speedPoints + 1); + m_activeSwipe.speedPoints++; auto workspaceIDLeft = getWorkspaceIDNameFromString((*PSWIPEUSER ? "r-1" : "m-1")).id; auto workspaceIDRight = getWorkspaceIDNameFromString((*PSWIPEUSER ? "r+1" : "m+1")).id; - if ((workspaceIDLeft == WORKSPACE_INVALID || workspaceIDRight == WORKSPACE_INVALID || workspaceIDLeft == m_sActiveSwipe.pWorkspaceBegin->m_id) && !*PSWIPENEW) { - m_sActiveSwipe.pWorkspaceBegin = nullptr; // invalidate the swipe + if ((workspaceIDLeft == WORKSPACE_INVALID || workspaceIDRight == WORKSPACE_INVALID || workspaceIDLeft == m_activeSwipe.pWorkspaceBegin->m_id) && !*PSWIPENEW) { + m_activeSwipe.pWorkspaceBegin = nullptr; // invalidate the swipe return; } - m_sActiveSwipe.pWorkspaceBegin->m_forceRendering = true; + m_activeSwipe.pWorkspaceBegin->m_forceRendering = true; - m_sActiveSwipe.delta = std::clamp(m_sActiveSwipe.delta, (double)-SWIPEDISTANCE, (double)SWIPEDISTANCE); + m_activeSwipe.delta = std::clamp(m_activeSwipe.delta, (double)-SWIPEDISTANCE, (double)SWIPEDISTANCE); - if ((m_sActiveSwipe.pWorkspaceBegin->m_id == workspaceIDLeft && *PSWIPENEW && (m_sActiveSwipe.delta < 0)) || - (m_sActiveSwipe.delta > 0 && m_sActiveSwipe.pWorkspaceBegin->getWindows() == 0 && workspaceIDRight <= m_sActiveSwipe.pWorkspaceBegin->m_id) || - (m_sActiveSwipe.delta < 0 && m_sActiveSwipe.pWorkspaceBegin->m_id <= workspaceIDLeft)) { + if ((m_activeSwipe.pWorkspaceBegin->m_id == workspaceIDLeft && *PSWIPENEW && (m_activeSwipe.delta < 0)) || + (m_activeSwipe.delta > 0 && m_activeSwipe.pWorkspaceBegin->getWindows() == 0 && workspaceIDRight <= m_activeSwipe.pWorkspaceBegin->m_id) || + (m_activeSwipe.delta < 0 && m_activeSwipe.pWorkspaceBegin->m_id <= workspaceIDLeft)) { - m_sActiveSwipe.delta = 0; + m_activeSwipe.delta = 0; return; } if (*PSWIPEDIRLOCK) { - if (m_sActiveSwipe.initialDirection != 0 && m_sActiveSwipe.initialDirection != (m_sActiveSwipe.delta < 0 ? -1 : 1)) - m_sActiveSwipe.delta = 0; - else if (m_sActiveSwipe.initialDirection == 0 && abs(m_sActiveSwipe.delta) > *PSWIPEDIRLOCKTHRESHOLD) - m_sActiveSwipe.initialDirection = m_sActiveSwipe.delta < 0 ? -1 : 1; + if (m_activeSwipe.initialDirection != 0 && m_activeSwipe.initialDirection != (m_activeSwipe.delta < 0 ? -1 : 1)) + m_activeSwipe.delta = 0; + else if (m_activeSwipe.initialDirection == 0 && abs(m_activeSwipe.delta) > *PSWIPEDIRLOCKTHRESHOLD) + m_activeSwipe.initialDirection = m_activeSwipe.delta < 0 ? -1 : 1; } - if (m_sActiveSwipe.delta < 0) { + if (m_activeSwipe.delta < 0) { const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceIDLeft); - if (workspaceIDLeft > m_sActiveSwipe.pWorkspaceBegin->m_id || !PWORKSPACE) { + if (workspaceIDLeft > m_activeSwipe.pWorkspaceBegin->m_id || !PWORKSPACE) { if (*PSWIPENEW) { - g_pHyprRenderer->damageMonitor(m_sActiveSwipe.pMonitor.lock()); + g_pHyprRenderer->damageMonitor(m_activeSwipe.pMonitor.lock()); if (VERTANIMS) - m_sActiveSwipe.pWorkspaceBegin->m_renderOffset->setValueAndWarp(Vector2D(0.0, ((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * YDISTANCE)); + m_activeSwipe.pWorkspaceBegin->m_renderOffset->setValueAndWarp(Vector2D(0.0, ((-m_activeSwipe.delta) / SWIPEDISTANCE) * YDISTANCE)); else - m_sActiveSwipe.pWorkspaceBegin->m_renderOffset->setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * XDISTANCE, 0.0)); + m_activeSwipe.pWorkspaceBegin->m_renderOffset->setValueAndWarp(Vector2D(((-m_activeSwipe.delta) / SWIPEDISTANCE) * XDISTANCE, 0.0)); - m_sActiveSwipe.pWorkspaceBegin->updateWindowDecos(); + m_activeSwipe.pWorkspaceBegin->updateWindowDecos(); return; } - m_sActiveSwipe.delta = 0; + m_activeSwipe.delta = 0; return; } PWORKSPACE->m_forceRendering = true; PWORKSPACE->m_alpha->setValueAndWarp(1.f); - if (workspaceIDLeft != workspaceIDRight && workspaceIDRight != m_sActiveSwipe.pWorkspaceBegin->m_id) { + if (workspaceIDLeft != workspaceIDRight && workspaceIDRight != m_activeSwipe.pWorkspaceBegin->m_id) { const auto PWORKSPACER = g_pCompositor->getWorkspaceByID(workspaceIDRight); if (PWORKSPACER) { @@ -283,37 +283,37 @@ void CInputManager::updateWorkspaceSwipe(double delta) { } if (VERTANIMS) { - PWORKSPACE->m_renderOffset->setValueAndWarp(Vector2D(0.0, ((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * YDISTANCE - YDISTANCE)); - m_sActiveSwipe.pWorkspaceBegin->m_renderOffset->setValueAndWarp(Vector2D(0.0, ((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * YDISTANCE)); + PWORKSPACE->m_renderOffset->setValueAndWarp(Vector2D(0.0, ((-m_activeSwipe.delta) / SWIPEDISTANCE) * YDISTANCE - YDISTANCE)); + m_activeSwipe.pWorkspaceBegin->m_renderOffset->setValueAndWarp(Vector2D(0.0, ((-m_activeSwipe.delta) / SWIPEDISTANCE) * YDISTANCE)); } else { - PWORKSPACE->m_renderOffset->setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * XDISTANCE - XDISTANCE, 0.0)); - m_sActiveSwipe.pWorkspaceBegin->m_renderOffset->setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * XDISTANCE, 0.0)); + PWORKSPACE->m_renderOffset->setValueAndWarp(Vector2D(((-m_activeSwipe.delta) / SWIPEDISTANCE) * XDISTANCE - XDISTANCE, 0.0)); + m_activeSwipe.pWorkspaceBegin->m_renderOffset->setValueAndWarp(Vector2D(((-m_activeSwipe.delta) / SWIPEDISTANCE) * XDISTANCE, 0.0)); } PWORKSPACE->updateWindowDecos(); } else { const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceIDRight); - if (workspaceIDRight < m_sActiveSwipe.pWorkspaceBegin->m_id || !PWORKSPACE) { + if (workspaceIDRight < m_activeSwipe.pWorkspaceBegin->m_id || !PWORKSPACE) { if (*PSWIPENEW) { - g_pHyprRenderer->damageMonitor(m_sActiveSwipe.pMonitor.lock()); + g_pHyprRenderer->damageMonitor(m_activeSwipe.pMonitor.lock()); if (VERTANIMS) - m_sActiveSwipe.pWorkspaceBegin->m_renderOffset->setValueAndWarp(Vector2D(0.0, ((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * YDISTANCE)); + m_activeSwipe.pWorkspaceBegin->m_renderOffset->setValueAndWarp(Vector2D(0.0, ((-m_activeSwipe.delta) / SWIPEDISTANCE) * YDISTANCE)); else - m_sActiveSwipe.pWorkspaceBegin->m_renderOffset->setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * XDISTANCE, 0.0)); + m_activeSwipe.pWorkspaceBegin->m_renderOffset->setValueAndWarp(Vector2D(((-m_activeSwipe.delta) / SWIPEDISTANCE) * XDISTANCE, 0.0)); - m_sActiveSwipe.pWorkspaceBegin->updateWindowDecos(); + m_activeSwipe.pWorkspaceBegin->updateWindowDecos(); return; } - m_sActiveSwipe.delta = 0; + m_activeSwipe.delta = 0; return; } PWORKSPACE->m_forceRendering = true; PWORKSPACE->m_alpha->setValueAndWarp(1.f); - if (workspaceIDLeft != workspaceIDRight && workspaceIDLeft != m_sActiveSwipe.pWorkspaceBegin->m_id) { + if (workspaceIDLeft != workspaceIDRight && workspaceIDLeft != m_activeSwipe.pWorkspaceBegin->m_id) { const auto PWORKSPACEL = g_pCompositor->getWorkspaceByID(workspaceIDLeft); if (PWORKSPACEL) { @@ -323,22 +323,22 @@ void CInputManager::updateWorkspaceSwipe(double delta) { } if (VERTANIMS) { - PWORKSPACE->m_renderOffset->setValueAndWarp(Vector2D(0.0, ((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * YDISTANCE + YDISTANCE)); - m_sActiveSwipe.pWorkspaceBegin->m_renderOffset->setValueAndWarp(Vector2D(0.0, ((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * YDISTANCE)); + PWORKSPACE->m_renderOffset->setValueAndWarp(Vector2D(0.0, ((-m_activeSwipe.delta) / SWIPEDISTANCE) * YDISTANCE + YDISTANCE)); + m_activeSwipe.pWorkspaceBegin->m_renderOffset->setValueAndWarp(Vector2D(0.0, ((-m_activeSwipe.delta) / SWIPEDISTANCE) * YDISTANCE)); } else { - PWORKSPACE->m_renderOffset->setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * XDISTANCE + XDISTANCE, 0.0)); - m_sActiveSwipe.pWorkspaceBegin->m_renderOffset->setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / SWIPEDISTANCE) * XDISTANCE, 0.0)); + PWORKSPACE->m_renderOffset->setValueAndWarp(Vector2D(((-m_activeSwipe.delta) / SWIPEDISTANCE) * XDISTANCE + XDISTANCE, 0.0)); + m_activeSwipe.pWorkspaceBegin->m_renderOffset->setValueAndWarp(Vector2D(((-m_activeSwipe.delta) / SWIPEDISTANCE) * XDISTANCE, 0.0)); } PWORKSPACE->updateWindowDecos(); } - g_pHyprRenderer->damageMonitor(m_sActiveSwipe.pMonitor.lock()); + g_pHyprRenderer->damageMonitor(m_activeSwipe.pMonitor.lock()); - m_sActiveSwipe.pWorkspaceBegin->updateWindowDecos(); + m_activeSwipe.pWorkspaceBegin->updateWindowDecos(); if (*PSWIPEFOREVER) { - if (abs(m_sActiveSwipe.delta) >= SWIPEDISTANCE) { + if (abs(m_activeSwipe.delta) >= SWIPEDISTANCE) { onSwipeEnd({}); beginWorkspaceSwipe(); } diff --git a/src/managers/input/Tablets.cpp b/src/managers/input/Tablets.cpp index 347ea6c7..5d80f1d4 100644 --- a/src/managers/input/Tablets.cpp +++ b/src/managers/input/Tablets.cpp @@ -136,7 +136,7 @@ void CInputManager::onTabletAxis(CTablet::SAxisEvent e) { simulateMouseMovement(); refocusTablet(PTAB, PTOOL, true); - m_tmrLastCursorMovement.reset(); + m_lastCursorMovement.reset(); } if (e.updatedAxes & CTablet::eTabletToolAxes::HID_TABLET_TOOL_AXIS_PRESSURE) @@ -217,8 +217,8 @@ void CInputManager::onTabletProximity(CTablet::SProximityEvent e) { } void CInputManager::newTablet(SP pDevice) { - const auto PNEWTABLET = m_vTablets.emplace_back(CTablet::create(pDevice)); - m_vHIDs.emplace_back(PNEWTABLET); + const auto PNEWTABLET = m_tablets.emplace_back(CTablet::create(pDevice)); + m_hids.emplace_back(PNEWTABLET); try { PNEWTABLET->m_hlName = g_pInputManager->getNameForNewDevice(pDevice->getName()); @@ -240,13 +240,13 @@ void CInputManager::newTablet(SP pDevice) { SP CInputManager::ensureTabletToolPresent(SP pTool) { - for (auto const& t : m_vTabletTools) { + for (auto const& t : m_tabletTools) { if (t->aq() == pTool) return t; } - const auto PTOOL = m_vTabletTools.emplace_back(CTabletTool::create(pTool)); - m_vHIDs.emplace_back(PTOOL); + const auto PTOOL = m_tabletTools.emplace_back(CTabletTool::create(pTool)); + m_hids.emplace_back(PTOOL); try { PTOOL->m_hlName = g_pInputManager->getNameForNewDevice(pTool->getName()); @@ -265,8 +265,8 @@ SP CInputManager::ensureTabletToolPresent(SP pDevice) { - const auto PNEWPAD = m_vTabletPads.emplace_back(CTabletPad::create(pDevice)); - m_vHIDs.emplace_back(PNEWPAD); + const auto PNEWPAD = m_tabletPads.emplace_back(CTabletPad::create(pDevice)); + m_hids.emplace_back(PNEWPAD); try { PNEWPAD->m_hlName = g_pInputManager->getNameForNewDevice(pDevice->getName()); diff --git a/src/managers/input/TextInput.cpp b/src/managers/input/TextInput.cpp index 25c5b949..160d1c90 100644 --- a/src/managers/input/TextInput.cpp +++ b/src/managers/input/TextInput.cpp @@ -7,48 +7,48 @@ #include "../../protocols/InputMethodV2.hpp" #include "../../protocols/core/Compositor.hpp" -CTextInput::CTextInput(WP ti) : pV1Input(ti) { +CTextInput::CTextInput(WP ti) : m_v1Input(ti) { initCallbacks(); } -CTextInput::CTextInput(WP ti) : pV3Input(ti) { +CTextInput::CTextInput(WP ti) : m_v3Input(ti) { initCallbacks(); } void CTextInput::initCallbacks() { if (isV3()) { - const auto INPUT = pV3Input.lock(); + const auto INPUT = m_v3Input.lock(); - listeners.enable = INPUT->events.enable.registerListener([this](std::any p) { onEnabled(); }); - listeners.disable = INPUT->events.disable.registerListener([this](std::any p) { onDisabled(); }); - listeners.commit = INPUT->events.onCommit.registerListener([this](std::any p) { onCommit(); }); - listeners.reset = INPUT->events.reset.registerListener([this](std::any p) { onReset(); }); - listeners.destroy = INPUT->events.destroy.registerListener([this](std::any p) { - listeners.surfaceUnmap.reset(); - listeners.surfaceDestroy.reset(); - g_pInputManager->m_sIMERelay.removeTextInput(this); - if (!g_pInputManager->m_sIMERelay.getFocusedTextInput()) - g_pInputManager->m_sIMERelay.deactivateIME(this); + m_listeners.enable = INPUT->events.enable.registerListener([this](std::any p) { onEnabled(); }); + m_listeners.disable = INPUT->events.disable.registerListener([this](std::any p) { onDisabled(); }); + m_listeners.commit = INPUT->events.onCommit.registerListener([this](std::any p) { onCommit(); }); + m_listeners.reset = INPUT->events.reset.registerListener([this](std::any p) { onReset(); }); + m_listeners.destroy = INPUT->events.destroy.registerListener([this](std::any p) { + m_listeners.surfaceUnmap.reset(); + m_listeners.surfaceDestroy.reset(); + g_pInputManager->m_relay.removeTextInput(this); + if (!g_pInputManager->m_relay.getFocusedTextInput()) + g_pInputManager->m_relay.deactivateIME(this); }); if (!g_pCompositor->m_lastFocus.expired() && g_pCompositor->m_lastFocus->client() == INPUT->client()) enter(g_pCompositor->m_lastFocus.lock()); } else { - const auto INPUT = pV1Input.lock(); + const auto INPUT = m_v1Input.lock(); - listeners.enable = INPUT->events.enable.registerListener([this](std::any p) { + m_listeners.enable = INPUT->events.enable.registerListener([this](std::any p) { const auto SURFACE = std::any_cast>(p); onEnabled(SURFACE); }); - listeners.disable = INPUT->events.disable.registerListener([this](std::any p) { onDisabled(); }); - listeners.commit = INPUT->events.onCommit.registerListener([this](std::any p) { onCommit(); }); - listeners.reset = INPUT->events.reset.registerListener([this](std::any p) { onReset(); }); - listeners.destroy = INPUT->events.destroy.registerListener([this](std::any p) { - listeners.surfaceUnmap.reset(); - listeners.surfaceDestroy.reset(); - g_pInputManager->m_sIMERelay.removeTextInput(this); - if (!g_pInputManager->m_sIMERelay.getFocusedTextInput()) - g_pInputManager->m_sIMERelay.deactivateIME(this); + m_listeners.disable = INPUT->events.disable.registerListener([this](std::any p) { onDisabled(); }); + m_listeners.commit = INPUT->events.onCommit.registerListener([this](std::any p) { onCommit(); }); + m_listeners.reset = INPUT->events.reset.registerListener([this](std::any p) { onReset(); }); + m_listeners.destroy = INPUT->events.destroy.registerListener([this](std::any p) { + m_listeners.surfaceUnmap.reset(); + m_listeners.surfaceDestroy.reset(); + g_pInputManager->m_relay.removeTextInput(this); + if (!g_pInputManager->m_relay.getFocusedTextInput()) + g_pInputManager->m_relay.deactivateIME(this); }); } } @@ -56,24 +56,24 @@ void CTextInput::initCallbacks() { void CTextInput::onEnabled(SP surfV1) { Debug::log(LOG, "TI ENABLE"); - if (g_pInputManager->m_sIMERelay.m_pIME.expired()) { + if (g_pInputManager->m_relay.m_inputMethod.expired()) { // Debug::log(WARN, "Enabling TextInput on no IME!"); return; } // v1 only, map surface to PTI if (!isV3()) { - if (g_pCompositor->m_lastFocus != surfV1 || !pV1Input->active) + if (g_pCompositor->m_lastFocus != surfV1 || !m_v1Input->active) return; enter(surfV1); } - g_pInputManager->m_sIMERelay.activateIME(this); + g_pInputManager->m_relay.activateIME(this); } void CTextInput::onDisabled() { - if (g_pInputManager->m_sIMERelay.m_pIME.expired()) { + if (g_pInputManager->m_relay.m_inputMethod.expired()) { // Debug::log(WARN, "Disabling TextInput on no IME!"); return; } @@ -81,103 +81,103 @@ void CTextInput::onDisabled() { if (!isV3()) leave(); - listeners.surfaceUnmap.reset(); - listeners.surfaceDestroy.reset(); + m_listeners.surfaceUnmap.reset(); + m_listeners.surfaceDestroy.reset(); if (!focusedSurface()) return; - const auto PFOCUSEDTI = g_pInputManager->m_sIMERelay.getFocusedTextInput(); + const auto PFOCUSEDTI = g_pInputManager->m_relay.getFocusedTextInput(); if (!PFOCUSEDTI || PFOCUSEDTI != this) return; - g_pInputManager->m_sIMERelay.deactivateIME(this); + g_pInputManager->m_relay.deactivateIME(this); } void CTextInput::onReset() { - if (g_pInputManager->m_sIMERelay.m_pIME.expired()) + if (g_pInputManager->m_relay.m_inputMethod.expired()) return; if (!focusedSurface()) return; - const auto PFOCUSEDTI = g_pInputManager->m_sIMERelay.getFocusedTextInput(); + const auto PFOCUSEDTI = g_pInputManager->m_relay.getFocusedTextInput(); if (!PFOCUSEDTI || PFOCUSEDTI != this) return; - g_pInputManager->m_sIMERelay.deactivateIME(this, false); - g_pInputManager->m_sIMERelay.activateIME(this); + g_pInputManager->m_relay.deactivateIME(this, false); + g_pInputManager->m_relay.activateIME(this); } void CTextInput::onCommit() { - if (g_pInputManager->m_sIMERelay.m_pIME.expired()) { + if (g_pInputManager->m_relay.m_inputMethod.expired()) { // Debug::log(WARN, "Committing TextInput on no IME!"); return; } - if (!(isV3() ? pV3Input->current.enabled.value : pV1Input->active)) { + if (!(isV3() ? m_v3Input->current.enabled.value : m_v1Input->active)) { Debug::log(WARN, "Disabled TextInput commit?"); return; } - g_pInputManager->m_sIMERelay.commitIMEState(this); + g_pInputManager->m_relay.commitIMEState(this); } void CTextInput::setFocusedSurface(SP pSurface) { - if (pSurface == pFocusedSurface) + if (pSurface == m_focusedSurface) return; - pFocusedSurface = pSurface; + m_focusedSurface = pSurface; if (!pSurface) return; - listeners.surfaceUnmap.reset(); - listeners.surfaceDestroy.reset(); + m_listeners.surfaceUnmap.reset(); + m_listeners.surfaceDestroy.reset(); - listeners.surfaceUnmap = pSurface->events.unmap.registerListener([this](std::any d) { + m_listeners.surfaceUnmap = pSurface->events.unmap.registerListener([this](std::any d) { Debug::log(LOG, "Unmap TI owner1"); - if (enterLocks) - enterLocks--; - pFocusedSurface.reset(); - listeners.surfaceUnmap.reset(); - listeners.surfaceDestroy.reset(); + if (m_enterLocks) + m_enterLocks--; + m_focusedSurface.reset(); + m_listeners.surfaceUnmap.reset(); + m_listeners.surfaceDestroy.reset(); - if (isV3() && !pV3Input.expired() && pV3Input->current.enabled.value) { - pV3Input->pending.enabled.value = false; - pV3Input->pending.enabled.isDisablePending = false; - pV3Input->pending.enabled.isEnablePending = false; - pV3Input->current.enabled.value = false; + if (isV3() && !m_v3Input.expired() && m_v3Input->current.enabled.value) { + m_v3Input->pending.enabled.value = false; + m_v3Input->pending.enabled.isDisablePending = false; + m_v3Input->pending.enabled.isEnablePending = false; + m_v3Input->current.enabled.value = false; } - if (!g_pInputManager->m_sIMERelay.getFocusedTextInput()) - g_pInputManager->m_sIMERelay.deactivateIME(this); + if (!g_pInputManager->m_relay.getFocusedTextInput()) + g_pInputManager->m_relay.deactivateIME(this); }); - listeners.surfaceDestroy = pSurface->events.destroy.registerListener([this](std::any d) { + m_listeners.surfaceDestroy = pSurface->events.destroy.registerListener([this](std::any d) { Debug::log(LOG, "Destroy TI owner1"); - if (enterLocks) - enterLocks--; - pFocusedSurface.reset(); - listeners.surfaceUnmap.reset(); - listeners.surfaceDestroy.reset(); + if (m_enterLocks) + m_enterLocks--; + m_focusedSurface.reset(); + m_listeners.surfaceUnmap.reset(); + m_listeners.surfaceDestroy.reset(); - if (isV3() && !pV3Input.expired() && pV3Input->current.enabled.value) { - pV3Input->pending.enabled.value = false; - pV3Input->pending.enabled.isDisablePending = false; - pV3Input->pending.enabled.isEnablePending = false; - pV3Input->current.enabled.value = false; + if (isV3() && !m_v3Input.expired() && m_v3Input->current.enabled.value) { + m_v3Input->pending.enabled.value = false; + m_v3Input->pending.enabled.isDisablePending = false; + m_v3Input->pending.enabled.isEnablePending = false; + m_v3Input->current.enabled.value = false; } - if (!g_pInputManager->m_sIMERelay.getFocusedTextInput()) - g_pInputManager->m_sIMERelay.deactivateIME(this); + if (!g_pInputManager->m_relay.getFocusedTextInput()) + g_pInputManager->m_relay.deactivateIME(this); }); } bool CTextInput::isV3() { - return pV3Input && !pV1Input; + return m_v3Input && !m_v1Input; } void CTextInput::enter(SP pSurface) { @@ -190,17 +190,17 @@ void CTextInput::enter(SP pSurface) { if (focusedSurface()) leave(); - enterLocks++; - if (enterLocks != 1) { + m_enterLocks++; + if (m_enterLocks != 1) { Debug::log(ERR, "BUG THIS: TextInput has != 1 locks in enter"); leave(); - enterLocks = 1; + m_enterLocks = 1; } if (isV3()) - pV3Input->enter(pSurface); + m_v3Input->enter(pSurface); else { - pV1Input->enter(pSurface); + m_v1Input->enter(pSurface); } setFocusedSurface(pSurface); @@ -210,33 +210,33 @@ void CTextInput::leave() { if (!focusedSurface()) return; - enterLocks--; - if (enterLocks != 0) { + m_enterLocks--; + if (m_enterLocks != 0) { Debug::log(ERR, "BUG THIS: TextInput has != 0 locks in leave"); - enterLocks = 0; + m_enterLocks = 0; } if (isV3()) - pV3Input->leave(focusedSurface()); + m_v3Input->leave(focusedSurface()); else - pV1Input->leave(); + m_v1Input->leave(); setFocusedSurface(nullptr); - g_pInputManager->m_sIMERelay.deactivateIME(this); + g_pInputManager->m_relay.deactivateIME(this); } SP CTextInput::focusedSurface() { - return pFocusedSurface.lock(); + return m_focusedSurface.lock(); } wl_client* CTextInput::client() { - return isV3() ? pV3Input->client() : pV1Input->client(); + return isV3() ? m_v3Input->client() : m_v1Input->client(); } void CTextInput::commitStateToIME(SP ime) { - if (isV3() && !pV3Input.expired()) { - const auto INPUT = pV3Input.lock(); + if (isV3() && !m_v3Input.expired()) { + const auto INPUT = m_v3Input.lock(); if (INPUT->current.surrounding.updated) ime->surroundingText(INPUT->current.surrounding.text, INPUT->current.surrounding.cursor, INPUT->current.surrounding.anchor); @@ -245,26 +245,26 @@ void CTextInput::commitStateToIME(SP ime) { if (INPUT->current.contentType.updated) ime->textContentType(INPUT->current.contentType.hint, INPUT->current.contentType.purpose); - } else if (!pV1Input.expired()) { - const auto INPUT = pV1Input.lock(); + } else if (!m_v1Input.expired()) { + const auto INPUT = m_v1Input.lock(); if (INPUT->pendingSurrounding.isPending) ime->surroundingText(INPUT->pendingSurrounding.text, INPUT->pendingSurrounding.cursor, INPUT->pendingSurrounding.anchor); ime->textChangeCause(ZWP_TEXT_INPUT_V3_CHANGE_CAUSE_INPUT_METHOD); - if (pV1Input->pendingContentType.isPending) + if (m_v1Input->pendingContentType.isPending) ime->textContentType((zwpTextInputV3ContentHint)INPUT->pendingContentType.hint, (zwpTextInputV3ContentPurpose)INPUT->pendingContentType.purpose); } - g_pInputManager->m_sIMERelay.updateAllPopups(); + g_pInputManager->m_relay.updateAllPopups(); ime->done(); } void CTextInput::updateIMEState(SP ime) { if (isV3()) { - const auto INPUT = pV3Input.lock(); + const auto INPUT = m_v3Input.lock(); if (ime->current.preeditString.committed) INPUT->preeditString(ime->current.preeditString.string, ime->current.preeditString.begin, ime->current.preeditString.end); @@ -277,35 +277,35 @@ void CTextInput::updateIMEState(SP ime) { INPUT->sendDone(); } else { - const auto INPUT = pV1Input.lock(); + const auto INPUT = m_v1Input.lock(); if (ime->current.preeditString.committed) { INPUT->preeditCursor(ime->current.preeditString.begin); INPUT->preeditStyling(0, std::string(ime->current.preeditString.string).length(), ZWP_TEXT_INPUT_V1_PREEDIT_STYLE_HIGHLIGHT); - INPUT->preeditString(pV1Input->serial, ime->current.preeditString.string.c_str(), ""); + INPUT->preeditString(m_v1Input->serial, ime->current.preeditString.string.c_str(), ""); } else { INPUT->preeditCursor(0); INPUT->preeditStyling(0, 0, ZWP_TEXT_INPUT_V1_PREEDIT_STYLE_HIGHLIGHT); - INPUT->preeditString(pV1Input->serial, "", ""); + INPUT->preeditString(m_v1Input->serial, "", ""); } if (ime->current.committedString.committed) - INPUT->commitString(pV1Input->serial, ime->current.committedString.string.c_str()); + INPUT->commitString(m_v1Input->serial, ime->current.committedString.string.c_str()); if (ime->current.deleteSurrounding.committed) { INPUT->deleteSurroundingText(std::string(ime->current.preeditString.string).length() - ime->current.deleteSurrounding.before, ime->current.deleteSurrounding.after + ime->current.deleteSurrounding.before); if (ime->current.preeditString.committed) - INPUT->commitString(pV1Input->serial, ime->current.preeditString.string.c_str()); + INPUT->commitString(m_v1Input->serial, ime->current.preeditString.string.c_str()); } } } bool CTextInput::hasCursorRectangle() { - return !isV3() || pV3Input->current.box.updated; + return !isV3() || m_v3Input->current.box.updated; } CBox CTextInput::cursorBox() { - return CBox{isV3() ? pV3Input->current.box.cursorBox : pV1Input->cursorRectangle}; + return CBox{isV3() ? m_v3Input->current.box.cursorBox : m_v1Input->cursorRectangle}; } diff --git a/src/managers/input/TextInput.hpp b/src/managers/input/TextInput.hpp index 37b471af..fd24dbfa 100644 --- a/src/managers/input/TextInput.hpp +++ b/src/managers/input/TextInput.hpp @@ -38,10 +38,10 @@ class CTextInput { void setFocusedSurface(SP pSurface); void initCallbacks(); - WP pFocusedSurface; - int enterLocks = 0; - WP pV3Input; - WP pV1Input; + WP m_focusedSurface; + int m_enterLocks = 0; + WP m_v3Input; + WP m_v1Input; struct { CHyprSignalListener enable; @@ -51,5 +51,5 @@ class CTextInput { CHyprSignalListener destroy; CHyprSignalListener surfaceUnmap; CHyprSignalListener surfaceDestroy; - } listeners; + } m_listeners; }; diff --git a/src/managers/input/Touch.cpp b/src/managers/input/Touch.cpp index f8964521..83447593 100644 --- a/src/managers/input/Touch.cpp +++ b/src/managers/input/Touch.cpp @@ -12,7 +12,7 @@ #include "debug/Log.hpp" void CInputManager::onTouchDown(ITouch::SDownEvent e) { - m_bLastInputTouch = true; + m_lastInputTouch = true; static auto PSWIPETOUCH = CConfigValue("gestures:workspace_swipe_touch"); static auto PGAPSOUTDATA = CConfigValue("general:gaps_out"); @@ -31,7 +31,7 @@ void CInputManager::onTouchDown(ITouch::SDownEvent e) { refocus(); - if (m_ecbClickBehavior == CLICKMODE_KILL) { + if (m_clickBehavior == CLICKMODE_KILL) { IPointer::SButtonEvent e; e.state = WL_POINTER_BUTTON_STATE_PRESSED; g_pInputManager->processMouseDownKill(e); @@ -39,10 +39,10 @@ void CInputManager::onTouchDown(ITouch::SDownEvent e) { } // Don't propagate new touches when a workspace swipe is in progress. - if (m_sActiveSwipe.pWorkspaceBegin) { + if (m_activeSwipe.pWorkspaceBegin) { return; // TODO: Don't swipe if you touched a floating window. - } else if (*PSWIPETOUCH && (m_pFoundLSToFocus.expired() || m_pFoundLSToFocus->m_layer <= 1) && !g_pSessionLockManager->isSessionLocked()) { + } else if (*PSWIPETOUCH && (m_foundLSToFocus.expired() || m_foundLSToFocus->m_layer <= 1) && !g_pSessionLockManager->isSessionLocked()) { const auto PWORKSPACE = PMONITOR->m_activeWorkspace; const auto STYLE = PWORKSPACE->m_renderOffset->getStyle(); const bool VERTANIMS = STYLE == "slidevert" || STYLE.starts_with("slidefadevert"); @@ -51,83 +51,83 @@ void CInputManager::onTouchDown(ITouch::SDownEvent e) { const double POSITION = (VERTANIMS ? e.pos.y : e.pos.x); if (POSITION < TARGETLEFT || POSITION > TARGETRIGHT) { beginWorkspaceSwipe(); - m_sActiveSwipe.touch_id = e.touchID; + m_activeSwipe.touch_id = e.touchID; // Set the initial direction based on which edge you started from if (POSITION > 0.5) - m_sActiveSwipe.initialDirection = *PSWIPEINVR ? -1 : 1; + m_activeSwipe.initialDirection = *PSWIPEINVR ? -1 : 1; else - m_sActiveSwipe.initialDirection = *PSWIPEINVR ? 1 : -1; + m_activeSwipe.initialDirection = *PSWIPEINVR ? 1 : -1; return; } } if (g_pSessionLockManager->isSessionLocked()) { - m_sTouchData.touchFocusLockSurface = g_pSessionLockManager->getSessionLockSurfaceForMonitor(PMONITOR->m_id); - if (!m_sTouchData.touchFocusLockSurface) + m_touchData.touchFocusLockSurface = g_pSessionLockManager->getSessionLockSurfaceForMonitor(PMONITOR->m_id); + if (!m_touchData.touchFocusLockSurface) Debug::log(WARN, "The session is locked but can't find a lock surface"); else - m_sTouchData.touchFocusSurface = m_sTouchData.touchFocusLockSurface->surface->surface(); + m_touchData.touchFocusSurface = m_touchData.touchFocusLockSurface->surface->surface(); } else { - m_sTouchData.touchFocusLockSurface.reset(); - m_sTouchData.touchFocusWindow = m_pFoundWindowToFocus; - m_sTouchData.touchFocusSurface = m_pFoundSurfaceToFocus; - m_sTouchData.touchFocusLS = m_pFoundLSToFocus; + m_touchData.touchFocusLockSurface.reset(); + m_touchData.touchFocusWindow = m_foundWindowToFocus; + m_touchData.touchFocusSurface = m_foundSurfaceToFocus; + m_touchData.touchFocusLS = m_foundLSToFocus; } Vector2D local; - if (m_sTouchData.touchFocusLockSurface) { - local = g_pInputManager->getMouseCoordsInternal() - PMONITOR->m_position; - m_sTouchData.touchSurfaceOrigin = g_pInputManager->getMouseCoordsInternal() - local; - } else if (!m_sTouchData.touchFocusWindow.expired()) { - if (m_sTouchData.touchFocusWindow->m_isX11) { - local = (g_pInputManager->getMouseCoordsInternal() - m_sTouchData.touchFocusWindow->m_realPosition->goal()) * m_sTouchData.touchFocusWindow->m_X11SurfaceScaledBy; - m_sTouchData.touchSurfaceOrigin = m_sTouchData.touchFocusWindow->m_realPosition->goal(); + if (m_touchData.touchFocusLockSurface) { + local = g_pInputManager->getMouseCoordsInternal() - PMONITOR->m_position; + m_touchData.touchSurfaceOrigin = g_pInputManager->getMouseCoordsInternal() - local; + } else if (!m_touchData.touchFocusWindow.expired()) { + if (m_touchData.touchFocusWindow->m_isX11) { + local = (g_pInputManager->getMouseCoordsInternal() - m_touchData.touchFocusWindow->m_realPosition->goal()) * m_touchData.touchFocusWindow->m_X11SurfaceScaledBy; + m_touchData.touchSurfaceOrigin = m_touchData.touchFocusWindow->m_realPosition->goal(); } else { - g_pCompositor->vectorWindowToSurface(g_pInputManager->getMouseCoordsInternal(), m_sTouchData.touchFocusWindow.lock(), local); - m_sTouchData.touchSurfaceOrigin = g_pInputManager->getMouseCoordsInternal() - local; + g_pCompositor->vectorWindowToSurface(g_pInputManager->getMouseCoordsInternal(), m_touchData.touchFocusWindow.lock(), local); + m_touchData.touchSurfaceOrigin = g_pInputManager->getMouseCoordsInternal() - local; } - } else if (!m_sTouchData.touchFocusLS.expired()) { - local = g_pInputManager->getMouseCoordsInternal() - m_sTouchData.touchFocusLS->m_geometry.pos(); + } else if (!m_touchData.touchFocusLS.expired()) { + local = g_pInputManager->getMouseCoordsInternal() - m_touchData.touchFocusLS->m_geometry.pos(); - m_sTouchData.touchSurfaceOrigin = g_pInputManager->getMouseCoordsInternal() - local; + m_touchData.touchSurfaceOrigin = g_pInputManager->getMouseCoordsInternal() - local; } else return; // oops, nothing found. - g_pSeatManager->sendTouchDown(m_sTouchData.touchFocusSurface.lock(), e.timeMs, e.touchID, local); + g_pSeatManager->sendTouchDown(m_touchData.touchFocusSurface.lock(), e.timeMs, e.touchID, local); } void CInputManager::onTouchUp(ITouch::SUpEvent e) { - m_bLastInputTouch = true; + m_lastInputTouch = true; EMIT_HOOK_EVENT_CANCELLABLE("touchUp", e); - if (m_sActiveSwipe.pWorkspaceBegin) { + if (m_activeSwipe.pWorkspaceBegin) { // If there was a swipe from this finger, end it. - if (e.touchID == m_sActiveSwipe.touch_id) + if (e.touchID == m_activeSwipe.touch_id) endWorkspaceSwipe(); return; } - if (m_sTouchData.touchFocusSurface) + if (m_touchData.touchFocusSurface) g_pSeatManager->sendTouchUp(e.timeMs, e.touchID); } void CInputManager::onTouchMove(ITouch::SMotionEvent e) { - m_bLastInputTouch = true; + m_lastInputTouch = true; EMIT_HOOK_EVENT_CANCELLABLE("touchMove", e); - if (m_sActiveSwipe.pWorkspaceBegin) { + if (m_activeSwipe.pWorkspaceBegin) { // Do nothing if this is using a different finger. - if (e.touchID != m_sActiveSwipe.touch_id) + if (e.touchID != m_activeSwipe.touch_id) return; - const auto ANIMSTYLE = m_sActiveSwipe.pWorkspaceBegin->m_renderOffset->getStyle(); + const auto ANIMSTYLE = m_activeSwipe.pWorkspaceBegin->m_renderOffset->getStyle(); const bool VERTANIMS = ANIMSTYLE == "slidevert" || ANIMSTYLE.starts_with("slidefadevert"); static auto PSWIPEINVR = CConfigValue("gestures:workspace_swipe_touch_invert"); static auto PSWIPEDIST = CConfigValue("gestures:workspace_swipe_distance"); const auto SWIPEDISTANCE = std::clamp(*PSWIPEDIST, (int64_t)1LL, (int64_t)UINT32_MAX); // Handle the workspace swipe if there is one - if (m_sActiveSwipe.initialDirection == -1) { + if (m_activeSwipe.initialDirection == -1) { if (*PSWIPEINVR) // go from 0 to -SWIPEDISTANCE updateWorkspaceSwipe(SWIPEDISTANCE * ((VERTANIMS ? e.pos.y : e.pos.x) - 1)); @@ -142,27 +142,27 @@ void CInputManager::onTouchMove(ITouch::SMotionEvent e) { updateWorkspaceSwipe(SWIPEDISTANCE * (1 - (VERTANIMS ? e.pos.y : e.pos.x))); return; } - if (m_sTouchData.touchFocusLockSurface) { - const auto PMONITOR = g_pCompositor->getMonitorFromID(m_sTouchData.touchFocusLockSurface->iMonitorID); + if (m_touchData.touchFocusLockSurface) { + const auto PMONITOR = g_pCompositor->getMonitorFromID(m_touchData.touchFocusLockSurface->iMonitorID); g_pCompositor->warpCursorTo({PMONITOR->m_position.x + e.pos.x * PMONITOR->m_size.x, PMONITOR->m_position.y + e.pos.y * PMONITOR->m_size.y}, true); auto local = g_pInputManager->getMouseCoordsInternal() - PMONITOR->m_position; g_pSeatManager->sendTouchMotion(e.timeMs, e.touchID, local); - } else if (validMapped(m_sTouchData.touchFocusWindow)) { - const auto PMONITOR = m_sTouchData.touchFocusWindow->m_monitor.lock(); + } else if (validMapped(m_touchData.touchFocusWindow)) { + const auto PMONITOR = m_touchData.touchFocusWindow->m_monitor.lock(); g_pCompositor->warpCursorTo({PMONITOR->m_position.x + e.pos.x * PMONITOR->m_size.x, PMONITOR->m_position.y + e.pos.y * PMONITOR->m_size.y}, true); - auto local = g_pInputManager->getMouseCoordsInternal() - m_sTouchData.touchSurfaceOrigin; - if (m_sTouchData.touchFocusWindow->m_isX11) - local = local * m_sTouchData.touchFocusWindow->m_X11SurfaceScaledBy; + auto local = g_pInputManager->getMouseCoordsInternal() - m_touchData.touchSurfaceOrigin; + if (m_touchData.touchFocusWindow->m_isX11) + local = local * m_touchData.touchFocusWindow->m_X11SurfaceScaledBy; g_pSeatManager->sendTouchMotion(e.timeMs, e.touchID, local); - } else if (!m_sTouchData.touchFocusLS.expired()) { - const auto PMONITOR = m_sTouchData.touchFocusLS->m_monitor.lock(); + } else if (!m_touchData.touchFocusLS.expired()) { + const auto PMONITOR = m_touchData.touchFocusLS->m_monitor.lock(); g_pCompositor->warpCursorTo({PMONITOR->m_position.x + e.pos.x * PMONITOR->m_size.x, PMONITOR->m_position.y + e.pos.y * PMONITOR->m_size.y}, true); - const auto local = g_pInputManager->getMouseCoordsInternal() - m_sTouchData.touchSurfaceOrigin; + const auto local = g_pInputManager->getMouseCoordsInternal() - m_touchData.touchSurfaceOrigin; g_pSeatManager->sendTouchMotion(e.timeMs, e.touchID, local); } diff --git a/src/protocols/PointerConstraints.cpp b/src/protocols/PointerConstraints.cpp index ed24a5fe..2858ee95 100644 --- a/src/protocols/PointerConstraints.cpp +++ b/src/protocols/PointerConstraints.cpp @@ -69,7 +69,7 @@ CPointerConstraint::CPointerConstraint(SP resource_, SPm_vConstraints, [this](const auto& c) { + std::erase_if(g_pInputManager->m_constraints, [this](const auto& c) { const auto SHP = c.lock(); return !SHP || SHP.get() == this; }); @@ -85,7 +85,7 @@ void CPointerConstraint::sharedConstructions() { if (active) deactivate(); - std::erase_if(g_pInputManager->m_vConstraints, [this](const auto& c) { + std::erase_if(g_pInputManager->m_constraints, [this](const auto& c) { const auto SHP = c.lock(); return !SHP || SHP.get() == this; }); @@ -113,7 +113,7 @@ void CPointerConstraint::deactivate() { if (lifetime == ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_ONESHOT) { dead = true; // remove from inputmgr - std::erase_if(g_pInputManager->m_vConstraints, [this](const auto& c) { + std::erase_if(g_pInputManager->m_constraints, [this](const auto& c) { const auto SHP = c.lock(); return !SHP || SHP.get() == this; }); @@ -240,7 +240,7 @@ void CPointerConstraintsProtocol::onNewConstraint(SP constra OWNER->appendConstraint(constraint); - g_pInputManager->m_vConstraints.emplace_back(constraint); + g_pInputManager->m_constraints.emplace_back(constraint); if (g_pCompositor->m_lastFocus == OWNER->resource()) constraint->activate(); diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 445c39cd..9dbc732b 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -104,13 +104,13 @@ CHyprRenderer::CHyprRenderer() { }); static auto P2 = g_pHookSystem->hookDynamic("mouseMove", [&](void* self, SCallbackInfo& info, std::any param) { - if (!m_sCursorHiddenConditions.hiddenOnKeyboard && m_sCursorHiddenConditions.hiddenOnTouch == g_pInputManager->m_bLastInputTouch && + if (!m_sCursorHiddenConditions.hiddenOnKeyboard && m_sCursorHiddenConditions.hiddenOnTouch == g_pInputManager->m_lastInputTouch && !m_sCursorHiddenConditions.hiddenOnTimeout) return; m_sCursorHiddenConditions.hiddenOnKeyboard = false; m_sCursorHiddenConditions.hiddenOnTimeout = false; - m_sCursorHiddenConditions.hiddenOnTouch = g_pInputManager->m_bLastInputTouch; + m_sCursorHiddenConditions.hiddenOnTouch = g_pInputManager->m_lastInputTouch; ensureCursorRenderingMode(); }); @@ -969,7 +969,7 @@ void CHyprRenderer::renderAllClientsForWorkspace(PHLMONITOR pMonitor, PHLWORKSPA } // Render IME popups - for (auto const& imep : g_pInputManager->m_sIMERelay.m_vIMEPopups) { + for (auto const& imep : g_pInputManager->m_relay.m_inputMethodPopups) { renderIMEPopup(imep.get(), pMonitor, time); } @@ -2004,7 +2004,7 @@ void CHyprRenderer::ensureCursorRenderingMode() { m_sCursorHiddenConditions.hiddenOnKeyboard = false; if (*PCURSORTIMEOUT > 0) - m_sCursorHiddenConditions.hiddenOnTimeout = *PCURSORTIMEOUT < g_pInputManager->m_tmrLastCursorMovement.getSeconds(); + m_sCursorHiddenConditions.hiddenOnTimeout = *PCURSORTIMEOUT < g_pInputManager->m_lastCursorMovement.getSeconds(); const bool HIDE = m_sCursorHiddenConditions.hiddenOnTimeout || m_sCursorHiddenConditions.hiddenOnTouch || m_sCursorHiddenConditions.hiddenOnKeyboard; diff --git a/src/render/decorations/CHyprGroupBarDecoration.cpp b/src/render/decorations/CHyprGroupBarDecoration.cpp index aa070e67..bb7383b3 100644 --- a/src/render/decorations/CHyprGroupBarDecoration.cpp +++ b/src/render/decorations/CHyprGroupBarDecoration.cpp @@ -404,7 +404,7 @@ bool CHyprGroupBarDecoration::onBeginWindowDragOnDeco(const Vector2D& pos) { g_pKeybindManager->m_bGroupsLocked = GROUPSLOCKEDPREV; } - g_pInputManager->currentlyDraggedWindow = pWindow; + g_pInputManager->m_currentlyDraggedWindow = pWindow; if (!g_pCompositor->isWindowActive(pWindow)) g_pCompositor->focusWindow(pWindow); @@ -421,11 +421,11 @@ bool CHyprGroupBarDecoration::onEndWindowDragOnDeco(const Vector2D& pos, PHLWIND static auto PINNERGAP = CConfigValue("group:groupbar:gaps_in"); const bool FLOATEDINTOTILED = !m_pWindow->m_isFloating && !pDraggedWindow->m_draggingTiled; - g_pInputManager->m_bWasDraggingWindow = false; + g_pInputManager->m_wasDraggingWindow = false; if (!pDraggedWindow->canBeGroupedInto(m_pWindow.lock()) || (*PDRAGINTOGROUP != 1 && *PDRAGINTOGROUP != 2) || (FLOATEDINTOTILED && !*PMERGEFLOATEDINTOTILEDONGROUPBAR) || (!*PMERGEGROUPSONGROUPBAR && pDraggedWindow->m_groupData.pNextWindow.lock() && m_pWindow->m_groupData.pNextWindow.lock())) { - g_pInputManager->m_bWasDraggingWindow = true; + g_pInputManager->m_wasDraggingWindow = true; return false; } diff --git a/src/render/pass/SurfacePassElement.cpp b/src/render/pass/SurfacePassElement.cpp index ed0e3000..3813e714 100644 --- a/src/render/pass/SurfacePassElement.cpp +++ b/src/render/pass/SurfacePassElement.cpp @@ -51,7 +51,7 @@ void CSurfacePassElement::draw(const CRegion& damage) { if (!TEXTURE->m_iTexID) return; - const auto INTERACTIVERESIZEINPROGRESS = data.pWindow && g_pInputManager->currentlyDraggedWindow && g_pInputManager->dragMode == MBIND_RESIZE; + const auto INTERACTIVERESIZEINPROGRESS = data.pWindow && g_pInputManager->m_currentlyDraggedWindow && g_pInputManager->m_dragMode == MBIND_RESIZE; TRACY_GPU_ZONE("RenderSurface"); auto PSURFACE = CWLSurface::fromResource(data.surface); @@ -140,7 +140,7 @@ void CSurfacePassElement::draw(const CRegion& damage) { CBox CSurfacePassElement::getTexBox() { const double outputX = -data.pMonitor->m_position.x, outputY = -data.pMonitor->m_position.y; - const auto INTERACTIVERESIZEINPROGRESS = data.pWindow && g_pInputManager->currentlyDraggedWindow && g_pInputManager->dragMode == MBIND_RESIZE; + const auto INTERACTIVERESIZEINPROGRESS = data.pWindow && g_pInputManager->m_currentlyDraggedWindow && g_pInputManager->m_dragMode == MBIND_RESIZE; auto PSURFACE = CWLSurface::fromResource(data.surface); CBox windowBox;