Actually, that patch breaks the navigate() and clipboard()
functions.

There's an updated one attached.

> On 21 August 2010 19:32, Alex Puterbaugh <puterbau...@gmail.com> wrote:
> Hey all,
>
> I've made a small patch that allows you to bind keys for
> horizontal scrolling.
>
> This approach (which imho is the least of many evils) requires
> the Arg union to be a struct, to allow the scroll() function
> to use both .b and .i as arguments.
>
> I think that horizontal scrolling via the keyboard is far from an
> "edge" use case for a web browser that already depends so heavily on
> the keyboard, so I propose that this patch be included in the
> next version of surf.
>
>
diff -r dbb565b8d61c config.def.h
--- a/config.def.h      Fri Jun 25 09:42:58 2010 +0200
+++ b/config.def.h      Sat Aug 21 15:04:55 2010 -0400
@@ -27,10 +27,12 @@
     { MODKEY|GDK_SHIFT_MASK,GDK_j,      zoom,       { .i = -1 } },
     { MODKEY|GDK_SHIFT_MASK,GDK_k,      zoom,       { .i = +1 } },
     { MODKEY|GDK_SHIFT_MASK,GDK_i,      zoom,       { .i = 0  } },
-    { MODKEY,               GDK_l,      navigate,   { .i = +1 } },
-    { MODKEY,               GDK_h,      navigate,   { .i = -1 } },
-    { MODKEY,               GDK_j,      scroll,     { .i = +1 } },
-    { MODKEY,               GDK_k,      scroll,     { .i = -1 } },
+    { MODKEY,               GDK_f,      navigate,   { .i = +1 } },
+    { MODKEY,               GDK_b,      navigate,   { .i = -1 } },
+    { MODKEY,               GDK_h,      scroll,     { .i = -1, .b = FALSE } },
+    { MODKEY,               GDK_l,      scroll,     { .i = +1, .b = FALSE } },
+    { MODKEY,               GDK_j,      scroll,     { .i = +1, .b = TRUE } },
+    { MODKEY,               GDK_k,      scroll,     { .i = -1, .b = TRUE } },
     { 0,                    GDK_Escape, stop,       { 0 } },
     { MODKEY,               GDK_o,      source,     { 0 } },
     { MODKEY,               GDK_g,      spawn,      SETPROP("_SURF_URI", 
"_SURF_GO") },
diff -r dbb565b8d61c surf.c
--- a/surf.c    Fri Jun 25 09:42:58 2010 +0200
+++ b/surf.c    Sat Aug 21 15:04:55 2010 -0400
@@ -25,8 +25,8 @@
 
 enum { AtomFind, AtomGo, AtomUri, AtomLast };
 
-typedef union Arg Arg;
-union Arg {
+typedef struct Arg Arg;
+struct Arg {
        gboolean b;
        gint i;
        const void *v;
@@ -159,7 +159,7 @@
 
 void
 clipboard(Client *c, const Arg *arg) {
-       gboolean paste = *(gboolean *)arg;
+       gboolean paste = arg->b;
 
        if(paste)
                
gtk_clipboard_request_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), pasteuri, 
c);
@@ -405,7 +405,7 @@
 
 void
 navigate(Client *c, const Arg *arg) {
-       int steps = *(int *)arg;
+       int steps = arg->i;
        webkit_web_view_go_back_or_forward(c->view, steps);
 }
 
@@ -631,7 +631,8 @@
        gdouble v;
        GtkAdjustment *a;
 
-       a = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(c->scroll));
+       a = arg-> b? 
gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(c->scroll)):
+               
gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(c->scroll));
        v = gtk_adjustment_get_value(a);
        v += gtk_adjustment_get_step_increment(a) * arg->i;
        v = MAX(v, 0.0);

Reply via email to