v0.15.0 9006957

touchpad_gestures.go RawHistoryFolder

1package webkit
2
3import (
4	"fmt"
5	"math"
6
7	"github.com/bnema/dumber/internal/logging"
8	"github.com/diamondburned/gotk4/pkg/gtk/v4"
9)
10
11// Touchpad swipe velocity threshold (pixels per second)
12// Lower values make gestures more sensitive, higher values require faster swipes
13const (
14	swipeVelocityThreshold = 500.0 // Reasonable threshold for intentional swipes
15)
16
17// AttachTouchpadGestures attaches touchpad swipe gesture handling to the WebView
18// This enables two-finger swipe navigation (left/right for back/forward)
19func (w *WebView) AttachTouchpadGestures() {
20	if w.view == nil {
21		logging.Error(fmt.Sprintf("[touchpad-gestures] Cannot attach: WebView is nil"))
22		return
23	}
24
25	// Create gesture controller for swipe detection
26	gestureSwipe := gtk.NewGestureSwipe()
27
28	// Set to capture phase to intercept before WebView processes
29	gestureSwipe.SetPropagationPhase(gtk.PhaseCapture)
30
31	// Set to require touchpad (2 fingers minimum for touchpad gestures)
32	// This prevents single-finger drags from triggering navigation
33	gestureSwipe.SetTouchOnly(false) // Allow both touch and touchpad
34
35	// Connect to swipe signal
36	gestureSwipe.ConnectSwipe(func(velocityX, velocityY float64) {
37		// Only process horizontal swipes (ignore mostly vertical swipes)
38		// Use absolute values to compare magnitudes
39		absVelocityX := math.Abs(velocityX)
40		absVelocityY := math.Abs(velocityY)
41
42		// Require horizontal velocity to be dominant
43		if absVelocityY > absVelocityX {
44			logging.Debug(fmt.Sprintf("[touchpad-gestures] Swipe is more vertical (X:%.1f Y:%.1f), ignoring", velocityX, velocityY))
45			return
46		}
47
48		// Check if swipe velocity meets threshold
49		if absVelocityX < swipeVelocityThreshold {
50			logging.Debug(fmt.Sprintf("[touchpad-gestures] Swipe velocity too low (%.1f < %.1f), ignoring", absVelocityX, swipeVelocityThreshold))
51			return
52		}
53
54		// Determine swipe direction and navigate
55		if velocityX > 0 {
56			// Swipe right (positive velocity) - go back
57			if w.view.CanGoBack() {
58				logging.Debug(fmt.Sprintf("[touchpad-gestures] Swipe right detected (velocity: %.1f) - navigating backward", velocityX))
59				w.view.GoBack()
60			} else {
61				logging.Debug(fmt.Sprintf("[touchpad-gestures] Swipe right detected but cannot go back"))
62			}
63		} else {
64			// Swipe left (negative velocity) - go forward
65			if w.view.CanGoForward() {
66				logging.Debug(fmt.Sprintf("[touchpad-gestures] Swipe left detected (velocity: %.1f) - navigating forward", velocityX))
67				w.view.GoForward()
68			} else {
69				logging.Debug(fmt.Sprintf("[touchpad-gestures] Swipe left detected but cannot go forward"))
70			}
71		}
72	})
73
74	// Attach controller to WebView
75	w.view.AddController(gestureSwipe)
76	logging.Debug(fmt.Sprintf("[touchpad-gestures] Touchpad gesture controller attached to WebView ID %d", w.id))
77}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close