summaryrefslogtreecommitdiff
path: root/surf.c.diff
blob: 329df08d39bb297060ae2ba535cfa0bb0cd23a19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
diff --git a/surf.c b/surf.c
index f01a91c..76d4706 100644
--- a/surf.c
+++ b/surf.c
@@ -2,6 +2,10 @@
  *
  * To understand surf, start reading main().
  */
+
+#include <sys/ipc.h>
+#include <sys/shm.h>
+
 #include <sys/file.h>
 #include <sys/types.h>
 #include <sys/wait.h>
@@ -223,6 +227,7 @@ static void togglefullscreen(Client *c, const Arg *a);
 static void togglecookiepolicy(Client *c, const Arg *a);
 static void toggleinspector(Client *c, const Arg *a);
 static void find(Client *c, const Arg *a);
+static void domlinks(Client *c, const Arg *a);
 
 /* Buttons */
 static void clicknavigate(Client *c, const Arg *a, WebKitHitTestResult *h);
@@ -2052,3 +2057,47 @@ main(int argc, char *argv[])
 
 	return 0;
 }
+
+void
+domlinks(Client *c, const Arg *a)
+{
+	static int goto_link=0;
+	int digit=a->i;
+
+	// follow link
+	if(digit==99)
+	{
+	    printf("follow link %i\n",goto_link);
+
+	    key_t my_ftok = ftok("~/surf-webext-dom-shared-mem",'a');
+	    int mem_seg=shmget(my_ftok,1024*1024,IPC_CREAT|0660);
+	    if(mem_seg==-1)
+	    {
+		g_print("shmget failed\n");
+	    }
+	    char *shared_buf=shmat(mem_seg,NULL,0);
+	    if(shared_buf==(void*)-1)
+	    {
+		g_print("shmat failed\n");
+	    }
+
+	    printf("linking to : %s\n",&(shared_buf[goto_link*1024]));
+	    Arg aa = {.v = &(shared_buf[goto_link*1024]) };
+	    loaduri(c, &aa);
+	    goto_link=0;
+	    return;
+	}
+
+	// adjust link number
+	if(goto_link==0)
+	{
+	    goto_link=digit;
+	}
+	else
+	{
+	    goto_link*=10;
+	    goto_link+=digit;
+	}
+	printf("update link num to: %i\n",goto_link);
+
+}