I just produced this patch.
It solves the one thing that I missed most when switching from MacOSX
to Linux on my MacBook.

@Christophe,
I'm sure this patch introduces style changes again, without intention.
Have you a set of 'indent' parameters I can use.

Nevertheless, I found this worth posting.

commit 33a5ecfae080395d679147eb22ca23f292ac4c38
Author: Kurt Van Dijck <k...@vandijck-laurijssen.be>
Date:   Sun Apr 21 13:46:25 2013

    add 3-finger back and forward control
    
    This patch will make surf 'go back' when
    3 fingers are swiped to the right, and
    'go forward' when 3 fingers are swiped to the left,
    as if you moved the web page physically.
    This behaviour is copied from the Safari web browser.
    Basic web surfing is then controlled by 1 hand only.
    
    Signed-off-by: Kurt Van Dijck <k...@vandijck-laurijssen.be>

diff --git a/surf.c b/surf.c
index 87116f9..599d7e3 100644
--- a/surf.c
+++ b/surf.c
@@ -79,6 +79,7 @@ static char winid[64];
 static gboolean usingproxy = 0;
 static char togglestat[6];
 static char pagestat[3];
+static GdkEventButton last_3finger_ev;
 
 static void addaccelgroup(Client *c);
 static void beforerequest(WebKitWebView *w, WebKitWebFrame *f,
@@ -228,12 +229,40 @@ buildpath(const char *path) {
        return apath;
 }
 
+static gboolean test_3fingers_movement(const GdkEventButton *e, int *paction) {
+       switch (e->button) {
+       case 10:
+               /* swipe to right */
+               /* allow 1 'back' per 500msec */
+               *paction = (((last_3finger_ev.time + 500) < e->time) ||
+                               (last_3finger_ev.button != e->button))
+                       ? -1 : 0;
+               last_3finger_ev = *e;
+               return true;
+       case 11:
+               /* swipe to left */
+               /* allow 1 'forward' per 500msec */
+               *paction = (((last_3finger_ev.time + 500) < e->time) ||
+                               (last_3finger_ev.button != e->button))
+                       ? +1 : 0;
+               last_3finger_ev = *e;
+               return true;
+       }
+       return false;
+}
+
 static gboolean
 buttonrelease(WebKitWebView *web, GdkEventButton *e, GList *gl) {
        WebKitHitTestResultContext context;
        WebKitHitTestResult *result = webkit_web_view_get_hit_test_result(web,
                        e);
        Arg arg;
+       int move_3fingers;
+
+       if (test_3fingers_movement(e, &move_3fingers)) {
+               webkit_web_view_go_back_or_forward(web, -move_3fingers);
+               return true;
+       }
 
        g_object_get(result, "context", &context, NULL);
        if(context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK) {

Reply via email to