From 21217bcb2bb691ea015563a7ba7ce2d334de6b39 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 19 Jul 2022 14:05:12 +0200 Subject: notify enter on subsurfaces with follow mouse not 1 --- src/managers/input/InputManager.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/managers/input') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index fae530b9..f484a6ee 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -233,6 +233,12 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { } else if (*PFOLLOWMOUSE == 2) { wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y); } + + if (pFoundWindow == g_pCompositor->m_pLastWindow && foundSurface != g_pCompositor->m_pLastFocus) { + // we changed the subsurface + wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y); + } + wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, time, surfaceLocal.x, surfaceLocal.y); return; // don't enter any new surfaces } else { -- cgit v1.2.3 From 0026414f9bbefed9ba4838b600dd2566968bfc8a Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 19 Jul 2022 18:30:53 +0200 Subject: fix workspace swipes mistake --- src/managers/input/Swipe.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/managers/input') diff --git a/src/managers/input/Swipe.cpp b/src/managers/input/Swipe.cpp index 98f31945..d606dc98 100644 --- a/src/managers/input/Swipe.cpp +++ b/src/managers/input/Swipe.cpp @@ -58,6 +58,10 @@ void CInputManager::onSwipeEnd(wlr_pointer_swipe_end_event* e) { PWORKSPACEL->m_vRenderOffset.setValue(RENDEROFFSET); PWORKSPACEL->m_fAlpha.setValueAndWarp(255.f); + m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValue(RENDEROFFSETMIDDLE); + m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset = Vector2D(m_sActiveSwipe.pMonitor->vecSize.x, 0); + m_sActiveSwipe.pWorkspaceBegin->m_fAlpha.setValueAndWarp(255.f); + Debug::log(LOG, "Ended swipe to the left"); } else { // switch to right @@ -68,12 +72,13 @@ void CInputManager::onSwipeEnd(wlr_pointer_swipe_end_event* e) { PWORKSPACER->m_vRenderOffset.setValue(RENDEROFFSET); PWORKSPACER->m_fAlpha.setValueAndWarp(255.f); + m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValue(RENDEROFFSETMIDDLE); + m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset = Vector2D(-m_sActiveSwipe.pMonitor->vecSize.x, 0); + m_sActiveSwipe.pWorkspaceBegin->m_fAlpha.setValueAndWarp(255.f); + Debug::log(LOG, "Ended swipe to the right"); } - m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValue(RENDEROFFSETMIDDLE); - m_sActiveSwipe.pWorkspaceBegin->m_fAlpha.setValueAndWarp(255.f); - PWORKSPACEL->m_bForceRendering = false; PWORKSPACER->m_bForceRendering = false; m_sActiveSwipe.pWorkspaceBegin->m_bForceRendering = false; -- cgit v1.2.3 From 1ba600ca23706683ddd4035ce12cace43b911980 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 19 Jul 2022 18:35:24 +0200 Subject: added workspace swipe fingers --- src/managers/input/Swipe.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/managers/input') diff --git a/src/managers/input/Swipe.cpp b/src/managers/input/Swipe.cpp index d606dc98..74783f42 100644 --- a/src/managers/input/Swipe.cpp +++ b/src/managers/input/Swipe.cpp @@ -4,8 +4,9 @@ void CInputManager::onSwipeBegin(wlr_pointer_swipe_begin_event* e) { static auto *const PSWIPE = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe")->intValue; + static auto *const PSWIPEFINGERS = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_fingers")->intValue; - if (e->fingers < 3 || *PSWIPE == 0) + if (e->fingers != *PSWIPEFINGERS|| *PSWIPE == 0) return; const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace); -- cgit v1.2.3 From d52446135bd46dc0260d9507e82173847d4196c8 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Tue, 19 Jul 2022 19:26:53 +0200 Subject: add sensitivity per device & reload mice on config --- src/managers/input/InputManager.cpp | 93 +++++++++++++++++++++++-------------- src/managers/input/InputManager.hpp | 1 + 2 files changed, 58 insertions(+), 36 deletions(-) (limited to 'src/managers/input') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index f484a6ee..5fbdcf23 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -522,47 +522,14 @@ void CInputManager::newMouse(wlr_input_device* mouse, bool virt) { Debug::log(ERR, "Mouse had no name???"); // logic error } - const auto HASCONFIG = g_pConfigManager->deviceConfigExists(PMOUSE->name); - if (wlr_input_device_is_libinput(mouse)) { const auto LIBINPUTDEV = (libinput_device*)wlr_libinput_get_device_handle(mouse); - if ((HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "clickfinger_behavior") : g_pConfigManager->getInt("input:touchpad:clickfinger_behavior")) == 0) // toggle software buttons or clickfinger - libinput_device_config_click_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS); - else - libinput_device_config_click_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER); - - if (libinput_device_config_middle_emulation_is_available(LIBINPUTDEV)) { // middleclick on r+l mouse button pressed - if ((HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "middle_button_emulation") : g_pConfigManager->getInt("input:touchpad:middle_button_emulation")) == 1) - libinput_device_config_middle_emulation_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED); - else - libinput_device_config_middle_emulation_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED); - } - - if ((HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "drag_lock") : g_pConfigManager->getInt("input:touchpad:drag_lock")) == 0) - libinput_device_config_tap_set_drag_lock_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_DRAG_LOCK_DISABLED); - else - libinput_device_config_tap_set_drag_lock_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_DRAG_LOCK_ENABLED); - - if (libinput_device_config_tap_get_finger_count(LIBINPUTDEV)) // this is for tapping (like on a laptop) - if ((HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "tap-to-click") : g_pConfigManager->getInt("input:touchpad:tap-to-click")) == 1) - libinput_device_config_tap_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_TAP_ENABLED); - - if (libinput_device_config_scroll_has_natural_scroll(LIBINPUTDEV)) { - double w = 0, h = 0; - - if (libinput_device_has_capability(LIBINPUTDEV, LIBINPUT_DEVICE_CAP_POINTER) && libinput_device_get_size(LIBINPUTDEV, &w, &h) == 0) // pointer with size is a touchpad - libinput_device_config_scroll_set_natural_scroll_enabled(LIBINPUTDEV, (HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "natural_scroll") : g_pConfigManager->getInt("input:touchpad:natural_scroll"))); - else - libinput_device_config_scroll_set_natural_scroll_enabled(LIBINPUTDEV, (HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "natural_scroll") : g_pConfigManager->getInt("input:natural_scroll"))); - } - - if (libinput_device_config_dwt_is_available(LIBINPUTDEV)) { - const auto DWT = static_cast((HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "disable_while_typing") : g_pConfigManager->getInt("input:touchpad:disable_while_typing")) != 0); - libinput_device_config_dwt_set_enabled(LIBINPUTDEV, DWT); - } + Debug::log(LOG, "New mouse has libinput sens %.2f (%.2f) with accel profile %i (%i)", libinput_device_config_accel_get_speed(LIBINPUTDEV), libinput_device_config_accel_get_default_speed(LIBINPUTDEV), libinput_device_config_accel_get_profile(LIBINPUTDEV), libinput_device_config_accel_get_default_profile(LIBINPUTDEV)); } + setMouseConfigs(); + PMOUSE->hyprListener_destroyMouse.initCallback(&mouse->events.destroy, &Events::listener_destroyMouse, PMOUSE, "Mouse"); wlr_cursor_attach_input_device(g_pCompositor->m_sWLRCursor, mouse); @@ -574,6 +541,60 @@ void CInputManager::newMouse(wlr_input_device* mouse, bool virt) { Debug::log(LOG, "New mouse created, pointer WLR: %x", mouse); } +void CInputManager::setMouseConfigs() { + for (auto& m : m_lMice) { + const auto PMOUSE = &m; + + const auto HASCONFIG = g_pConfigManager->deviceConfigExists(PMOUSE->name); + + if (wlr_input_device_is_libinput(m.mouse)) { + const auto LIBINPUTDEV = (libinput_device*)wlr_libinput_get_device_handle(m.mouse); + + if ((HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "clickfinger_behavior") : g_pConfigManager->getInt("input:touchpad:clickfinger_behavior")) == 0) // toggle software buttons or clickfinger + libinput_device_config_click_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS); + else + libinput_device_config_click_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER); + + if (libinput_device_config_middle_emulation_is_available(LIBINPUTDEV)) { // middleclick on r+l mouse button pressed + if ((HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "middle_button_emulation") : g_pConfigManager->getInt("input:touchpad:middle_button_emulation")) == 1) + libinput_device_config_middle_emulation_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED); + else + libinput_device_config_middle_emulation_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED); + } + + if ((HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "drag_lock") : g_pConfigManager->getInt("input:touchpad:drag_lock")) == 0) + libinput_device_config_tap_set_drag_lock_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_DRAG_LOCK_DISABLED); + else + libinput_device_config_tap_set_drag_lock_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_DRAG_LOCK_ENABLED); + + if (libinput_device_config_tap_get_finger_count(LIBINPUTDEV)) // this is for tapping (like on a laptop) + if ((HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "tap-to-click") : g_pConfigManager->getInt("input:touchpad:tap-to-click")) == 1) + libinput_device_config_tap_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_TAP_ENABLED); + + if (libinput_device_config_scroll_has_natural_scroll(LIBINPUTDEV)) { + double w = 0, h = 0; + + if (libinput_device_has_capability(LIBINPUTDEV, LIBINPUT_DEVICE_CAP_POINTER) && libinput_device_get_size(LIBINPUTDEV, &w, &h) == 0) // pointer with size is a touchpad + libinput_device_config_scroll_set_natural_scroll_enabled(LIBINPUTDEV, (HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "natural_scroll") : g_pConfigManager->getInt("input:touchpad:natural_scroll"))); + else + libinput_device_config_scroll_set_natural_scroll_enabled(LIBINPUTDEV, (HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "natural_scroll") : g_pConfigManager->getInt("input:natural_scroll"))); + } + + if (libinput_device_config_dwt_is_available(LIBINPUTDEV)) { + const auto DWT = static_cast((HASCONFIG ? g_pConfigManager->getDeviceInt(PMOUSE->name, "disable_while_typing") : g_pConfigManager->getInt("input:touchpad:disable_while_typing")) != 0); + libinput_device_config_dwt_set_enabled(LIBINPUTDEV, DWT); + } + + const auto LIBINPUTSENS = std::clamp((HASCONFIG ? g_pConfigManager->getDeviceFloat(PMOUSE->name, "sensitivity") : g_pConfigManager->getFloat("input:sensitivity")), -1.f, 1.f); + + libinput_device_config_accel_set_profile(LIBINPUTDEV, LIBINPUT_CONFIG_ACCEL_PROFILE_NONE); + libinput_device_config_accel_set_speed(LIBINPUTDEV, LIBINPUTSENS); + + Debug::log(LOG, "Applied config to mouse %s, sens %.2f", m.name.c_str(), LIBINPUTSENS); + } + } +} + void CInputManager::destroyKeyboard(SKeyboard* pKeyboard) { pKeyboard->hyprListener_keyboardDestroy.removeCallback(); pKeyboard->hyprListener_keyboardMod.removeCallback(); diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp index 1dacac8e..514d5bad 100644 --- a/src/managers/input/InputManager.hpp +++ b/src/managers/input/InputManager.hpp @@ -32,6 +32,7 @@ public: void refocus(); void setKeyboardLayout(); + void setMouseConfigs(); void updateDragIcon(); void updateCapabilities(wlr_input_device*); -- cgit v1.2.3 From 641aaff998d6297831b9b139e5ff8767ab5c0c79 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 20 Jul 2022 18:39:08 +0200 Subject: minor code adjustments --- src/managers/input/InputManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/managers/input') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 5fbdcf23..f1ef0a91 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -117,7 +117,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { ACTIVEWORKSPACE->setActive(true); // event - g_pEventManager->postEvent(SHyprIPCEvent("activemon", PMONITOR->szName + "," + ACTIVEWORKSPACE->m_szName)); + g_pEventManager->postEvent(SHyprIPCEvent{"activemon", PMONITOR->szName + "," + ACTIVEWORKSPACE->m_szName}); } Vector2D surfaceCoords; -- cgit v1.2.3 From fa2bd3b1a846e7395f96b3bd3587a5ef92ed30be Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 20 Jul 2022 22:45:06 +0200 Subject: added keybinds on key up --- src/managers/input/InputManager.cpp | 19 ++----------------- src/managers/input/InputManager.hpp | 6 +++--- 2 files changed, 5 insertions(+), 20 deletions(-) (limited to 'src/managers/input') diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index f1ef0a91..c922421c 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -629,26 +629,11 @@ void CInputManager::destroyMouse(wlr_input_device* mouse) { } void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboard) { - const auto KEYCODE = e->keycode + 8; // Because to xkbcommon it's +8 from libinput - - const xkb_keysym_t* keysyms; - int syms = xkb_state_key_get_syms(wlr_keyboard_from_input_device(pKeyboard->keyboard)->xkb_state, KEYCODE, &keysyms); - - const auto MODS = accumulateModsFromAllKBs(); + bool passEvent = g_pKeybindManager->onKeyEvent(e, pKeyboard); wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat); - bool found = false; - if (e->state == WL_KEYBOARD_KEY_STATE_PRESSED) { - for (int i = 0; i < syms; ++i) - found = g_pKeybindManager->handleKeybinds(MODS, keysyms[i], 0) || found; - - found = g_pKeybindManager->handleKeybinds(MODS, 0, KEYCODE) || found; - } else if (e->state == WL_KEYBOARD_KEY_STATE_RELEASED) { - // hee hee - } - - if (!found) { + if (passEvent) { wlr_seat_set_keyboard(g_pCompositor->m_sSeat.seat, wlr_keyboard_from_input_device(pKeyboard->keyboard)); wlr_seat_keyboard_notify_key(g_pCompositor->m_sSeat.seat, e->time_msec, e->keycode, e->state); } diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp index 514d5bad..107d891f 100644 --- a/src/managers/input/InputManager.hpp +++ b/src/managers/input/InputManager.hpp @@ -76,6 +76,9 @@ public: CTimer m_tmrLastCursorMovement; + // for shared mods + uint32_t accumulateModsFromAllKBs(); + private: // for click behavior override @@ -92,9 +95,6 @@ private: STabletTool* ensureTabletToolPresent(wlr_tablet_tool*); void applyConfigToKeyboard(SKeyboard*); - - // for shared mods - uint32_t accumulateModsFromAllKBs(); }; inline std::unique_ptr g_pInputManager; \ No newline at end of file -- cgit v1.2.3