diff options
| author | Vaxry <vaxry@vaxry.net> | 2024-05-05 22:18:10 +0100 |
|---|---|---|
| committer | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2024-05-09 13:37:39 +0100 |
| commit | ed411f53bdcf8d455f9e6ca769693aa84dc8372f (patch) | |
| tree | aacedb349acdd1022975d7b622dc7cfe11388223 /src/managers/KeybindManager.cpp | |
| parent | e4e84064f2d07810e0c150bce1369a0a00503e9a (diff) | |
cursor: move to a hyprland impl
This moves wlr_cursor to a completely new impl mostly under
CPointerManager
Also adds beginSimple to OpenGL for simple render passes (e.g. cursor)
Diffstat (limited to 'src/managers/KeybindManager.cpp')
| -rw-r--r-- | src/managers/KeybindManager.cpp | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index c52fda17..62265e00 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -256,7 +256,7 @@ bool CKeybindManager::tryMoveFocusToMonitor(CMonitor* monitor) { if (!monitor) return false; - const auto LASTMONITOR = g_pCompositor->m_pLastMonitor; + const auto LASTMONITOR = g_pCompositor->m_pLastMonitor.get(); if (LASTMONITOR == monitor) { Debug::log(LOG, "Tried to move to active monitor"); return false; @@ -407,7 +407,7 @@ bool CKeybindManager::onKeyEvent(std::any event, SP<IKeyboard> pKeyboard) { return !suppressEvent && !mouseBindWasActive; } -bool CKeybindManager::onAxisEvent(wlr_pointer_axis_event* e) { +bool CKeybindManager::onAxisEvent(const IPointer::SAxisEvent& e) { const auto MODS = g_pInputManager->accumulateModsFromAllKBs(); static auto PDELAY = CConfigValue<Hyprlang::INT>("binds:scroll_event_delay"); @@ -426,13 +426,13 @@ bool CKeybindManager::onAxisEvent(wlr_pointer_axis_event* e) { } bool found = false; - if (e->source == WL_POINTER_AXIS_SOURCE_WHEEL && e->orientation == WL_POINTER_AXIS_VERTICAL_SCROLL) { - if (e->delta < 0) + if (e.source == WL_POINTER_AXIS_SOURCE_WHEEL && e.axis == WL_POINTER_AXIS_VERTICAL_SCROLL) { + if (e.delta < 0) found = handleKeybinds(MODS, SPressedKeyWithMods{.keyName = "mouse_down"}, true); else found = handleKeybinds(MODS, SPressedKeyWithMods{.keyName = "mouse_up"}, true); - } else if (e->source == WL_POINTER_AXIS_SOURCE_WHEEL && e->orientation == WL_POINTER_AXIS_HORIZONTAL_SCROLL) { - if (e->delta < 0) + } else if (e.source == WL_POINTER_AXIS_SOURCE_WHEEL && e.axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL) { + if (e.delta < 0) found = handleKeybinds(MODS, SPressedKeyWithMods{.keyName = "mouse_left"}, true); else found = handleKeybinds(MODS, SPressedKeyWithMods{.keyName = "mouse_right"}, true); @@ -444,18 +444,18 @@ bool CKeybindManager::onAxisEvent(wlr_pointer_axis_event* e) { return !found; } -bool CKeybindManager::onMouseEvent(wlr_pointer_button_event* e) { +bool CKeybindManager::onMouseEvent(const IPointer::SButtonEvent& e) { const auto MODS = g_pInputManager->accumulateModsFromAllKBs(); bool suppressEvent = false; - m_uLastMouseCode = e->button; + m_uLastMouseCode = e.button; m_uLastCode = 0; - m_uTimeLastMs = e->time_msec; + m_uTimeLastMs = e.timeMs; bool mouseBindWasActive = ensureMouseBindState(); - const auto KEY_NAME = "mouse:" + std::to_string(e->button); + const auto KEY_NAME = "mouse:" + std::to_string(e.button); const auto KEY = SPressedKeyWithMods{ .keyName = KEY_NAME, @@ -468,7 +468,7 @@ bool CKeybindManager::onMouseEvent(wlr_pointer_button_event* e) { m_pActiveKeybind = nullptr; } - if (e->state == WL_POINTER_BUTTON_STATE_PRESSED) { + if (e.state == WL_POINTER_BUTTON_STATE_PRESSED) { m_dPressedKeys.push_back(KEY); suppressEvent = handleKeybinds(MODS, KEY, true); @@ -501,12 +501,11 @@ bool CKeybindManager::onMouseEvent(wlr_pointer_button_event* e) { return !suppressEvent && !mouseBindWasActive; } -void CKeybindManager::resizeWithBorder(wlr_pointer_button_event* e) { - if (e->state == WL_POINTER_BUTTON_STATE_PRESSED) { +void CKeybindManager::resizeWithBorder(const IPointer::SButtonEvent& e) { + if (e.state == WL_POINTER_BUTTON_STATE_PRESSED) mouse("1resizewindow"); - } else { + else mouse("0resizewindow"); - } } void CKeybindManager::onSwitchEvent(const std::string& switchName) { @@ -965,7 +964,7 @@ void CKeybindManager::changeworkspace(std::string args) { static auto PALLOWWORKSPACECYCLES = CConfigValue<Hyprlang::INT>("binds:allow_workspace_cycles"); static auto PWORKSPACECENTERON = CConfigValue<Hyprlang::INT>("binds:workspace_center_on"); - const auto PMONITOR = g_pCompositor->m_pLastMonitor; + const auto PMONITOR = g_pCompositor->m_pLastMonitor.get(); if (!PMONITOR) return; @@ -1445,20 +1444,20 @@ void CKeybindManager::moveCursorToCorner(std::string arg) { switch (CORNER) { case 0: // bottom left - wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, PWINDOW->m_vRealPosition.value().x, PWINDOW->m_vRealPosition.value().y + PWINDOW->m_vRealSize.value().y); + g_pCompositor->warpCursorTo({PWINDOW->m_vRealPosition.value().x, PWINDOW->m_vRealPosition.value().y + PWINDOW->m_vRealSize.value().y}, true); break; case 1: // bottom right - wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, PWINDOW->m_vRealPosition.value().x + PWINDOW->m_vRealSize.value().x, - PWINDOW->m_vRealPosition.value().y + PWINDOW->m_vRealSize.value().y); + g_pCompositor->warpCursorTo({PWINDOW->m_vRealPosition.value().x + PWINDOW->m_vRealSize.value().x, PWINDOW->m_vRealPosition.value().y + PWINDOW->m_vRealSize.value().y}, + true); break; case 2: // top right - wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, PWINDOW->m_vRealPosition.value().x + PWINDOW->m_vRealSize.value().x, PWINDOW->m_vRealPosition.value().y); + g_pCompositor->warpCursorTo({PWINDOW->m_vRealPosition.value().x + PWINDOW->m_vRealSize.value().x, PWINDOW->m_vRealPosition.value().y}, true); break; case 3: // top left - wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, PWINDOW->m_vRealPosition.value().x, PWINDOW->m_vRealPosition.value().y); + g_pCompositor->warpCursorTo({PWINDOW->m_vRealPosition.value().x, PWINDOW->m_vRealPosition.value().y}, true); break; } } @@ -1488,7 +1487,7 @@ void CKeybindManager::moveCursor(std::string args) { x = std::stoi(x_str); y = std::stoi(y_str); - wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, x, y); + g_pCompositor->warpCursorTo({x, y}, true); } void CKeybindManager::workspaceOpt(std::string args) { @@ -1624,7 +1623,7 @@ void CKeybindManager::focusWorkspaceOnCurrentMonitor(std::string args) { return; } - const auto PCURRMONITOR = g_pCompositor->m_pLastMonitor; + const auto PCURRMONITOR = g_pCompositor->m_pLastMonitor.get(); if (!PCURRMONITOR) { Debug::log(ERR, "focusWorkspaceOnCurrentMonitor monitor doesn't exist!"); |
