diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2025-02-16 08:46:38 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2025-02-16 10:18:00 +0300 |
| commit | f2b1fc66f21f720ba85a4c218546298e527ba8b9 (patch) | |
| tree | ec7c6950c3a7007357f3ede823392982295c3e1b /src/layout/workspace.rs | |
| parent | 22302bf224def0ba24ad73e10a987ee6ba33cb2d (diff) | |
| download | niri-f2b1fc66f21f720ba85a4c218546298e527ba8b9.tar.gz niri-f2b1fc66f21f720ba85a4c218546298e527ba8b9.tar.bz2 niri-f2b1fc66f21f720ba85a4c218546298e527ba8b9.zip | |
Make DnD edge view scroll configurable
Diffstat (limited to 'src/layout/workspace.rs')
| -rw-r--r-- | src/layout/workspace.rs | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs index 37e6aa99..54926a1f 100644 --- a/src/layout/workspace.rs +++ b/src/layout/workspace.rs @@ -1614,22 +1614,32 @@ impl<W: LayoutElement> Workspace<W> { } pub fn dnd_scroll_gesture_scroll(&mut self, pos: Point<f64, Logical>) { - // Taken from GTK 4. - const SCROLL_EDGE_SIZE: f64 = 30.; + let config = &self.options.gestures.dnd_edge_view_scroll; + let trigger_width = config.trigger_width.0; // This working area intentionally does not include extra struts from Options. let x = pos.x - self.working_area.loc.x; let width = self.working_area.size.w; + let x = x.clamp(0., width); + let trigger_width = trigger_width.clamp(0., width / 2.); - let delta = if x < SCROLL_EDGE_SIZE { - -(SCROLL_EDGE_SIZE - x) - } else if width - x < SCROLL_EDGE_SIZE { - SCROLL_EDGE_SIZE - (width - x) + let delta = if x < trigger_width { + -(trigger_width - x) + } else if width - x < trigger_width { + trigger_width - (width - x) } else { 0. }; + let delta = if trigger_width < 0.01 { + // Sanity check for trigger-width 0 or small window sizes. + 0. + } else { + // Normalize to [0, 1]. + delta / trigger_width + }; + self.scrolling.dnd_scroll_gesture_scroll(delta); } |
