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 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/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": { diff --git a/src/Compositor.cpp b/src/Compositor.cpp index f345e300..3a73c1b4 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() { @@ -710,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/config/ConfigManager.cpp b/src/config/ConfigManager.cpp index 5f7725a2..893f4ef0 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; @@ -119,6 +120,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; @@ -138,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; @@ -155,6 +159,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 +779,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, configCurrentPath); if (!std::filesystem::exists(value)) { Debug::log(ERR, "source= file doesnt exist"); @@ -924,6 +914,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); @@ -1152,9 +1143,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(); } @@ -1167,7 +1162,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; } } @@ -1346,7 +1341,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(); } @@ -1379,4 +1377,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..72eb58f6 100644 --- a/src/config/ConfigManager.hpp +++ b/src/config/ConfigManager.hpp @@ -106,6 +106,8 @@ public: SAnimationPropertyConfig* getAnimationPropertyConfig(const std::string&); + std::string configCurrentPath; + private: std::deque configPaths; // stores all the config paths std::unordered_map configModifyTimes; // stores modify times @@ -115,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 @@ -159,4 +159,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/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 diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp index 1eb35cc8..c195a115 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; @@ -387,11 +389,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); diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp index b7285637..405a53d8 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); @@ -53,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 a40471a9..bbfb8ca2 100644 --- a/src/helpers/MiscFunctions.hpp +++ b/src/helpers/MiscFunctions.hpp @@ -2,8 +2,8 @@ #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 std::string escapeJSONStrings(const std::string& str); void scaleBox(wlr_box*, float); @@ -17,4 +17,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/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/helpers/Workspace.hpp b/src/helpers/Workspace.hpp index 5a3a24ba..3faebdd8 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/layout/DwindleLayout.cpp b/src/layout/DwindleLayout.cpp index 923f4f2b..da48ac31 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 && 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())); + } + + if (!OPENINGON && g_pCompositor->getWindowsOnWorkspace(PNODE->workspaceID) > 0) + OPENINGON = getFirstNodeOnWorkspace(PMONITOR->activeWorkspace); } else OPENINGON = getFirstNodeOnWorkspace(pWindow->m_iWorkspaceID); @@ -408,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()) { @@ -455,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; } @@ -1055,4 +1069,4 @@ void CHyprDwindleLayout::onEnable() { void CHyprDwindleLayout::onDisable() { m_lDwindleNodesData.clear(); -} \ No newline at end of file +} diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index 7581f643..a79c0396 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -454,11 +454,34 @@ 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 PCURRENTWORKSPACE = g_pCompositor->getWorkspaceByID( + g_pCompositor->m_pLastMonitor->activeWorkspace); + + // Do nothing if there's no previous workspace, otherwise switch to it. + if (PCURRENTWORKSPACE->m_iPrevWorkspaceID == -1) { + Debug::log(LOG, "No previous workspace to change to"); + return; + } + else { + 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. + static auto *const PALLOWWORKSPACECYCLES = &g_pConfigManager->getConfigValuePtr("binds:allow_workspace_cycles")->intValue; + if (!*PALLOWWORKSPACECYCLES) + PCURRENTWORKSPACE->m_iPrevWorkspaceID = -1; + } } else { workspaceToChangeTo = getWorkspaceIDFromString(args, workspaceName); } @@ -468,6 +491,25 @@ 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. + 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 + && PCURRENTWORKSPACE->m_iID == workspaceToChangeTo + && PCURRENTWORKSPACE->m_iPrevWorkspaceID != -1) { + + 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. + static auto *const PALLOWWORKSPACECYCLES = &g_pConfigManager->getConfigValuePtr("binds:allow_workspace_cycles")->intValue; + if (!*PALLOWWORKSPACECYCLES) + PCURRENTWORKSPACE->m_iPrevWorkspaceID = -1; + } + // remove constraints g_pInputManager->unconstrainMouse(); @@ -477,6 +519,10 @@ void CKeybindManager::changeworkspace(std::string args) { const auto PWORKSPACETOCHANGETO = g_pCompositor->getWorkspaceByID(workspaceToChangeTo); + if (!isSwitchingToPrevious) + // Remember previous workspace. + PWORKSPACETOCHANGETO->m_iPrevWorkspaceID = g_pCompositor->m_pLastMonitor->activeWorkspace; + if (workspaceToChangeTo == SPECIAL_WORKSPACE_ID) PWORKSPACETOCHANGETO->m_iMonitorID = PMONITOR->ID; @@ -541,6 +587,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); diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index f8899f62..87869da1 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -182,9 +182,15 @@ 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); + // TODO: this causes crashes, sometimes. ??? + // if (refocus && !pFoundWindow) { + // pFoundWindow = g_pCompositor->getFirstWindowOnWorkspace(PMONITOR->activeWorkspace); + // } + } + if (pFoundWindow) { if (!pFoundWindow->m_bIsX11) { foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords); @@ -267,8 +273,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); @@ -519,6 +527,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 +535,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 +549,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 +573,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 = absolutePath(FILEPATH, g_pConfigManager->configCurrentPath); + + 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 +966,4 @@ void CInputManager::disableAllKeyboards(bool virt) { k.active = false; } -} \ No newline at end of file +} diff --git a/src/managers/input/Swipe.cpp b/src/managers/input/Swipe.cpp index ca4c60e6..51be5248 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; + 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)); @@ -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; + 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)); 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); 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); 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 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