From 43aea417b0ed46e9ab634f32c0cc8b47c94e64ee Mon Sep 17 00:00:00 2001 From: vaxerski Date: Thu, 18 Aug 2022 22:35:55 +0200 Subject: [PATCH 01/26] Fix occasional hangups on exit --- src/Compositor.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 5d6d65ec..bf549695 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -233,6 +233,14 @@ void CCompositor::cleanup() { wl_display_terminate(m_sWLDisplay); m_sWLDisplay = nullptr; + + // kill the PID with a sigkill after 2 seconds + const auto PID = getpid(); + + std::string call = "sleep 2 && kill -9 " + std::to_string(PID); + + execl("/bin/sh", "/bin/sh", "-c", call.c_str(), ">", "/dev/null", nullptr); // this is to prevent that random "freezing" + // the PID should not be reused. } void CCompositor::startCompositor() { From 6cae44e2c0254e959ad05e4f2d98576cb6b82258 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Fri, 19 Aug 2022 14:52:18 +0200 Subject: [PATCH 02/26] fix custom rounding in shadow deco --- src/render/decorations/CHyprDropShadowDecoration.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/render/decorations/CHyprDropShadowDecoration.cpp b/src/render/decorations/CHyprDropShadowDecoration.cpp index db1b8263..0abccdd5 100644 --- a/src/render/decorations/CHyprDropShadowDecoration.cpp +++ b/src/render/decorations/CHyprDropShadowDecoration.cpp @@ -80,6 +80,8 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a) { return; // cannot parse } + const auto ROUNDING = !m_pWindow->m_sSpecialRenderData.rounding ? 0 : (m_pWindow->m_sAdditionalConfigData.rounding == -1 ? *PROUNDING : m_pWindow->m_sAdditionalConfigData.rounding); + // update the extents m_seExtents = {{*PSHADOWSIZE + 2 - offset.x, *PSHADOWSIZE + 2 - offset.y}, {*PSHADOWSIZE + 2 + offset.x, *PSHADOWSIZE + 2 + offset.y}}; @@ -113,15 +115,15 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a) { glDisable(GL_STENCIL_TEST); return; // prevent assert failed } - - g_pHyprOpenGL->renderRect(&windowBox, CColor(0,0,0,0), *PROUNDING * pMonitor->scale); + + g_pHyprOpenGL->renderRect(&windowBox, CColor(0, 0, 0, 0), ROUNDING * pMonitor->scale); glStencilFunc(GL_NOTEQUAL, 1, -1); glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); } scaleBox(&fullBox, pMonitor->scale); - g_pHyprOpenGL->renderRoundedShadow(&fullBox, *PROUNDING * pMonitor->scale, *PSHADOWSIZE * pMonitor->scale, a); + g_pHyprOpenGL->renderRoundedShadow(&fullBox, ROUNDING * pMonitor->scale, *PSHADOWSIZE * pMonitor->scale, a); if (*PSHADOWIGNOREWINDOW) { // cleanup From f9e30e985c03ee6cb0641cdd032f003e02976b96 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Fri, 19 Aug 2022 17:25:07 +0200 Subject: [PATCH 03/26] fix refocus on no window --- src/managers/input/InputManager.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index f8899f62..9a0d5226 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -182,9 +182,14 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { if (!(pFoundWindow && pFoundWindow->m_bIsFloating && pFoundWindow->m_bCreatedOverFullscreen)) pFoundWindow = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID); } - } else + } else { pFoundWindow = g_pCompositor->vectorToWindowIdeal(mouseCoords); + if (refocus && !pFoundWindow) { + pFoundWindow = g_pCompositor->getFirstWindowOnWorkspace(PMONITOR->activeWorkspace); + } + } + if (pFoundWindow) { if (!pFoundWindow->m_bIsX11) { foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords); From 81b27be6bb9fa86dae9fdae43e093743d7f24cf7 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Fri, 19 Aug 2022 17:29:16 +0200 Subject: [PATCH 04/26] reset lastwindow on full LS focus --- src/managers/input/InputManager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 9a0d5226..a0016dba 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -272,8 +272,10 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { g_pCompositor->focusWindow(pFoundWindow, foundSurface); } } else { - if (pFoundLayerSurface && pFoundLayerSurface->layerSurface->current.keyboard_interactive && *PFOLLOWMOUSE != 3 && allowKeyboardRefocus) + if (pFoundLayerSurface && pFoundLayerSurface->layerSurface->current.keyboard_interactive && *PFOLLOWMOUSE != 3 && allowKeyboardRefocus) { g_pCompositor->focusSurface(foundSurface); + g_pCompositor->m_pLastWindow = nullptr; // reset last window as we have a full focus on a LS + } } wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, foundSurface, surfaceLocal.x, surfaceLocal.y); From 504d07a87dd439767b5a87cd93b43fac47ca3f79 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Fri, 19 Aug 2022 17:36:01 +0200 Subject: [PATCH 05/26] fix swipe on workspace style fade --- src/managers/input/Swipe.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/managers/input/Swipe.cpp b/src/managers/input/Swipe.cpp index ca4c60e6..807d0bcc 100644 --- a/src/managers/input/Swipe.cpp +++ b/src/managers/input/Swipe.cpp @@ -143,11 +143,13 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) { const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceIDLeft); PWORKSPACE->m_bForceRendering = true; + PWORKSPACE->m_fAlpha.setValueAndWarp(255.f); if (workspaceIDLeft != workspaceIDRight) { const auto PWORKSPACER = g_pCompositor->getWorkspaceByID(workspaceIDRight); PWORKSPACER->m_bForceRendering = false; + PWORKSPACE->m_fAlpha.setValueAndWarp(0.f); } PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(((- m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x - m_sActiveSwipe.pMonitor->vecSize.x, 0)); @@ -163,11 +165,13 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) { const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceIDRight); PWORKSPACE->m_bForceRendering = true; + PWORKSPACE->m_fAlpha.setValueAndWarp(255.f); if (workspaceIDLeft != workspaceIDRight) { const auto PWORKSPACEL = g_pCompositor->getWorkspaceByID(workspaceIDLeft); PWORKSPACEL->m_bForceRendering = false; + PWORKSPACE->m_fAlpha.setValueAndWarp(0.f); } PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(((- m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x + m_sActiveSwipe.pMonitor->vecSize.x, 0)); From 946222f4a7f1cb4a5fb4e28613025ad652982812 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Fri, 19 Aug 2022 17:42:10 +0200 Subject: [PATCH 06/26] fix typo in swipe alpha control --- src/managers/input/Swipe.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/managers/input/Swipe.cpp b/src/managers/input/Swipe.cpp index 807d0bcc..51be5248 100644 --- a/src/managers/input/Swipe.cpp +++ b/src/managers/input/Swipe.cpp @@ -149,7 +149,7 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) { const auto PWORKSPACER = g_pCompositor->getWorkspaceByID(workspaceIDRight); PWORKSPACER->m_bForceRendering = false; - PWORKSPACE->m_fAlpha.setValueAndWarp(0.f); + PWORKSPACER->m_fAlpha.setValueAndWarp(0.f); } PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(((- m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x - m_sActiveSwipe.pMonitor->vecSize.x, 0)); @@ -171,7 +171,7 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) { const auto PWORKSPACEL = g_pCompositor->getWorkspaceByID(workspaceIDLeft); PWORKSPACEL->m_bForceRendering = false; - PWORKSPACE->m_fAlpha.setValueAndWarp(0.f); + PWORKSPACEL->m_fAlpha.setValueAndWarp(0.f); } PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(((- m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x + m_sActiveSwipe.pMonitor->vecSize.x, 0)); From 69d17bf4240e41f2b26abd7a46dfd0e754e9ee9e Mon Sep 17 00:00:00 2001 From: FlafyDev Date: Fri, 19 Aug 2022 21:01:51 +0300 Subject: [PATCH 07/26] add input:kb_file --- example/hyprland.conf | 3 +- src/config/ConfigManager.cpp | 47 +++++++++++++++++------------ src/config/ConfigManager.hpp | 3 +- src/config/defaultConfig.hpp | 3 +- src/helpers/WLClasses.hpp | 3 +- src/managers/input/InputManager.cpp | 22 ++++++++++++-- 6 files changed, 55 insertions(+), 26 deletions(-) diff --git a/example/hyprland.conf b/example/hyprland.conf index 506e0e7e..e2732c62 100644 --- a/example/hyprland.conf +++ b/example/hyprland.conf @@ -12,6 +12,7 @@ monitor=,preferred,auto,1 workspace=DP-1,1 input { + kb_file= kb_layout= kb_variant= kb_model= @@ -112,4 +113,4 @@ bind=ALT,9,movetoworkspace,9 bind=ALT,0,movetoworkspace,10 bind=SUPER,mouse_down,workspace,e+1 -bind=SUPER,mouse_up,workspace,e-1 \ No newline at end of file +bind=SUPER,mouse_up,workspace,e-1 diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 5f7725a2..37ea10fc 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -119,6 +119,7 @@ void CConfigManager::setDefaultVars() { configValues["animations:workspaces"].intValue = 1; configValues["input:sensitivity"].floatValue = 0.f; + configValues["input:kb_file"].strValue = STRVAL_EMPTY; configValues["input:kb_layout"].strValue = "us"; configValues["input:kb_variant"].strValue = STRVAL_EMPTY; configValues["input:kb_options"].strValue = STRVAL_EMPTY; @@ -155,6 +156,7 @@ void CConfigManager::setDeviceDefaultVars(const std::string& dev) { auto& cfgValues = deviceConfigs[dev]; cfgValues["sensitivity"].floatValue = 0.f; + cfgValues["kb_file"].strValue = STRVAL_EMPTY; cfgValues["kb_layout"].strValue = "us"; cfgValues["kb_variant"].strValue = STRVAL_EMPTY; cfgValues["kb_options"].strValue = STRVAL_EMPTY; @@ -774,28 +776,13 @@ void CConfigManager::handleSubmap(const std::string& command, const std::string& void CConfigManager::handleSource(const std::string& command, const std::string& rawpath) { static const char* const ENVHOME = getenv("HOME"); - auto value = rawpath; - - if (value.length() < 2) { + if (rawpath.length() < 2) { Debug::log(ERR, "source= path garbage"); - parseError = "source path " + value + " bogus!"; + parseError = "source path " + rawpath + " bogus!"; return; } - if (value[0] == '.') { - auto currentDir = configCurrentPath.substr(0, configCurrentPath.find_last_of('/')); - - if (value[1] == '.') { - auto parentDir = currentDir.substr(0, currentDir.find_last_of('/')); - value.replace(0, 2, parentDir); - } else { - value.replace(0, 1, currentDir); - } - } - - if (value[0] == '~') { - value.replace(0, 1, std::string(ENVHOME)); - } + auto value = absolutePath(rawpath); if (!std::filesystem::exists(value)) { Debug::log(ERR, "source= file doesnt exist"); @@ -889,6 +876,28 @@ std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std:: return parseError; } +std::string CConfigManager::absolutePath(const std::string& rawpath) { + auto value = rawpath; + + if (value[0] == '.') { + auto currentDir = configCurrentPath.substr(0, configCurrentPath.find_last_of('/')); + + if (value[1] == '.') { + auto parentDir = currentDir.substr(0, currentDir.find_last_of('/')); + value.replace(0, 2, parentDir); + } else { + value.replace(0, 1, currentDir); + } + } + + if (value[0] == '~') { + static const char* const ENVHOME = getenv("HOME"); + value.replace(0, 1, std::string(ENVHOME)); + } + + return value; +} + void CConfigManager::applyUserDefinedVars(std::string& line, const size_t equalsPlace) { auto dollarPlace = line.find_first_of('$', equalsPlace); @@ -1379,4 +1388,4 @@ SAnimationPropertyConfig* CConfigManager::getAnimationPropertyConfig(const std:: void CConfigManager::addParseError(const std::string& err) { if (parseError == "") parseError = err; -} \ No newline at end of file +} diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp index 87cbd956..05e00921 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -101,6 +101,7 @@ public: void ensureDPMS(); std::string parseKeyword(const std::string&, const std::string&, bool dynamic = false); + std::string absolutePath(const std::string&); void addParseError(const std::string&); @@ -159,4 +160,4 @@ private: void handleBlurLS(const std::string&, const std::string&); }; -inline std::unique_ptr g_pConfigManager; \ No newline at end of file +inline std::unique_ptr g_pConfigManager; diff --git a/src/config/defaultConfig.hpp b/src/config/defaultConfig.hpp index 75ec925f..9ecdbbb0 100644 --- a/src/config/defaultConfig.hpp +++ b/src/config/defaultConfig.hpp @@ -20,6 +20,7 @@ autogenerated=1 # remove this line to get rid of the warning on top. monitor=,preferred,auto,1 input { + kb_file= kb_layout= kb_variant= kb_model= @@ -122,4 +123,4 @@ bind=ALT,0,movetoworkspace,10 bind=SUPER,mouse_down,workspace,e+1 bind=SUPER,mouse_up,workspace,e-1 -)#"; \ No newline at end of file +)#"; diff --git a/src/helpers/WLClasses.hpp b/src/helpers/WLClasses.hpp index 6b0787bb..4c769202 100644 --- a/src/helpers/WLClasses.hpp +++ b/src/helpers/WLClasses.hpp @@ -103,6 +103,7 @@ struct SKeyboard { xkb_layout_index_t activeLayout = 0; std::string name = ""; + std::string xkbFilePath = ""; SStringRuleNames currentRules; int repeatRate = 0; @@ -316,4 +317,4 @@ struct SIMEPopup { bool operator==(const SIMEPopup& other) { return pSurface == other.pSurface; } -}; \ No newline at end of file +}; diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index f8899f62..82889f8a 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -519,6 +519,7 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) { const auto NUMLOCKON = HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "numlock_by_default") : g_pConfigManager->getInt("input:numlock_by_default"); + const auto FILEPATH = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_file") : g_pConfigManager->getString("input:kb_file"); const auto RULES = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_rules") : g_pConfigManager->getString("input:kb_rules"); const auto MODEL = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_model") : g_pConfigManager->getString("input:kb_model"); const auto LAYOUT = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_layout") : g_pConfigManager->getString("input:kb_layout"); @@ -526,7 +527,7 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) { const auto OPTIONS = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_options") : g_pConfigManager->getString("input:kb_options"); try { - if (NUMLOCKON == pKeyboard->numlockOn && REPEATDELAY == pKeyboard->repeatDelay && REPEATRATE == pKeyboard->repeatRate && RULES != "" && RULES == pKeyboard->currentRules.rules && MODEL == pKeyboard->currentRules.model && LAYOUT == pKeyboard->currentRules.layout && VARIANT == pKeyboard->currentRules.variant && OPTIONS == pKeyboard->currentRules.options) { + if (NUMLOCKON == pKeyboard->numlockOn && REPEATDELAY == pKeyboard->repeatDelay && REPEATRATE == pKeyboard->repeatRate && RULES != "" && RULES == pKeyboard->currentRules.rules && MODEL == pKeyboard->currentRules.model && LAYOUT == pKeyboard->currentRules.layout && VARIANT == pKeyboard->currentRules.variant && OPTIONS == pKeyboard->currentRules.options && FILEPATH == pKeyboard->xkbFilePath) { Debug::log(LOG, "Not applying config to keyboard, it did not change."); return; } @@ -540,6 +541,7 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) { pKeyboard->repeatDelay = REPEATDELAY; pKeyboard->repeatRate = REPEATRATE; pKeyboard->numlockOn = NUMLOCKON; + pKeyboard->xkbFilePath = FILEPATH.c_str(); xkb_rule_names rules = { .rules = RULES.c_str(), @@ -563,7 +565,21 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) { Debug::log(LOG, "Attempting to create a keymap for layout %s with variant %s (rules: %s, model: %s, options: %s)", rules.layout, rules.variant, rules.rules, rules.model, rules.options); - auto KEYMAP = xkb_keymap_new_from_names(CONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS); + xkb_keymap * KEYMAP = NULL; + + if (!FILEPATH.empty()) { + auto path = g_pConfigManager->absolutePath(FILEPATH); + + if (!std::filesystem::exists(path)) { + Debug::log(ERR, "input:kb_file= file doesnt exist"); + } else { + KEYMAP = xkb_keymap_new_from_file(CONTEXT, fopen(path.c_str(), "r"), XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS); + } + } + + if (!KEYMAP) { + KEYMAP = xkb_keymap_new_from_names(CONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS); + } if (!KEYMAP) { g_pConfigManager->addParseError("Invalid keyboard layout passed. ( rules: " + RULES + ", model: " + MODEL + ", variant: " + VARIANT + ", options: " + OPTIONS + ", layout: " + LAYOUT + " )"); @@ -942,4 +958,4 @@ void CInputManager::disableAllKeyboards(bool virt) { k.active = false; } -} \ No newline at end of file +} From e749331f303e542e5341b3517d760211d4592ef5 Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Fri, 19 Aug 2022 21:50:57 +0200 Subject: [PATCH 08/26] update wiki links in readme --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d88367de..4735b279 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ Try it out and report bugs / suggestions! -[Configure]: https://github.com/hyprwm/Hyprland/wiki/Configuring-Hyprland +[Configure]: https://wiki.hyprland.org/Configuring/Configuring-Hyprland/ [Discord]: https://discord.gg/hQ9XvMUjjr [Stars]: https://starchart.cc/hyprwm/Hyprland [Hypr]: https://github.com/hyprwm/Hypr @@ -132,9 +132,9 @@ Try it out and report bugs / suggestions! [Issues]: https://github.com/hyprwm/Hyprland/issues [Todo]: https://github.com/hyprwm/Hyprland/projects?type=beta -[Contribute]: https://github.com/hyprwm/Hyprland/wiki/Contributing-&-Debugging -[Install]: https://github.com/hyprwm/Hyprland/wiki/Installation -[Quick Start]: https://github.com/hyprwm/Hyprland/wiki/Quick-start +[Contribute]: https://wiki.hyprland.org/Contributing-and-Debugging/ +[Install]: https://wiki.hyprland.org/Getting-Started/Installation/ +[Quick Start]: https://wiki.hyprland.org/Getting-Started/Quick-start/ [License]: LICENSE From c2a3896cc9168a12f25a144dada6ecb94fb52b59 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Fri, 19 Aug 2022 22:03:35 +0200 Subject: [PATCH 09/26] added dwindle:use_active_for_splits --- src/config/ConfigManager.cpp | 1 + src/layout/DwindleLayout.cpp | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 5f7725a2..47f10bc5 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -92,6 +92,7 @@ void CConfigManager::setDefaultVars() { configValues["dwindle:special_scale_factor"].floatValue = 0.8f; configValues["dwindle:split_width_multiplier"].floatValue = 1.0f; configValues["dwindle:no_gaps_when_only"].intValue = 0; + configValues["dwindle:use_active_for_splits"].intValue = 1; configValues["master:special_scale_factor"].floatValue = 0.8f; configValues["master:new_is_master"].intValue = 1; diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index 923f4f2b..3e1b697b 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -258,6 +258,8 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) { const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID); + static auto *const PUSEACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:use_active_for_splits")->intValue; + // Populate the node with our window's data PNODE->workspaceID = pWindow->m_iWorkspaceID; PNODE->pWindow = pWindow; @@ -267,13 +269,22 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) { SDwindleNodeData* OPENINGON; const auto MONFROMCURSOR = g_pCompositor->getMonitorFromCursor(); - if (PMONITOR->ID == MONFROMCURSOR->ID && (PNODE->workspaceID == PMONITOR->activeWorkspace || (PNODE->workspaceID == SPECIAL_WORKSPACE_ID && PMONITOR->specialWorkspaceOpen))) { + if (PMONITOR->ID == MONFROMCURSOR->ID && (PNODE->workspaceID == PMONITOR->activeWorkspace || (PNODE->workspaceID == SPECIAL_WORKSPACE_ID && PMONITOR->specialWorkspaceOpen)) && !*PUSEACTIVE) { OPENINGON = getNodeFromWindow(g_pCompositor->vectorToWindowTiled(g_pInputManager->getMouseCoordsInternal())); // happens on reserved area if (!OPENINGON && g_pCompositor->getWindowsOnWorkspace(PNODE->workspaceID) > 0) OPENINGON = getFirstNodeOnWorkspace(PMONITOR->activeWorkspace); + } else if (*PUSEACTIVE) { + if (g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow) && !g_pCompositor->m_pLastWindow->m_bIsFloating) { + OPENINGON = getNodeFromWindow(g_pCompositor->m_pLastWindow); + } else { + OPENINGON = getNodeFromWindow(g_pCompositor->vectorToWindowTiled(g_pInputManager->getMouseCoordsInternal())); + } + + if (!OPENINGON && g_pCompositor->getWindowsOnWorkspace(PNODE->workspaceID) > 0) + OPENINGON = getFirstNodeOnWorkspace(PMONITOR->activeWorkspace); } else OPENINGON = getFirstNodeOnWorkspace(pWindow->m_iWorkspaceID); From f0ad77251b28fcf48dcaf25f23e3a140d69a4735 Mon Sep 17 00:00:00 2001 From: FlafyDev Date: Fri, 19 Aug 2022 23:18:09 +0300 Subject: [PATCH 10/26] move absolutePath to MiscFunctions --- src/config/ConfigManager.cpp | 24 +----------------------- src/config/ConfigManager.hpp | 5 ++--- src/helpers/MiscFunctions.cpp | 22 ++++++++++++++++++++++ src/helpers/MiscFunctions.hpp | 3 ++- src/managers/input/InputManager.cpp | 2 +- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 37ea10fc..162c8611 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -782,7 +782,7 @@ void CConfigManager::handleSource(const std::string& command, const std::string& return; } - auto value = absolutePath(rawpath); + auto value = absolutePath(rawpath, configCurrentPath); if (!std::filesystem::exists(value)) { Debug::log(ERR, "source= file doesnt exist"); @@ -876,28 +876,6 @@ std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std:: return parseError; } -std::string CConfigManager::absolutePath(const std::string& rawpath) { - auto value = rawpath; - - if (value[0] == '.') { - auto currentDir = configCurrentPath.substr(0, configCurrentPath.find_last_of('/')); - - if (value[1] == '.') { - auto parentDir = currentDir.substr(0, currentDir.find_last_of('/')); - value.replace(0, 2, parentDir); - } else { - value.replace(0, 1, currentDir); - } - } - - if (value[0] == '~') { - static const char* const ENVHOME = getenv("HOME"); - value.replace(0, 1, std::string(ENVHOME)); - } - - return value; -} - void CConfigManager::applyUserDefinedVars(std::string& line, const size_t equalsPlace) { auto dollarPlace = line.find_first_of('$', equalsPlace); diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp index 05e00921..72eb58f6 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -101,12 +101,13 @@ public: void ensureDPMS(); std::string parseKeyword(const std::string&, const std::string&, bool dynamic = false); - std::string absolutePath(const std::string&); void addParseError(const std::string&); SAnimationPropertyConfig* getAnimationPropertyConfig(const std::string&); + std::string configCurrentPath; + private: std::deque configPaths; // stores all the config paths std::unordered_map configModifyTimes; // stores modify times @@ -116,8 +117,6 @@ private: std::unordered_map animationConfig; // stores all the animations with their set values - std::string configCurrentPath; - std::string currentCategory = ""; // For storing the category of the current item std::string parseError = ""; // For storing a parse error to display later diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp index b7285637..b27489ca 100644 --- a/src/helpers/MiscFunctions.cpp +++ b/src/helpers/MiscFunctions.cpp @@ -40,6 +40,28 @@ static const float transforms[][9] = {{ }, }; +std::string absolutePath(const std::string& rawpath, const std::string& currentPath) { + auto value = rawpath; + + if (value[0] == '.') { + auto currentDir = currentPath.substr(0, currentPath.find_last_of('/')); + + if (value[1] == '.') { + auto parentDir = currentDir.substr(0, currentDir.find_last_of('/')); + value.replace(0, 2, parentDir); + } else { + value.replace(0, 1, currentDir); + } + } + + if (value[0] == '~') { + static const char* const ENVHOME = getenv("HOME"); + value.replace(0, 1, std::string(ENVHOME)); + } + + return value; +} + void addWLSignal(wl_signal* pSignal, wl_listener* pListener, void* pOwner, std::string ownerString) { ASSERT(pSignal); ASSERT(pListener); diff --git a/src/helpers/MiscFunctions.hpp b/src/helpers/MiscFunctions.hpp index a40471a9..9f002c20 100644 --- a/src/helpers/MiscFunctions.hpp +++ b/src/helpers/MiscFunctions.hpp @@ -2,6 +2,7 @@ #include "../includes.hpp" +std::string absolutePath(const std::string&, const std::string&); void addWLSignal(wl_signal*, wl_listener*, void* pOwner, std::string ownerString); void wlr_signal_emit_safe(struct wl_signal *signal, void *data); std::string getFormat(const char *fmt, ...); // Basically Debug::log to a string @@ -17,4 +18,4 @@ std::string execAndGet(const char*); float getPlusMinusKeywordResult(std::string in, float relative); -void matrixProjection(float mat[9], int w, int h, wl_output_transform tr); \ No newline at end of file +void matrixProjection(float mat[9], int w, int h, wl_output_transform tr); diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index 82889f8a..b35d9064 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -568,7 +568,7 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) { xkb_keymap * KEYMAP = NULL; if (!FILEPATH.empty()) { - auto path = g_pConfigManager->absolutePath(FILEPATH); + auto path = absolutePath(FILEPATH, g_pConfigManager->configCurrentPath); if (!std::filesystem::exists(path)) { Debug::log(ERR, "input:kb_file= file doesnt exist"); From 1b1a0259a856892c136d03fe210151b0cdeda91c Mon Sep 17 00:00:00 2001 From: vaxerski Date: Fri, 19 Aug 2022 23:22:53 +0200 Subject: [PATCH 11/26] fix crash --- src/managers/input/InputManager.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index d6cf00be..87869da1 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -185,9 +185,10 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) { } else { pFoundWindow = g_pCompositor->vectorToWindowIdeal(mouseCoords); - if (refocus && !pFoundWindow) { - pFoundWindow = g_pCompositor->getFirstWindowOnWorkspace(PMONITOR->activeWorkspace); - } + // TODO: this causes crashes, sometimes. ??? + // if (refocus && !pFoundWindow) { + // pFoundWindow = g_pCompositor->getFirstWindowOnWorkspace(PMONITOR->activeWorkspace); + // } } if (pFoundWindow) { From 185f93ae64d2fe616d06ba1b9919cf1e98168bd6 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 20 Aug 2022 17:59:15 +0200 Subject: [PATCH 12/26] fix dwindle active for splits --- src/layout/DwindleLayout.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index 3e1b697b..da48ac31 100644 --- a/src/layout/DwindleLayout.cpp +++ b/src/layout/DwindleLayout.cpp @@ -277,7 +277,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) { OPENINGON = getFirstNodeOnWorkspace(PMONITOR->activeWorkspace); } else if (*PUSEACTIVE) { - if (g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow) && !g_pCompositor->m_pLastWindow->m_bIsFloating) { + if (g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow) && !g_pCompositor->m_pLastWindow->m_bIsFloating && g_pCompositor->m_pLastWindow != pWindow && g_pCompositor->m_pLastWindow->m_iWorkspaceID == pWindow->m_iWorkspaceID && g_pCompositor->m_pLastWindow->m_bIsMapped) { OPENINGON = getNodeFromWindow(g_pCompositor->m_pLastWindow); } else { OPENINGON = getNodeFromWindow(g_pCompositor->vectorToWindowTiled(g_pInputManager->getMouseCoordsInternal())); @@ -419,8 +419,10 @@ void CHyprDwindleLayout::onWindowRemovedTiling(CWindow* pWindow) { const auto PNODE = getNodeFromWindow(pWindow); - if (!PNODE) + if (!PNODE) { + Debug::log(ERR, "onWindowRemovedTiling node null?"); return; + } // check if it was grouped if (PNODE->isGroupMember()) { @@ -466,6 +468,7 @@ void CHyprDwindleLayout::onWindowRemovedTiling(CWindow* pWindow) { const auto PPARENT = PNODE->pParent; if (!PPARENT) { + Debug::log(LOG, "Removing last node (dwindle)"); m_lDwindleNodesData.remove(*PNODE); return; } @@ -1066,4 +1069,4 @@ void CHyprDwindleLayout::onEnable() { void CHyprDwindleLayout::onDisable() { m_lDwindleNodesData.clear(); -} \ No newline at end of file +} From 0ebef9a8ae1753e2eb8c87ccb4ab25c28ed87e1c Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 20 Aug 2022 18:00:50 +0200 Subject: [PATCH 13/26] no focus to OR Xwayland --- src/events/Windows.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 660b08a2..f9cb8fc4 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -85,6 +85,8 @@ void Events::listener_mapWindow(void* owner, void* data) { PWINDOW->m_bRequestsFloat = true; } + PWINDOW->m_bX11ShouldntFocus = PWINDOW->m_bX11ShouldntFocus || (PWINDOW->m_bIsX11 && PWINDOW->m_iX11Type == 2); + if (PWORKSPACE->m_bDefaultFloating) PWINDOW->m_bIsFloating = true; From 45a0e69286c5da38202542987f26c27916527093 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 20 Aug 2022 18:12:59 +0200 Subject: [PATCH 14/26] Find a candidate better on window close --- src/events/Windows.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index f9cb8fc4..071061f6 100644 --- a/src/events/Windows.cpp +++ b/src/events/Windows.cpp @@ -384,11 +384,17 @@ void Events::listener_unmapWindow(void* owner, void* data) { PWINDOW->m_bIsMapped = false; // refocus on a new window - g_pInputManager->refocus(); + auto PWINDOWCANDIDATE = g_pCompositor->vectorToWindowIdeal(PWINDOW->m_vRealPosition.goalv() + PWINDOW->m_vRealSize.goalv() / 2.f); - if (!g_pCompositor->m_pLastWindow) { - g_pCompositor->focusWindow(g_pCompositor->getFirstWindowOnWorkspace(PWORKSPACE->m_iID)); - } + if (!PWINDOWCANDIDATE) + PWINDOWCANDIDATE = g_pCompositor->getFirstWindowOnWorkspace(PWINDOW->m_iWorkspaceID); + + if (!PWINDOWCANDIDATE || PWINDOW == PWINDOWCANDIDATE || !PWINDOWCANDIDATE->m_bIsMapped || PWINDOWCANDIDATE->m_bHidden || PWINDOWCANDIDATE->m_bX11ShouldntFocus || PWINDOWCANDIDATE->m_iX11Type == 2) + PWINDOWCANDIDATE = nullptr; + + Debug::log(LOG, "On closed window, new focused candidate is %x", PWINDOWCANDIDATE); + + g_pCompositor->focusWindow(PWINDOWCANDIDATE); Debug::log(LOG, "Destroying the SubSurface tree of unmapped window %x", PWINDOW); SubsurfaceTree::destroySurfaceTree(PWINDOW->m_pSurfaceTree); From 132c96f867198cb68e77ed9930165c51bb8e49f7 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 20 Aug 2022 18:47:48 +0200 Subject: [PATCH 15/26] multiple fixes for device configs --- src/config/ConfigManager.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index e1108b22..ff1791f5 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -912,6 +912,7 @@ void CConfigManager::parseLine(std::string& line) { if (line.contains(" {")) { auto cat = line.substr(0, line.find(" {")); transform(cat.begin(), cat.end(), cat.begin(), ::tolower); + std::replace(cat.begin(), cat.end(), ' ', '-'); if (currentCategory.length() != 0) { currentCategory.push_back(':'); currentCategory.append(cat); @@ -1140,9 +1141,13 @@ SConfigValue CConfigManager::getConfigValueSafe(const std::string& val) { SConfigValue CConfigManager::getConfigValueSafeDevice(const std::string& dev, const std::string& val) { std::lock_guard lg(configmtx); - const auto it = deviceConfigs.find(dev); + auto devcopy = dev; + std::replace(devcopy.begin(), devcopy.end(), ' ', '-'); + + const auto it = deviceConfigs.find(devcopy); if (it == deviceConfigs.end()) { + Debug::log(ERR, "getConfigValueSafeDevice: No device config for %s found???", devcopy.c_str()); return SConfigValue(); } @@ -1155,7 +1160,7 @@ SConfigValue CConfigManager::getConfigValueSafeDevice(const std::string& dev, co if (foundIt == std::string::npos) continue; - if (foundIt == cv.first.length() - val.length()) { + if (cv.first == "input:" + val || cv.first == "input:touchpad:" + cv.first) { copy = cv.second; } } @@ -1334,7 +1339,10 @@ SConfigValue* CConfigManager::getConfigValuePtrSafe(std::string val) { } bool CConfigManager::deviceConfigExists(const std::string& dev) { - const auto it = deviceConfigs.find(dev); + auto copy = dev; + std::replace(copy.begin(), copy.end(), ' ', '-'); + + const auto it = deviceConfigs.find(copy); return it != deviceConfigs.end(); } From 7af193d921dcc52e36b91a67a3433abdd5a994f7 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 20 Aug 2022 18:57:30 +0200 Subject: [PATCH 16/26] reload on input and device hyprctl --- src/debug/HyprCtl.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index 2f5660df..6b89b3c6 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -493,8 +493,10 @@ std::string dispatchKeyword(std::string in) { if (COMMAND == "monitor") g_pConfigManager->m_bWantsMonitorReload = true; // for monitor keywords - if (COMMAND.contains("input")) + if (COMMAND.contains("input") || COMMAND.contains("device:")) { g_pInputManager->setKeyboardLayout(); // update kb layout + g_pInputManager->setMouseConfigs(); // update mouse cfgs + } if (COMMAND.contains("general:layout")) g_pLayoutManager->switchToLayout(g_pConfigManager->getString("general:layout")); // update layout From cc3f0ff9e7906bff60a041fc5556e7c5cbd71df5 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 20 Aug 2022 20:06:24 +0200 Subject: [PATCH 17/26] update wlroots dep --- src/Compositor.cpp | 2 +- src/helpers/MiscFunctions.cpp | 29 ------------------------ src/helpers/MiscFunctions.hpp | 1 - src/wlrunstable/wlr_ext_workspace_v1.cpp | 12 +++++----- subprojects/wlroots | 2 +- 5 files changed, 8 insertions(+), 38 deletions(-) diff --git a/src/Compositor.cpp b/src/Compositor.cpp index bf549695..088440f1 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -718,7 +718,7 @@ void CCompositor::focusSurface(wlr_surface* pSurface, CWindow* pWindowOwner) { .old_surface = m_pLastFocus, .new_surface = pSurface, }; - wlr_signal_emit_safe(&m_sSeat.seat->keyboard_state.events.focus_change, &event); + wl_signal_emit_mutable(&m_sSeat.seat->keyboard_state.events.focus_change, &event); if (pWindowOwner) Debug::log(LOG, "Set keyboard focus to surface %x, with window name: %s", pSurface, pWindowOwner->m_szTitle.c_str()); diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp index b27489ca..405a53d8 100644 --- a/src/helpers/MiscFunctions.cpp +++ b/src/helpers/MiscFunctions.cpp @@ -75,35 +75,6 @@ void handleNoop(struct wl_listener *listener, void *data) { // Do nothing } -void wlr_signal_emit_safe(struct wl_signal *signal, void *data) { - struct wl_listener cursor; - struct wl_listener end; - - /* Add two special markers: one cursor and one end marker. This way, we know - * that we've already called listeners on the left of the cursor and that we - * don't want to call listeners on the right of the end marker. The 'it' - * function can remove any element it wants from the list without troubles. - * wl_list_for_each_safe tries to be safe but it fails: it works fine - * if the current item is removed, but not if the next one is. */ - wl_list_insert(&signal->listener_list, &cursor.link); - cursor.notify = handleNoop; - wl_list_insert(signal->listener_list.prev, &end.link); - end.notify = handleNoop; - - while (cursor.link.next != &end.link) { - struct wl_list *pos = cursor.link.next; - struct wl_listener *l = wl_container_of(pos, l, link); - - wl_list_remove(&cursor.link); - wl_list_insert(pos, &cursor.link); - - l->notify(l, data); - } - - wl_list_remove(&cursor.link); - wl_list_remove(&end.link); -} - std::string getFormat(const char *fmt, ...) { char* outputStr = nullptr; diff --git a/src/helpers/MiscFunctions.hpp b/src/helpers/MiscFunctions.hpp index 9f002c20..bbfb8ca2 100644 --- a/src/helpers/MiscFunctions.hpp +++ b/src/helpers/MiscFunctions.hpp @@ -4,7 +4,6 @@ std::string absolutePath(const std::string&, const std::string&); void addWLSignal(wl_signal*, wl_listener*, void* pOwner, std::string ownerString); -void wlr_signal_emit_safe(struct wl_signal *signal, void *data); std::string getFormat(const char *fmt, ...); // Basically Debug::log to a string std::string escapeJSONStrings(const std::string& str); void scaleBox(wlr_box*, float); diff --git a/src/wlrunstable/wlr_ext_workspace_v1.cpp b/src/wlrunstable/wlr_ext_workspace_v1.cpp index 50a43c7b..3a8cbfd3 100644 --- a/src/wlrunstable/wlr_ext_workspace_v1.cpp +++ b/src/wlrunstable/wlr_ext_workspace_v1.cpp @@ -112,7 +112,7 @@ static void workspace_handle_remove(struct wl_client *client, return; } - wlr_signal_emit_safe(&workspace->events.remove_request, NULL); + wl_signal_emit_mutable(&workspace->events.remove_request, NULL); } static void workspace_handle_deactivate(struct wl_client *client, @@ -312,7 +312,7 @@ void wlr_ext_workspace_handle_v1_destroy( return; } - wlr_signal_emit_safe(&workspace->events.destroy, workspace); + wl_signal_emit_mutable(&workspace->events.destroy, workspace); workspace_manager_update_idle_source(workspace->group->manager); @@ -338,7 +338,7 @@ static void workspace_group_handle_handle_create_workspace(struct wl_client *cli struct wlr_ext_workspace_group_handle_v1_create_workspace_event event; event.workspace_group = group; event.name = arg; - wlr_signal_emit_safe(&group->events.create_workspace_request, &event); + wl_signal_emit_mutable(&group->events.create_workspace_request, &event); } static void workspace_group_handle_handle_destroy(struct wl_client *client, @@ -513,7 +513,7 @@ void wlr_ext_workspace_group_handle_v1_destroy( wlr_ext_workspace_handle_v1_destroy(workspace); } - wlr_signal_emit_safe(&group->events.destroy, group); + wl_signal_emit_mutable(&group->events.destroy, group); workspace_manager_update_idle_source(group->manager); struct wlr_ext_workspace_group_handle_v1_output *output, *tmp2; @@ -556,7 +556,7 @@ static void workspace_manager_commit(struct wl_client *client, } } - wlr_signal_emit_safe(&manager->events.commit, manager); + wl_signal_emit_mutable(&manager->events.commit, manager); } static void workspace_manager_stop(struct wl_client *client, @@ -602,7 +602,7 @@ static void handle_display_destroy(struct wl_listener *listener, void *data) { struct wlr_ext_workspace_manager_v1 *manager = wl_container_of(listener, manager, display_destroy); - wlr_signal_emit_safe(&manager->events.destroy, manager); + wl_signal_emit_mutable(&manager->events.destroy, manager); wl_list_remove(&manager->display_destroy.link); wl_global_destroy(manager->global); diff --git a/subprojects/wlroots b/subprojects/wlroots index 3baf2a6b..7c575922 160000 --- a/subprojects/wlroots +++ b/subprojects/wlroots @@ -1 +1 @@ -Subproject commit 3baf2a6bcfc4cb86c364f5724aaec80f28715a01 +Subproject commit 7c575922c05e4d5fd9a403c2aa631a54c7531d44 From 61aa4ff70ea6805090ead06a2ebae435a5bdef3e Mon Sep 17 00:00:00 2001 From: vaxerski Date: Sat, 20 Aug 2022 18:07:29 +0000 Subject: [PATCH 18/26] [gha] bump flake inputs --- flake.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/flake.lock b/flake.lock index 46dc4de0..97579846 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1659522808, - "narHash": "sha256-HBcM19nGhI3IWwPNVlYb0MZ8VW6iKp4JbAVkeIHVykc=", + "lastModified": 1660908602, + "narHash": "sha256-SwZ85IPWvC4NxxFhWhRMTJpApSHbY1u4YK2UFWEBWvY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "168d1c578909dc143ba52dbed661c36e76b12b36", + "rev": "495b19d5b3e62b4ec7e846bdfb6ef3d9c3b83492", "type": "github" }, "original": { @@ -26,11 +26,11 @@ "flake": false, "locked": { "host": "gitlab.freedesktop.org", - "lastModified": 1659738224, - "narHash": "sha256-bV3TLiCgptpKoUKLiH/5RMtiIsfn0hawdaCEHQFB6WY=", + "lastModified": 1660930713, + "narHash": "sha256-bY7q1NqG/sjCUAWPn/Ne9NCigLlPlH5Lk1WCMqv3rTU=", "owner": "wlroots", "repo": "wlroots", - "rev": "3baf2a6bcfc4cb86c364f5724aaec80f28715a01", + "rev": "7c575922c05e4d5fd9a403c2aa631a54c7531d44", "type": "gitlab" }, "original": { From 08e874bcf91e524059ceaf8a757c463d412b7136 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 20 Aug 2022 20:15:40 +0200 Subject: [PATCH 19/26] fix special workspace windows being xray with new optim --- src/render/OpenGL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index ddd3f1fb..dbbd72fc 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -685,7 +685,7 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox, } // vvv TODO: layered blur fbs? - const bool USENEWOPTIMIZE = (*PBLURNEWOPTIMIZE && m_pCurrentWindow && !m_pCurrentWindow->m_bIsFloating && m_RenderData.pCurrentMonData->blurFB.m_cTex.m_iTexID); + const bool USENEWOPTIMIZE = (*PBLURNEWOPTIMIZE && m_pCurrentWindow && !m_pCurrentWindow->m_bIsFloating && m_RenderData.pCurrentMonData->blurFB.m_cTex.m_iTexID && m_pCurrentWindow->m_iWorkspaceID != SPECIAL_WORKSPACE_ID); const auto POUTFB = USENEWOPTIMIZE ? &m_RenderData.pCurrentMonData->blurFB : blurMainFramebufferWithDamage(a, pBox, &inverseOpaque); From 9513031da30861b6ab593625aebe88b811758427 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Sat, 20 Aug 2022 22:45:30 +0200 Subject: [PATCH 20/26] fix a minor border issue --- src/render/Renderer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 71440dc7..a618a580 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -36,6 +36,8 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) { float rounding = RDATA->dontRound ? 0 : RDATA->rounding == -1 ? *PROUNDING : RDATA->rounding; rounding *= RDATA->output->scale; + rounding -= 1; // to fix a border issue + if (RDATA->surface && surface == RDATA->surface) { if (wlr_surface_is_xwayland_surface(surface) && !wlr_xwayland_surface_from_wlr_surface(surface)->has_alpha && RDATA->fadeAlpha * RDATA->alpha == 255.f) { g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, rounding, true); From 04f0efadc33fd3ac9fb0ed176dbc00dde9906f8e Mon Sep 17 00:00:00 2001 From: Charles Taylor Date: Sun, 21 Aug 2022 20:21:21 +1000 Subject: [PATCH 21/26] add switching to previous workspace --- src/helpers/Workspace.hpp | 3 +++ src/managers/KeybindManager.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/helpers/Workspace.hpp b/src/helpers/Workspace.hpp index 5a3a24ba..9243c9cc 100644 --- a/src/helpers/Workspace.hpp +++ b/src/helpers/Workspace.hpp @@ -18,6 +18,9 @@ public: int m_iID = -1; std::string m_szName = ""; uint64_t m_iMonitorID = -1; + // Previous workspace ID is stored during a workspace change, allowing travel + // to the previous workspace. + int m_iPrevWorkspaceID = -1; bool m_bHasFullscreenWindow = false; eFullscreenMode m_efFullscreenMode = FULLSCREEN_FULL; diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 9939993a..543066c1 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -454,11 +454,31 @@ void CKeybindManager::changeworkspace(std::string args) { int workspaceToChangeTo = 0; std::string workspaceName = ""; + // Flag needed so that the previous workspace is not recorded when switching + // to a previous workspace. + bool isSwitchingToPrevious = false; + if (args.find("[internal]") == 0) { workspaceToChangeTo = std::stoi(args.substr(10)); const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceToChangeTo); if (PWORKSPACE) workspaceName = PWORKSPACE->m_szName; + } else if (args.find("previous") == 0) { + const auto P_MONITOR = g_pCompositor->getMonitorFromCursor(); + const auto P_CURRENT_WORKSPACE = g_pCompositor->getWorkspaceByID(P_MONITOR->activeWorkspace); + + // Do nothing if there's no previous workspace, otherwise switch to it. + if (P_CURRENT_WORKSPACE->m_iPrevWorkspaceID == -1) { + Debug::log(LOG, "No previous workspace to change to"); + return; + } + else { + workspaceToChangeTo = P_CURRENT_WORKSPACE->m_iPrevWorkspaceID; + isSwitchingToPrevious = true; + + // TODO: Add support for cycles + P_CURRENT_WORKSPACE->m_iPrevWorkspaceID = -1; + } } else { workspaceToChangeTo = getWorkspaceIDFromString(args, workspaceName); } @@ -477,6 +497,10 @@ void CKeybindManager::changeworkspace(std::string args) { const auto PWORKSPACETOCHANGETO = g_pCompositor->getWorkspaceByID(workspaceToChangeTo); + if (!isSwitchingToPrevious) + // Remember previous workspace. + PWORKSPACETOCHANGETO->m_iPrevWorkspaceID = g_pCompositor->getMonitorFromCursor()->activeWorkspace; + if (workspaceToChangeTo == SPECIAL_WORKSPACE_ID) PWORKSPACETOCHANGETO->m_iMonitorID = PMONITOR->ID; @@ -541,6 +565,10 @@ void CKeybindManager::changeworkspace(std::string args) { const auto PWORKSPACE = g_pCompositor->m_vWorkspaces.emplace_back(std::make_unique(PMONITOR->ID, workspaceName, workspaceToChangeTo == SPECIAL_WORKSPACE_ID)).get(); + if (!isSwitchingToPrevious) + // Remember previous workspace. + PWORKSPACE->m_iPrevWorkspaceID = OLDWORKSPACE; + // start anim on new workspace PWORKSPACE->startAnim(true, ANIMTOLEFT); From d6ff7e40cfde6a8484b50911358032b4c53c721c Mon Sep 17 00:00:00 2001 From: Charles Taylor Date: Sun, 21 Aug 2022 20:40:06 +1000 Subject: [PATCH 22/26] add general:workspace_back_and_forth option --- src/config/ConfigManager.cpp | 1 + src/managers/KeybindManager.cpp | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index ff1791f5..53c008f9 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -34,6 +34,7 @@ void CConfigManager::setDefaultVars() { configValues["general:apply_sens_to_raw"].intValue = 0; configValues["general:main_mod"].strValue = "SUPER"; // exposed to the user for easier configuring configValues["general:main_mod_internal"].intValue = g_pKeybindManager->stringToModMask("SUPER"); // actually used and automatically calculated + configValues["general:workspace_back_and_forth"].intValue = 0; configValues["general:damage_tracking"].strValue = "full"; configValues["general:damage_tracking_internal"].intValue = DAMAGE_TRACKING_FULL; diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 543066c1..45af02a0 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -464,8 +464,8 @@ void CKeybindManager::changeworkspace(std::string args) { if (PWORKSPACE) workspaceName = PWORKSPACE->m_szName; } else if (args.find("previous") == 0) { - const auto P_MONITOR = g_pCompositor->getMonitorFromCursor(); - const auto P_CURRENT_WORKSPACE = g_pCompositor->getWorkspaceByID(P_MONITOR->activeWorkspace); + const auto P_CURRENT_WORKSPACE = g_pCompositor->getWorkspaceByID( + g_pCompositor->getMonitorFromCursor()->activeWorkspace); // Do nothing if there's no previous workspace, otherwise switch to it. if (P_CURRENT_WORKSPACE->m_iPrevWorkspaceID == -1) { @@ -488,6 +488,21 @@ void CKeybindManager::changeworkspace(std::string args) { return; } + // Workspace_back_and_forth being enabled means that an attempt to switch to + // the current workspace will instead switch to the previous. + if (g_pConfigManager->getConfigValuePtr("general:workspace_back_and_forth")->intValue == 1 + && g_pCompositor->getMonitorFromCursor()->activeWorkspace == workspaceToChangeTo) { + + const auto P_CURRENT_WORKSPACE = g_pCompositor->getWorkspaceByID( + g_pCompositor->getMonitorFromCursor()->activeWorkspace); + + workspaceToChangeTo = P_CURRENT_WORKSPACE->m_iPrevWorkspaceID; + isSwitchingToPrevious = true; + + // TODO: Add support for cycles + P_CURRENT_WORKSPACE->m_iPrevWorkspaceID = -1; + } + // remove constraints g_pInputManager->unconstrainMouse(); From 9ee42836d5e2c707f7cf203628a0ae530d59c5cd Mon Sep 17 00:00:00 2001 From: Charles Taylor Date: Sun, 21 Aug 2022 20:47:56 +1000 Subject: [PATCH 23/26] add general:allow_workspace_cycles option --- src/config/ConfigManager.cpp | 1 + src/managers/KeybindManager.cpp | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 53c008f9..079d9a8d 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -35,6 +35,7 @@ void CConfigManager::setDefaultVars() { configValues["general:main_mod"].strValue = "SUPER"; // exposed to the user for easier configuring configValues["general:main_mod_internal"].intValue = g_pKeybindManager->stringToModMask("SUPER"); // actually used and automatically calculated configValues["general:workspace_back_and_forth"].intValue = 0; + configValues["general:allow_workspace_cycles"].intValue = 0; configValues["general:damage_tracking"].strValue = "full"; configValues["general:damage_tracking_internal"].intValue = DAMAGE_TRACKING_FULL; diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 45af02a0..ab22d98f 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -476,8 +476,10 @@ void CKeybindManager::changeworkspace(std::string args) { workspaceToChangeTo = P_CURRENT_WORKSPACE->m_iPrevWorkspaceID; isSwitchingToPrevious = true; - // TODO: Add support for cycles - P_CURRENT_WORKSPACE->m_iPrevWorkspaceID = -1; + // If the previous workspace ID isn't reset, cycles can form when continually going + // to the previous workspace again and again. + if (!g_pConfigManager->getConfigValuePtr("general:allow_workspace_cycles")->intValue) + P_CURRENT_WORKSPACE->m_iPrevWorkspaceID = -1; } } else { workspaceToChangeTo = getWorkspaceIDFromString(args, workspaceName); @@ -499,8 +501,10 @@ void CKeybindManager::changeworkspace(std::string args) { workspaceToChangeTo = P_CURRENT_WORKSPACE->m_iPrevWorkspaceID; isSwitchingToPrevious = true; - // TODO: Add support for cycles - P_CURRENT_WORKSPACE->m_iPrevWorkspaceID = -1; + // If the previous workspace ID isn't reset, cycles can form when continually going + // to the previous workspace again and again. + if (!g_pConfigManager->getConfigValuePtr("general:allow_workspace_cycles")->intValue) + P_CURRENT_WORKSPACE->m_iPrevWorkspaceID = -1; } // remove constraints From 3c8c605541d6b3e046951ba8710dfb2e9452a3de Mon Sep 17 00:00:00 2001 From: Charles Taylor Date: Sun, 21 Aug 2022 21:58:46 +1000 Subject: [PATCH 24/26] fix style conflicts and config + monitor retrieval --- src/config/ConfigManager.cpp | 4 ++-- src/helpers/Workspace.hpp | 2 +- src/managers/KeybindManager.cpp | 28 +++++++++++++++------------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 079d9a8d..893f4ef0 100644 --- a/src/config/ConfigManager.cpp +++ b/src/config/ConfigManager.cpp @@ -34,8 +34,6 @@ void CConfigManager::setDefaultVars() { configValues["general:apply_sens_to_raw"].intValue = 0; configValues["general:main_mod"].strValue = "SUPER"; // exposed to the user for easier configuring configValues["general:main_mod_internal"].intValue = g_pKeybindManager->stringToModMask("SUPER"); // actually used and automatically calculated - configValues["general:workspace_back_and_forth"].intValue = 0; - configValues["general:allow_workspace_cycles"].intValue = 0; configValues["general:damage_tracking"].strValue = "full"; configValues["general:damage_tracking_internal"].intValue = DAMAGE_TRACKING_FULL; @@ -142,6 +140,8 @@ void CConfigManager::setDefaultVars() { configValues["binds:pass_mouse_when_bound"].intValue = 1; configValues["binds:scroll_event_delay"].intValue = 300; + configValues["binds:workspace_back_and_forth"].intValue = 0; + configValues["binds:allow_workspace_cycles"].intValue = 0; configValues["gestures:workspace_swipe"].intValue = 0; configValues["gestures:workspace_swipe_fingers"].intValue = 3; diff --git a/src/helpers/Workspace.hpp b/src/helpers/Workspace.hpp index 9243c9cc..3faebdd8 100644 --- a/src/helpers/Workspace.hpp +++ b/src/helpers/Workspace.hpp @@ -20,7 +20,7 @@ public: uint64_t m_iMonitorID = -1; // Previous workspace ID is stored during a workspace change, allowing travel // to the previous workspace. - int m_iPrevWorkspaceID = -1; + int m_iPrevWorkspaceID = -1; bool m_bHasFullscreenWindow = false; eFullscreenMode m_efFullscreenMode = FULLSCREEN_FULL; diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index ab22d98f..374525a2 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -464,22 +464,23 @@ void CKeybindManager::changeworkspace(std::string args) { if (PWORKSPACE) workspaceName = PWORKSPACE->m_szName; } else if (args.find("previous") == 0) { - const auto P_CURRENT_WORKSPACE = g_pCompositor->getWorkspaceByID( + const auto PCURRENTWORKSPACE = g_pCompositor->getWorkspaceByID( g_pCompositor->getMonitorFromCursor()->activeWorkspace); // Do nothing if there's no previous workspace, otherwise switch to it. - if (P_CURRENT_WORKSPACE->m_iPrevWorkspaceID == -1) { + if (PCURRENTWORKSPACE->m_iPrevWorkspaceID == -1) { Debug::log(LOG, "No previous workspace to change to"); return; } else { - workspaceToChangeTo = P_CURRENT_WORKSPACE->m_iPrevWorkspaceID; + workspaceToChangeTo = PCURRENTWORKSPACE->m_iPrevWorkspaceID; isSwitchingToPrevious = true; // If the previous workspace ID isn't reset, cycles can form when continually going // to the previous workspace again and again. - if (!g_pConfigManager->getConfigValuePtr("general:allow_workspace_cycles")->intValue) - P_CURRENT_WORKSPACE->m_iPrevWorkspaceID = -1; + static auto *const PALLOWWORKSPACECYCLES = &g_pConfigManager->getConfigValuePtr("binds:allow_workspace_cycles")->intValue; + if (!*PALLOWWORKSPACECYCLES) + PCURRENTWORKSPACE->m_iPrevWorkspaceID = -1; } } else { workspaceToChangeTo = getWorkspaceIDFromString(args, workspaceName); @@ -492,19 +493,20 @@ void CKeybindManager::changeworkspace(std::string args) { // Workspace_back_and_forth being enabled means that an attempt to switch to // the current workspace will instead switch to the previous. - if (g_pConfigManager->getConfigValuePtr("general:workspace_back_and_forth")->intValue == 1 - && g_pCompositor->getMonitorFromCursor()->activeWorkspace == workspaceToChangeTo) { + static auto *const PBACKANDFORTH = &g_pConfigManager->getConfigValuePtr("binds:workspace_back_and_forth")->intValue; + if (*PBACKANDFORTH && g_pCompositor->m_pLastMonitor->activeWorkspace == workspaceToChangeTo) { - const auto P_CURRENT_WORKSPACE = g_pCompositor->getWorkspaceByID( - g_pCompositor->getMonitorFromCursor()->activeWorkspace); + const auto PCURRENTWORKSPACE = g_pCompositor->getWorkspaceByID( + g_pCompositor->m_pLastMonitor->activeWorkspace); - workspaceToChangeTo = P_CURRENT_WORKSPACE->m_iPrevWorkspaceID; + workspaceToChangeTo = PCURRENTWORKSPACE->m_iPrevWorkspaceID; isSwitchingToPrevious = true; // If the previous workspace ID isn't reset, cycles can form when continually going // to the previous workspace again and again. - if (!g_pConfigManager->getConfigValuePtr("general:allow_workspace_cycles")->intValue) - P_CURRENT_WORKSPACE->m_iPrevWorkspaceID = -1; + static auto *const PALLOWWORKSPACECYCLES = &g_pConfigManager->getConfigValuePtr("binds:allow_workspace_cycles")->intValue; + if (!*PALLOWWORKSPACECYCLES) + PCURRENTWORKSPACE->m_iPrevWorkspaceID = -1; } // remove constraints @@ -518,7 +520,7 @@ void CKeybindManager::changeworkspace(std::string args) { if (!isSwitchingToPrevious) // Remember previous workspace. - PWORKSPACETOCHANGETO->m_iPrevWorkspaceID = g_pCompositor->getMonitorFromCursor()->activeWorkspace; + PWORKSPACETOCHANGETO->m_iPrevWorkspaceID = g_pCompositor->m_pLastMonitor->activeWorkspace; if (workspaceToChangeTo == SPECIAL_WORKSPACE_ID) PWORKSPACETOCHANGETO->m_iMonitorID = PMONITOR->ID; From 6ec932d11fcc490f3d3f8c544af8fa1a5c8ef4f7 Mon Sep 17 00:00:00 2001 From: Charles Taylor Date: Sun, 21 Aug 2022 22:05:35 +1000 Subject: [PATCH 25/26] fix bug which allowed a switch to workspace ID -1. This only happened for the workspace_back_and_forth setting, since it was missing a check. --- src/managers/KeybindManager.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 374525a2..ddf65b42 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -493,11 +493,12 @@ void CKeybindManager::changeworkspace(std::string args) { // Workspace_back_and_forth being enabled means that an attempt to switch to // the current workspace will instead switch to the previous. + const auto PCURRENTWORKSPACE = g_pCompositor->getWorkspaceByID( + g_pCompositor->m_pLastMonitor->activeWorkspace); static auto *const PBACKANDFORTH = &g_pConfigManager->getConfigValuePtr("binds:workspace_back_and_forth")->intValue; - if (*PBACKANDFORTH && g_pCompositor->m_pLastMonitor->activeWorkspace == workspaceToChangeTo) { - - const auto PCURRENTWORKSPACE = g_pCompositor->getWorkspaceByID( - g_pCompositor->m_pLastMonitor->activeWorkspace); + if (*PBACKANDFORTH + && PCURRENTWORKSPACE->m_iID == workspaceToChangeTo + && PCURRENTWORKSPACE->m_iPrevWorkspaceID != -1) { workspaceToChangeTo = PCURRENTWORKSPACE->m_iPrevWorkspaceID; isSwitchingToPrevious = true; From 9dbdd66da417eb2316387f3af078349c50bc2929 Mon Sep 17 00:00:00 2001 From: Charles Taylor Date: Sun, 21 Aug 2022 22:11:40 +1000 Subject: [PATCH 26/26] fix retrieval of monitor --- src/managers/KeybindManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index ddf65b42..3d821d14 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -465,7 +465,7 @@ void CKeybindManager::changeworkspace(std::string args) { workspaceName = PWORKSPACE->m_szName; } else if (args.find("previous") == 0) { const auto PCURRENTWORKSPACE = g_pCompositor->getWorkspaceByID( - g_pCompositor->getMonitorFromCursor()->activeWorkspace); + g_pCompositor->m_pLastMonitor->activeWorkspace); // Do nothing if there's no previous workspace, otherwise switch to it. if (PCURRENTWORKSPACE->m_iPrevWorkspaceID == -1) {