From eec67e6c4d0b1e163c6eae407634afcabf8158cf Mon Sep 17 00:00:00 2001 From: LavaDesu Date: Fri, 25 Mar 2022 19:53:07 +0700 Subject: [PATCH] overlays/eww: patch out smooth scroll --- overlays/eww.nix | 4 +++- overlays/patches/eww.patch | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 overlays/patches/eww.patch diff --git a/overlays/eww.nix b/overlays/eww.nix index 466608c..0e954ec 100644 --- a/overlays/eww.nix +++ b/overlays/eww.nix @@ -1,5 +1,5 @@ self: super: { - # Mainly for https://github.com/elkowar/eww/pull/280 + # For https://github.com/elkowar/eww/pull/280 eww = super.eww.overrideAttrs (old: rec { version = "unstable-fb0e57a"; src = self.fetchFromGitHub { @@ -8,6 +8,8 @@ self: super: { rev = "fb0e57a0149904e76fb33807a2804d4af82350de"; sha256 = "089rvcswr0wy05fac8xbfrws1qacqi3iialpv8sai7mzlpsw21m0"; }; + # Use normal scroll events instead of smooth scroll ( due to https://bugzilla.gnome.org/show_bug.cgi?id=675959 ) + patches = old.patches ++ [ ./patches/eww.patch ]; cargoSha256 = "1s7rxilqis2nbvjqjp5zarvmr9g6ndcicyx1rilgjv34qwna3mz1"; cargoDeps = self.rustPlatform.fetchCargoTarball { inherit src; diff --git a/overlays/patches/eww.patch b/overlays/patches/eww.patch new file mode 100644 index 0000000..8b61d41 --- /dev/null +++ b/overlays/patches/eww.patch @@ -0,0 +1,32 @@ +diff --git a/crates/eww/src/widgets/widget_definitions.rs b/crates/eww/src/widgets/widget_definitions.rs +index ec307537407..49c70571d4b 100644 +--- a/crates/eww/src/widgets/widget_definitions.rs ++++ b/crates/eww/src/widgets/widget_definitions.rs +@@ -6,7 +6,7 @@ use crate::{ + use anyhow::*; + use codespan_reporting::diagnostic::Severity; + use eww_shared_util::Spanned; +-use gdk::NotifyType; ++use gdk::{NotifyType, ScrollDirection}; + use gtk::{self, glib, prelude::*}; + use itertools::Itertools; + use once_cell::sync::Lazy; +@@ -523,11 +523,14 @@ fn build_gtk_event_box(bargs: &mut BuilderArgs) -> Result { + // @prop onscroll - event to execute when the user scrolls with the mouse over the widget. The placeholder `{}` used in the command will be replaced with either `up` or `down`. + prop(timeout: as_duration = Duration::from_millis(200), onscroll: as_string) { + gtk_widget.add_events(gdk::EventMask::SCROLL_MASK); +- gtk_widget.add_events(gdk::EventMask::SMOOTH_SCROLL_MASK); + connect_single_handler!(gtk_widget, gtk_widget.connect_scroll_event(move |_, evt| { +- let delta = evt.delta().1; +- if delta != 0f64 { // Ignore the first event https://bugzilla.gnome.org/show_bug.cgi?id=675959 +- run_command(timeout, &onscroll, if delta < 0f64 { "up" } else { "down" }); ++ let dir = match evt.direction() { ++ ScrollDirection::Up => "up", ++ ScrollDirection::Down => "down", ++ _ => "", ++ }; ++ if dir != "" { ++ run_command(timeout, &onscroll, dir); + } + gtk::Inhibit(false) + }));