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 +#include + #include #include #include @@ -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); + +}