detached 377b106

refactor(webkit): improve WebKit integration for gesture handling and initialization

Enhance touchpad gesture detection and WebView initialization patterns to
better support content filtering at startup.
commit
377b106162e402488d190c68606830227b3f6ed9
author
bnema · · 2025-12-06 20:52 UTC
parent
b6ebf7a
signature
unsigned
2 files · +33 -2
M pkg/webkit/touchpad_gestures.go +3 -2
@@ -25,8 +25,9 @@ func (w *WebView) AttachTouchpadGestures() {
2525 // Create gesture controller for swipe detection
2626 gestureSwipe := gtk.NewGestureSwipe()
2727
28- // Set to capture phase to intercept before WebView processes
29- gestureSwipe.SetPropagationPhase(gtk.PhaseCapture)
28+ // Use bubble phase instead of capture to not interfere with scroll events
29+ // This lets normal scrolling work while still detecting navigation swipes
30+ gestureSwipe.SetPropagationPhase(gtk.PhaseBubble)
3031
3132 // Set to require touchpad (2 fingers minimum for touchpad gestures)
3233 // This prevents single-finger drags from triggering navigation
@@ -25,8 +25,9 @@ func (w *WebView) AttachTouchpadGestures() {
25 // Create gesture controller for swipe detection25 // Create gesture controller for swipe detection
26 gestureSwipe := gtk.NewGestureSwipe()26 gestureSwipe := gtk.NewGestureSwipe()
27 27
28- // Set to capture phase to intercept before WebView processes28+ // Use bubble phase instead of capture to not interfere with scroll events
29- gestureSwipe.SetPropagationPhase(gtk.PhaseCapture)29+ // This lets normal scrolling work while still detecting navigation swipes
30+ gestureSwipe.SetPropagationPhase(gtk.PhaseBubble)
30 31
31 // Set to require touchpad (2 fingers minimum for touchpad gestures)32 // Set to require touchpad (2 fingers minimum for touchpad gestures)
32 // This prevents single-finger drags from triggering navigation33 // This prevents single-finger drags from triggering navigation
M pkg/webkit/webview.go +30 -0
@@ -203,6 +203,20 @@ func (w *WebView) applyConfig() error {
203203 // Enable hardware acceleration if configured
204204 settings.SetHardwareAccelerationPolicy(webkit.HardwareAccelerationPolicyAlways)
205205
206+ // Media performance optimizations
207+ // Force hardware decoding for video content types via GStreamer VA-API/NVDEC
208+ settings.SetMediaContentTypesRequiringHardwareSupport("video/mp4;video/webm;video/x-h264;video/av01")
209+ // Enable media capabilities API for efficient codec queries
210+ settings.SetEnableMediaCapabilities(true)
211+ // Enable MediaSource Extensions for adaptive streaming (YouTube, Twitch)
212+ settings.SetEnableMediasource(true)
213+ // GPU-accelerated 2D canvas for image-heavy pages
214+ settings.SetEnable2DCanvasAcceleration(true)
215+ // Allow inline video playback (no forced fullscreen)
216+ settings.SetMediaPlaybackAllowsInline(true)
217+ // Require user gesture for autoplay (browser standard)
218+ settings.SetMediaPlaybackRequiresUserGesture(true)
219+
206220 // Performance optimizations for faster page transitions
207221 // Enable page cache for instant back/forward navigation (bfcache)
208222 settings.SetEnablePageCache(w.config.EnablePageCache)
@@ -210,6 +224,22 @@ func (w *WebView) applyConfig() error {
210224 // Enable smooth scrolling for better UX
211225 settings.SetEnableSmoothScrolling(w.config.EnableSmoothScrolling)
212226
227+ // Enable fullscreen API (required for video fullscreen)
228+ settings.SetEnableFullscreen(true)
229+
230+ // Web app storage APIs
231+ settings.SetEnableHtml5LocalStorage(true) // localStorage/sessionStorage
232+ settings.SetEnableHtml5Database(true) // IndexedDB
233+
234+ // Web Audio API for games and audio apps
235+ settings.SetEnableWebaudio(true)
236+
237+ // Touchpad swipe gestures for back/forward navigation
238+ settings.SetEnableBackForwardNavigationGestures(true)
239+
240+ // WebKit compatibility hacks for popular broken sites
241+ settings.SetEnableSiteSpecificQuirks(true)
242+
213243 // Disable console messages to stdout to prevent page script flooding
214244 // This stops malicious/buggy pages from spamming the terminal with console.log()
215245 // Inspector/DevTools console (F12) will still show all messages
@@ -203,6 +203,20 @@ func (w *WebView) applyConfig() error {
203 // Enable hardware acceleration if configured203 // Enable hardware acceleration if configured
204 settings.SetHardwareAccelerationPolicy(webkit.HardwareAccelerationPolicyAlways)204 settings.SetHardwareAccelerationPolicy(webkit.HardwareAccelerationPolicyAlways)
205 205
206+ // Media performance optimizations
207+ // Force hardware decoding for video content types via GStreamer VA-API/NVDEC
208+ settings.SetMediaContentTypesRequiringHardwareSupport("video/mp4;video/webm;video/x-h264;video/av01")
209+ // Enable media capabilities API for efficient codec queries
210+ settings.SetEnableMediaCapabilities(true)
211+ // Enable MediaSource Extensions for adaptive streaming (YouTube, Twitch)
212+ settings.SetEnableMediasource(true)
213+ // GPU-accelerated 2D canvas for image-heavy pages
214+ settings.SetEnable2DCanvasAcceleration(true)
215+ // Allow inline video playback (no forced fullscreen)
216+ settings.SetMediaPlaybackAllowsInline(true)
217+ // Require user gesture for autoplay (browser standard)
218+ settings.SetMediaPlaybackRequiresUserGesture(true)
219+
206 // Performance optimizations for faster page transitions220 // Performance optimizations for faster page transitions
207 // Enable page cache for instant back/forward navigation (bfcache)221 // Enable page cache for instant back/forward navigation (bfcache)
208 settings.SetEnablePageCache(w.config.EnablePageCache)222 settings.SetEnablePageCache(w.config.EnablePageCache)
@@ -210,6 +224,22 @@ func (w *WebView) applyConfig() error {
210 // Enable smooth scrolling for better UX224 // Enable smooth scrolling for better UX
211 settings.SetEnableSmoothScrolling(w.config.EnableSmoothScrolling)225 settings.SetEnableSmoothScrolling(w.config.EnableSmoothScrolling)
212 226
227+ // Enable fullscreen API (required for video fullscreen)
228+ settings.SetEnableFullscreen(true)
229+
230+ // Web app storage APIs
231+ settings.SetEnableHtml5LocalStorage(true) // localStorage/sessionStorage
232+ settings.SetEnableHtml5Database(true) // IndexedDB
233+
234+ // Web Audio API for games and audio apps
235+ settings.SetEnableWebaudio(true)
236+
237+ // Touchpad swipe gestures for back/forward navigation
238+ settings.SetEnableBackForwardNavigationGestures(true)
239+
240+ // WebKit compatibility hacks for popular broken sites
241+ settings.SetEnableSiteSpecificQuirks(true)
242+
213 // Disable console messages to stdout to prevent page script flooding243 // Disable console messages to stdout to prevent page script flooding
214 // This stops malicious/buggy pages from spamming the terminal with console.log()244 // This stops malicious/buggy pages from spamming the terminal with console.log()
215 // Inspector/DevTools console (F12) will still show all messages245 // Inspector/DevTools console (F12) will still show all messages

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