From 5c836e6460ae5e8c290cfff61ec0d2d0e99dfa15 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 16 Jul 2022 15:57:31 +0200 Subject: added master layout --- src/managers/AnimationManager.cpp | 1 - src/managers/LayoutManager.cpp | 20 ++++++++++++++++++++ src/managers/LayoutManager.hpp | 5 +++++ 3 files changed, 25 insertions(+), 1 deletion(-) (limited to 'src/managers') diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp index a8743afd..5d3027c9 100644 --- a/src/managers/AnimationManager.cpp +++ b/src/managers/AnimationManager.cpp @@ -191,7 +191,6 @@ void CAnimationManager::tick() { } case AVARDAMAGE_SHADOW: { RASSERT(PWINDOW, "Tried to AVARDAMAGE_SHADOW a non-window AVAR!"); - static auto* const PSHADOWSIZE = &g_pConfigManager->getConfigValuePtr("decoration:shadow_range")->intValue; static auto* const PSHADOWIGNOREWINDOW = &g_pConfigManager->getConfigValuePtr("decoration:shadow_ignore_window")->intValue; const auto PDECO = PWINDOW->getDecorationByType(DECORATION_SHADOW); diff --git a/src/managers/LayoutManager.cpp b/src/managers/LayoutManager.cpp index ec723350..8e7e397b 100644 --- a/src/managers/LayoutManager.cpp +++ b/src/managers/LayoutManager.cpp @@ -4,8 +4,28 @@ IHyprLayout* CLayoutManager::getCurrentLayout() { switch (m_iCurrentLayoutID) { case DWINDLE: return &m_cDwindleLayout; + case MASTER: + return &m_cMasterLayout; } // fallback return &m_cDwindleLayout; +} + +void CLayoutManager::switchToLayout(std::string layout) { + if (layout == "dwindle") { + if (m_iCurrentLayoutID != DWINDLE) { + getCurrentLayout()->onDisable(); + m_iCurrentLayoutID = DWINDLE; + getCurrentLayout()->onEnable(); + } + } else if (layout == "master") { + if (m_iCurrentLayoutID != MASTER) { + getCurrentLayout()->onDisable(); + m_iCurrentLayoutID = MASTER; + getCurrentLayout()->onEnable(); + } + } else { + Debug::log(ERR, "Unknown layout %s!", layout.c_str()); + } } \ No newline at end of file diff --git a/src/managers/LayoutManager.hpp b/src/managers/LayoutManager.hpp index 20f1f7f9..aa340e79 100644 --- a/src/managers/LayoutManager.hpp +++ b/src/managers/LayoutManager.hpp @@ -1,20 +1,25 @@ #pragma once #include "../layout/DwindleLayout.hpp" +#include "../layout/MasterLayout.hpp" class CLayoutManager { public: IHyprLayout* getCurrentLayout(); + void switchToLayout(std::string); + private: enum HYPRLAYOUTS { DWINDLE = 0, + MASTER }; HYPRLAYOUTS m_iCurrentLayoutID = DWINDLE; CHyprDwindleLayout m_cDwindleLayout; + CHyprMasterLayout m_cMasterLayout; }; inline std::unique_ptr g_pLayoutManager; \ No newline at end of file -- cgit v1.2.3 From edcecae7a074f76d6e0a9c7c29e796621c5b9e52 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 16 Jul 2022 19:55:40 +0200 Subject: dont cycle on fullscreen --- src/managers/KeybindManager.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/managers') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 60e4cdd6..86fb2275 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -1047,6 +1047,11 @@ void CKeybindManager::circleNext(std::string arg) { if (!g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow)) return; + const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastWindow->m_iWorkspaceID); + + if (PWORKSPACE->m_bHasFullscreenWindow) + return; + if (arg == "last" || arg == "l" || arg == "prev" || arg == "p") g_pCompositor->focusWindow(g_pCompositor->getPrevWindowOnWorkspace(g_pCompositor->m_pLastWindow)); else -- cgit v1.2.3 From dc1f34c5fad7c4067808cfcff4d1fde74331de4c Mon Sep 17 00:00:00 2001 From: Daniel Gerblick Date: Sun, 17 Jul 2022 19:00:12 -0400 Subject: added PID and address-based options for focuswindow, as well as updated `hyprctl clients` to be consistent with logs and `hyprctl activewindow` --- src/managers/KeybindManager.cpp | 51 ++++++++++++++++++++++++++++++++--------- src/managers/KeybindManager.hpp | 9 +++++++- 2 files changed, 48 insertions(+), 12 deletions(-) (limited to 'src/managers') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 86fb2275..67e331b8 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -1063,28 +1063,57 @@ void CKeybindManager::circleNext(std::string arg) { } void CKeybindManager::focusWindow(std::string regexp) { - bool titleRegex = false; + eFocusWindowMode mode = MODE_CLASS_REGEX; + std::regex regexCheck(regexp); + std::string matchCheck; if (regexp.find("title:") == 0) { - titleRegex = true; + mode = MODE_TITLE_REGEX; regexCheck = std::regex(regexp.substr(6)); } + else if (regexp.find("address:") == 0) { + mode = MODE_ADDRESS; + matchCheck = regexp.substr(8); + } + else if (regexp.find("pid:") == 0) { + mode = MODE_PID; + matchCheck = regexp.substr(4); + } for (auto& w : g_pCompositor->m_vWindows) { if (!w->m_bIsMapped || w->m_bHidden) continue; - if (titleRegex) { - const auto windowTitle = g_pXWaylandManager->getTitle(w.get()); - if (!std::regex_search(windowTitle, regexCheck)) - continue; - } - else { - const auto windowClass = g_pXWaylandManager->getAppIDClass(w.get()); - if (!std::regex_search(windowClass, regexCheck)) - continue; + switch (mode) { + case MODE_CLASS_REGEX: { + const auto windowClass = g_pXWaylandManager->getAppIDClass(w.get()); + if (!std::regex_search(g_pXWaylandManager->getAppIDClass(w.get()), regexCheck)) + continue; + break; + } + case MODE_TITLE_REGEX: { + const auto windowTitle = g_pXWaylandManager->getTitle(w.get()); + if (!std::regex_search(windowTitle, regexCheck)) + continue; + break; + } + case MODE_ADDRESS: { + std::string addr = getFormat("0x%x", w.get()); + if (matchCheck != addr) + continue; + break; + } + case MODE_PID: { + std::string pid = getFormat("%d", w->getPID()); + if (matchCheck != pid) + continue; + break; + } + default: + break; } + Debug::log(LOG, "Focusing to window name: %s", w->m_szTitle.c_str()); changeworkspace("[internal]" + std::to_string(w->m_iWorkspaceID)); diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp index 08a1cba3..3aece7be 100644 --- a/src/managers/KeybindManager.hpp +++ b/src/managers/KeybindManager.hpp @@ -66,6 +66,13 @@ private: static void setSubmap(std::string); friend class CCompositor; + + enum eFocusWindowMode { + MODE_CLASS_REGEX = 0, + MODE_TITLE_REGEX, + MODE_ADDRESS, + MODE_PID + }; }; -inline std::unique_ptr g_pKeybindManager; \ No newline at end of file +inline std::unique_ptr g_pKeybindManager; -- cgit v1.2.3 From 8bcfda22300d3b656b6f098f9dba5ce5f0914595 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Mon, 18 Jul 2022 20:53:29 +0200 Subject: update moveactivetoworkspace logic --- src/managers/KeybindManager.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/managers') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 86fb2275..1ad338cd 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -429,6 +429,9 @@ void CKeybindManager::moveActiveToWorkspace(std::string args) { return; } + auto PSAVEDSIZE = PWINDOW->m_vRealSize.vec(); + auto PSAVEDPOS = PWINDOW->m_vRealPosition.vec(); + g_pLayoutManager->getCurrentLayout()->onWindowRemoved(PWINDOW); g_pKeybindManager->changeworkspace(args); @@ -456,20 +459,21 @@ void CKeybindManager::moveActiveToWorkspace(std::string args) { PWORKSPACE->m_bHasFullscreenWindow = false; } + if (PWINDOW->m_bIsFullscreen) { + PWINDOW->m_bIsFullscreen = false; + PSAVEDPOS = PSAVEDPOS + Vector2D(10, 10); + PSAVEDSIZE = PSAVEDSIZE - Vector2D(20, 20); + } + // Hack: So that the layout doesnt find our window at the cursor PWINDOW->m_vPosition = Vector2D(-42069, -42069); - // Save the real position and size because the layout might set its own - const auto PSAVEDSIZE = PWINDOW->m_vRealSize.vec(); - const auto PSAVEDPOS = PWINDOW->m_vRealPosition.vec(); g_pLayoutManager->getCurrentLayout()->onWindowCreated(PWINDOW); - // and restore it - PWINDOW->m_vRealPosition.setValue(PSAVEDPOS); - PWINDOW->m_vRealSize.setValue(PSAVEDSIZE); + // and restore it if (PWINDOW->m_bIsFloating) { - PWINDOW->m_vRealPosition.setValue(PWINDOW->m_vRealPosition.vec() - g_pCompositor->getMonitorFromID(OLDWORKSPACE->m_iMonitorID)->vecPosition); - PWINDOW->m_vRealPosition.setValue(PWINDOW->m_vRealPosition.vec() + g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID)->vecPosition); + PWINDOW->m_vRealSize.setValue(PSAVEDSIZE); + PWINDOW->m_vRealPosition.setValueAndWarp(PSAVEDPOS - g_pCompositor->getMonitorFromID(OLDWORKSPACE->m_iMonitorID)->vecPosition + g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID)->vecPosition); PWINDOW->m_vPosition = PWINDOW->m_vRealPosition.vec(); } -- cgit v1.2.3 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') 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') 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') 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') 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/KeybindManager.cpp | 6 +++--- src/managers/input/InputManager.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/managers') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 2c91f81f..1d7a4ba4 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -230,7 +230,7 @@ void CKeybindManager::killActive(std::string args) { g_pXWaylandManager->sendCloseWindow(g_pCompositor->m_pLastWindow); g_pCompositor->m_pLastFocus = nullptr; g_pCompositor->m_pLastWindow = nullptr; - g_pEventManager->postEvent(SHyprIPCEvent("activewindow", ",")); // post an activewindow event to empty, as we are currently unfocused + g_pEventManager->postEvent(SHyprIPCEvent{"activewindow", ","}); // post an activewindow event to empty, as we are currently unfocused } g_pCompositor->focusWindow(g_pCompositor->windowFromCursor()); @@ -325,7 +325,7 @@ void CKeybindManager::changeworkspace(std::string args) { // start anim on new workspace PWORKSPACETOCHANGETO->startAnim(true, ANIMTOLEFT); - g_pEventManager->postEvent(SHyprIPCEvent("workspace", PWORKSPACETOCHANGETO->m_szName)); + g_pEventManager->postEvent(SHyprIPCEvent{"workspace", PWORKSPACETOCHANGETO->m_szName}); } // If the monitor is not the one our cursor's at, warp to it. @@ -398,7 +398,7 @@ void CKeybindManager::changeworkspace(std::string args) { g_pInputManager->refocus(); // Event - g_pEventManager->postEvent(SHyprIPCEvent("workspace", PWORKSPACE->m_szName)); + g_pEventManager->postEvent(SHyprIPCEvent{"workspace", PWORKSPACE->m_szName}); Debug::log(LOG, "Changed to workspace %i", workspaceToChangeTo); } 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/KeybindManager.cpp | 34 +++++++++++++++++++++++++++++++--- src/managers/KeybindManager.hpp | 6 +++++- src/managers/input/InputManager.cpp | 19 ++----------------- src/managers/input/InputManager.hpp | 6 +++--- 4 files changed, 41 insertions(+), 24 deletions(-) (limited to 'src/managers') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 1d7a4ba4..52afbfdd 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -82,7 +82,31 @@ uint32_t CKeybindManager::stringToModMask(std::string mods) { return modMask; } -bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t& key, const int& keycode) { +bool CKeybindManager::onKeyEvent(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 = g_pInputManager->accumulateModsFromAllKBs(); + + 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, true) || found; + + found = g_pKeybindManager->handleKeybinds(MODS, 0, KEYCODE, true) || found; + } else if (e->state == WL_KEYBOARD_KEY_STATE_RELEASED) { + for (int i = 0; i < syms; ++i) + found = g_pKeybindManager->handleKeybinds(MODS, keysyms[i], 0, false) || found; + + found = g_pKeybindManager->handleKeybinds(MODS, 0, KEYCODE, false) || found; + } + + return !found; +} + +bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t& key, const int& keycode, bool pressed) { bool found = false; if (handleInternalKeybinds(key)) @@ -92,10 +116,9 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t Debug::log(LOG, "Keybind handling only locked (inhibitor)"); for (auto& k : m_lKeybinds) { - if (modmask != k.modmask || (g_pCompositor->m_sSeat.exclusiveClient && !k.locked) || k.submap != m_szCurrentSelectedSubmap) + if (modmask != k.modmask || (g_pCompositor->m_sSeat.exclusiveClient && !k.locked) || k.submap != m_szCurrentSelectedSubmap || (!pressed && !k.release)) continue; - if (k.keycode != -1) { if (keycode != k.keycode) continue; @@ -114,6 +137,11 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t continue; } + if (pressed && k.release) { + // suppress down event + return true; + } + const auto DISPATCHER = m_mDispatchers.find(k.handler); // Should never happen, as we check in the ConfigManager, but oh well diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp index 3aece7be..fc3b06f8 100644 --- a/src/managers/KeybindManager.hpp +++ b/src/managers/KeybindManager.hpp @@ -14,13 +14,15 @@ struct SKeybind { std::string arg = ""; bool locked = false; std::string submap = ""; + bool release = false; }; class CKeybindManager { public: CKeybindManager(); - bool handleKeybinds(const uint32_t&, const xkb_keysym_t&, const int&); + bool onKeyEvent(wlr_keyboard_key_event*, SKeyboard*); + void addKeybind(SKeybind); void removeKeybind(uint32_t, const std::string&); uint32_t stringToModMask(std::string); @@ -33,6 +35,8 @@ private: inline static std::string m_szCurrentSelectedSubmap = ""; + bool handleKeybinds(const uint32_t&, const xkb_keysym_t&, const int&, bool); + bool handleInternalKeybinds(xkb_keysym_t); bool handleVT(xkb_keysym_t); 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 From 189cbe9f098816231673e9ebe1ac5fa5872f33e7 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Wed, 20 Jul 2022 23:17:26 +0200 Subject: added shadowing keybinds --- src/managers/KeybindManager.cpp | 62 ++++++++++++++++++++++++++++++++++------- src/managers/KeybindManager.hpp | 11 +++++++- 2 files changed, 62 insertions(+), 11 deletions(-) (limited to 'src/managers') diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 52afbfdd..74cecc45 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -85,28 +85,35 @@ uint32_t CKeybindManager::stringToModMask(std::string mods) { bool CKeybindManager::onKeyEvent(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 xkb_keysym_t keysym = xkb_state_key_get_one_sym(wlr_keyboard_from_input_device(pKeyboard->keyboard)->xkb_state, KEYCODE); const auto MODS = g_pInputManager->accumulateModsFromAllKBs(); + 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, true) || found; + m_dPressedKeycodes.push_back(KEYCODE); + m_dPressedKeysyms.push_back(keysym); + + found = g_pKeybindManager->handleKeybinds(MODS, keysym, 0, true, e->time_msec) || found; - found = g_pKeybindManager->handleKeybinds(MODS, 0, KEYCODE, true) || found; + found = g_pKeybindManager->handleKeybinds(MODS, 0, KEYCODE, true, e->time_msec) || found; } else if (e->state == WL_KEYBOARD_KEY_STATE_RELEASED) { - for (int i = 0; i < syms; ++i) - found = g_pKeybindManager->handleKeybinds(MODS, keysyms[i], 0, false) || found; - found = g_pKeybindManager->handleKeybinds(MODS, 0, KEYCODE, false) || found; + m_dPressedKeycodes.erase(std::remove(m_dPressedKeycodes.begin(), m_dPressedKeycodes.end(), KEYCODE)); + m_dPressedKeysyms.erase(std::remove(m_dPressedKeysyms.begin(), m_dPressedKeysyms.end(), keysym)); + + found = g_pKeybindManager->handleKeybinds(MODS, keysym, 0, false, e->time_msec) || found; + + found = g_pKeybindManager->handleKeybinds(MODS, 0, KEYCODE, false, e->time_msec) || found; + + shadowKeybinds(); } return !found; } -bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t& key, const int& keycode, bool pressed) { +bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t& key, const int& keycode, bool pressed, uint32_t time) { bool found = false; if (handleInternalKeybinds(key)) @@ -115,8 +122,14 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t if (g_pCompositor->m_sSeat.exclusiveClient) Debug::log(LOG, "Keybind handling only locked (inhibitor)"); + if (pressed && m_kHeldBack) { + // release the held back event + wlr_seat_keyboard_notify_key(g_pCompositor->m_sSeat.seat, time, m_kHeldBack, WL_KEYBOARD_KEY_STATE_PRESSED); + m_kHeldBack = 0; + } + for (auto& k : m_lKeybinds) { - if (modmask != k.modmask || (g_pCompositor->m_sSeat.exclusiveClient && !k.locked) || k.submap != m_szCurrentSelectedSubmap || (!pressed && !k.release)) + if (modmask != k.modmask || (g_pCompositor->m_sSeat.exclusiveClient && !k.locked) || k.submap != m_szCurrentSelectedSubmap || (!pressed && !k.release) || k.shadowed) continue; if (k.keycode != -1) { @@ -139,6 +152,7 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t if (pressed && k.release) { // suppress down event + m_kHeldBack = key; return true; } @@ -153,12 +167,40 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t DISPATCHER->second(k.arg); } + shadowKeybinds(); + found = true; } return found; } +void CKeybindManager::shadowKeybinds() { + // shadow disables keybinds after one has been triggered + + for (auto& k : m_lKeybinds) { + + bool shadow = false; + + const auto KBKEY = xkb_keysym_from_name(k.key.c_str(), XKB_KEYSYM_CASE_INSENSITIVE); + const auto KBKEYUPPER = xkb_keysym_to_upper(KBKEY); + + for (auto& pk : m_dPressedKeysyms) { + if ((pk == KBKEY || pk == KBKEYUPPER)) { + shadow = true; + } + } + + for (auto& pk : m_dPressedKeycodes) { + if (pk == (unsigned int)k.keycode) { + shadow = true; + } + } + + k.shadowed = shadow; + } +} + bool CKeybindManager::handleVT(xkb_keysym_t keysym) { // Handles the CTRL+ALT+FX TTY keybinds if (!(keysym >= XKB_KEY_XF86Switch_VT_1 && keysym <= XKB_KEY_XF86Switch_VT_12)) diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp index fc3b06f8..62568fc0 100644 --- a/src/managers/KeybindManager.hpp +++ b/src/managers/KeybindManager.hpp @@ -15,6 +15,9 @@ struct SKeybind { bool locked = false; std::string submap = ""; bool release = false; + + // DO NOT INITIALIZE + bool shadowed = false; }; class CKeybindManager { @@ -32,10 +35,16 @@ public: private: std::list m_lKeybinds; + std::deque m_dPressedKeysyms; + std::deque m_dPressedKeycodes; inline static std::string m_szCurrentSelectedSubmap = ""; - bool handleKeybinds(const uint32_t&, const xkb_keysym_t&, const int&, bool); + xkb_keysym_t m_kHeldBack = 0; + + bool handleKeybinds(const uint32_t&, const xkb_keysym_t&, const int&, bool, uint32_t); + + void shadowKeybinds(); bool handleInternalKeybinds(xkb_keysym_t); bool handleVT(xkb_keysym_t); -- cgit v1.2.3 From 75ce01b1a722b2ae39322f4a1413cb1c2d8ead16 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 21 Jul 2022 12:33:22 +0200 Subject: Make the thread manager into a wl event loop timer --- src/managers/ThreadManager.cpp | 35 +++++++++++++++-------------------- src/managers/ThreadManager.hpp | 6 ++---- 2 files changed, 17 insertions(+), 24 deletions(-) (limited to 'src/managers') diff --git a/src/managers/ThreadManager.cpp b/src/managers/ThreadManager.cpp index fa3d0d4e..3ca4d550 100644 --- a/src/managers/ThreadManager.cpp +++ b/src/managers/ThreadManager.cpp @@ -1,34 +1,29 @@ #include "ThreadManager.hpp" #include "../debug/HyprCtl.hpp" +#include "../Compositor.hpp" -CThreadManager::CThreadManager() { - m_tMainThread = new std::thread([&]() { - // Call the handle method. - this->handle(); - }); +int slowUpdate = 0; - m_tMainThread->detach(); // detach and continue. -} +int handleTimer(void* data) { + const auto PTM = (CThreadManager*)data; -CThreadManager::~CThreadManager() { - // -} + g_pConfigManager->tick(); -int slowUpdate = 0; + wl_event_source_timer_update(PTM->m_esConfigTimer, 1000); -void CThreadManager::handle() { + return 0; +} +CThreadManager::CThreadManager() { g_pConfigManager->init(); HyprCtl::startHyprCtlSocket(); - while (3.1415f) { - slowUpdate++; - if (slowUpdate >= g_pConfigManager->getInt("general:max_fps")){ - g_pConfigManager->tick(); - slowUpdate = 0; - } + m_esConfigTimer = wl_event_loop_add_timer(g_pCompositor->m_sWLEventLoop, handleTimer, this); + + wl_event_source_timer_update(m_esConfigTimer, 1000); +} - std::this_thread::sleep_for(std::chrono::microseconds(1000000 / g_pConfigManager->getInt("general:max_fps"))); - } +CThreadManager::~CThreadManager() { + // } \ No newline at end of file diff --git a/src/managers/ThreadManager.hpp b/src/managers/ThreadManager.hpp index 40ed88d6..0a716e0b 100644 --- a/src/managers/ThreadManager.hpp +++ b/src/managers/ThreadManager.hpp @@ -9,11 +9,9 @@ public: CThreadManager(); ~CThreadManager(); -private: + wl_event_source* m_esConfigTimer; - void handle(); - - std::thread* m_tMainThread; + private: }; inline std::unique_ptr g_pThreadManager; \ No newline at end of file -- cgit v1.2.3