Hi y'all,

This patch moves away from webext scrolling to Surf-internal JS to
scroll. See patch for more involved description and downsides.

>From 36711a5d4c7cd95d4157acba4f35ee2ac6e6a71e Mon Sep 17 00:00:00 2001
From: Artyom Bologov <g...@aartaka.me>
Date: Sun, 20 Apr 2025 17:48:44 +0400
Subject: [PATCH] Scroll window directly in surf, and not in webext.

This is because WebkitWebExtension-s might be deprecated
<https://lists.webkit.org/pipermail/webkit-dev/2022-August/032329.html>
and we need to move away from it. One significant downside of this
patch is that it requires JavaScript setting to be on to work. This is
handled in another patch, using JavaScriptMarkup (to be added) instead
of JavaScript setting.
---
 surf.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/surf.c b/surf.c
index f11613a..660e7cf 100644
--- a/surf.c
+++ b/surf.c
@@ -1925,13 +1925,17 @@ msgext(Client *c, char type, const Arg *a)
 void
 scrollv(Client *c, const Arg *a)
 {
-	msgext(c, 'v', a);
+	char js[48];
+	snprintf(js, sizeof(js), "window.scrollBy(0,window.innerHeight/100*%hhd);", a->i);
+	webkit_web_view_evaluate_javascript(c->view, js, -1, NULL, NULL, NULL, NULL, NULL);
 }
 
 void
 scrollh(Client *c, const Arg *a)
 {
-	msgext(c, 'h', a);
+	char js[48];
+	snprintf(js, sizeof(js), "window.scrollBy(window.innerWidth/100*%hhd,0);", a->i);
+	webkit_web_view_evaluate_javascript(c->view, js, -1, NULL, NULL, NULL, NULL, NULL);
 }
 
 void
-- 
2.48.1

Thanks,
-- 
Artyom Bologov
https://aartaka.me

Reply via email to