From 0d2e1e1270ba0bf03c022974342ab412e98b8c67 Mon Sep 17 00:00:00 2001 From: rubyowo Date: Sat, 7 Jan 2023 15:33:36 +0400 Subject: [PATCH 1/9] fix crashes and bug wiki link (#1333) --- src/Compositor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Compositor.cpp b/src/Compositor.cpp index b60d70d7..35e30b77 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -49,7 +49,7 @@ CCompositor::CCompositor() { Debug::log(NONE, "\n\n"); // pad - Debug::log(INFO, "If you are crashing, or encounter any bugs, please consult https://github.com/hyprwm/Hyprland/wiki/Crashing-and-bugs\n\n"); + Debug::log(INFO, "If you are crashing, or encounter any bugs, please consult https://wiki.hyprland.org/Crashes-and-Bugs/\n\n"); setRandomSplash(); From 2b248b25c8446621713766360d2e00bd927f5fdf Mon Sep 17 00:00:00 2001 From: vaxerski Date: Sat, 7 Jan 2023 13:12:02 +0100 Subject: [PATCH 2/9] clamp a instead of asserting --- src/render/OpenGL.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index fc40b75e..4d24842b 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -460,7 +460,8 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b bool allowCustomUV, bool allowDim) { RASSERT(m_RenderData.pMonitor, "Tried to render texture without begin()!"); RASSERT((tex.m_iTexID > 0), "Attempted to draw NULL texture!"); - RASSERT(alpha <= 1.0, "Tried to render texture with a > 1"); + + alpha = std::clamp(alpha, 0.f, 1.f); if (!pixman_region32_not_empty(m_RenderData.pDamage)) return; From 2858e08ce03ab82c3f7a993686f58919a9a62d0d Mon Sep 17 00:00:00 2001 From: vaxerski Date: Sat, 7 Jan 2023 13:38:19 +0100 Subject: [PATCH 3/9] remove color rassert to fix overshot beziers --- src/helpers/Color.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/helpers/Color.cpp b/src/helpers/Color.cpp index 788d7bdf..ecd5a33c 100644 --- a/src/helpers/Color.cpp +++ b/src/helpers/Color.cpp @@ -4,7 +4,6 @@ CColor::CColor() {} CColor::CColor(float r, float g, float b, float a) { - RASSERT(r <= 1.f && g <= 1.f && b <= 1.f && a <= 1.f, "un-normalized color assignment"); this->r = r; this->g = g; this->b = b; From af4b9700b7a1a1b36439dc51334b9aeaadcfcd41 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Sat, 7 Jan 2023 13:49:19 +0100 Subject: [PATCH 4/9] bump ver to 0.20.1 --- props.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/props.json b/props.json index e96cb77f..119cd938 100644 --- a/props.json +++ b/props.json @@ -1 +1 @@ -{"version": "0.20.0"} +{"version": "0.20.1"} From 809b7181a86b266a9d914e0b1e2c963030975513 Mon Sep 17 00:00:00 2001 From: Mihai Fufezan Date: Sat, 7 Jan 2023 20:25:20 +0200 Subject: [PATCH 5/9] nix: add hyprland-protocols through pkgconfig (#1275) --- flake.lock | 12 ++++++++---- flake.nix | 4 ++-- nix/default.nix | 5 +---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/flake.lock b/flake.lock index b348c55e..ce27045c 100644 --- a/flake.lock +++ b/flake.lock @@ -1,13 +1,17 @@ { "nodes": { "hyprland-protocols": { - "flake": false, + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, "locked": { - "lastModified": 1670703428, - "narHash": "sha256-4KUW5SKR0Y9uaYGcYwy53YJ3B/sgiprCL4fRGO+mpOA=", + "lastModified": 1671839510, + "narHash": "sha256-+PY1qqJfmZzzROgcIY4I7AkCwpnC+qBIYk2eFoA9RWc=", "owner": "hyprwm", "repo": "hyprland-protocols", - "rev": "d0d6db8cb5bef6d93ca3ad8fb2124964173396da", + "rev": "b8f55e02a328c47ed373133c52483bbfa20a1b75", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index a6def7bd..b3f8e70e 100644 --- a/flake.nix +++ b/flake.nix @@ -15,7 +15,7 @@ hyprland-protocols = { url = "github:hyprwm/hyprland-protocols"; - flake = false; + inputs.nixpkgs.follows = "nixpkgs"; }; }; @@ -50,7 +50,7 @@ stdenv = prev.gcc12Stdenv; version = props.version + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty"); wlroots = wlroots-hyprland; - inherit (inputs) hyprland-protocols; + inherit (inputs.hyprland-protocols.packages.${prev.hostPlatform.system}) hyprland-protocols; }; hyprland-debug = hyprland.override {debug = true;}; hyprland-no-hidpi = hyprland.override {hidpiXWayland = false;}; diff --git a/nix/default.nix b/nix/default.nix index c45969f4..89037960 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -67,6 +67,7 @@ in [ git cairo + hyprland-protocols libdrm libinput libxkbcommon @@ -99,10 +100,6 @@ in postPatch = '' # Fix hardcoded paths to /usr installation sed -i "s#/usr#$out#" src/render/OpenGL.cpp - - # for some reason rmdir doesn't work in a dirty tree - rmdir subprojects/hyprland-protocols || true - ln -s ${hyprland-protocols} subprojects/hyprland-protocols ''; passthru.providedSessions = ["hyprland"]; From b1104b1ca70372c377289efe6ed99f2d1f6a1ca3 Mon Sep 17 00:00:00 2001 From: Mihai Fufezan Date: Sat, 7 Jan 2023 20:33:15 +0200 Subject: [PATCH 6/9] nix: update xdph --- flake.lock | 26 ++++++-------------------- flake.nix | 11 ++++++----- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/flake.lock b/flake.lock index ce27045c..b48873a3 100644 --- a/flake.lock +++ b/flake.lock @@ -20,22 +20,6 @@ "type": "github" } }, - "hyprland-protocols_2": { - "flake": false, - "locked": { - "lastModified": 1670703428, - "narHash": "sha256-4KUW5SKR0Y9uaYGcYwy53YJ3B/sgiprCL4fRGO+mpOA=", - "owner": "hyprwm", - "repo": "hyprland-protocols", - "rev": "d0d6db8cb5bef6d93ca3ad8fb2124964173396da", - "type": "github" - }, - "original": { - "owner": "hyprwm", - "repo": "hyprland-protocols", - "type": "github" - } - }, "nixpkgs": { "locked": { "lastModified": 1672791794, @@ -80,17 +64,19 @@ }, "xdph": { "inputs": { - "hyprland-protocols": "hyprland-protocols_2", + "hyprland-protocols": [ + "hyprland-protocols" + ], "nixpkgs": [ "nixpkgs" ] }, "locked": { - "lastModified": 1671837878, - "narHash": "sha256-OmFDyktTc/l+3wHboHeFpAQgPt3r7jjqZf8MrwuUGMo=", + "lastModified": 1673116118, + "narHash": "sha256-eR0yDSkR2XYMesfdRWJs25kAdXET2mbNNHu5t+KUcKA=", "owner": "hyprwm", "repo": "xdg-desktop-portal-hyprland", - "rev": "e47f4cec698080768821b271510985ab94a37e91", + "rev": "d479c846531fd0e1d2357c9588b8310a2b859ef2", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index b3f8e70e..15ff9e61 100644 --- a/flake.nix +++ b/flake.nix @@ -8,15 +8,16 @@ flake = false; }; - xdph = { - url = "github:hyprwm/xdg-desktop-portal-hyprland"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - hyprland-protocols = { url = "github:hyprwm/hyprland-protocols"; inputs.nixpkgs.follows = "nixpkgs"; }; + + xdph = { + url = "github:hyprwm/xdg-desktop-portal-hyprland"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.hyprland-protocols.follows = "hyprland-protocols"; + }; }; outputs = inputs @ { From 3173fbdc4a2b0a306cf56e282524bcb33914ab96 Mon Sep 17 00:00:00 2001 From: Cyril Levis Date: Sun, 8 Jan 2023 14:19:18 +0100 Subject: [PATCH 7/9] feat: dispatcher, add workspace renaming (#1336) * feat: dispatcher, add workspace renaming Co-authored-by: vaxerski --- src/Compositor.cpp | 17 +++++++++++++++-- src/Compositor.hpp | 1 + src/managers/KeybindManager.cpp | 16 ++++++++++++++++ src/managers/KeybindManager.hpp | 1 + 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 35e30b77..6b72465d 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -391,11 +391,10 @@ void CCompositor::startCompositor() { if (sd_booted() > 0) // tell systemd that we are ready so it can start other bond, following, related units sd_notify(0, "READY=1"); - else + else Debug::log(LOG, "systemd integration is baked in but system itself is not booted à la systemd!"); #endif - // This blocks until we are done. Debug::log(LOG, "Hyprland is ready, running the event loop!"); wl_display_run(m_sWLDisplay); @@ -2071,6 +2070,20 @@ CWorkspace* CCompositor::createNewWorkspace(const int& id, const int& monid, con return PWORKSPACE; } +void CCompositor::renameWorkspace(const int& id, const std::string& name) { + const auto PWORKSPACE = getWorkspaceByID(id); + + if (!PWORKSPACE) + return; + + if (isWorkspaceSpecial(id)) + return; + + Debug::log(LOG, "renameWorkspace: Renaming workspace %d to '%s'", id, name); + wlr_ext_workspace_handle_v1_set_name(PWORKSPACE->m_pWlrHandle, name.c_str()); + PWORKSPACE->m_szName = name; +} + void CCompositor::setActiveMonitor(CMonitor* pMonitor) { if (m_pLastMonitor == pMonitor) return; diff --git a/src/Compositor.hpp b/src/Compositor.hpp index e12caec5..fb0eb8fa 100644 --- a/src/Compositor.hpp +++ b/src/Compositor.hpp @@ -171,6 +171,7 @@ class CCompositor { void forceReportSizesToWindowsOnWorkspace(const int&); bool cursorOnReservedArea(); CWorkspace* createNewWorkspace(const int&, const int&, const std::string& name = ""); // will be deleted next frame if left empty and unfocused! + void renameWorkspace(const int&, const std::string& name = ""); void setActiveMonitor(CMonitor*); bool isWorkspaceSpecial(const int&); int getNewSpecialID(); diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index ead93231..f5b3e34b 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -10,6 +10,7 @@ CKeybindManager::CKeybindManager() { m_mDispatchers["closewindow"] = kill; m_mDispatchers["togglefloating"] = toggleActiveFloating; m_mDispatchers["workspace"] = changeworkspace; + m_mDispatchers["renameworkspace"] = renameWorkspace; m_mDispatchers["fullscreen"] = fullscreenActive; m_mDispatchers["fakefullscreen"] = fakeFullscreenActive; m_mDispatchers["movetoworkspace"] = moveActiveToWorkspace; @@ -1289,6 +1290,21 @@ void CKeybindManager::workspaceOpt(std::string args) { g_pLayoutManager->getCurrentLayout()->recalculateMonitor(g_pCompositor->m_pLastMonitor->ID); } +void CKeybindManager::renameWorkspace(std::string args) { + try { + const auto FIRSTSPACEPOS = args.find_first_of(' '); + if (FIRSTSPACEPOS != std::string::npos) { + int workspace = std::stoi(args.substr(0, FIRSTSPACEPOS)); + std::string name = args.substr(FIRSTSPACEPOS + 1); + g_pCompositor->renameWorkspace(workspace, name); + } else { + g_pCompositor->renameWorkspace(std::stoi(args), ""); + } + } catch (std::exception& e) { + Debug::log(ERR, "Invalid arg in renameWorkspace, expected numeric id only or a numeric id and string name. \"%s\": \"%s\"", args.c_str(), e.what()); + } +} + void CKeybindManager::exitHyprland(std::string argz) { g_pCompositor->cleanup(); } diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp index 7794c24c..3923d571 100644 --- a/src/managers/KeybindManager.hpp +++ b/src/managers/KeybindManager.hpp @@ -104,6 +104,7 @@ class CKeybindManager { static void toggleSplit(std::string); static void moveCursorToCorner(std::string); static void workspaceOpt(std::string); + static void renameWorkspace(std::string); static void exitHyprland(std::string); static void moveCurrentWorkspaceToMonitor(std::string); static void moveWorkspaceToMonitor(std::string); From 50e106f2e60785126331eaf2a9c43595a2a768d4 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Sun, 8 Jan 2023 14:46:45 +0100 Subject: [PATCH 8/9] expand region twice in blur damage we need to update possible blurriness above --- src/events/Monitors.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/events/Monitors.cpp b/src/events/Monitors.cpp index 8c529c1b..a631b0a1 100644 --- a/src/events/Monitors.cpp +++ b/src/events/Monitors.cpp @@ -216,10 +216,12 @@ void Events::listener_monitorFrame(void* owner, void* data) { static auto* const PBLURPASSES = &g_pConfigManager->getConfigValuePtr("decoration:blur_passes")->intValue; const auto BLURRADIUS = *PBLURSIZE * pow(2, *PBLURPASSES); // is this 2^pass? I don't know but it works... I think. - pixman_region32_copy(&g_pHyprOpenGL->m_rOriginalDamageRegion, &damage); - // now, prep the damage, get the extended damage region wlr_region_expand(&damage, &damage, BLURRADIUS); // expand for proper blurring + + pixman_region32_copy(&g_pHyprOpenGL->m_rOriginalDamageRegion, &damage); + + wlr_region_expand(&damage, &damage, BLURRADIUS); // expand for proper blurring 2 } else { pixman_region32_copy(&g_pHyprOpenGL->m_rOriginalDamageRegion, &damage); } @@ -280,7 +282,7 @@ void Events::listener_monitorFrame(void* owner, void* data) { pixman_region32_init(&frameDamage); const auto TRANSFORM = wlr_output_transform_invert(PMONITOR->output->transform); - wlr_region_transform(&frameDamage, &PMONITOR->damage->current, TRANSFORM, (int)PMONITOR->vecTransformedSize.x, (int)PMONITOR->vecTransformedSize.y); + wlr_region_transform(&frameDamage, &g_pHyprOpenGL->m_rOriginalDamageRegion, TRANSFORM, (int)PMONITOR->vecTransformedSize.x, (int)PMONITOR->vecTransformedSize.y); if (*PDAMAGETRACKINGMODE == DAMAGE_TRACKING_NONE || *PDAMAGETRACKINGMODE == DAMAGE_TRACKING_MONITOR) pixman_region32_union_rect(&frameDamage, &frameDamage, 0, 0, (int)PMONITOR->vecTransformedSize.x, (int)PMONITOR->vecTransformedSize.y); From e5dcbf73d881178c7f9c6306d287ed610d6efea1 Mon Sep 17 00:00:00 2001 From: riChar Date: Sun, 8 Jan 2023 23:35:24 +0800 Subject: [PATCH 9/9] Add "on" and "off" for the bind of switch (#1342) --- src/managers/KeybindManager.cpp | 8 ++++++++ src/managers/KeybindManager.hpp | 2 ++ src/managers/input/InputManager.cpp | 13 +++++++++++++ 3 files changed, 23 insertions(+) diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp index f5b3e34b..cb2faf11 100644 --- a/src/managers/KeybindManager.cpp +++ b/src/managers/KeybindManager.cpp @@ -287,6 +287,14 @@ void CKeybindManager::onSwitchEvent(const std::string& switchName) { handleKeybinds(0, "switch:" + switchName, 0, 0, true, 0); } +void CKeybindManager::onSwitchOnEvent(const std::string& switchName) { + handleKeybinds(0, "switch:on:" + switchName, 0, 0, true, 0); +} + +void CKeybindManager::onSwitchOffEvent(const std::string& switchName) { + handleKeybinds(0, "switch:off:" + switchName, 0, 0, true, 0); +} + int repeatKeyHandler(void* data) { SKeybind** ppActiveKeybind = (SKeybind**)data; diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp index 3923d571..b29b48b0 100644 --- a/src/managers/KeybindManager.hpp +++ b/src/managers/KeybindManager.hpp @@ -40,6 +40,8 @@ class CKeybindManager { bool onAxisEvent(wlr_pointer_axis_event*); bool onMouseEvent(wlr_pointer_button_event*); void onSwitchEvent(const std::string&); + void onSwitchOnEvent(const std::string&); + void onSwitchOffEvent(const std::string&); void addKeybind(SKeybind); void removeKeybind(uint32_t, const std::string&); diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp index c67bcba3..a5ff20f7 100644 --- a/src/managers/input/InputManager.cpp +++ b/src/managers/input/InputManager.cpp @@ -1,5 +1,6 @@ #include "InputManager.hpp" #include "../../Compositor.hpp" +#include "wlr/types/wlr_switch.h" void CInputManager::onMouseMoved(wlr_pointer_motion_event* e) { static auto* const PSENS = &g_pConfigManager->getConfigValuePtr("general:sensitivity")->floatValue; @@ -1215,6 +1216,18 @@ void CInputManager::newSwitch(wlr_input_device* pDevice) { Debug::log(LOG, "Switch %s fired, triggering binds.", NAME.c_str()); g_pKeybindManager->onSwitchEvent(NAME); + + const auto event_data = (wlr_switch_toggle_event*)data; + switch (event_data->switch_state) { + case WLR_SWITCH_STATE_ON: + Debug::log(LOG, "Switch %s turn on, triggering binds.", NAME.c_str()); + g_pKeybindManager->onSwitchOnEvent(NAME); + break; + case WLR_SWITCH_STATE_OFF: + Debug::log(LOG, "Switch %s turn off, triggering binds.", NAME.c_str()); + g_pKeybindManager->onSwitchOffEvent(NAME); + break; + } }, PNEWDEV, "SwitchDevice"); }