diff --git a/.github/workflows/nix-build.yaml b/.github/workflows/nix-build.yaml index 319a8cb..714d8b4 100644 --- a/.github/workflows/nix-build.yaml +++ b/.github/workflows/nix-build.yaml @@ -1,50 +1,11 @@ -name: Build Hyprpicker (Nix) +name: Build on: [push, pull_request, workflow_dispatch] + jobs: nix: - name: "Build" - runs-on: ubuntu-latest - steps: - - name: Clone repository - uses: actions/checkout@v3 - with: - submodules: recursive - - - name: Install Nix - uses: nixbuild/nix-quick-install-action@v31 - with: - nix_conf: | - keep-env-derivations = true - keep-outputs = true - - - name: Restore and save Nix store - uses: nix-community/cache-nix-action@v6 - with: - # restore and save a cache using this key - primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', '**/flake.lock') }} - # if there's no cache hit, restore a cache by this prefix - restore-prefixes-first-match: nix-${{ runner.os }}- - # collect garbage until the Nix store size (in bytes) is at most this number - # before trying to save a new cache - # 1G = 1073741824 - gc-max-store-size-linux: 1G - # do purge caches - purge: true - # purge all versions of the cache - purge-prefixes: nix-${{ runner.os }}- - # created more than this number of seconds ago - purge-created: 0 - # or, last accessed more than this number of seconds ago - # relative to the start of the `Post Restore and save Nix store` phase - purge-last-accessed: 0 - # except any version with the key that is the same as the `primary-key` - purge-primary-key: never - - - uses: cachix/cachix-action@v16 - with: - name: hyprland - authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - - - name: Build Hyprpicker with default settings - run: nix build --print-build-logs --accept-flake-config + if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork) + uses: hyprwm/actions/.github/workflows/nix.yml@main + secrets: inherit + with: + command: nix build --print-build-logs --accept-flake-config diff --git a/flake.lock b/flake.lock index 4487f9d..850a16b 100644 --- a/flake.lock +++ b/flake.lock @@ -10,11 +10,11 @@ ] }, "locked": { - "lastModified": 1749135356, - "narHash": "sha256-Q8mAKMDsFbCEuq7zoSlcTuxgbIBVhfIYpX0RjE32PS0=", + "lastModified": 1772459870, + "narHash": "sha256-xxkK2Cvqxpf/4UGcJ/TyCwrvmiNWsKsJfFzHMp2bxis=", "owner": "hyprwm", "repo": "hyprutils", - "rev": "e36db00dfb3a3d3fdcc4069cb292ff60d2699ccb", + "rev": "e63f3a79334dec49f8eb1691f66f18115df04085", "type": "github" }, "original": { @@ -33,11 +33,11 @@ ] }, "locked": { - "lastModified": 1749145760, - "narHash": "sha256-IHaGWpGrv7seFWdw/1A+wHtTsPlOGIKMrk1TUIYJEFI=", + "lastModified": 1772459835, + "narHash": "sha256-978jRz/y/9TKmZb/qD4lEYHCQGHpEXGqy+8X2lFZsak=", "owner": "hyprwm", "repo": "hyprwayland-scanner", - "rev": "817918315ea016cc2d94004bfb3223b5fd9dfcc6", + "rev": "0a692d4a645165eebd65f109146b8861e3a925e7", "type": "github" }, "original": { @@ -48,11 +48,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1748929857, - "narHash": "sha256-lcZQ8RhsmhsK8u7LIFsJhsLh/pzR9yZ8yqpTzyGdj+Q=", + "lastModified": 1772433332, + "narHash": "sha256-izhTDFKsg6KeVBxJS9EblGeQ8y+O8eCa6RcW874vxEc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "c2a03962b8e24e669fb37b7df10e7c79531ff1a4", + "rev": "cf59864ef8aa2e178cccedbe2c178185b0365705", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index c75867e..490297e 100644 --- a/flake.nix +++ b/flake.nix @@ -18,46 +18,32 @@ }; }; - outputs = { - self, - nixpkgs, - systems, - ... - } @ inputs: let - inherit (nixpkgs) lib; - eachSystem = lib.genAttrs (import systems); - pkgsFor = eachSystem (system: - import nixpkgs { - localSystem.system = system; - overlays = with self.overlays; [hyprpicker]; + outputs = + { + self, + nixpkgs, + systems, + ... + }@inputs: + let + inherit (nixpkgs) lib; + eachSystem = lib.genAttrs (import systems); + pkgsFor = eachSystem ( + system: + import nixpkgs { + localSystem.system = system; + overlays = with self.overlays; [ hyprpicker-with-deps ]; + } + ); + in + { + overlays = import ./nix/overlays.nix { inherit inputs lib self; }; + + packages = eachSystem (system: { + default = self.packages.${system}.hyprpicker; + inherit (pkgsFor.${system}) hyprpicker hyprpicker-debug; }); - mkDate = longDate: (lib.concatStringsSep "-" [ - (builtins.substring 0 4 longDate) - (builtins.substring 4 2 longDate) - (builtins.substring 6 2 longDate) - ]); - version = lib.removeSuffix "\n" (builtins.readFile ./VERSION); - in { - overlays = { - default = self.overlays.hyprpicker; - hyprpicker = lib.composeManyExtensions [ - inputs.hyprutils.overlays.default - inputs.hyprwayland-scanner.overlays.default - (final: prev: { - hyprpicker = prev.callPackage ./nix/default.nix { - stdenv = prev.gcc15Stdenv; - version = version + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty"); - }; - hyprpicker-debug = final.hyprpicker.override {debug = true;}; - }) - ]; + + formatter = eachSystem (system: pkgsFor.${system}.nixfmt-tree); }; - - packages = eachSystem (system: { - default = self.packages.${system}.hyprpicker; - inherit (pkgsFor.${system}) hyprpicker hyprpicker-debug; - }); - - formatter = eachSystem (system: pkgsFor.${system}.alejandra); - }; } diff --git a/nix/default.nix b/nix/default.nix index 59cf94c..7c30814 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -13,6 +13,7 @@ libselinux, libsepol, libthai, + libXdmcp, libxkbcommon, pango, pcre, @@ -21,7 +22,6 @@ wayland, wayland-protocols, wayland-scanner, - xorg, debug ? false, version ? "git", }: @@ -31,10 +31,7 @@ stdenv.mkDerivation { src = ../.; - cmakeBuildType = - if debug - then "Debug" - else "Release"; + cmakeBuildType = if debug then "Debug" else "Release"; nativeBuildInputs = [ cmake @@ -52,6 +49,7 @@ stdenv.mkDerivation { libselinux libsepol libthai + libXdmcp libxkbcommon pango pcre @@ -60,7 +58,6 @@ stdenv.mkDerivation { wayland wayland-protocols wayland-scanner - xorg.libXdmcp ]; outputs = [ diff --git a/nix/overlays.nix b/nix/overlays.nix new file mode 100644 index 0000000..ecced7c --- /dev/null +++ b/nix/overlays.nix @@ -0,0 +1,37 @@ +{ + lib, + inputs, + self, + ... +}: +let + mkDate = + longDate: + (lib.concatStringsSep "-" [ + (builtins.substring 0 4 longDate) + (builtins.substring 4 2 longDate) + (builtins.substring 6 2 longDate) + ]); + version = lib.removeSuffix "\n" (builtins.readFile ../VERSION); +in +{ + default = self.overlays.hyprpicker; + hyprpicker-with-deps = lib.composeManyExtensions [ + inputs.hyprutils.overlays.default + inputs.hyprwayland-scanner.overlays.default + self.overlays.hyprpicker + ]; + + hyprpicker = final: prev: { + hyprpicker = prev.callPackage ./default.nix { + stdenv = prev.gcc15Stdenv; + version = + version + + "+date=" + + (mkDate (self.lastModifiedDate or "19700101")) + + "_" + + (self.shortRev or "dirty"); + }; + hyprpicker-debug = final.hyprpicker.override { debug = true; }; + }; +} diff --git a/src/hyprpicker.cpp b/src/hyprpicker.cpp index 90f0228..4059c85 100644 --- a/src/hyprpicker.cpp +++ b/src/hyprpicker.cpp @@ -1,10 +1,12 @@ #include "hyprpicker.hpp" #include "src/debug/Log.hpp" #include "src/notify/Notify.hpp" +#include #include #include #include #include +#include #include #include #include @@ -786,10 +788,19 @@ void CHyprpicker::initMouse() { double delta = wl_fixed_to_double(value); - if (delta < 0) - m_fZoomScale = std::min(m_fZoomScale + 1.0, 100.0); + double velocity = std::pow(M_E, m_fZoomScale * 0.01) - 1.; + + delta *= velocity; + + if (delta > 0) + delta = std::min(delta, 1.); else - m_fZoomScale = std::max(m_fZoomScale - 1.0, 1.0); + delta = std::max(delta, -1.); + + if (delta > 0) + m_fZoomScale = std::max(m_fZoomScale - delta, 1.); + else + m_fZoomScale = std::min(m_fZoomScale - delta, 100.); markDirty(); }); diff --git a/src/hyprpicker.hpp b/src/hyprpicker.hpp index 062928d..cad8f02 100644 --- a/src/hyprpicker.hpp +++ b/src/hyprpicker.hpp @@ -1,7 +1,6 @@ #pragma once #include - #include "defines.hpp" #include "helpers/LayerSurface.hpp" #include "helpers/PoolBuffer.hpp" diff --git a/src/main.cpp b/src/main.cpp index 4a7f472..004e307 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include #include