about summary refs log tree commit diff
diff options
context:
space:
mode:
authorQuentin Rameau <quinq@fifth.space>2015-11-20 00:53:14 +0100
committerQuentin Rameau <quinq@fifth.space>2015-11-20 00:53:14 +0100
commita53dc901710fc2bf487b5d98e5b6596c572d9250 (patch)
tree7e759a75838b8859b102427bace43fcc71dfdf06
parentAdapt inspector handling (diff)
downloadsurf-a53dc901710fc2bf487b5d98e5b6596c572d9250.tar.gz
surf-a53dc901710fc2bf487b5d98e5b6596c572d9250.tar.bz2
surf-a53dc901710fc2bf487b5d98e5b6596c572d9250.zip
Adapt scrolling
In fact, we have a scrolling handle ersatz for now using JavaScript
calls as we don't have access anymore to scrollbars.
We'll have to manipulate the DOM directly (later).
-rw-r--r--config.def.h13
-rw-r--r--surf.c40
2 files changed, 15 insertions, 38 deletions
diff --git a/config.def.h b/config.def.h
index 17a5149..997aaab 100644
--- a/config.def.h
+++ b/config.def.h
@@ -100,12 +100,13 @@ static Key keys[] = {
 	{ MODKEY,                GDK_KEY_l,      navigate,   { .i = +1 } },
 	{ MODKEY,                GDK_KEY_h,      navigate,   { .i = -1 } },
 
-	{ MODKEY,                GDK_KEY_j,      scroll_v,   { .i = +1 } },
-	{ MODKEY,                GDK_KEY_k,      scroll_v,   { .i = -1 } },
-	{ MODKEY,                GDK_KEY_b,      scroll_v,   { .i = -10000 } },
-	{ MODKEY,                GDK_KEY_space,  scroll_v,   { .i = +10000 } },
-	{ MODKEY,                GDK_KEY_i,      scroll_h,   { .i = +1 } },
-	{ MODKEY,                GDK_KEY_u,      scroll_h,   { .i = -1 } },
+	                                                     /* in page % */
+	{ MODKEY,                GDK_KEY_j,      scroll_v,   { .i = +10 } },
+	{ MODKEY,                GDK_KEY_k,      scroll_v,   { .i = -10 } },
+	{ MODKEY,                GDK_KEY_b,      scroll_v,   { .i = -50 } },
+	{ MODKEY,                GDK_KEY_space,  scroll_v,   { .i = +50 } },
+	{ MODKEY,                GDK_KEY_i,      scroll_h,   { .i = +10 } },
+	{ MODKEY,                GDK_KEY_u,      scroll_h,   { .i = -10 } },
 
 	{ 0,                     GDK_KEY_F11,    togglefullscreen, { 0 } },
 	{ 0,                     GDK_KEY_Escape, stop,       { 0 } },
diff --git a/surf.c b/surf.c
index 726369a..3c17d17 100644
--- a/surf.c
+++ b/surf.c
@@ -167,9 +167,8 @@ static void progresschanged(WebKitWebView *v, GParamSpec *ps, Client *c);
 static void linkopen(Client *c, const Arg *arg);
 static void linkopenembed(Client *c, const Arg *arg);
 static void reload(Client *c, const Arg *arg);
-static void scroll_h(Client *c, const Arg *arg);
-static void scroll_v(Client *c, const Arg *arg);
-static void scroll(GtkAdjustment *a, const Arg *arg);
+static void scroll_h(Client *c, const Arg *a);
+static void scroll_v(Client *c, const Arg *a);
 static void setatom(Client *c, int a, const char *v);
 static void setup(void);
 static void sigchld(int unused);
@@ -1169,40 +1168,17 @@ reload(Client *c, const Arg *arg)
 }
 
 void
-scroll_h(Client *c, const Arg *arg)
+scroll_h(Client *c, const Arg *a)
 {
-	scroll(gtk_scrolled_window_get_hadjustment(
-	       GTK_SCROLLED_WINDOW(c->scroll)), arg);
+	evalscript(c, "window.scrollBy(%d * (window.innerWidth / 100), 0)",
+	    a->i);
 }
 
 void
-scroll_v(Client *c, const Arg *arg)
+scroll_v(Client *c, const Arg *a)
 {
-	scroll(gtk_scrolled_window_get_vadjustment(
-	       GTK_SCROLLED_WINDOW(c->scroll)), arg);
-}
-
-void
-scroll(GtkAdjustment *a, const Arg *arg)
-{
-	gdouble v;
-
-	v = gtk_adjustment_get_value(a);
-	switch (arg->i) {
-	case +10000:
-	case -10000:
-		v += gtk_adjustment_get_page_increment(a) * (arg->i / 10000);
-		break;
-	case +20000:
-	case -20000:
-	default:
-		v += gtk_adjustment_get_step_increment(a) * arg->i;
-	}
-
-	v = MAX(v, 0.0);
-	v = MIN(v, gtk_adjustment_get_upper(a) -
-	        gtk_adjustment_get_page_size(a));
-	gtk_adjustment_set_value(a, v);
+	evalscript(c, "window.scrollBy(0, %d * (window.innerHeight / 100))",
+	    a->i);
 }
 
 void